diff --git a/OsmAnd/src/net/osmand/plus/profiles/SelectProfileBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/profiles/SelectProfileBottomSheetDialogFragment.java index f968291d6e..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); @@ -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); 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 38a6dbccf9..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(Context ctx) { + public static List getBaseProfiles(OsmandApplication app) { 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(), + 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 7db17b5c5e..c2c4f25439 100644 --- a/OsmAnd/src/net/osmand/plus/settings/ProfileAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/ProfileAppearanceFragment.java @@ -348,10 +348,12 @@ 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(); + 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; }