From c2465e05c276466c18d8064ba9bb9c29bc6c2769 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Thu, 30 Jan 2020 12:48:39 +0200 Subject: [PATCH 1/2] Issue navigation bar color --- OsmAnd/src/net/osmand/plus/base/BaseOsmAndFragment.java | 2 ++ .../net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java | 1 + .../src/net/osmand/plus/chooseplan/OsmLiveCancelledDialog.java | 1 + .../osmand/plus/mapmarkers/CoordinateInputDialogFragment.java | 1 + OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java | 2 ++ .../src/net/osmand/plus/wikivoyage/WikiBaseDialogFragment.java | 1 + .../plus/wikivoyage/explore/WikivoyageExploreActivity.java | 1 + 7 files changed, 9 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/base/BaseOsmAndFragment.java b/OsmAnd/src/net/osmand/plus/base/BaseOsmAndFragment.java index 35915f558c..46eb9c95c3 100644 --- a/OsmAnd/src/net/osmand/plus/base/BaseOsmAndFragment.java +++ b/OsmAnd/src/net/osmand/plus/base/BaseOsmAndFragment.java @@ -42,6 +42,7 @@ public class BaseOsmAndFragment extends Fragment implements TransitionAnimator { } else { statusBarColor = activity.getWindow().getStatusBarColor(); activity.getWindow().setStatusBarColor(ContextCompat.getColor(activity, colorId)); + activity.getWindow().setNavigationBarColor(ContextCompat.getColor(activity, colorId)); } } if (!isFullScreenAllowed() && activity instanceof MapActivity) { @@ -59,6 +60,7 @@ public class BaseOsmAndFragment extends Fragment implements TransitionAnimator { if (activity != null) { if (!(activity instanceof MapActivity) && statusBarColor != -1) { activity.getWindow().setStatusBarColor(statusBarColor); + activity.getWindow().setNavigationBarColor(statusBarColor); } if (!isFullScreenAllowed() && activity instanceof MapActivity) { ((MapActivity) activity).enterToFullScreen(); diff --git a/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java b/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java index 6c114d8218..c2510c0469 100644 --- a/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java @@ -171,6 +171,7 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment } if (Build.VERSION.SDK_INT >= 21) { window.setStatusBarColor(ContextCompat.getColor(ctx, getStatusBarColor())); + window.setNavigationBarColor(ContextCompat.getColor(ctx, getStatusBarColor())); } } return dialog; diff --git a/OsmAnd/src/net/osmand/plus/chooseplan/OsmLiveCancelledDialog.java b/OsmAnd/src/net/osmand/plus/chooseplan/OsmLiveCancelledDialog.java index 9dac53298c..ec2aae3507 100644 --- a/OsmAnd/src/net/osmand/plus/chooseplan/OsmLiveCancelledDialog.java +++ b/OsmAnd/src/net/osmand/plus/chooseplan/OsmLiveCancelledDialog.java @@ -79,6 +79,7 @@ public class OsmLiveCancelledDialog extends BaseOsmAndDialogFragment implements } if (Build.VERSION.SDK_INT >= 21) { window.setStatusBarColor(ContextCompat.getColor(ctx, getStatusBarColor())); + window.setNavigationBarColor(ContextCompat.getColor(ctx, getStatusBarColor())); } } return dialog; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java index acaceda8a7..480d4f4300 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java @@ -241,6 +241,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); if (!lightTheme && Build.VERSION.SDK_INT >= 21) { window.setStatusBarColor(getResolvedColor(R.color.status_bar_coordinate_input_dark)); + window.setNavigationBarColor(getResolvedColor(R.color.status_bar_coordinate_input_dark)); } } return dialog; diff --git a/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java index 5a8610e9a2..f4a3f15278 100644 --- a/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java @@ -237,6 +237,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl } else { statusBarColor = activity.getWindow().getStatusBarColor(); activity.getWindow().setStatusBarColor(ContextCompat.getColor(activity, colorId)); + activity.getWindow().setNavigationBarColor(ContextCompat.getColor(activity, colorId)); } } if (activity instanceof MapActivity) { @@ -259,6 +260,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl if (Build.VERSION.SDK_INT >= 21) { if (!(activity instanceof MapActivity) && statusBarColor != -1) { activity.getWindow().setStatusBarColor(statusBarColor); + activity.getWindow().setNavigationBarColor(statusBarColor); } if (activity instanceof MapActivity) { ((MapActivity) activity).enterToFullScreen(); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikiBaseDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikiBaseDialogFragment.java index d74a355a76..add373e494 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikiBaseDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikiBaseDialogFragment.java @@ -45,6 +45,7 @@ public class WikiBaseDialogFragment extends BaseOsmAndDialogFragment { } if (Build.VERSION.SDK_INT >= 21) { window.setStatusBarColor(getResolvedColor(getStatusBarColor())); + window.setNavigationBarColor(getResolvedColor(getStatusBarColor())); } } return dialog; diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java index 3941f44906..9a3c7429b1 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java @@ -79,6 +79,7 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv } if (Build.VERSION.SDK_INT >= 21) { window.setStatusBarColor(getResolvedColor(getStatusBarColor())); + window.setNavigationBarColor(getResolvedColor(getStatusBarColor())); } } From 22992aa8d78d70266290994924d7a871e02d3e68 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Thu, 30 Jan 2020 17:15:00 +0200 Subject: [PATCH 2/2] Fix #5865 --- OsmAnd/res/values/colors.xml | 3 +++ .../src/net/osmand/plus/activities/MapActivity.java | 11 +++++++++++ .../src/net/osmand/plus/base/BaseOsmAndFragment.java | 2 -- .../plus/chooseplan/ChoosePlanDialogFragment.java | 1 - .../plus/chooseplan/OsmLiveCancelledDialog.java | 1 - .../mapmarkers/CoordinateInputDialogFragment.java | 1 - .../osmand/plus/settings/BaseSettingsFragment.java | 3 +-- .../plus/wikivoyage/WikiBaseDialogFragment.java | 1 - .../wikivoyage/explore/WikivoyageExploreActivity.java | 1 - 9 files changed, 15 insertions(+), 9 deletions(-) diff --git a/OsmAnd/res/values/colors.xml b/OsmAnd/res/values/colors.xml index 93da10b6a0..658b32a8ff 100644 --- a/OsmAnd/res/values/colors.xml +++ b/OsmAnd/res/values/colors.xml @@ -422,6 +422,9 @@ #ff8800 #101112 #E68200 + #CCCCCC + #2B2E31 + #17181a #f0f0f0 #222526 diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 6449751c41..6630907879 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -1520,6 +1520,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven mapLayers.updateLayers(mapView); mapActions.updateDrawerMenu(); + updateNavigationBarColor(); mapView.setComplexZoom(mapView.getZoom(), mapView.getSettingsMapDensity()); app.getDaynightHelper().startSensorIfNeeded(new StateChangedListener() { @@ -1532,6 +1533,16 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven applyScreenOrientation(); } + public void updateNavigationBarColor() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + if (getMyApplication().getDaynightHelper().isNightModeForMapControls() || getMyApplication().getDaynightHelper().isNightMode()) { + getWindow().setNavigationBarColor(ContextCompat.getColor(app, R.color.navigation_bar_bg_dark)); + } else { + getWindow().setNavigationBarColor(ContextCompat.getColor(app, R.color.navigation_bar_bg_light)); + } + } + } + public void updateMapSettings() { if (app.isApplicationInitializing()) { return; diff --git a/OsmAnd/src/net/osmand/plus/base/BaseOsmAndFragment.java b/OsmAnd/src/net/osmand/plus/base/BaseOsmAndFragment.java index 46eb9c95c3..35915f558c 100644 --- a/OsmAnd/src/net/osmand/plus/base/BaseOsmAndFragment.java +++ b/OsmAnd/src/net/osmand/plus/base/BaseOsmAndFragment.java @@ -42,7 +42,6 @@ public class BaseOsmAndFragment extends Fragment implements TransitionAnimator { } else { statusBarColor = activity.getWindow().getStatusBarColor(); activity.getWindow().setStatusBarColor(ContextCompat.getColor(activity, colorId)); - activity.getWindow().setNavigationBarColor(ContextCompat.getColor(activity, colorId)); } } if (!isFullScreenAllowed() && activity instanceof MapActivity) { @@ -60,7 +59,6 @@ public class BaseOsmAndFragment extends Fragment implements TransitionAnimator { if (activity != null) { if (!(activity instanceof MapActivity) && statusBarColor != -1) { activity.getWindow().setStatusBarColor(statusBarColor); - activity.getWindow().setNavigationBarColor(statusBarColor); } if (!isFullScreenAllowed() && activity instanceof MapActivity) { ((MapActivity) activity).enterToFullScreen(); diff --git a/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java b/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java index c2510c0469..6c114d8218 100644 --- a/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java @@ -171,7 +171,6 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment } if (Build.VERSION.SDK_INT >= 21) { window.setStatusBarColor(ContextCompat.getColor(ctx, getStatusBarColor())); - window.setNavigationBarColor(ContextCompat.getColor(ctx, getStatusBarColor())); } } return dialog; diff --git a/OsmAnd/src/net/osmand/plus/chooseplan/OsmLiveCancelledDialog.java b/OsmAnd/src/net/osmand/plus/chooseplan/OsmLiveCancelledDialog.java index ec2aae3507..9dac53298c 100644 --- a/OsmAnd/src/net/osmand/plus/chooseplan/OsmLiveCancelledDialog.java +++ b/OsmAnd/src/net/osmand/plus/chooseplan/OsmLiveCancelledDialog.java @@ -79,7 +79,6 @@ public class OsmLiveCancelledDialog extends BaseOsmAndDialogFragment implements } if (Build.VERSION.SDK_INT >= 21) { window.setStatusBarColor(ContextCompat.getColor(ctx, getStatusBarColor())); - window.setNavigationBarColor(ContextCompat.getColor(ctx, getStatusBarColor())); } } return dialog; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java index 480d4f4300..acaceda8a7 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java @@ -241,7 +241,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); if (!lightTheme && Build.VERSION.SDK_INT >= 21) { window.setStatusBarColor(getResolvedColor(R.color.status_bar_coordinate_input_dark)); - window.setNavigationBarColor(getResolvedColor(R.color.status_bar_coordinate_input_dark)); } } return dialog; diff --git a/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java index f4a3f15278..f1824f7b50 100644 --- a/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java @@ -237,7 +237,6 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl } else { statusBarColor = activity.getWindow().getStatusBarColor(); activity.getWindow().setStatusBarColor(ContextCompat.getColor(activity, colorId)); - activity.getWindow().setNavigationBarColor(ContextCompat.getColor(activity, colorId)); } } if (activity instanceof MapActivity) { @@ -260,7 +259,6 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl if (Build.VERSION.SDK_INT >= 21) { if (!(activity instanceof MapActivity) && statusBarColor != -1) { activity.getWindow().setStatusBarColor(statusBarColor); - activity.getWindow().setNavigationBarColor(statusBarColor); } if (activity instanceof MapActivity) { ((MapActivity) activity).enterToFullScreen(); @@ -276,6 +274,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl Activity activity = getActivity(); if (activity instanceof MapActivity) { ((MapActivity) activity).updateStatusBarColor(); + ((MapActivity) activity).updateNavigationBarColor(); } } } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikiBaseDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikiBaseDialogFragment.java index add373e494..d74a355a76 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikiBaseDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikiBaseDialogFragment.java @@ -45,7 +45,6 @@ public class WikiBaseDialogFragment extends BaseOsmAndDialogFragment { } if (Build.VERSION.SDK_INT >= 21) { window.setStatusBarColor(getResolvedColor(getStatusBarColor())); - window.setNavigationBarColor(getResolvedColor(getStatusBarColor())); } } return dialog; diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java index 9a3c7429b1..3941f44906 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java @@ -79,7 +79,6 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv } if (Build.VERSION.SDK_INT >= 21) { window.setStatusBarColor(getResolvedColor(getStatusBarColor())); - window.setNavigationBarColor(getResolvedColor(getStatusBarColor())); } }