diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml index 49af75e6e8..780b066d5f 100644 --- a/OsmAnd/res/values-de/strings.xml +++ b/OsmAnd/res/values-de/strings.xml @@ -3390,6 +3390,6 @@ Abgedeckte Fläche: %1$s x %2$s %1$s Importfehler: %2$s %1$s erfolgreich importiert. Weiß - %1 und %2 s tauschen + %1$s und %2$s tauschen Startpunkt \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 1dc9c484a7..ba102dcf9d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -2086,7 +2086,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven Fragment fragment = Fragment.instantiate(this, fragmentName); getSupportFragmentManager().beginTransaction() - .replace(R.id.fragmentContainer, fragment, fragment.getClass().getSimpleName()) + .replace(R.id.fragmentContainer, fragment, fragment.getClass().getName()) .addToBackStack(DRAWER_SETTINGS_ID + ".new") .commit(); diff --git a/OsmAnd/src/net/osmand/plus/profiles/SelectAppModesBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/profiles/SelectAppModesBottomSheetDialogFragment.java index 6dad949aab..af3a315e6a 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/SelectAppModesBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/profiles/SelectAppModesBottomSheetDialogFragment.java @@ -58,11 +58,12 @@ public class SelectAppModesBottomSheetDialogFragment extends AppModesBottomSheet dismiss(); } - public static void showInstance(@NonNull FragmentManager fm, Fragment target) { + public static void showInstance(@NonNull FragmentManager fm, Fragment target, boolean usedOnMap) { try { if (fm.findFragmentByTag(SelectAppModesBottomSheetDialogFragment.TAG) == null) { SelectAppModesBottomSheetDialogFragment fragment = new SelectAppModesBottomSheetDialogFragment(); fragment.setTargetFragment(target, 0); + fragment.setUsedOnMap(usedOnMap); fragment.show(fm, SelectAppModesBottomSheetDialogFragment.TAG); } } catch (RuntimeException e) { diff --git a/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java index e5bb17f270..2fdd8b2c78 100644 --- a/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java @@ -125,9 +125,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl @Override @SuppressLint("RestrictedApi") public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - nightMode = !settings.isLightContent(); - themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; - + updateTheme(); View view = super.onCreateView(inflater, container, savedInstanceState); if (view != null) { AndroidUtils.addStatusBarPadding21v(getContext(), view); @@ -145,10 +143,17 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl setDivider(null); view.setBackgroundColor(ContextCompat.getColor(app, getBackgroundColorRes())); } - return view; } + private boolean updateTheme() { + boolean nightMode = !settings.isLightContent(); + boolean changed = this.nightMode != nightMode; + this.nightMode = nightMode; + this.themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; + return changed; + } + @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); @@ -157,11 +162,9 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl @Override public RecyclerView onCreateRecyclerView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) { - LayoutInflater themedInflater = UiUtilities.getInflater(getActivity(), nightMode); - + LayoutInflater themedInflater = UiUtilities.getInflater(getActivity(), isNightMode()); RecyclerView recyclerView = super.onCreateRecyclerView(themedInflater, parent, savedInstanceState); recyclerView.setPadding(0, 0, 0, AndroidUtils.dpToPx(app, 80)); - return recyclerView; } @@ -285,8 +288,25 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl @Override public void onAppModeChanged() { - updateToolbar(); - updateAllSettings(); + if (updateTheme()) { + recreate(); + } else { + updateToolbar(); + updateAllSettings(); + } + } + + public void recreate() { + FragmentActivity activity = getActivity(); + if (activity != null) { + Fragment fragment = Fragment.instantiate(activity, currentScreenType.fragmentName); + FragmentManager fm = activity.getSupportFragmentManager(); + fm.popBackStack(); + fm.beginTransaction() + .replace(R.id.fragmentContainer, fragment, fragment.getClass().getName()) + .addToBackStack(DRAWER_SETTINGS_ID + ".new") + .commit(); + } } protected abstract void setupPreferences(); @@ -311,7 +331,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl AppBarLayout appBarLayout = (AppBarLayout) view.findViewById(R.id.appbar); ViewCompat.setElevation(appBarLayout, 5.0f); - View toolbarContainer = UiUtilities.getInflater(getActivity(), nightMode).inflate(currentScreenType.toolbarResId, appBarLayout); + View toolbarContainer = UiUtilities.getInflater(getActivity(), isNightMode()).inflate(currentScreenType.toolbarResId, appBarLayout); TextView toolbarTitle = (TextView) view.findViewById(R.id.toolbar_title); toolbarTitle.setText(getPreferenceScreen().getTitle()); @@ -334,7 +354,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl public void onClick(View v) { FragmentManager fragmentManager = getFragmentManager(); if (fragmentManager != null) { - SelectAppModesBottomSheetDialogFragment.showInstance(fragmentManager, BaseSettingsFragment.this); + SelectAppModesBottomSheetDialogFragment.showInstance(fragmentManager, BaseSettingsFragment.this, false); } } }); @@ -433,7 +453,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl public void updateAllSettings() { PreferenceScreen screen = getPreferenceScreen(); if (screen != null) { - getPreferenceScreen().removeAll(); + screen.removeAll(); } updatePreferencesScreen(); }