From d306bd42105bdb613f7760a89cd576c24c848da2 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 26 Jul 2021 19:58:16 -0700 Subject: Handle empty URL --- app/build.gradle | 4 ++-- app/src/main/java/org/traccar/manager/MainFragment.kt | 8 +++++++- app/src/main/java/org/traccar/manager/StartFragment.kt | 1 - 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 2a1dd91..1a17eab 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { applicationId 'org.traccar.manager' minSdkVersion 19 targetSdkVersion 30 - versionCode 26 - versionName '2.15' + versionCode 27 + versionName '2.16' } compileOptions { diff --git a/app/src/main/java/org/traccar/manager/MainFragment.kt b/app/src/main/java/org/traccar/manager/MainFragment.kt index 2675d0c..3f09e56 100644 --- a/app/src/main/java/org/traccar/manager/MainFragment.kt +++ b/app/src/main/java/org/traccar/manager/MainFragment.kt @@ -77,7 +77,13 @@ class MainFragment : WebViewFragment() { webSettings.mediaPlaybackRequiresUserGesture = false val url = PreferenceManager.getDefaultSharedPreferences(activity) .getString(MainActivity.PREFERENCE_URL, null) - url?.let { webView.loadUrl(it) } + if (url != null) { + webView.loadUrl(url) + } else { + activity.fragmentManager + .beginTransaction().replace(android.R.id.content, StartFragment()) + .commitAllowingStateLoss() + } } private val broadcastReceiver: BroadcastReceiver = object : BroadcastReceiver() { diff --git a/app/src/main/java/org/traccar/manager/StartFragment.kt b/app/src/main/java/org/traccar/manager/StartFragment.kt index ee379a2..536b22c 100644 --- a/app/src/main/java/org/traccar/manager/StartFragment.kt +++ b/app/src/main/java/org/traccar/manager/StartFragment.kt @@ -31,7 +31,6 @@ import android.widget.EditText import androidx.preference.PreferenceManager import org.json.JSONException import org.json.JSONObject -import org.traccar.manager.StartFragment import java.io.BufferedReader import java.io.IOException import java.io.InputStreamReader -- cgit v1.2.3