From 7d5e139210a3c361fc8c7f5e7191ef9ed93fecad Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Fri, 14 Feb 2020 16:53:25 +0200 Subject: [PATCH 1/2] Preferences ui fixes --- .../plus/profiles/SelectProfileBottomSheetDialogFragment.java | 4 ++-- OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java | 4 ++-- .../net/osmand/plus/settings/ProfileAppearanceFragment.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/profiles/SelectProfileBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/profiles/SelectProfileBottomSheetDialogFragment.java index f968291d6e..52e7d56d75 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/SelectProfileBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/profiles/SelectProfileBottomSheetDialogFragment.java @@ -181,7 +181,7 @@ public class SelectProfileBottomSheetDialogFragment extends MenuBottomSheetDialo int activeColorResId = nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light; int iconDefaultColorResId = nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light; - View itemView = View.inflate(getContext(), R.layout.bottom_sheet_item_with_descr_and_radio_btn, null); + View itemView = UiUtilities.getInflater(getContext(), nightMode).inflate(R.layout.bottom_sheet_item_with_descr_and_radio_btn, null); TextView tvTitle = itemView.findViewById(R.id.title); TextView tvDescription = itemView.findViewById(R.id.description); ImageView ivIcon = itemView.findViewById(R.id.icon); @@ -239,7 +239,7 @@ public class SelectProfileBottomSheetDialogFragment extends MenuBottomSheetDialo if (type.equals(TYPE_NAV_PROFILE)) { profiles.addAll(NavigationFragment.getSortedRoutingProfiles(app)); } else if (type.equals(TYPE_BASE_APP_PROFILE)) { - profiles.addAll(NavigationFragment.getBaseProfiles(app)); + profiles.addAll(NavigationFragment.getBaseProfiles()); } else { LOG.error("Check data type!"); dismiss(); diff --git a/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java b/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java index 38a6dbccf9..2bcf275ae3 100644 --- a/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java @@ -241,9 +241,9 @@ public class NavigationFragment extends BaseSettingsFragment { return profilesObjects; } - public static List getBaseProfiles(Context ctx) { + public static List getBaseProfiles() { List profiles = new ArrayList<>(); - for (ApplicationMode mode : ApplicationMode.getDefaultValues()) { + for (ApplicationMode mode : ApplicationMode.allPossibleValues()) { if (mode != ApplicationMode.DEFAULT) { profiles.add(new ProfileDataObject(mode.toHumanString(), mode.getDescription(), mode.getStringKey(), mode.getIconRes(), false, mode.getIconColorInfo())); diff --git a/OsmAnd/src/net/osmand/plus/settings/ProfileAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/settings/ProfileAppearanceFragment.java index 7db17b5c5e..81a9261487 100644 --- a/OsmAnd/src/net/osmand/plus/settings/ProfileAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/ProfileAppearanceFragment.java @@ -348,7 +348,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment { selectNavTypeBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if (getSelectedAppMode().isCustomProfile()) { + if (isNewProfile) { hideKeyboard(); final SelectProfileBottomSheetDialogFragment fragment = new SelectProfileBottomSheetDialogFragment(); Bundle bundle = new Bundle(); From 52b79b7f6e4ba97daa8f146c0e952ac3f57ce767 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Fri, 14 Feb 2020 17:21:48 +0200 Subject: [PATCH 2/2] Fix select profile theme bug --- .../SelectProfileBottomSheetDialogFragment.java | 6 +++--- .../osmand/plus/settings/MainSettingsFragment.java | 2 ++ .../net/osmand/plus/settings/NavigationFragment.java | 12 +++++++----- .../plus/settings/ProfileAppearanceFragment.java | 2 ++ .../bottomsheets/BasePreferenceBottomSheet.java | 2 +- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/profiles/SelectProfileBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/profiles/SelectProfileBottomSheetDialogFragment.java index 52e7d56d75..6b737143b7 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/SelectProfileBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/profiles/SelectProfileBottomSheetDialogFragment.java @@ -22,7 +22,6 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem; @@ -30,6 +29,7 @@ import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; import net.osmand.plus.settings.MainSettingsFragment; import net.osmand.plus.settings.NavigationFragment; import net.osmand.plus.settings.ProfileAppearanceFragment; +import net.osmand.plus.settings.bottomsheets.BasePreferenceBottomSheet; import org.apache.commons.logging.Log; @@ -38,7 +38,7 @@ import java.util.List; import static net.osmand.plus.helpers.ImportHelper.ImportType.ROUTING; -public class SelectProfileBottomSheetDialogFragment extends MenuBottomSheetDialogFragment { +public class SelectProfileBottomSheetDialogFragment extends BasePreferenceBottomSheet { private static final Log LOG = PlatformUtil .getLog(SelectProfileBottomSheetDialogFragment.class); @@ -239,7 +239,7 @@ public class SelectProfileBottomSheetDialogFragment extends MenuBottomSheetDialo if (type.equals(TYPE_NAV_PROFILE)) { profiles.addAll(NavigationFragment.getSortedRoutingProfiles(app)); } else if (type.equals(TYPE_BASE_APP_PROFILE)) { - profiles.addAll(NavigationFragment.getBaseProfiles()); + profiles.addAll(NavigationFragment.getBaseProfiles(app)); } else { LOG.error("Check data type!"); dismiss(); diff --git a/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java index 8c7c50a435..ca6f0dcdab 100644 --- a/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java @@ -118,6 +118,8 @@ public class MainSettingsFragment extends BaseSettingsFragment { Bundle bundle = new Bundle(); bundle.putString(DIALOG_TYPE, TYPE_BASE_APP_PROFILE); dialog.setArguments(bundle); + dialog.setUsedOnMap(false); + dialog.setAppMode(getSelectedAppMode()); if (getActivity() != null) { getActivity().getSupportFragmentManager().beginTransaction() .add(dialog, "select_base_profile").commitAllowingStateLoss(); diff --git a/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java b/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java index 2bcf275ae3..ba7b3ab808 100644 --- a/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java @@ -1,12 +1,9 @@ package net.osmand.plus.settings; -import android.content.Context; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.support.v7.preference.Preference; import android.support.v7.preference.SwitchPreferenceCompat; -import android.view.LayoutInflater; -import android.view.View; import net.osmand.plus.ApplicationMode; import net.osmand.plus.OsmandApplication; @@ -113,6 +110,7 @@ public class NavigationFragment extends BaseSettingsFragment { bundle.putString(DIALOG_TYPE, TYPE_NAV_PROFILE); dialog.setArguments(bundle); dialog.setUsedOnMap(false); + dialog.setAppMode(getSelectedAppMode()); if (getActivity() != null) { getActivity().getSupportFragmentManager().beginTransaction() .add(dialog, "select_nav_type").commitAllowingStateLoss(); @@ -241,11 +239,15 @@ public class NavigationFragment extends BaseSettingsFragment { return profilesObjects; } - public static List getBaseProfiles() { + public static List getBaseProfiles(OsmandApplication app) { List profiles = new ArrayList<>(); for (ApplicationMode mode : ApplicationMode.allPossibleValues()) { if (mode != ApplicationMode.DEFAULT) { - profiles.add(new ProfileDataObject(mode.toHumanString(), mode.getDescription(), + String description = mode.getDescription(); + if (Algorithms.isEmpty(description)) { + description = getAppModeDescription(app, mode); + } + profiles.add(new ProfileDataObject(mode.toHumanString(), description, mode.getStringKey(), mode.getIconRes(), false, mode.getIconColorInfo())); } } diff --git a/OsmAnd/src/net/osmand/plus/settings/ProfileAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/settings/ProfileAppearanceFragment.java index 81a9261487..c2c4f25439 100644 --- a/OsmAnd/src/net/osmand/plus/settings/ProfileAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/ProfileAppearanceFragment.java @@ -352,6 +352,8 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment { hideKeyboard(); final SelectProfileBottomSheetDialogFragment fragment = new SelectProfileBottomSheetDialogFragment(); Bundle bundle = new Bundle(); + fragment.setUsedOnMap(false); + fragment.setAppMode(getSelectedAppMode()); if (getSelectedAppMode() != null) { bundle.putString(SELECTED_KEY, getSelectedAppMode().getRoutingProfile()); } diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BasePreferenceBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BasePreferenceBottomSheet.java index f6ae08a36c..c40c2739dd 100644 --- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BasePreferenceBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BasePreferenceBottomSheet.java @@ -24,7 +24,7 @@ public abstract class BasePreferenceBottomSheet extends MenuBottomSheetDialogFra private ApplicationMode appMode; private boolean profileDependent; - protected void setAppMode(ApplicationMode appMode) { + public void setAppMode(ApplicationMode appMode) { this.appMode = appMode; }