commit
d4c505e674
5 changed files with 17 additions and 11 deletions
|
@ -22,7 +22,6 @@ import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
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.BaseBottomSheetItem;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem;
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem;
|
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.MainSettingsFragment;
|
||||||
import net.osmand.plus.settings.NavigationFragment;
|
import net.osmand.plus.settings.NavigationFragment;
|
||||||
import net.osmand.plus.settings.ProfileAppearanceFragment;
|
import net.osmand.plus.settings.ProfileAppearanceFragment;
|
||||||
|
import net.osmand.plus.settings.bottomsheets.BasePreferenceBottomSheet;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ import java.util.List;
|
||||||
|
|
||||||
import static net.osmand.plus.helpers.ImportHelper.ImportType.ROUTING;
|
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
|
private static final Log LOG = PlatformUtil
|
||||||
.getLog(SelectProfileBottomSheetDialogFragment.class);
|
.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 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;
|
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 tvTitle = itemView.findViewById(R.id.title);
|
||||||
TextView tvDescription = itemView.findViewById(R.id.description);
|
TextView tvDescription = itemView.findViewById(R.id.description);
|
||||||
ImageView ivIcon = itemView.findViewById(R.id.icon);
|
ImageView ivIcon = itemView.findViewById(R.id.icon);
|
||||||
|
|
|
@ -118,6 +118,8 @@ public class MainSettingsFragment extends BaseSettingsFragment {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString(DIALOG_TYPE, TYPE_BASE_APP_PROFILE);
|
bundle.putString(DIALOG_TYPE, TYPE_BASE_APP_PROFILE);
|
||||||
dialog.setArguments(bundle);
|
dialog.setArguments(bundle);
|
||||||
|
dialog.setUsedOnMap(false);
|
||||||
|
dialog.setAppMode(getSelectedAppMode());
|
||||||
if (getActivity() != null) {
|
if (getActivity() != null) {
|
||||||
getActivity().getSupportFragmentManager().beginTransaction()
|
getActivity().getSupportFragmentManager().beginTransaction()
|
||||||
.add(dialog, "select_base_profile").commitAllowingStateLoss();
|
.add(dialog, "select_base_profile").commitAllowingStateLoss();
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
package net.osmand.plus.settings;
|
package net.osmand.plus.settings;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.SwitchPreferenceCompat;
|
import android.support.v7.preference.SwitchPreferenceCompat;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
@ -113,6 +110,7 @@ public class NavigationFragment extends BaseSettingsFragment {
|
||||||
bundle.putString(DIALOG_TYPE, TYPE_NAV_PROFILE);
|
bundle.putString(DIALOG_TYPE, TYPE_NAV_PROFILE);
|
||||||
dialog.setArguments(bundle);
|
dialog.setArguments(bundle);
|
||||||
dialog.setUsedOnMap(false);
|
dialog.setUsedOnMap(false);
|
||||||
|
dialog.setAppMode(getSelectedAppMode());
|
||||||
if (getActivity() != null) {
|
if (getActivity() != null) {
|
||||||
getActivity().getSupportFragmentManager().beginTransaction()
|
getActivity().getSupportFragmentManager().beginTransaction()
|
||||||
.add(dialog, "select_nav_type").commitAllowingStateLoss();
|
.add(dialog, "select_nav_type").commitAllowingStateLoss();
|
||||||
|
@ -241,11 +239,15 @@ public class NavigationFragment extends BaseSettingsFragment {
|
||||||
return profilesObjects;
|
return profilesObjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ProfileDataObject> getBaseProfiles(Context ctx) {
|
public static List<ProfileDataObject> getBaseProfiles(OsmandApplication app) {
|
||||||
List<ProfileDataObject> profiles = new ArrayList<>();
|
List<ProfileDataObject> profiles = new ArrayList<>();
|
||||||
for (ApplicationMode mode : ApplicationMode.getDefaultValues()) {
|
for (ApplicationMode mode : ApplicationMode.allPossibleValues()) {
|
||||||
if (mode != ApplicationMode.DEFAULT) {
|
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()));
|
mode.getStringKey(), mode.getIconRes(), false, mode.getIconColorInfo()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -348,10 +348,12 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
|
||||||
selectNavTypeBtn.setOnClickListener(new View.OnClickListener() {
|
selectNavTypeBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (getSelectedAppMode().isCustomProfile()) {
|
if (isNewProfile) {
|
||||||
hideKeyboard();
|
hideKeyboard();
|
||||||
final SelectProfileBottomSheetDialogFragment fragment = new SelectProfileBottomSheetDialogFragment();
|
final SelectProfileBottomSheetDialogFragment fragment = new SelectProfileBottomSheetDialogFragment();
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
|
fragment.setUsedOnMap(false);
|
||||||
|
fragment.setAppMode(getSelectedAppMode());
|
||||||
if (getSelectedAppMode() != null) {
|
if (getSelectedAppMode() != null) {
|
||||||
bundle.putString(SELECTED_KEY, getSelectedAppMode().getRoutingProfile());
|
bundle.putString(SELECTED_KEY, getSelectedAppMode().getRoutingProfile());
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ public abstract class BasePreferenceBottomSheet extends MenuBottomSheetDialogFra
|
||||||
private ApplicationMode appMode;
|
private ApplicationMode appMode;
|
||||||
private boolean profileDependent;
|
private boolean profileDependent;
|
||||||
|
|
||||||
protected void setAppMode(ApplicationMode appMode) {
|
public void setAppMode(ApplicationMode appMode) {
|
||||||
this.appMode = appMode;
|
this.appMode = appMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue