diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2021-12-25 15:44:26 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2021-12-25 15:44:26 -0800 |
commit | a207f4b9f2ae815f99e19174d5efdf0ba3440e6f (patch) | |
tree | c37079d633ca84d66a9adebf7707793cefbc7a0c /app/src/main/java | |
parent | 60030ac7a4afce24d4ddc238317dd8df06dcbaa1 (diff) | |
download | etbsa-traccar-manager-android-a207f4b9f2ae815f99e19174d5efdf0ba3440e6f.tar.gz etbsa-traccar-manager-android-a207f4b9f2ae815f99e19174d5efdf0ba3440e6f.tar.bz2 etbsa-traccar-manager-android-a207f4b9f2ae815f99e19174d5efdf0ba3440e6f.zip |
Handle server change
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/org/traccar/manager/MainFragment.kt | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/app/src/main/java/org/traccar/manager/MainFragment.kt b/app/src/main/java/org/traccar/manager/MainFragment.kt index d5144f5..0f223d0 100644 --- a/app/src/main/java/org/traccar/manager/MainFragment.kt +++ b/app/src/main/java/org/traccar/manager/MainFragment.kt @@ -51,8 +51,13 @@ class MainFragment : WebViewFragment() { inner class AppInterface { @JavascriptInterface fun postMessage(message: String) { - if (message.contains("login")) { + if (message.startsWith("login")) { broadcastManager.sendBroadcast(Intent(EVENT_LOGIN)) + } else if (message.startsWith("server")) { + val url = message.substring(7) + PreferenceManager.getDefaultSharedPreferences(activity) + .edit().putString(MainActivity.PREFERENCE_URL, url).apply() + activity.runOnUiThread { webView.loadUrl(url) } } } } @@ -138,7 +143,7 @@ class MainFragment : WebViewFragment() { private var geolocationRequestOrigin: String? = null private var geolocationCallback: GeolocationPermissions.Callback? = null - private val webChromeClient: WebChromeClient = object : WebChromeClient() { + private val webChromeClient = object : WebChromeClient() { override fun onGeolocationPermissionsShowPrompt(origin: String, callback: GeolocationPermissions.Callback) { geolocationRequestOrigin = null |