From 44eb20bd6fc5d76aea1fc07fdf561cc926d126a1 Mon Sep 17 00:00:00 2001 From: Alexey Osminin Date: Tue, 15 Dec 2020 15:55:38 +0300 Subject: [PATCH] [android] ability for debugging webview --- android/src/com/mapswithme/maps/MwmApplication.java | 3 +++ android/src/com/mapswithme/util/Utils.java | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/android/src/com/mapswithme/maps/MwmApplication.java b/android/src/com/mapswithme/maps/MwmApplication.java index a60add9f39..aee3bca023 100644 --- a/android/src/com/mapswithme/maps/MwmApplication.java +++ b/android/src/com/mapswithme/maps/MwmApplication.java @@ -5,6 +5,7 @@ import android.content.Context; import android.content.SharedPreferences; import android.os.Handler; import android.os.Message; +import android.webkit.WebView; import androidx.annotation.NonNull; import androidx.multidex.MultiDex; @@ -42,6 +43,7 @@ import com.mapswithme.util.SharedPropertiesUtils; import com.mapswithme.util.StorageUtils; import com.mapswithme.util.ThemeSwitcher; import com.mapswithme.util.UiUtils; +import com.mapswithme.util.Utils; import com.mapswithme.util.log.Logger; import com.mapswithme.util.log.LoggerFactory; import com.mapswithme.util.statistics.Statistics; @@ -172,6 +174,7 @@ public class MwmApplication extends Application implements AppBackgroundTracker. mPurchaseOperationObservable = new PurchaseOperationObservable(); mPlayer = new MediaPlayerWrapper(this); mGeofenceRegistry = new GeofenceRegistryImpl(this); + WebView.setWebContentsDebuggingEnabled(Utils.isDebugOrBeta()); } private void initNotificationChannels() diff --git a/android/src/com/mapswithme/util/Utils.java b/android/src/com/mapswithme/util/Utils.java index 04477ffa24..be14d981e1 100644 --- a/android/src/com/mapswithme/util/Utils.java +++ b/android/src/com/mapswithme/util/Utils.java @@ -681,7 +681,7 @@ public class Utils catch (RuntimeException e) { LOGGER.e(TAG, "Failed to get string with id '" + key + "'", e); - if (BuildConfig.BUILD_TYPE.equals("debug") || BuildConfig.BUILD_TYPE.equals("beta")) + if (isDebugOrBeta()) { Toast.makeText(context, "Add string id for '" + key + "'!", Toast.LENGTH_LONG).show(); @@ -690,6 +690,11 @@ public class Utils return INVALID_ID; } + public static boolean isDebugOrBeta() + { + return BuildConfig.BUILD_TYPE.equals("debug") || BuildConfig.BUILD_TYPE.equals("beta"); + } + /** * Returns a string value for the specified key. If the value is not found then its key will be * returned.