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;
import android.content.Context;
import android.support.annotation.DrawableRes;
import com.google.gson.Gson;
@ -258,7 +257,7 @@ public class ApplicationMode {
return false;
}
public boolean isWidgetVisible(OsmandApplication app, String key) {
public boolean isWidgetVisible(String key) {
if (app.getAppCustomization().areWidgetsCustomized()) {
return app.getAppCustomization().isWidgetVisible(key, this);
}
@ -286,7 +285,7 @@ public class ApplicationMode {
return set;
}
public boolean isWidgetAvailable(OsmandApplication app, String key) {
public boolean isWidgetAvailable(String key) {
if (app.getAppCustomization().areWidgetsCustomized()) {
return app.getAppCustomization().isWidgetAvailable(key, this);
}
@ -313,12 +312,19 @@ public class ApplicationMode {
return parentAppMode;
}
public void setParentAppMode(ApplicationMode parentAppMode) {
if (isCustomProfile()) {
this.parentAppMode = parentAppMode;
app.getSettings().PARENT_APP_MODE.setModeValue(this, parentAppMode.getStringKey());
}
}
public int getNameKeyResource() {
return keyName;
}
public String toHumanString(Context ctx) {
String userProfileName = getCustomProfileName();
public String toHumanString() {
String userProfileName = getUserProfileName();
if (Algorithms.isEmpty(userProfileName) && keyName != -1) {
return app.getString(keyName);
} else {
@ -326,7 +332,7 @@ public class ApplicationMode {
}
}
public String getDescription(Context ctx) {
public String getDescription() {
if (descriptionId != 0) {
return app.getString(descriptionId);
}
@ -393,7 +399,23 @@ public class ApplicationMode {
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);
}
@ -401,11 +423,8 @@ public class ApplicationMode {
app.getSettings().USER_PROFILE_NAME.setModeValue(this, userProfileName);
}
public void setParentAppMode(ApplicationMode parentAppMode) {
if (isCustomProfile()) {
this.parentAppMode = parentAppMode;
app.getSettings().PARENT_APP_MODE.setModeValue(this, parentAppMode.getStringKey());
}
public String getRoutingProfile() {
return app.getSettings().ROUTING_PROFILE.getModeValue(this);
}
public void setRoutingProfile(String routingProfile) {
@ -436,18 +455,14 @@ public class ApplicationMode {
app.getSettings().LOCATION_ICON.setModeValue(this, locationIcon);
}
public String getRoutingProfile() {
return app.getSettings().ROUTING_PROFILE.getModeValue(this);
public ProfileIconColors getIconColorInfo() {
return app.getSettings().ICON_COLOR.getModeValue(this);
}
public void setIconColor(ProfileIconColors iconColor) {
app.getSettings().ICON_COLOR.setModeValue(this, iconColor);
}
public ProfileIconColors getIconColorInfo() {
return app.getSettings().ICON_COLOR.getModeValue(this);
}
public int getOrder() {
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();
StringBuilder stringBuilder = new StringBuilder();
Iterator<ApplicationMode> it = ApplicationMode.getCustomValues().iterator();
@ -545,19 +560,21 @@ public class ApplicationMode {
return mode;
}
public static ApplicationModeBuilder fromJson(String json) {
public static ApplicationModeBean fromJson(String json) {
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);
builder.setUserProfileName(mb.userProfileName);
builder.setIconResName(mb.iconName);
builder.setIconColor(mb.iconColor);
builder.setRoutingProfile(mb.routingProfile);
builder.setRouteService(mb.routeService);
builder.setLocationIcon(mb.locIcon);
builder.setNavigationIcon(mb.navIcon);
builder.setOrder(mb.order);
public static ApplicationModeBuilder fromModeBean(ApplicationModeBean modeBean) {
ApplicationModeBuilder builder = createCustomMode(valueOfStringKey(modeBean.parent, null), modeBean.stringKey);
builder.setUserProfileName(modeBean.userProfileName);
builder.setIconResName(modeBean.iconName);
builder.setIconColor(modeBean.iconColor);
builder.setRoutingProfile(modeBean.routingProfile);
builder.setRouteService(modeBean.routeService);
builder.setLocationIcon(modeBean.locIcon);
builder.setNavigationIcon(modeBean.navIcon);
builder.setOrder(modeBean.order);
return builder;
}
@ -565,7 +582,7 @@ public class ApplicationMode {
public String toJson() {
ApplicationModeBean mb = new ApplicationModeBean();
mb.stringKey = stringKey;
mb.userProfileName = getCustomProfileName();
mb.userProfileName = getUserProfileName();
mb.iconColor = getIconColorInfo();
mb.iconName = getIconName();
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.plus.ApplicationMode.ApplicationModeBuilder;
import net.osmand.plus.OsmandSettings.OsmandPreference;
import net.osmand.plus.ApplicationMode.ApplicationModeBean;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
@ -400,6 +401,7 @@ public class SettingsHelper {
private ApplicationMode appMode;
private ApplicationModeBuilder builder;
private ApplicationModeBean modeBean;
public ProfileSettingsItem(@NonNull OsmandSettings settings, @NonNull ApplicationMode appMode) {
super(SettingsItemType.PROFILE, settings);
@ -421,7 +423,7 @@ public class SettingsHelper {
@Override
public String getPublicName(@NonNull Context ctx) {
if (appMode.isCustomProfile()) {
return appMode.getCustomProfileName();
return modeBean.userProfileName;
} else if (appMode.getNameKeyResource() != -1) {
return ctx.getString(appMode.getNameKeyResource());
} else {
@ -437,7 +439,8 @@ public class SettingsHelper {
void readFromJson(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException {
String appModeJson = json.getString("appMode");
builder = ApplicationMode.fromJson(appModeJson);
modeBean = ApplicationMode.fromJson(appModeJson);
builder = ApplicationMode.fromModeBean(modeBean);
ApplicationMode appMode = builder.getApplicationMode();
if (!appMode.isCustomProfile()) {
appMode = ApplicationMode.valueOfStringKey(appMode.getStringKey(), appMode);

View file

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

View file

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

View file

@ -1,7 +1,6 @@
package net.osmand.plus.activities;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@ -91,7 +90,7 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
ApplicationMode[] appModes = ApplicationMode.values(app).toArray(new ApplicationMode[0]);
entries = new String[appModes.length];
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);
@ -545,7 +544,7 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
super.updateAllSettings();
updateApplicationDirTextAndSummary();
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) + " ["
+ 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;
}
float settingsMinSpeed = settings.MIN_SPEED.getModeValue(mode);
float settingsMaxSpeed = settings.MAX_SPEED.getModeValue(mode);
float settingsMinSpeed = mode.getMinSpeed();
float settingsMaxSpeed = mode.getMaxSpeed();
final int[] defaultValue = {Math.round(mode.getDefaultSpeed() * ratio[0])};
final int[] minValue = new int[1];
@ -785,8 +785,8 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
public void onClick(DialogInterface dialog, int which) {
mode.setDefaultSpeed(defaultValue[0] / ratio[0]);
if (!defaultSpeedOnly) {
settings.MIN_SPEED.setModeValue(mode, minValue[0] / ratio[0]);
settings.MAX_SPEED.setModeValue(mode, maxValue[0] / ratio[0]);
mode.setMinSpeed(minValue[0] / ratio[0]);
mode.setMaxSpeed(maxValue[0] / ratio[0]);
}
RoutingHelper routingHelper = app.getRoutingHelper();
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) {
mode.resetDefaultSpeed();
if (!defaultSpeedOnly) {
settings.MIN_SPEED.setModeValue(mode,0f);
settings.MAX_SPEED.setModeValue(mode,0f);
mode.setMinSpeed(0f);
mode.setMaxSpeed(0f);
}
RoutingHelper routingHelper = app.getRoutingHelper();
if (mode.equals(routingHelper.getAppMode()) && (routingHelper.isRouteCalculated() || routingHelper.isRouteBeingCalculated())) {

View file

@ -1,7 +1,6 @@
package net.osmand.plus.activities.actions;
import android.app.Activity;
import android.content.res.Configuration;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Build.VERSION_CODES;
@ -117,7 +116,7 @@ public class AppModeDialog {
ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon);
if (checked) {
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.setVisibility(View.VISIBLE);
} else {
@ -127,7 +126,7 @@ public class AppModeDialog {
} else {
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);
}
iv.setOnClickListener(new View.OnClickListener() {
@ -170,7 +169,7 @@ public class AppModeDialog {
Drawable drawable = ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode));
if (checked) {
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) {
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);
@ -193,7 +192,7 @@ public class AppModeDialog {
} else {
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() {
@ -229,7 +228,7 @@ public class AppModeDialog {
View tb = layoutInflater.inflate(layoutId, null);
ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon);
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);
LayoutParams lp = new LinearLayout.LayoutParams(metricsX, metricsY);
// lp.setMargins(left, 0, 0, 0);

View file

@ -198,7 +198,7 @@ public class PluginInstalledBottomSheetDialog extends MenuBottomSheetDialogFragm
appModeItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setChecked(ApplicationMode.values(app).contains(mode))
.setDescription(BaseSettingsFragment.getAppModeDescription(app, mode))
.setTitle(mode.toHumanString(app))
.setTitle(mode.toHumanString())
.setIcon(getActiveIcon(mode.getIconRes()))
.setLayoutId(R.layout.bottom_sheet_item_with_descr_and_switch_56dp)
.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);
ApplicationMode appMode = settings.APPLICATION_MODE.get();
appModeTv.setText(appMode.toHumanString(getContext()));
appModeTv.setText(appMode.toHumanString());
appModeTv.setCompoundDrawablesWithIntrinsicBounds(null, null, getIconsCache().getIcon(
appMode.getIconRes()), null);

View file

@ -2,11 +2,8 @@ package net.osmand.plus.measurementtool;
import android.app.Dialog;
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.BottomSheetDialog;
import android.support.v4.content.ContextCompat;
import android.view.ContextThemeWrapper;
import android.view.View;
import android.view.Window;
@ -19,7 +16,6 @@ import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
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);
((ImageView) row.findViewById(R.id.icon)).setImageDrawable(
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.setTag(i);
container.addView(row);

View file

@ -248,7 +248,7 @@ public class SettingsMonitoringActivity extends SettingsBaseActivity {
protected void showConfirmDialog(final String prefId, final Object newValue) {
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);
int start = currentModeText.indexOf(appModeName);

View file

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

View file

@ -169,7 +169,6 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
mode.setOrder(order);
}
ApplicationMode.reorderAppModes();
ApplicationMode.saveCustomAppModesToSettings(app);
mapActivity.onBackPressed();
}
}
@ -234,7 +233,7 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
if (order == null) {
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));
}
}

View file

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

View file

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

View file

@ -704,11 +704,11 @@ public class RouteProvider {
if (defaultSpeed > 0) {
paramsR.put(GeneralRouter.DEFAULT_SPEED, String.valueOf(defaultSpeed));
}
Float minSpeed = settings.MIN_SPEED.getModeValue(params.mode);
Float minSpeed = params.mode.getMinSpeed();
if (minSpeed > 0) {
paramsR.put(GeneralRouter.MIN_SPEED, String.valueOf(minSpeed));
}
Float maxSpeed = settings.MAX_SPEED.getModeValue(params.mode);
Float maxSpeed = params.mode.getMaxSpeed();
if (maxSpeed > 0) {
paramsR.put(GeneralRouter.MAX_SPEED, String.valueOf(maxSpeed));
}
@ -790,7 +790,7 @@ public class RouteProvider {
}
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() {

View file

@ -447,7 +447,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
}
TextView profileTitle = (TextView) view.findViewById(R.id.profile_title);
if (profileTitle != null) {
String appName = selectedAppMode.toHumanString(app);
String appName = selectedAppMode.toHumanString();
profileTitle.setText(appName);
}
View toolbarDivider = view.findViewById(R.id.toolbar_divider);
@ -745,7 +745,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
String description;
if (mode.isCustomProfile()) {
description = String.format(ctx.getString(R.string.profile_type_descr_string),
Algorithms.capitalizeFirstLetterAndLowercase(mode.getParent().toHumanString(ctx)));
Algorithms.capitalizeFirstLetterAndLowercase(mode.getParent().toHumanString()));
} else {
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);
toolbarTitle.setTypeface(FontCache.getRobotoMedium(view.getContext()));
toolbarTitle.setText(getSelectedAppMode().toHumanString(getContext()));
toolbarTitle.setText(getSelectedAppMode().toHumanString());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
float letterSpacing = AndroidUtils.getFloatValueFromRes(view.getContext(), R.dimen.title_letter_spacing);
toolbarTitle.setLetterSpacing(letterSpacing);
@ -147,7 +147,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment implements Co
if (view != null) {
updateToolbarSwitch();
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();
final Intent sendIntent = new Intent();
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.setType("*/*");
sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
@ -392,7 +392,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment implements Co
if (!tempDir.exists()) {
tempDir.mkdirs();
}
String fileName = profile.toHumanString(ctx);
String fileName = profile.toHumanString();
app.getSettingsHelper().exportSettings(tempDir, fileName, new SettingsHelper.SettingsExportListener() {
@Override
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.setMessage(String
.format(getString(R.string.profile_alert_delete_msg),
profile.getCustomProfileName()));
profile.getUserProfileName()));
bld.setPositiveButton(R.string.shared_string_delete,
new DialogInterface.OnClickListener() {
@Override

View file

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

View file

@ -147,7 +147,7 @@ public class MainSettingsFragment extends BaseSettingsFragment {
private void setupConfigureProfilePref() {
ApplicationMode selectedMode = app.getSettings().APPLICATION_MODE.get();
String title = selectedMode.toHumanString(getContext());
String title = selectedMode.toHumanString();
String profileType = getAppModeDescription(getContext(), selectedMode);
int iconRes = selectedMode.getIconRes();
Preference configureProfile = findPreference(CONFIGURE_PROFILE);
@ -181,7 +181,7 @@ public class MainSettingsFragment extends BaseSettingsFragment {
pref.setPersistent(false);
pref.setKey(applicationMode.getStringKey());
pref.setIcon(getAppProfilesIcon(applicationMode, isAppProfileEnabled));
pref.setTitle(applicationMode.toHumanString(getContext()));
pref.setTitle(applicationMode.toHumanString());
pref.setSummary(getAppModeDescription(getContext(), applicationMode));
pref.setChecked(isAppProfileEnabled);
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<>();
for (ApplicationMode mode : ApplicationMode.getDefaultValues()) {
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()));
}
}

View file

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

View file

@ -79,7 +79,7 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
Preference routeParametersInfo = findPreference(ROUTE_PARAMETERS_INFO);
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();
setupTimeConditionalRoutingPref();

View file

@ -31,7 +31,7 @@ public class VehicleParametersFragment extends BaseSettingsFragment implements O
Preference vehicleParametersInfo = findPreference("vehicle_parameters_info");
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();
if (routeService == RouteService.OSMAND) {

View file

@ -65,7 +65,7 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh
ApplicationMode selectedAppMode = getAppMode();
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()))
.setLayoutId(R.layout.bottom_sheet_item_simple)
.setOnClickListener(new View.OnClickListener() {

View file

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

View file

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