Remove unnecessary context as methods parameter

This commit is contained in:
Vitaliy 2020-01-30 15:30:37 +02:00
parent 148f3974e5
commit 468428e9d2
27 changed files with 110 additions and 98 deletions

View file

@ -1,6 +1,5 @@
package net.osmand.plus; package net.osmand.plus;
import android.content.Context;
import android.support.annotation.DrawableRes; import android.support.annotation.DrawableRes;
import com.google.gson.Gson; import com.google.gson.Gson;
@ -258,7 +257,7 @@ public class ApplicationMode {
return false; return false;
} }
public boolean isWidgetVisible(OsmandApplication app, String key) { public boolean isWidgetVisible(String key) {
if (app.getAppCustomization().areWidgetsCustomized()) { if (app.getAppCustomization().areWidgetsCustomized()) {
return app.getAppCustomization().isWidgetVisible(key, this); return app.getAppCustomization().isWidgetVisible(key, this);
} }
@ -286,7 +285,7 @@ public class ApplicationMode {
return set; return set;
} }
public boolean isWidgetAvailable(OsmandApplication app, String key) { public boolean isWidgetAvailable(String key) {
if (app.getAppCustomization().areWidgetsCustomized()) { if (app.getAppCustomization().areWidgetsCustomized()) {
return app.getAppCustomization().isWidgetAvailable(key, this); return app.getAppCustomization().isWidgetAvailable(key, this);
} }
@ -313,12 +312,19 @@ public class ApplicationMode {
return parentAppMode; return parentAppMode;
} }
public void setParentAppMode(ApplicationMode parentAppMode) {
if (isCustomProfile()) {
this.parentAppMode = parentAppMode;
app.getSettings().PARENT_APP_MODE.setModeValue(this, parentAppMode.getStringKey());
}
}
public int getNameKeyResource() { public int getNameKeyResource() {
return keyName; return keyName;
} }
public String toHumanString(Context ctx) { public String toHumanString() {
String userProfileName = getCustomProfileName(); String userProfileName = getUserProfileName();
if (Algorithms.isEmpty(userProfileName) && keyName != -1) { if (Algorithms.isEmpty(userProfileName) && keyName != -1) {
return app.getString(keyName); return app.getString(keyName);
} else { } else {
@ -326,7 +332,7 @@ public class ApplicationMode {
} }
} }
public String getDescription(Context ctx) { public String getDescription() {
if (descriptionId != 0) { if (descriptionId != 0) {
return app.getString(descriptionId); return app.getString(descriptionId);
} }
@ -393,7 +399,23 @@ public class ApplicationMode {
app.getSettings().DEFAULT_SPEED.resetModeToDefault(this); app.getSettings().DEFAULT_SPEED.resetModeToDefault(this);
} }
public String getCustomProfileName() { public float getMinSpeed() {
return app.getSettings().MIN_SPEED.getModeValue(this);
}
public void setMinSpeed(float defaultSpeed) {
app.getSettings().MIN_SPEED.setModeValue(this, defaultSpeed);
}
public float getMaxSpeed() {
return app.getSettings().MAX_SPEED.getModeValue(this);
}
public void setMaxSpeed(float defaultSpeed) {
app.getSettings().MAX_SPEED.setModeValue(this, defaultSpeed);
}
public String getUserProfileName() {
return app.getSettings().USER_PROFILE_NAME.getModeValue(this); return app.getSettings().USER_PROFILE_NAME.getModeValue(this);
} }
@ -401,11 +423,8 @@ public class ApplicationMode {
app.getSettings().USER_PROFILE_NAME.setModeValue(this, userProfileName); app.getSettings().USER_PROFILE_NAME.setModeValue(this, userProfileName);
} }
public void setParentAppMode(ApplicationMode parentAppMode) { public String getRoutingProfile() {
if (isCustomProfile()) { return app.getSettings().ROUTING_PROFILE.getModeValue(this);
this.parentAppMode = parentAppMode;
app.getSettings().PARENT_APP_MODE.setModeValue(this, parentAppMode.getStringKey());
}
} }
public void setRoutingProfile(String routingProfile) { public void setRoutingProfile(String routingProfile) {
@ -436,18 +455,14 @@ public class ApplicationMode {
app.getSettings().LOCATION_ICON.setModeValue(this, locationIcon); app.getSettings().LOCATION_ICON.setModeValue(this, locationIcon);
} }
public String getRoutingProfile() { public ProfileIconColors getIconColorInfo() {
return app.getSettings().ROUTING_PROFILE.getModeValue(this); return app.getSettings().ICON_COLOR.getModeValue(this);
} }
public void setIconColor(ProfileIconColors iconColor) { public void setIconColor(ProfileIconColors iconColor) {
app.getSettings().ICON_COLOR.setModeValue(this, iconColor); app.getSettings().ICON_COLOR.setModeValue(this, iconColor);
} }
public ProfileIconColors getIconColorInfo() {
return app.getSettings().ICON_COLOR.getModeValue(this);
}
public int getOrder() { public int getOrder() {
return app.getSettings().APP_MODE_ORDER.getModeValue(this); return app.getSettings().APP_MODE_ORDER.getModeValue(this);
} }
@ -510,7 +525,7 @@ public class ApplicationMode {
} }
} }
public static void saveCustomAppModesToSettings(OsmandApplication app) { private static void saveCustomAppModesToSettings(OsmandApplication app) {
OsmandSettings settings = app.getSettings(); OsmandSettings settings = app.getSettings();
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
Iterator<ApplicationMode> it = ApplicationMode.getCustomValues().iterator(); Iterator<ApplicationMode> it = ApplicationMode.getCustomValues().iterator();
@ -545,19 +560,21 @@ public class ApplicationMode {
return mode; return mode;
} }
public static ApplicationModeBuilder fromJson(String json) { public static ApplicationModeBean fromJson(String json) {
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
ApplicationModeBean mb = gson.fromJson(json, ApplicationModeBean.class); return gson.fromJson(json, ApplicationModeBean.class);
}
ApplicationModeBuilder builder = createCustomMode(valueOfStringKey(mb.parent, null), mb.stringKey); public static ApplicationModeBuilder fromModeBean(ApplicationModeBean modeBean) {
builder.setUserProfileName(mb.userProfileName); ApplicationModeBuilder builder = createCustomMode(valueOfStringKey(modeBean.parent, null), modeBean.stringKey);
builder.setIconResName(mb.iconName); builder.setUserProfileName(modeBean.userProfileName);
builder.setIconColor(mb.iconColor); builder.setIconResName(modeBean.iconName);
builder.setRoutingProfile(mb.routingProfile); builder.setIconColor(modeBean.iconColor);
builder.setRouteService(mb.routeService); builder.setRoutingProfile(modeBean.routingProfile);
builder.setLocationIcon(mb.locIcon); builder.setRouteService(modeBean.routeService);
builder.setNavigationIcon(mb.navIcon); builder.setLocationIcon(modeBean.locIcon);
builder.setOrder(mb.order); builder.setNavigationIcon(modeBean.navIcon);
builder.setOrder(modeBean.order);
return builder; return builder;
} }
@ -565,7 +582,7 @@ public class ApplicationMode {
public String toJson() { public String toJson() {
ApplicationModeBean mb = new ApplicationModeBean(); ApplicationModeBean mb = new ApplicationModeBean();
mb.stringKey = stringKey; mb.stringKey = stringKey;
mb.userProfileName = getCustomProfileName(); mb.userProfileName = getUserProfileName();
mb.iconColor = getIconColorInfo(); mb.iconColor = getIconColorInfo();
mb.iconName = getIconName(); mb.iconName = getIconName();
mb.parent = parentAppMode != null ? parentAppMode.getStringKey() : null; mb.parent = parentAppMode != null ? parentAppMode.getStringKey() : null;

View file

@ -12,6 +12,7 @@ import android.support.v7.app.AlertDialog;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.plus.ApplicationMode.ApplicationModeBuilder; import net.osmand.plus.ApplicationMode.ApplicationModeBuilder;
import net.osmand.plus.OsmandSettings.OsmandPreference; import net.osmand.plus.OsmandSettings.OsmandPreference;
import net.osmand.plus.ApplicationMode.ApplicationModeBean;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -400,6 +401,7 @@ public class SettingsHelper {
private ApplicationMode appMode; private ApplicationMode appMode;
private ApplicationModeBuilder builder; private ApplicationModeBuilder builder;
private ApplicationModeBean modeBean;
public ProfileSettingsItem(@NonNull OsmandSettings settings, @NonNull ApplicationMode appMode) { public ProfileSettingsItem(@NonNull OsmandSettings settings, @NonNull ApplicationMode appMode) {
super(SettingsItemType.PROFILE, settings); super(SettingsItemType.PROFILE, settings);
@ -421,7 +423,7 @@ public class SettingsHelper {
@Override @Override
public String getPublicName(@NonNull Context ctx) { public String getPublicName(@NonNull Context ctx) {
if (appMode.isCustomProfile()) { if (appMode.isCustomProfile()) {
return appMode.getCustomProfileName(); return modeBean.userProfileName;
} else if (appMode.getNameKeyResource() != -1) { } else if (appMode.getNameKeyResource() != -1) {
return ctx.getString(appMode.getNameKeyResource()); return ctx.getString(appMode.getNameKeyResource());
} else { } else {
@ -437,7 +439,8 @@ public class SettingsHelper {
void readFromJson(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException { void readFromJson(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException {
String appModeJson = json.getString("appMode"); String appModeJson = json.getString("appMode");
builder = ApplicationMode.fromJson(appModeJson); modeBean = ApplicationMode.fromJson(appModeJson);
builder = ApplicationMode.fromModeBean(modeBean);
ApplicationMode appMode = builder.getApplicationMode(); ApplicationMode appMode = builder.getApplicationMode();
if (!appMode.isCustomProfile()) { if (!appMode.isCustomProfile()) {
appMode = ApplicationMode.valueOfStringKey(appMode.getStringKey(), appMode); appMode = ApplicationMode.valueOfStringKey(appMode.getStringKey(), appMode);

View file

@ -673,7 +673,7 @@ public class MapActivityActions implements DialogProvider {
for (final ApplicationMode appMode : activeModes) { for (final ApplicationMode appMode : activeModes) {
if (appMode.isCustomProfile()) { if (appMode.isCustomProfile()) {
modeDescription = String.format(app.getString(R.string.profile_type_descr_string), modeDescription = String.format(app.getString(R.string.profile_type_descr_string),
Algorithms.capitalizeFirstLetterAndLowercase(appMode.getParent().toHumanString(app))); Algorithms.capitalizeFirstLetterAndLowercase(appMode.getParent().toHumanString()));
} else { } else {
modeDescription = getString(R.string.profile_type_base_string); modeDescription = getString(R.string.profile_type_base_string);
} }
@ -684,7 +684,7 @@ public class MapActivityActions implements DialogProvider {
.setIcon(appMode.getIconRes()) .setIcon(appMode.getIconRes())
.setColor(appMode.getIconColorInfo().getColor(nightMode)) .setColor(appMode.getIconColorInfo().getColor(nightMode))
.setTag(tag) .setTag(tag)
.setTitle(appMode.toHumanString(app)) .setTitle(appMode.toHumanString())
.setDescription(modeDescription) .setDescription(modeDescription)
.setListener(new ItemClickListener() { .setListener(new ItemClickListener() {
@Override @Override
@ -994,7 +994,7 @@ public class MapActivityActions implements DialogProvider {
String modeDescription; String modeDescription;
if (currentMode.isCustomProfile()) { if (currentMode.isCustomProfile()) {
modeDescription = String.format(app.getString(R.string.profile_type_descr_string), modeDescription = String.format(app.getString(R.string.profile_type_descr_string),
Algorithms.capitalizeFirstLetterAndLowercase(currentMode.getParent().toHumanString(app))); Algorithms.capitalizeFirstLetterAndLowercase(currentMode.getParent().toHumanString()));
} else { } else {
modeDescription = getString(R.string.profile_type_base_string); modeDescription = getString(R.string.profile_type_base_string);
} }
@ -1004,7 +1004,7 @@ public class MapActivityActions implements DialogProvider {
.setIcon(currentMode.getIconRes()) .setIcon(currentMode.getIconRes())
.setSecondaryIcon(icArrowResId) .setSecondaryIcon(icArrowResId)
.setColor(currentMode.getIconColorInfo().getColor(nightMode)) .setColor(currentMode.getIconColorInfo().getColor(nightMode))
.setTitle(currentMode.toHumanString(app)) .setTitle(currentMode.toHumanString())
.setDescription(modeDescription) .setDescription(modeDescription)
.setListener(new ItemClickListener() { .setListener(new ItemClickListener() {
@Override @Override

View file

@ -386,7 +386,7 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
if (am != ApplicationMode.DEFAULT || !(this instanceof SettingsNavigationActivity)) { if (am != ApplicationMode.DEFAULT || !(this instanceof SettingsNavigationActivity)) {
activeModes.add(new ProfileDataObject( activeModes.add(new ProfileDataObject(
am.toHumanString(getMyApplication()), am.toHumanString(),
getAppModeDescription(am), getAppModeDescription(am),
am.getStringKey(), am.getStringKey(),
am.getIconRes(), am.getIconRes(),
@ -429,7 +429,7 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
void updateModeButton(ApplicationMode mode) { void updateModeButton(ApplicationMode mode) {
OsmandApplication app = getMyApplication(); OsmandApplication app = getMyApplication();
boolean nightMode = !app.getSettings().isLightContent(); boolean nightMode = !app.getSettings().isLightContent();
String title = mode.toHumanString(SettingsBaseActivity.this); String title = mode.toHumanString();
getModeTitleTV().setText(title); getModeTitleTV().setText(title);
getModeSubTitleTV().setText(getAppModeDescription(mode)); getModeSubTitleTV().setText(getAppModeDescription(mode));
@ -448,7 +448,7 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
descr = getString(R.string.profile_type_base_string); descr = getString(R.string.profile_type_base_string);
} else { } else {
descr = String.format(getString(R.string.profile_type_descr_string), descr = String.format(getString(R.string.profile_type_descr_string),
mode.getParent().toHumanString(getMyApplication())); mode.getParent().toHumanString());
if (mode.getRoutingProfile() != null && mode.getRoutingProfile().contains("/")) { if (mode.getRoutingProfile() != null && mode.getRoutingProfile().contains("/")) {
descr = descr.concat(", " + mode.getRoutingProfile() descr = descr.concat(", " + mode.getRoutingProfile()
.substring(0, mode.getRoutingProfile().indexOf("/"))); .substring(0, mode.getRoutingProfile().indexOf("/")));

View file

@ -1,7 +1,6 @@
package net.osmand.plus.activities; package net.osmand.plus.activities;
import android.app.Activity;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
@ -91,7 +90,7 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
ApplicationMode[] appModes = ApplicationMode.values(app).toArray(new ApplicationMode[0]); ApplicationMode[] appModes = ApplicationMode.values(app).toArray(new ApplicationMode[0]);
entries = new String[appModes.length]; entries = new String[appModes.length];
for (int i = 0; i < entries.length; i++) { for (int i = 0; i < entries.length; i++) {
entries[i] = appModes[i].toHumanString(app); entries[i] = appModes[i].toHumanString();
} }
registerListPreference(settings.DEFAULT_APPLICATION_MODE, screen, entries, appModes); registerListPreference(settings.DEFAULT_APPLICATION_MODE, screen, entries, appModes);
@ -545,7 +544,7 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
super.updateAllSettings(); super.updateAllSettings();
updateApplicationDirTextAndSummary(); updateApplicationDirTextAndSummary();
applicationModePreference.setTitle(getString(R.string.settings_preset) + " [" applicationModePreference.setTitle(getString(R.string.settings_preset) + " ["
+ settings.APPLICATION_MODE.get().toHumanString(getMyApplication()) + "]"); + settings.APPLICATION_MODE.get().toHumanString() + "]");
drivingRegionPreference.setTitle(getString(R.string.driving_region) + " [" drivingRegionPreference.setTitle(getString(R.string.driving_region) + " ["
+ getString(settings.DRIVING_REGION_AUTOMATIC.get() ? R.string.driving_region_automatic : settings.DRIVING_REGION.get().name) + "]"); + getString(settings.DRIVING_REGION_AUTOMATIC.get() ? R.string.driving_region_automatic : settings.DRIVING_REGION.get().name) + "]");
} }

View file

@ -755,8 +755,8 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
break; break;
} }
float settingsMinSpeed = settings.MIN_SPEED.getModeValue(mode); float settingsMinSpeed = mode.getMinSpeed();
float settingsMaxSpeed = settings.MAX_SPEED.getModeValue(mode); float settingsMaxSpeed = mode.getMaxSpeed();
final int[] defaultValue = {Math.round(mode.getDefaultSpeed() * ratio[0])}; final int[] defaultValue = {Math.round(mode.getDefaultSpeed() * ratio[0])};
final int[] minValue = new int[1]; final int[] minValue = new int[1];
@ -785,8 +785,8 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
mode.setDefaultSpeed(defaultValue[0] / ratio[0]); mode.setDefaultSpeed(defaultValue[0] / ratio[0]);
if (!defaultSpeedOnly) { if (!defaultSpeedOnly) {
settings.MIN_SPEED.setModeValue(mode, minValue[0] / ratio[0]); mode.setMinSpeed(minValue[0] / ratio[0]);
settings.MAX_SPEED.setModeValue(mode, maxValue[0] / ratio[0]); mode.setMaxSpeed(maxValue[0] / ratio[0]);
} }
RoutingHelper routingHelper = app.getRoutingHelper(); RoutingHelper routingHelper = app.getRoutingHelper();
if (mode.equals(routingHelper.getAppMode()) && (routingHelper.isRouteCalculated() || routingHelper.isRouteBeingCalculated())) { if (mode.equals(routingHelper.getAppMode()) && (routingHelper.isRouteCalculated() || routingHelper.isRouteBeingCalculated())) {
@ -800,8 +800,8 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
mode.resetDefaultSpeed(); mode.resetDefaultSpeed();
if (!defaultSpeedOnly) { if (!defaultSpeedOnly) {
settings.MIN_SPEED.setModeValue(mode,0f); mode.setMinSpeed(0f);
settings.MAX_SPEED.setModeValue(mode,0f); mode.setMaxSpeed(0f);
} }
RoutingHelper routingHelper = app.getRoutingHelper(); RoutingHelper routingHelper = app.getRoutingHelper();
if (mode.equals(routingHelper.getAppMode()) && (routingHelper.isRouteCalculated() || routingHelper.isRouteBeingCalculated())) { if (mode.equals(routingHelper.getAppMode()) && (routingHelper.isRouteCalculated() || routingHelper.isRouteBeingCalculated())) {

View file

@ -1,7 +1,6 @@
package net.osmand.plus.activities.actions; package net.osmand.plus.activities.actions;
import android.app.Activity; import android.app.Activity;
import android.content.res.Configuration;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
import android.os.Build.VERSION_CODES; import android.os.Build.VERSION_CODES;
@ -117,7 +116,7 @@ public class AppModeDialog {
ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon); ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon);
if (checked) { if (checked) {
iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode))); iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode)));
iv.setContentDescription(String.format("%s %s", mode.toHumanString(ctx), ctx.getString(R.string.item_checked))); iv.setContentDescription(String.format("%s %s", mode.toHumanString(), ctx.getString(R.string.item_checked)));
selection.setBackgroundResource(mode.getIconColorInfo().getColor(nightMode)); selection.setBackgroundResource(mode.getIconColorInfo().getColor(nightMode));
selection.setVisibility(View.VISIBLE); selection.setVisibility(View.VISIBLE);
} else { } else {
@ -127,7 +126,7 @@ public class AppModeDialog {
} else { } else {
iv.setImageDrawable(ctx.getUIUtilities().getThemedIcon(mode.getIconRes())); iv.setImageDrawable(ctx.getUIUtilities().getThemedIcon(mode.getIconRes()));
} }
iv.setContentDescription(String.format("%s %s", mode.toHumanString(ctx), ctx.getString(R.string.item_unchecked))); iv.setContentDescription(String.format("%s %s", mode.toHumanString(), ctx.getString(R.string.item_unchecked)));
selection.setVisibility(View.INVISIBLE); selection.setVisibility(View.INVISIBLE);
} }
iv.setOnClickListener(new View.OnClickListener() { iv.setOnClickListener(new View.OnClickListener() {
@ -170,7 +169,7 @@ public class AppModeDialog {
Drawable drawable = ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode)); Drawable drawable = ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode));
if (checked) { if (checked) {
iv.setImageDrawable(drawable); iv.setImageDrawable(drawable);
iv.setContentDescription(String.format("%s %s", mode.toHumanString(ctx), ctx.getString(R.string.item_checked))); iv.setContentDescription(String.format("%s %s", mode.toHumanString(), ctx.getString(R.string.item_checked)));
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
AndroidUtils.setBackground(ctx, iv, nightMode, R.drawable.btn_checked_border_light, R.drawable.btn_checked_border_light); AndroidUtils.setBackground(ctx, iv, nightMode, R.drawable.btn_checked_border_light, R.drawable.btn_checked_border_light);
AndroidUtils.setBackground(ctx, selection, nightMode, R.drawable.ripple_light, R.drawable.ripple_light); AndroidUtils.setBackground(ctx, selection, nightMode, R.drawable.ripple_light, R.drawable.ripple_light);
@ -193,7 +192,7 @@ public class AppModeDialog {
} else { } else {
iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode))); iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode)));
} }
iv.setContentDescription(String.format("%s %s", mode.toHumanString(ctx), ctx.getString(R.string.item_unchecked))); iv.setContentDescription(String.format("%s %s", mode.toHumanString(), ctx.getString(R.string.item_unchecked)));
} }
tb.setOnClickListener(new View.OnClickListener() { tb.setOnClickListener(new View.OnClickListener() {
@ -229,7 +228,7 @@ public class AppModeDialog {
View tb = layoutInflater.inflate(layoutId, null); View tb = layoutInflater.inflate(layoutId, null);
ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon); ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon);
iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(isNightMode(ctx, useMapTheme)))); iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(isNightMode(ctx, useMapTheme))));
iv.setContentDescription(mode.toHumanString(ctx)); iv.setContentDescription(mode.toHumanString());
// tb.setCompoundDrawablesWithIntrinsicBounds(null, ctx.getIconsCache().getIcon(mode.getIconId(), R.color.app_mode_icon_color), null, null); // tb.setCompoundDrawablesWithIntrinsicBounds(null, ctx.getIconsCache().getIcon(mode.getIconId(), R.color.app_mode_icon_color), null, null);
LayoutParams lp = new LinearLayout.LayoutParams(metricsX, metricsY); LayoutParams lp = new LinearLayout.LayoutParams(metricsX, metricsY);
// lp.setMargins(left, 0, 0, 0); // lp.setMargins(left, 0, 0, 0);

View file

@ -198,7 +198,7 @@ public class PluginInstalledBottomSheetDialog extends MenuBottomSheetDialogFragm
appModeItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() appModeItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setChecked(ApplicationMode.values(app).contains(mode)) .setChecked(ApplicationMode.values(app).contains(mode))
.setDescription(BaseSettingsFragment.getAppModeDescription(app, mode)) .setDescription(BaseSettingsFragment.getAppModeDescription(app, mode))
.setTitle(mode.toHumanString(app)) .setTitle(mode.toHumanString())
.setIcon(getActiveIcon(mode.getIconRes())) .setIcon(getActiveIcon(mode.getIconRes()))
.setLayoutId(R.layout.bottom_sheet_item_with_descr_and_switch_56dp) .setLayoutId(R.layout.bottom_sheet_item_with_descr_and_switch_56dp)
.setOnClickListener(new View.OnClickListener() { .setOnClickListener(new View.OnClickListener() {

View file

@ -80,7 +80,7 @@ public class DirectionIndicationDialogFragment extends BaseOsmAndDialogFragment
TextView appModeTv = (TextView) mainView.findViewById(R.id.app_mode_text_view); TextView appModeTv = (TextView) mainView.findViewById(R.id.app_mode_text_view);
ApplicationMode appMode = settings.APPLICATION_MODE.get(); ApplicationMode appMode = settings.APPLICATION_MODE.get();
appModeTv.setText(appMode.toHumanString(getContext())); appModeTv.setText(appMode.toHumanString());
appModeTv.setCompoundDrawablesWithIntrinsicBounds(null, null, getIconsCache().getIcon( appModeTv.setCompoundDrawablesWithIntrinsicBounds(null, null, getIconsCache().getIcon(
appMode.getIconRes()), null); appMode.getIconRes()), null);

View file

@ -2,11 +2,8 @@ package net.osmand.plus.measurementtool;
import android.app.Dialog; import android.app.Dialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.support.annotation.DrawableRes;
import android.support.design.widget.BottomSheetBehavior; import android.support.design.widget.BottomSheetBehavior;
import android.support.design.widget.BottomSheetDialog; import android.support.design.widget.BottomSheetDialog;
import android.support.v4.content.ContextCompat;
import android.view.ContextThemeWrapper; import android.view.ContextThemeWrapper;
import android.view.View; import android.view.View;
import android.view.Window; import android.view.Window;
@ -19,7 +16,6 @@ import android.widget.TextView;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.plus.ApplicationMode; import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.AndroidUiHelper;
@ -92,7 +88,7 @@ public class SnapToRoadBottomSheetDialogFragment extends android.support.design.
View row = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.list_item_icon_and_title, null); View row = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.list_item_icon_and_title, null);
((ImageView) row.findViewById(R.id.icon)).setImageDrawable( ((ImageView) row.findViewById(R.id.icon)).setImageDrawable(
app.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode))); app.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode)));
((TextView) row.findViewById(R.id.title)).setText(mode.toHumanString(getContext())); ((TextView) row.findViewById(R.id.title)).setText(mode.toHumanString());
row.setOnClickListener(onClickListener); row.setOnClickListener(onClickListener);
row.setTag(i); row.setTag(i);
container.addView(row); container.addView(row);

View file

@ -248,7 +248,7 @@ public class SettingsMonitoringActivity extends SettingsBaseActivity {
protected void showConfirmDialog(final String prefId, final Object newValue) { protected void showConfirmDialog(final String prefId, final Object newValue) {
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
String appModeName = selectedAppMode.toHumanString(this); String appModeName = selectedAppMode.toHumanString();
String currentModeText = getString(R.string.apply_to_current_profile, appModeName); String currentModeText = getString(R.string.apply_to_current_profile, appModeName);
int start = currentModeText.indexOf(appModeName); int start = currentModeText.indexOf(appModeName);

View file

@ -103,7 +103,7 @@ public class ConfigureProfileMenuAdapter extends AbstractProfileMenuAdapter<Conf
holder.compoundButton.setVisibility(View.VISIBLE); holder.compoundButton.setVisibility(View.VISIBLE);
holder.menuIcon.setVisibility(View.VISIBLE); holder.menuIcon.setVisibility(View.VISIBLE);
final ApplicationMode item = (ApplicationMode) obj; final ApplicationMode item = (ApplicationMode) obj;
holder.title.setText(item.toHumanString(app)); holder.title.setText(item.toHumanString());
holder.descr.setText(BaseSettingsFragment.getAppModeDescription(app, item)); holder.descr.setText(BaseSettingsFragment.getAppModeDescription(app, item));
holder.initSwitcher = true; holder.initSwitcher = true;

View file

@ -169,7 +169,6 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
mode.setOrder(order); mode.setOrder(order);
} }
ApplicationMode.reorderAppModes(); ApplicationMode.reorderAppModes();
ApplicationMode.saveCustomAppModesToSettings(app);
mapActivity.onBackPressed(); mapActivity.onBackPressed();
} }
} }
@ -234,7 +233,7 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
if (order == null) { if (order == null) {
order = mode.getOrder(); order = mode.getOrder();
} }
profiles.add(new EditProfileDataObject(modeKey, mode.toHumanString(getContext()), BaseSettingsFragment.getAppModeDescription(getContext(), mode), profiles.add(new EditProfileDataObject(modeKey, mode.toHumanString(), BaseSettingsFragment.getAppModeDescription(getContext(), mode),
mode.getIconRes(), false, mode.isCustomProfile(), deleted, mode.getIconColorInfo(), order)); mode.getIconRes(), false, mode.isCustomProfile(), deleted, mode.getIconColorInfo(), order));
} }
} }

View file

@ -50,7 +50,7 @@ public class SelectCopyProfilesMenuAdapter extends AbstractProfileMenuAdapter<Se
ApplicationMode appMode = items.get(position); ApplicationMode appMode = items.get(position);
boolean selected = appMode == selectedAppMode; boolean selected = appMode == selectedAppMode;
holder.title.setText(appMode.toHumanString(app)); holder.title.setText(appMode.toHumanString());
holder.compoundButton.setChecked(selected); holder.compoundButton.setChecked(selected);
updateViewHolder(holder, appMode, selected); updateViewHolder(holder, appMode, selected);

View file

@ -97,7 +97,7 @@ public class SelectProfileMenuAdapter extends AbstractProfileMenuAdapter<SelectP
holder.compoundButton.setVisibility(View.GONE); holder.compoundButton.setVisibility(View.GONE);
holder.menuIcon.setVisibility(View.GONE); holder.menuIcon.setVisibility(View.GONE);
final ApplicationMode item = (ApplicationMode) obj; final ApplicationMode item = (ApplicationMode) obj;
holder.title.setText(item.toHumanString(app)); holder.title.setText(item.toHumanString());
holder.descr.setText(BaseSettingsFragment.getAppModeDescription(app, item)); holder.descr.setText(BaseSettingsFragment.getAppModeDescription(app, item));
int profileColorResId = item.getIconColorInfo().getColor(nightMode); int profileColorResId = item.getIconColorInfo().getColor(nightMode);

View file

@ -704,11 +704,11 @@ public class RouteProvider {
if (defaultSpeed > 0) { if (defaultSpeed > 0) {
paramsR.put(GeneralRouter.DEFAULT_SPEED, String.valueOf(defaultSpeed)); paramsR.put(GeneralRouter.DEFAULT_SPEED, String.valueOf(defaultSpeed));
} }
Float minSpeed = settings.MIN_SPEED.getModeValue(params.mode); Float minSpeed = params.mode.getMinSpeed();
if (minSpeed > 0) { if (minSpeed > 0) {
paramsR.put(GeneralRouter.MIN_SPEED, String.valueOf(minSpeed)); paramsR.put(GeneralRouter.MIN_SPEED, String.valueOf(minSpeed));
} }
Float maxSpeed = settings.MAX_SPEED.getModeValue(params.mode); Float maxSpeed = params.mode.getMaxSpeed();
if (maxSpeed > 0) { if (maxSpeed > 0) {
paramsR.put(GeneralRouter.MAX_SPEED, String.valueOf(maxSpeed)); paramsR.put(GeneralRouter.MAX_SPEED, String.valueOf(maxSpeed));
} }
@ -790,7 +790,7 @@ public class RouteProvider {
} }
private RouteCalculationResult applicationModeNotSupported(RouteCalculationParams params) { private RouteCalculationResult applicationModeNotSupported(RouteCalculationParams params) {
return new RouteCalculationResult("Application mode '"+ params.mode.toHumanString(params.ctx)+ "' is not supported."); return new RouteCalculationResult("Application mode '"+ params.mode.toHumanString()+ "' is not supported.");
} }
private RouteCalculationResult interrupted() { private RouteCalculationResult interrupted() {

View file

@ -447,7 +447,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
} }
TextView profileTitle = (TextView) view.findViewById(R.id.profile_title); TextView profileTitle = (TextView) view.findViewById(R.id.profile_title);
if (profileTitle != null) { if (profileTitle != null) {
String appName = selectedAppMode.toHumanString(app); String appName = selectedAppMode.toHumanString();
profileTitle.setText(appName); profileTitle.setText(appName);
} }
View toolbarDivider = view.findViewById(R.id.toolbar_divider); View toolbarDivider = view.findViewById(R.id.toolbar_divider);
@ -745,7 +745,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
String description; String description;
if (mode.isCustomProfile()) { if (mode.isCustomProfile()) {
description = String.format(ctx.getString(R.string.profile_type_descr_string), description = String.format(ctx.getString(R.string.profile_type_descr_string),
Algorithms.capitalizeFirstLetterAndLowercase(mode.getParent().toHumanString(ctx))); Algorithms.capitalizeFirstLetterAndLowercase(mode.getParent().toHumanString()));
} else { } else {
description = ctx.getString(R.string.profile_type_base_string); description = ctx.getString(R.string.profile_type_base_string);
} }

View file

@ -90,7 +90,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment implements Co
TextView toolbarTitle = view.findViewById(R.id.toolbar_title); TextView toolbarTitle = view.findViewById(R.id.toolbar_title);
toolbarTitle.setTypeface(FontCache.getRobotoMedium(view.getContext())); toolbarTitle.setTypeface(FontCache.getRobotoMedium(view.getContext()));
toolbarTitle.setText(getSelectedAppMode().toHumanString(getContext())); toolbarTitle.setText(getSelectedAppMode().toHumanString());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
float letterSpacing = AndroidUtils.getFloatValueFromRes(view.getContext(), R.dimen.title_letter_spacing); float letterSpacing = AndroidUtils.getFloatValueFromRes(view.getContext(), R.dimen.title_letter_spacing);
toolbarTitle.setLetterSpacing(letterSpacing); toolbarTitle.setLetterSpacing(letterSpacing);
@ -147,7 +147,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment implements Co
if (view != null) { if (view != null) {
updateToolbarSwitch(); updateToolbarSwitch();
TextView toolbarTitle = view.findViewById(R.id.toolbar_title); TextView toolbarTitle = view.findViewById(R.id.toolbar_title);
toolbarTitle.setText(getSelectedAppMode().toHumanString(getContext())); toolbarTitle.setText(getSelectedAppMode().toHumanString());
} }
} }
@ -317,7 +317,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment implements Co
Context ctx = requireContext(); Context ctx = requireContext();
final Intent sendIntent = new Intent(); final Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND); sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.exported_osmand_profile, profile.toHumanString(ctx))); sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.exported_osmand_profile, profile.toHumanString()));
sendIntent.putExtra(Intent.EXTRA_STREAM, AndroidUtils.getUriForFile(getMyApplication(), file)); sendIntent.putExtra(Intent.EXTRA_STREAM, AndroidUtils.getUriForFile(getMyApplication(), file));
sendIntent.setType("*/*"); sendIntent.setType("*/*");
sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
@ -392,7 +392,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment implements Co
if (!tempDir.exists()) { if (!tempDir.exists()) {
tempDir.mkdirs(); tempDir.mkdirs();
} }
String fileName = profile.toHumanString(ctx); String fileName = profile.toHumanString();
app.getSettingsHelper().exportSettings(tempDir, fileName, new SettingsHelper.SettingsExportListener() { app.getSettingsHelper().exportSettings(tempDir, fileName, new SettingsHelper.SettingsExportListener() {
@Override @Override
public void onSettingsExportFinished(@NonNull File file, boolean succeed) { public void onSettingsExportFinished(@NonNull File file, boolean succeed) {
@ -418,7 +418,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment implements Co
bld.setTitle(R.string.profile_alert_delete_title); bld.setTitle(R.string.profile_alert_delete_title);
bld.setMessage(String bld.setMessage(String
.format(getString(R.string.profile_alert_delete_msg), .format(getString(R.string.profile_alert_delete_msg),
profile.getCustomProfileName())); profile.getUserProfileName()));
bld.setPositiveButton(R.string.shared_string_delete, bld.setPositiveButton(R.string.shared_string_delete,
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override

View file

@ -102,7 +102,7 @@ public class GlobalSettingsFragment extends BaseSettingsFragment implements Send
String[] entries = new String[appModes.length]; String[] entries = new String[appModes.length];
String[] entryValues = new String[appModes.length]; String[] entryValues = new String[appModes.length];
for (int i = 0; i < entries.length; i++) { for (int i = 0; i < entries.length; i++) {
entries[i] = appModes[i].toHumanString(app); entries[i] = appModes[i].toHumanString();
entryValues[i] = appModes[i].getStringKey(); entryValues[i] = appModes[i].getStringKey();
} }

View file

@ -147,7 +147,7 @@ public class MainSettingsFragment extends BaseSettingsFragment {
private void setupConfigureProfilePref() { private void setupConfigureProfilePref() {
ApplicationMode selectedMode = app.getSettings().APPLICATION_MODE.get(); ApplicationMode selectedMode = app.getSettings().APPLICATION_MODE.get();
String title = selectedMode.toHumanString(getContext()); String title = selectedMode.toHumanString();
String profileType = getAppModeDescription(getContext(), selectedMode); String profileType = getAppModeDescription(getContext(), selectedMode);
int iconRes = selectedMode.getIconRes(); int iconRes = selectedMode.getIconRes();
Preference configureProfile = findPreference(CONFIGURE_PROFILE); Preference configureProfile = findPreference(CONFIGURE_PROFILE);
@ -181,7 +181,7 @@ public class MainSettingsFragment extends BaseSettingsFragment {
pref.setPersistent(false); pref.setPersistent(false);
pref.setKey(applicationMode.getStringKey()); pref.setKey(applicationMode.getStringKey());
pref.setIcon(getAppProfilesIcon(applicationMode, isAppProfileEnabled)); pref.setIcon(getAppProfilesIcon(applicationMode, isAppProfileEnabled));
pref.setTitle(applicationMode.toHumanString(getContext())); pref.setTitle(applicationMode.toHumanString());
pref.setSummary(getAppModeDescription(getContext(), applicationMode)); pref.setSummary(getAppModeDescription(getContext(), applicationMode));
pref.setChecked(isAppProfileEnabled); pref.setChecked(isAppProfileEnabled);
pref.setLayoutResource(R.layout.preference_with_descr_dialog_and_switch); pref.setLayoutResource(R.layout.preference_with_descr_dialog_and_switch);

View file

@ -193,7 +193,7 @@ public class NavigationFragment extends BaseSettingsFragment {
List<ProfileDataObject> profiles = new ArrayList<>(); List<ProfileDataObject> profiles = new ArrayList<>();
for (ApplicationMode mode : ApplicationMode.getDefaultValues()) { for (ApplicationMode mode : ApplicationMode.getDefaultValues()) {
if (mode != ApplicationMode.DEFAULT) { if (mode != ApplicationMode.DEFAULT) {
profiles.add(new ProfileDataObject(mode.toHumanString(ctx), mode.getDescription(ctx), profiles.add(new ProfileDataObject(mode.toHumanString(), mode.getDescription(),
mode.getStringKey(), mode.getIconRes(), false, mode.getIconColorInfo())); mode.getStringKey(), mode.getIconRes(), false, mode.getIconColorInfo()));
} }
} }

View file

@ -111,7 +111,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
if (baseModeForNewProfile != null) { if (baseModeForNewProfile != null) {
profile.stringKey = baseModeForNewProfile.getStringKey() + "_" + System.currentTimeMillis(); profile.stringKey = baseModeForNewProfile.getStringKey() + "_" + System.currentTimeMillis();
profile.parent = baseModeForNewProfile; profile.parent = baseModeForNewProfile;
profile.name = baseModeForNewProfile.toHumanString(app); profile.name = baseModeForNewProfile.toHumanString();
profile.color = baseModeForNewProfile.getIconColorInfo(); profile.color = baseModeForNewProfile.getIconColorInfo();
profile.iconRes = baseModeForNewProfile.getIconRes(); profile.iconRes = baseModeForNewProfile.getIconRes();
profile.routingProfile = baseModeForNewProfile.getRoutingProfile(); profile.routingProfile = baseModeForNewProfile.getRoutingProfile();
@ -122,7 +122,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
} else { } else {
profile.stringKey = getSelectedAppMode().getStringKey(); profile.stringKey = getSelectedAppMode().getStringKey();
profile.parent = getSelectedAppMode().getParent(); profile.parent = getSelectedAppMode().getParent();
profile.name = getSelectedAppMode().toHumanString(getContext()); profile.name = getSelectedAppMode().toHumanString();
profile.color = getSelectedAppMode().getIconColorInfo(); profile.color = getSelectedAppMode().getIconColorInfo();
profile.iconRes = getSelectedAppMode().getIconRes(); profile.iconRes = getSelectedAppMode().getIconRes();
profile.routingProfile = getSelectedAppMode().getRoutingProfile(); profile.routingProfile = getSelectedAppMode().getRoutingProfile();
@ -137,7 +137,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
changedProfile.stringKey = profile.stringKey; changedProfile.stringKey = profile.stringKey;
changedProfile.parent = profile.parent; changedProfile.parent = profile.parent;
if (baseModeForNewProfile != null) { if (baseModeForNewProfile != null) {
changedProfile.name = createNonDuplicateName(baseModeForNewProfile.toHumanString(app)); changedProfile.name = createNonDuplicateName(baseModeForNewProfile.toHumanString());
} else { } else {
changedProfile.name = profile.name; changedProfile.name = profile.name;
} }
@ -176,7 +176,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
private boolean hasProfileWithName(String newName) { private boolean hasProfileWithName(String newName) {
for (ApplicationMode m : ApplicationMode.allPossibleValues()) { for (ApplicationMode m : ApplicationMode.allPossibleValues()) {
if (m.toHumanString(app).equals(newName)) { if (m.toHumanString().equals(newName)) {
return true; return true;
} }
} }
@ -346,8 +346,8 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
baseProfileName = (EditText) holder.findViewById(R.id.master_profile_et); baseProfileName = (EditText) holder.findViewById(R.id.master_profile_et);
baseProfileName.setFocusable(false); baseProfileName.setFocusable(false);
baseProfileName.setText(changedProfile.parent != null baseProfileName.setText(changedProfile.parent != null
? changedProfile.parent.toHumanString(getContext()) ? changedProfile.parent.toHumanString()
: getSelectedAppMode().toHumanString(getContext())); : getSelectedAppMode().toHumanString());
OsmandTextFieldBoxes baseProfileNameHint = (OsmandTextFieldBoxes) holder.findViewById(R.id.master_profile_otfb); OsmandTextFieldBoxes baseProfileNameHint = (OsmandTextFieldBoxes) holder.findViewById(R.id.master_profile_otfb);
baseProfileNameHint.setLabelText(getString(R.string.master_profile)); baseProfileNameHint.setLabelText(getString(R.string.master_profile));
FrameLayout selectNavTypeBtn = (FrameLayout) holder.findViewById(R.id.select_nav_type_btn); FrameLayout selectNavTypeBtn = (FrameLayout) holder.findViewById(R.id.select_nav_type_btn);
@ -640,7 +640,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
private void setupBaseProfileView(String stringKey) { private void setupBaseProfileView(String stringKey) {
for (ApplicationMode am : ApplicationMode.getDefaultValues()) { for (ApplicationMode am : ApplicationMode.getDefaultValues()) {
if (am.getStringKey().equals(stringKey)) { if (am.getStringKey().equals(stringKey)) {
baseProfileName.setText(Algorithms.capitalizeFirstLetter(am.toHumanString(app))); baseProfileName.setText(Algorithms.capitalizeFirstLetter(am.toHumanString()));
} }
} }
} }
@ -687,7 +687,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
private boolean hasNameDuplicate() { private boolean hasNameDuplicate() {
for (ApplicationMode m : ApplicationMode.allPossibleValues()) { for (ApplicationMode m : ApplicationMode.allPossibleValues()) {
if (m.toHumanString(app).equals(changedProfile.name) && if (m.toHumanString().equals(changedProfile.name) &&
!m.getStringKey().equals(profile.stringKey)) { !m.getStringKey().equals(profile.stringKey)) {
return true; return true;
} }

View file

@ -79,7 +79,7 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
Preference routeParametersInfo = findPreference(ROUTE_PARAMETERS_INFO); Preference routeParametersInfo = findPreference(ROUTE_PARAMETERS_INFO);
routeParametersInfo.setIcon(getContentIcon(R.drawable.ic_action_info_dark)); routeParametersInfo.setIcon(getContentIcon(R.drawable.ic_action_info_dark));
routeParametersInfo.setTitle(getString(R.string.route_parameters_info, getSelectedAppMode().toHumanString(getContext()))); routeParametersInfo.setTitle(getString(R.string.route_parameters_info, getSelectedAppMode().toHumanString()));
setupRoutingPrefs(); setupRoutingPrefs();
setupTimeConditionalRoutingPref(); setupTimeConditionalRoutingPref();

View file

@ -31,7 +31,7 @@ public class VehicleParametersFragment extends BaseSettingsFragment implements O
Preference vehicleParametersInfo = findPreference("vehicle_parameters_info"); Preference vehicleParametersInfo = findPreference("vehicle_parameters_info");
vehicleParametersInfo.setIcon(getContentIcon(R.drawable.ic_action_info_dark)); vehicleParametersInfo.setIcon(getContentIcon(R.drawable.ic_action_info_dark));
vehicleParametersInfo.setTitle(getString(R.string.route_parameters_info, getSelectedAppMode().toHumanString(getContext()))); vehicleParametersInfo.setTitle(getString(R.string.route_parameters_info, getSelectedAppMode().toHumanString()));
RouteService routeService = getSelectedAppMode().getRouteService(); RouteService routeService = getSelectedAppMode().getRouteService();
if (routeService == RouteService.OSMAND) { if (routeService == RouteService.OSMAND) {

View file

@ -65,7 +65,7 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh
ApplicationMode selectedAppMode = getAppMode(); ApplicationMode selectedAppMode = getAppMode();
BaseBottomSheetItem applyToCurrentProfile = new SimpleBottomSheetItem.Builder() BaseBottomSheetItem applyToCurrentProfile = new SimpleBottomSheetItem.Builder()
.setTitle(getString(R.string.apply_to_current_profile, selectedAppMode.toHumanString(app))) .setTitle(getString(R.string.apply_to_current_profile, selectedAppMode.toHumanString()))
.setIcon(getActiveIcon(selectedAppMode.getIconRes())) .setIcon(getActiveIcon(selectedAppMode.getIconRes()))
.setLayoutId(R.layout.bottom_sheet_item_simple) .setLayoutId(R.layout.bottom_sheet_item_simple)
.setOnClickListener(new View.OnClickListener() { .setOnClickListener(new View.OnClickListener() {

View file

@ -46,7 +46,7 @@ public class ResetProfilePrefsBottomSheet extends BasePreferenceBottomSheet {
.setButtonTintList(ColorStateList.valueOf(getResolvedColor(profileColor))) .setButtonTintList(ColorStateList.valueOf(getResolvedColor(profileColor)))
.setDescription(BaseSettingsFragment.getAppModeDescription(ctx, mode)) .setDescription(BaseSettingsFragment.getAppModeDescription(ctx, mode))
.setIcon(getIcon(mode.getIconRes(), profileColor)) .setIcon(getIcon(mode.getIconRes(), profileColor))
.setTitle(mode.toHumanString(ctx)) .setTitle(mode.toHumanString())
.setBackground(new LayerDrawable(layers)) .setBackground(new LayerDrawable(layers))
.setLayoutId(R.layout.preference_profile_item_with_radio_btn) .setLayoutId(R.layout.preference_profile_item_with_radio_btn)
.create(); .create();

View file

@ -4,7 +4,6 @@ import android.content.Context;
import android.support.annotation.DrawableRes; import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.StringRes; import android.support.annotation.StringRes;
import android.support.v4.content.ContextCompat;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
@ -220,7 +219,7 @@ public class MapWidgetRegistry {
private void processVisibleModes(String key, MapWidgetRegInfo ii) { private void processVisibleModes(String key, MapWidgetRegInfo ii) {
for (ApplicationMode ms : ApplicationMode.values(app)) { for (ApplicationMode ms : ApplicationMode.values(app)) {
boolean collapse = ms.isWidgetCollapsible(key); boolean collapse = ms.isWidgetCollapsible(key);
boolean def = ms.isWidgetVisible(app, key); boolean def = ms.isWidgetVisible(key);
Set<String> set = visibleElementsFromSettings.get(ms); Set<String> set = visibleElementsFromSettings.get(ms);
if (set != null) { if (set != null) {
if (set.contains(key)) { if (set.contains(key)) {
@ -313,7 +312,7 @@ public class MapWidgetRegistry {
for (MapWidgetRegInfo ri : set) { for (MapWidgetRegInfo ri : set) {
ri.visibleCollapsible.remove(mode); ri.visibleCollapsible.remove(mode);
ri.visibleModes.remove(mode); ri.visibleModes.remove(mode);
if (mode.isWidgetVisible(app, ri.key)) { if (mode.isWidgetVisible(ri.key)) {
if (mode.isWidgetCollapsible(ri.key)) { if (mode.isWidgetCollapsible(ri.key)) {
ri.visibleCollapsible.add(mode); ri.visibleCollapsible.add(mode);
} else { } else {
@ -485,7 +484,7 @@ public class MapWidgetRegistry {
private void addControls(final MapActivity mapActivity, final ContextMenuAdapter contextMenuAdapter, private void addControls(final MapActivity mapActivity, final ContextMenuAdapter contextMenuAdapter,
Set<MapWidgetRegInfo> groupTitle, final ApplicationMode mode) { Set<MapWidgetRegInfo> groupTitle, final ApplicationMode mode) {
for (final MapWidgetRegInfo r : groupTitle) { for (final MapWidgetRegInfo r : groupTitle) {
if (!mode.isWidgetAvailable(app, r.key)) { if (!mode.isWidgetAvailable(r.key)) {
continue; continue;
} }