From 2fb22fbf2f3369a011036785a02d5d71fd0e0cd2 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Tue, 5 Jan 2021 16:07:31 +0200 Subject: [PATCH] Fix #10437 --- .../layout/fragment_wikivoyage_article_dialog.xml | 1 + OsmAnd/src/net/osmand/AndroidUtils.java | 12 ++++++++++++ .../src/net/osmand/plus/activities/ExitActivity.java | 2 ++ .../osmand/plus/activities/PrintDialogActivity.java | 3 ++- .../plus/dialogs/HelpArticleDialogFragment.java | 1 + .../osmand/plus/mapillary/MapillaryImageDialog.java | 1 + .../plus/wikipedia/WikipediaDialogFragment.java | 3 +-- .../article/WikivoyageArticleDialogFragment.java | 1 + 8 files changed, 21 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/layout/fragment_wikivoyage_article_dialog.xml b/OsmAnd/res/layout/fragment_wikivoyage_article_dialog.xml index 232e041b75..c001ab748e 100644 --- a/OsmAnd/res/layout/fragment_wikivoyage_article_dialog.xml +++ b/OsmAnd/res/layout/fragment_wikivoyage_article_dialog.xml @@ -63,6 +63,7 @@ android:layout_width="match_parent" android:layout_weight="1" android:layout_height="0dp"> + = Build.VERSION_CODES.N) { + OsmandApplication app = (OsmandApplication) activity.getApplicationContext(); + app.checkPreferredLocale(); + activity.getResources().updateConfiguration( + new Configuration(app.getResources().getConfiguration()), + activity.getResources().getDisplayMetrics()); + } + } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/activities/ExitActivity.java b/OsmAnd/src/net/osmand/plus/activities/ExitActivity.java index 67beabb1ad..5097a4f0cc 100644 --- a/OsmAnd/src/net/osmand/plus/activities/ExitActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/ExitActivity.java @@ -1,5 +1,6 @@ package net.osmand.plus.activities; +import net.osmand.AndroidUtils; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import android.app.Activity; @@ -14,6 +15,7 @@ public class ExitActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.help_activity); + AndroidUtils.fixWebViewResetsLocaleToUserDefault(this); dis = getIntent().getBooleanExtra(DISABLE_SERVICE, true); } diff --git a/OsmAnd/src/net/osmand/plus/activities/PrintDialogActivity.java b/OsmAnd/src/net/osmand/plus/activities/PrintDialogActivity.java index 6c7e4d6579..b2211a639d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/PrintDialogActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/PrintDialogActivity.java @@ -3,7 +3,7 @@ */ package net.osmand.plus.activities; -import android.view.Window; +import net.osmand.AndroidUtils; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import android.annotation.SuppressLint; @@ -43,6 +43,7 @@ public class PrintDialogActivity extends ActionBarProgressActivity { getSupportActionBar().setTitle(R.string.print_route); setContentView(R.layout.print_dialog); + AndroidUtils.fixWebViewResetsLocaleToUserDefault(this); webView = (WebView) findViewById(R.id.printDialogWebview); Intent intent = getIntent(); diff --git a/OsmAnd/src/net/osmand/plus/dialogs/HelpArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/dialogs/HelpArticleDialogFragment.java index 42a036599c..3c47372356 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/HelpArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/HelpArticleDialogFragment.java @@ -54,6 +54,7 @@ public class HelpArticleDialogFragment extends DialogFragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.fragment_help_article, container, false); + AndroidUtils.fixWebViewResetsLocaleToUserDefault(getActivity()); Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar); toolbar.setNavigationIcon(AndroidUtils.getNavigationIconResId(getContext())); diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryImageDialog.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryImageDialog.java index 7b9cd23b69..d20f03f4fe 100644 --- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryImageDialog.java +++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryImageDialog.java @@ -220,6 +220,7 @@ public class MapillaryImageDialog extends ContextMenuCardDialog { @SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"}) private View getWebView() { View view = getMapActivity().getLayoutInflater().inflate(R.layout.mapillary_web_view, null); + AndroidUtils.fixWebViewResetsLocaleToUserDefault(getMapActivity()); final WebView webView = view.findViewById(R.id.webView); webView.setBackgroundColor(Color.argb(1, 0, 0, 0)); final View noInternetView = view.findViewById(R.id.mapillaryNoInternetLayout); diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaDialogFragment.java index 72ea3560cb..1ea89040cd 100644 --- a/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaDialogFragment.java @@ -17,7 +17,6 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.webkit.WebSettings; -import android.webkit.WebView; import android.widget.ImageView; import android.widget.TextView; @@ -28,7 +27,6 @@ import androidx.appcompat.widget.PopupMenu; import androidx.appcompat.widget.Toolbar; import androidx.browser.customtabs.CustomTabsIntent; import androidx.core.content.ContextCompat; -import androidx.core.view.MotionEventCompat; import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; @@ -74,6 +72,7 @@ public class WikipediaDialogFragment extends WikiArticleBaseDialogFragment { @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View mainView = inflater.inflate(R.layout.wikipedia_dialog_fragment, container, false); + AndroidUtils.fixWebViewResetsLocaleToUserDefault(getActivity()); setupToolbar((Toolbar) mainView.findViewById(R.id.toolbar)); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index 9303fb7b84..bc322b31fe 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -91,6 +91,7 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme } final View mainView = inflate(R.layout.fragment_wikivoyage_article_dialog, container); + AndroidUtils.fixWebViewResetsLocaleToUserDefault(getActivity()); setupToolbar((Toolbar) mainView.findViewById(R.id.toolbar));