Fix #10346 (3) migrate static code to ProfileDataUtils + small refactoring
This commit is contained in:
parent
1bb3fb730c
commit
a543d3ee91
15 changed files with 160 additions and 163 deletions
|
@ -63,6 +63,7 @@ import net.osmand.plus.measurementtool.MeasurementToolFragment;
|
|||
import net.osmand.plus.measurementtool.StartPlanRouteBottomSheet;
|
||||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||
import net.osmand.plus.osmedit.dialogs.DismissRouteBottomSheetFragment;
|
||||
import net.osmand.plus.profiles.ProfileDataUtils;
|
||||
import net.osmand.plus.profiles.RoutingProfileDataObject;
|
||||
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu;
|
||||
import net.osmand.plus.routepreparationmenu.WaypointsFragment;
|
||||
|
@ -736,7 +737,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
|
||||
String modeDescription;
|
||||
|
||||
Map<String, RoutingProfileDataObject> profilesObjects = RoutingProfileDataObject.getRoutingProfiles(app);
|
||||
Map<String, RoutingProfileDataObject> profilesObjects = ProfileDataUtils.getRoutingProfiles(app);
|
||||
for (final ApplicationMode appMode : activeModes) {
|
||||
if (appMode.isCustomProfile()) {
|
||||
modeDescription = getProfileDescription(app, appMode, profilesObjects, getString(R.string.profile_type_user_string));
|
||||
|
@ -1045,7 +1046,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
//switch profile button
|
||||
ApplicationMode currentMode = app.getSettings().APPLICATION_MODE.get();
|
||||
String modeDescription;
|
||||
Map<String, RoutingProfileDataObject> profilesObjects = RoutingProfileDataObject.getRoutingProfiles(app);
|
||||
Map<String, RoutingProfileDataObject> profilesObjects = ProfileDataUtils.getRoutingProfiles(app);
|
||||
if (currentMode.isCustomProfile()) {
|
||||
modeDescription = getProfileDescription(app, currentMode, profilesObjects, getString(R.string.profile_type_user_string));
|
||||
} else {
|
||||
|
|
|
@ -15,7 +15,7 @@ import androidx.fragment.app.FragmentManager;
|
|||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.plus.profiles.ProfileDataObject;
|
||||
import net.osmand.plus.profiles.ProfileDataUtils;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
|
@ -221,7 +221,7 @@ public class PluginInstalledBottomSheetDialog extends MenuBottomSheetDialogFragm
|
|||
final BottomSheetItemWithCompoundButton[] appModeItem = new BottomSheetItemWithCompoundButton[1];
|
||||
appModeItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
|
||||
.setChecked(ApplicationMode.values(app).contains(mode))
|
||||
.setDescription(ProfileDataObject.getAppModeDescription(app, mode))
|
||||
.setDescription(ProfileDataUtils.getAppModeDescription(app, mode))
|
||||
.setTitle(mode.toHumanString())
|
||||
.setIcon(getActiveIcon(mode.getIconRes()))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_with_descr_and_switch_56dp)
|
||||
|
|
|
@ -104,7 +104,7 @@ public class ConfigureProfileMenuAdapter extends AbstractProfileMenuAdapter<Conf
|
|||
holder.menuIcon.setVisibility(View.VISIBLE);
|
||||
final ApplicationMode item = (ApplicationMode) obj;
|
||||
holder.title.setText(item.toHumanString());
|
||||
holder.descr.setText(ProfileDataObject.getAppModeDescription(app, item));
|
||||
holder.descr.setText(ProfileDataUtils.getAppModeDescription(app, item));
|
||||
|
||||
holder.initSwitcher = true;
|
||||
holder.compoundButton.setChecked(selectedItems.contains(item));
|
||||
|
|
|
@ -240,7 +240,7 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
|
|||
if (order == null) {
|
||||
order = mode.getOrder();
|
||||
}
|
||||
profiles.add(new EditProfileDataObject(modeKey, mode.toHumanString(), ProfileDataObject.getAppModeDescription(getContext(), mode),
|
||||
profiles.add(new EditProfileDataObject(modeKey, mode.toHumanString(), ProfileDataUtils.getAppModeDescription(getContext(), mode),
|
||||
mode.getIconRes(), false, mode.isCustomProfile(), deleted, mode.getIconColorInfo(), order));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,8 @@
|
|||
package net.osmand.plus.profiles;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.ColorRes;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ProfileDataObject implements Comparable<ProfileDataObject> {
|
||||
|
||||
|
@ -73,28 +64,4 @@ public class ProfileDataObject implements Comparable<ProfileDataObject> {
|
|||
return this.name.compareToIgnoreCase(another.name);
|
||||
}
|
||||
|
||||
public static List<ProfileDataObject> getDataObjects(OsmandApplication app,
|
||||
List<ApplicationMode> appModes) {
|
||||
List<ProfileDataObject> profiles = new ArrayList<>();
|
||||
for (ApplicationMode mode : appModes) {
|
||||
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()));
|
||||
}
|
||||
return profiles;
|
||||
}
|
||||
|
||||
public static String getAppModeDescription(Context ctx, ApplicationMode mode) {
|
||||
String description;
|
||||
if (mode.isCustomProfile()) {
|
||||
description = ctx.getString(R.string.profile_type_user_string);
|
||||
} else {
|
||||
description = ctx.getString(R.string.profile_type_osmand_string);
|
||||
}
|
||||
|
||||
return description;
|
||||
}
|
||||
}
|
||||
|
|
136
OsmAnd/src/net/osmand/plus/profiles/ProfileDataUtils.java
Normal file
136
OsmAnd/src/net/osmand/plus/profiles/ProfileDataUtils.java
Normal file
|
@ -0,0 +1,136 @@
|
|||
package net.osmand.plus.profiles;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.router.GeneralRouter;
|
||||
import net.osmand.router.RoutingConfiguration;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ProfileDataUtils {
|
||||
|
||||
public static final String OSMAND_NAVIGATION = "osmand_navigation";
|
||||
|
||||
public static List<ProfileDataObject> getDataObjects(OsmandApplication app,
|
||||
List<ApplicationMode> appModes) {
|
||||
List<ProfileDataObject> profiles = new ArrayList<>();
|
||||
for (ApplicationMode mode : appModes) {
|
||||
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()));
|
||||
}
|
||||
return profiles;
|
||||
}
|
||||
|
||||
public static String getAppModeDescription(Context ctx, ApplicationMode mode) {
|
||||
String description;
|
||||
if (mode.isCustomProfile()) {
|
||||
description = ctx.getString(R.string.profile_type_user_string);
|
||||
} else {
|
||||
description = ctx.getString(R.string.profile_type_osmand_string);
|
||||
}
|
||||
|
||||
return description;
|
||||
}
|
||||
|
||||
public static List<RoutingProfileDataObject> getSortedRoutingProfiles(OsmandApplication app) {
|
||||
List<RoutingProfileDataObject> result = new ArrayList<>();
|
||||
Map<String, List<RoutingProfileDataObject>> routingProfilesByFileNames = getRoutingProfilesByFileNames(app);
|
||||
List<String> fileNames = new ArrayList<>(routingProfilesByFileNames.keySet());
|
||||
Collections.sort(fileNames, new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(String s, String t1) {
|
||||
return s.equals(OSMAND_NAVIGATION) ? -1 : t1.equals(OSMAND_NAVIGATION) ? 1 : s.compareToIgnoreCase(t1);
|
||||
}
|
||||
});
|
||||
for (String fileName : fileNames) {
|
||||
List<RoutingProfileDataObject> routingProfilesFromFile = routingProfilesByFileNames.get(fileName);
|
||||
if (routingProfilesFromFile != null) {
|
||||
Collections.sort(routingProfilesFromFile);
|
||||
result.addAll(routingProfilesFromFile);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Map<String, List<RoutingProfileDataObject>> getRoutingProfilesByFileNames(OsmandApplication app) {
|
||||
Map<String, List<RoutingProfileDataObject>> result = new HashMap<>();
|
||||
for (final RoutingProfileDataObject profile : getRoutingProfiles(app).values()) {
|
||||
String fileName = profile.getFileName() != null ? profile.getFileName() : OSMAND_NAVIGATION;
|
||||
if (result.containsKey(fileName)) {
|
||||
result.get(fileName).add(profile);
|
||||
} else {
|
||||
result.put(fileName, new ArrayList<RoutingProfileDataObject>() {
|
||||
{ add(profile); }
|
||||
});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Map<String, RoutingProfileDataObject> getRoutingProfiles(OsmandApplication context) {
|
||||
Map<String, RoutingProfileDataObject> profilesObjects = new HashMap<>();
|
||||
profilesObjects.put(RoutingProfileDataObject.RoutingProfilesResources.STRAIGHT_LINE_MODE.name(), new RoutingProfileDataObject(
|
||||
RoutingProfileDataObject.RoutingProfilesResources.STRAIGHT_LINE_MODE.name(),
|
||||
context.getString(RoutingProfileDataObject.RoutingProfilesResources.STRAIGHT_LINE_MODE.getStringRes()),
|
||||
context.getString(R.string.special_routing_type),
|
||||
RoutingProfileDataObject.RoutingProfilesResources.STRAIGHT_LINE_MODE.getIconRes(),
|
||||
false, null));
|
||||
profilesObjects.put(RoutingProfileDataObject.RoutingProfilesResources.DIRECT_TO_MODE.name(), new RoutingProfileDataObject(
|
||||
RoutingProfileDataObject.RoutingProfilesResources.DIRECT_TO_MODE.name(),
|
||||
context.getString(RoutingProfileDataObject.RoutingProfilesResources.DIRECT_TO_MODE.getStringRes()),
|
||||
context.getString(R.string.special_routing_type),
|
||||
RoutingProfileDataObject.RoutingProfilesResources.DIRECT_TO_MODE.getIconRes(),
|
||||
false, null));
|
||||
if (context.getBRouterService() != null) {
|
||||
profilesObjects.put(RoutingProfileDataObject.RoutingProfilesResources.BROUTER_MODE.name(), new RoutingProfileDataObject(
|
||||
RoutingProfileDataObject.RoutingProfilesResources.BROUTER_MODE.name(),
|
||||
context.getString(RoutingProfileDataObject.RoutingProfilesResources.BROUTER_MODE.getStringRes()),
|
||||
context.getString(R.string.third_party_routing_type),
|
||||
RoutingProfileDataObject.RoutingProfilesResources.BROUTER_MODE.getIconRes(),
|
||||
false, null));
|
||||
}
|
||||
|
||||
List<String> disabledRouterNames = OsmandPlugin.getDisabledRouterNames();
|
||||
for (RoutingConfiguration.Builder builder : context.getAllRoutingConfigs()) {
|
||||
collectRoutingProfilesFromConfig(context, builder, profilesObjects, disabledRouterNames);
|
||||
}
|
||||
return profilesObjects;
|
||||
}
|
||||
|
||||
private static void collectRoutingProfilesFromConfig(OsmandApplication app, RoutingConfiguration.Builder builder,
|
||||
Map<String, RoutingProfileDataObject> profilesObjects, List<String> disabledRouterNames) {
|
||||
for (Map.Entry<String, GeneralRouter> entry : builder.getAllRouters().entrySet()) {
|
||||
String routerKey = entry.getKey();
|
||||
GeneralRouter router = entry.getValue();
|
||||
if (!routerKey.equals("geocoding") && !disabledRouterNames.contains(router.getFilename())) {
|
||||
int iconRes = R.drawable.ic_action_gdirections_dark;
|
||||
String name = router.getProfileName();
|
||||
String description = app.getString(R.string.osmand_default_routing);
|
||||
String fileName = router.getFilename();
|
||||
if (!Algorithms.isEmpty(fileName)) {
|
||||
description = fileName;
|
||||
} else if (RoutingProfileDataObject.RoutingProfilesResources.isRpValue(name.toUpperCase())) {
|
||||
iconRes = RoutingProfileDataObject.RoutingProfilesResources.valueOf(name.toUpperCase()).getIconRes();
|
||||
name = app.getString(RoutingProfileDataObject.RoutingProfilesResources.valueOf(name.toUpperCase()).getStringRes());
|
||||
}
|
||||
profilesObjects.put(routerKey, new RoutingProfileDataObject(routerKey, name, description,
|
||||
iconRes, false, fileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,22 +1,12 @@
|
|||
package net.osmand.plus.profiles;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.router.GeneralRouter;
|
||||
import net.osmand.router.RoutingConfiguration;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class RoutingProfileDataObject extends ProfileDataObject {
|
||||
public static final String OSMAND_NAVIGATION = "osmand_navigation";
|
||||
|
||||
private String fileName;
|
||||
|
||||
|
@ -70,90 +60,4 @@ public class RoutingProfileDataObject extends ProfileDataObject {
|
|||
}
|
||||
}
|
||||
|
||||
public static List<RoutingProfileDataObject> getSortedRoutingProfiles(OsmandApplication app) {
|
||||
List<RoutingProfileDataObject> result = new ArrayList<>();
|
||||
Map<String, List<RoutingProfileDataObject>> routingProfilesByFileNames = getRoutingProfilesByFileNames(app);
|
||||
List<String> fileNames = new ArrayList<>(routingProfilesByFileNames.keySet());
|
||||
Collections.sort(fileNames, new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(String s, String t1) {
|
||||
return s.equals(OSMAND_NAVIGATION) ? -1 : t1.equals(OSMAND_NAVIGATION) ? 1 : s.compareToIgnoreCase(t1);
|
||||
}
|
||||
});
|
||||
for (String fileName : fileNames) {
|
||||
List<RoutingProfileDataObject> routingProfilesFromFile = routingProfilesByFileNames.get(fileName);
|
||||
if (routingProfilesFromFile != null) {
|
||||
Collections.sort(routingProfilesFromFile);
|
||||
result.addAll(routingProfilesFromFile);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Map<String, List<RoutingProfileDataObject>> getRoutingProfilesByFileNames(OsmandApplication app) {
|
||||
Map<String, List<RoutingProfileDataObject>> result = new HashMap<>();
|
||||
for (final RoutingProfileDataObject profile : getRoutingProfiles(app).values()) {
|
||||
String fileName = profile.getFileName() != null ? profile.getFileName() : OSMAND_NAVIGATION;
|
||||
if (result.containsKey(fileName)) {
|
||||
result.get(fileName).add(profile);
|
||||
} else {
|
||||
result.put(fileName, new ArrayList<RoutingProfileDataObject>() {
|
||||
{ add(profile); }
|
||||
});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Map<String, RoutingProfileDataObject> getRoutingProfiles(OsmandApplication context) {
|
||||
Map<String, RoutingProfileDataObject> profilesObjects = new HashMap<>();
|
||||
profilesObjects.put(RoutingProfilesResources.STRAIGHT_LINE_MODE.name(), new RoutingProfileDataObject(
|
||||
RoutingProfilesResources.STRAIGHT_LINE_MODE.name(),
|
||||
context.getString(RoutingProfilesResources.STRAIGHT_LINE_MODE.getStringRes()),
|
||||
context.getString(R.string.special_routing_type),
|
||||
RoutingProfilesResources.STRAIGHT_LINE_MODE.getIconRes(),
|
||||
false, null));
|
||||
profilesObjects.put(RoutingProfilesResources.DIRECT_TO_MODE.name(), new RoutingProfileDataObject(
|
||||
RoutingProfilesResources.DIRECT_TO_MODE.name(),
|
||||
context.getString(RoutingProfilesResources.DIRECT_TO_MODE.getStringRes()),
|
||||
context.getString(R.string.special_routing_type),
|
||||
RoutingProfilesResources.DIRECT_TO_MODE.getIconRes(),
|
||||
false, null));
|
||||
if (context.getBRouterService() != null) {
|
||||
profilesObjects.put(RoutingProfilesResources.BROUTER_MODE.name(), new RoutingProfileDataObject(
|
||||
RoutingProfilesResources.BROUTER_MODE.name(),
|
||||
context.getString(RoutingProfilesResources.BROUTER_MODE.getStringRes()),
|
||||
context.getString(R.string.third_party_routing_type),
|
||||
RoutingProfilesResources.BROUTER_MODE.getIconRes(),
|
||||
false, null));
|
||||
}
|
||||
|
||||
List<String> disabledRouterNames = OsmandPlugin.getDisabledRouterNames();
|
||||
for (RoutingConfiguration.Builder builder : context.getAllRoutingConfigs()) {
|
||||
collectRoutingProfilesFromConfig(context, builder, profilesObjects, disabledRouterNames);
|
||||
}
|
||||
return profilesObjects;
|
||||
}
|
||||
|
||||
private static void collectRoutingProfilesFromConfig(OsmandApplication app, RoutingConfiguration.Builder builder,
|
||||
Map<String, RoutingProfileDataObject> profilesObjects, List<String> disabledRouterNames) {
|
||||
for (Map.Entry<String, GeneralRouter> entry : builder.getAllRouters().entrySet()) {
|
||||
String routerKey = entry.getKey();
|
||||
GeneralRouter router = entry.getValue();
|
||||
if (!routerKey.equals("geocoding") && !disabledRouterNames.contains(router.getFilename())) {
|
||||
int iconRes = R.drawable.ic_action_gdirections_dark;
|
||||
String name = router.getProfileName();
|
||||
String description = app.getString(R.string.osmand_default_routing);
|
||||
String fileName = router.getFilename();
|
||||
if (!Algorithms.isEmpty(fileName)) {
|
||||
description = fileName;
|
||||
} else if (RoutingProfilesResources.isRpValue(name.toUpperCase())) {
|
||||
iconRes = RoutingProfilesResources.valueOf(name.toUpperCase()).getIconRes();
|
||||
name = app.getString(RoutingProfilesResources.valueOf(name.toUpperCase()).getStringRes());
|
||||
}
|
||||
profilesObjects.put(routerKey, new RoutingProfileDataObject(routerKey, name, description,
|
||||
iconRes, false, fileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public class SelectMultipleProfilesBottomSheet extends BasePreferenceBottomSheet
|
|||
private void refreshProfiles(OsmandApplication app) {
|
||||
profiles.clear();
|
||||
List<ApplicationMode> appModes = ApplicationMode.allPossibleValues();
|
||||
profiles.addAll(ProfileDataObject.getDataObjects(app, appModes));
|
||||
profiles.addAll(ProfileDataUtils.getDataObjects(app, appModes));
|
||||
for (ProfileDataObject profile : profiles) {
|
||||
String key = profile.getStringKey();
|
||||
profile.setSelected(selectedProfiles.contains(key));
|
||||
|
|
|
@ -331,16 +331,17 @@ public class SelectProfileBottomSheet extends BasePreferenceBottomSheet {
|
|||
profiles.clear();
|
||||
switch (dialogMode) {
|
||||
case BASE_PROFILE:
|
||||
List<ApplicationMode> appModes = ApplicationMode.values(app, false, ApplicationMode.DEFAULT);
|
||||
profiles.addAll(ProfileDataObject.getDataObjects(app, appModes));
|
||||
List<ApplicationMode> appModes = new ArrayList<>(ApplicationMode.allPossibleValues());
|
||||
appModes.remove(ApplicationMode.DEFAULT);
|
||||
profiles.addAll(ProfileDataUtils.getDataObjects(app, appModes));
|
||||
break;
|
||||
|
||||
case NAVIGATION_PROFILE:
|
||||
profiles.addAll(RoutingProfileDataObject.getSortedRoutingProfiles(app));
|
||||
profiles.addAll(ProfileDataUtils.getSortedRoutingProfiles(app));
|
||||
break;
|
||||
|
||||
case DEFAULT_PROFILE:
|
||||
profiles.addAll(ProfileDataObject.getDataObjects(app, ApplicationMode.values(app)));
|
||||
profiles.addAll(ProfileDataUtils.getDataObjects(app, ApplicationMode.values(app)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -366,8 +367,7 @@ public class SelectProfileBottomSheet extends BasePreferenceBottomSheet {
|
|||
fragment.setArguments(args);
|
||||
fragment.setUsedOnMap(usedOnMap);
|
||||
fragment.setTargetFragment(target, 0);
|
||||
FragmentManager fm = activity.getSupportFragmentManager();
|
||||
fm.beginTransaction().add(fragment, TAG).commitAllowingStateLoss();
|
||||
fragment.show(activity.getSupportFragmentManager(), TAG);
|
||||
}
|
||||
|
||||
public interface OnSelectProfileCallback {
|
||||
|
|
|
@ -98,7 +98,7 @@ public class SelectProfileMenuAdapter extends AbstractProfileMenuAdapter<SelectP
|
|||
holder.menuIcon.setVisibility(View.GONE);
|
||||
final ApplicationMode item = (ApplicationMode) obj;
|
||||
holder.title.setText(item.toHumanString());
|
||||
holder.descr.setText(ProfileDataObject.getAppModeDescription(app, item));
|
||||
holder.descr.setText(ProfileDataUtils.getAppModeDescription(app, item));
|
||||
|
||||
int profileColorResId = item.getIconColorInfo().getColor(nightMode);
|
||||
holder.icon.setImageDrawable(app.getUIUtilities().getIcon(profileColorResId, selectedIconColorRes));
|
||||
|
|
|
@ -116,18 +116,6 @@ public class ApplicationMode {
|
|||
.icon(R.drawable.ic_action_skiing)
|
||||
.description(R.string.base_profile_descr_ski).reg();
|
||||
|
||||
public static List<ApplicationMode> values(OsmandApplication app,
|
||||
boolean onlyActive,
|
||||
ApplicationMode ... exclude) {
|
||||
List<ApplicationMode> appModes = new ArrayList<>(onlyActive ? values(app) : allPossibleValues());
|
||||
if (exclude != null && exclude.length > 0) {
|
||||
for (ApplicationMode m : exclude) {
|
||||
appModes.remove(m);
|
||||
}
|
||||
}
|
||||
return appModes;
|
||||
}
|
||||
|
||||
public static List<ApplicationMode> values(OsmandApplication app) {
|
||||
if (customizationListener == null) {
|
||||
customizationListener = new OsmAndAppCustomization.OsmAndAppCustomizationListener() {
|
||||
|
|
|
@ -736,7 +736,7 @@ public class OsmandSettings {
|
|||
|
||||
public final OsmandPreference<String> LAST_FAV_CATEGORY_ENTERED = new StringPreference(this, "last_fav_category", "").makeGlobal();
|
||||
|
||||
public final OsmandPreference<Boolean> USE_LAST_APPLICATION_MODE_BY_DEFAULT = new BooleanPreference(this, "use_last_application_mode_by_default", false).makeGlobal();
|
||||
public final OsmandPreference<Boolean> USE_LAST_APPLICATION_MODE_BY_DEFAULT = new BooleanPreference(this, "use_last_application_mode_by_default", false).makeGlobal().makeShared();
|
||||
|
||||
public final OsmandPreference<String> LAST_USED_APPLICATION_MODE = new StringPreference(this, "last_used_application_mode", ApplicationMode.DEFAULT.getStringKey()).makeGlobal().makeShared();
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import androidx.core.content.ContextCompat;
|
|||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import net.osmand.plus.profiles.ProfileDataObject;
|
||||
import net.osmand.plus.profiles.ProfileDataUtils;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
|
@ -48,7 +48,7 @@ public class ResetProfilePrefsBottomSheet extends BasePreferenceBottomSheet {
|
|||
.setChecked(true)
|
||||
.setCompoundButtonColorId(profileColor)
|
||||
.setButtonTintList(ColorStateList.valueOf(getResolvedColor(profileColor)))
|
||||
.setDescription(ProfileDataObject.getAppModeDescription(ctx, mode))
|
||||
.setDescription(ProfileDataUtils.getAppModeDescription(ctx, mode))
|
||||
.setIcon(getIcon(mode.getIconRes(), profileColor))
|
||||
.setTitle(mode.toHumanString())
|
||||
.setBackground(new LayerDrawable(layers))
|
||||
|
|
|
@ -20,7 +20,7 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.profiles.ProfileDataObject;
|
||||
import net.osmand.plus.profiles.ProfileDataUtils;
|
||||
import net.osmand.plus.profiles.SelectProfileBottomSheet;
|
||||
import net.osmand.plus.profiles.SelectProfileBottomSheet.DialogMode;
|
||||
import net.osmand.plus.profiles.SelectProfileBottomSheet.OnSelectProfileCallback;
|
||||
|
@ -155,7 +155,7 @@ public class MainSettingsFragment extends BaseSettingsFragment implements OnSele
|
|||
private void setupConfigureProfilePref() {
|
||||
ApplicationMode selectedMode = app.getSettings().APPLICATION_MODE.get();
|
||||
String title = selectedMode.toHumanString();
|
||||
String profileType = ProfileDataObject.getAppModeDescription(getContext(), selectedMode);
|
||||
String profileType = ProfileDataUtils.getAppModeDescription(getContext(), selectedMode);
|
||||
Preference configureProfile = findPreference(CONFIGURE_PROFILE);
|
||||
configureProfile.setIcon(getAppProfilesIcon(selectedMode, true));
|
||||
configureProfile.setTitle(title);
|
||||
|
@ -193,7 +193,7 @@ public class MainSettingsFragment extends BaseSettingsFragment implements OnSele
|
|||
|
||||
pref.setIcon(getAppProfilesIcon(applicationMode, isAppProfileEnabled));
|
||||
pref.setTitle(applicationMode.toHumanString());
|
||||
pref.setSummary(ProfileDataObject.getAppModeDescription(getContext(), applicationMode));
|
||||
pref.setSummary(ProfileDataUtils.getAppModeDescription(getContext(), applicationMode));
|
||||
pref.setChecked(isAppProfileEnabled);
|
||||
pref.setLayoutResource(R.layout.preference_with_descr_dialog_and_switch);
|
||||
pref.setFragment(ConfigureProfileFragment.class.getName());
|
||||
|
|
|
@ -10,6 +10,7 @@ import androidx.preference.Preference;
|
|||
import androidx.preference.SwitchPreferenceCompat;
|
||||
|
||||
import net.osmand.plus.measurementtool.MeasurementToolFragment;
|
||||
import net.osmand.plus.profiles.ProfileDataUtils;
|
||||
import net.osmand.plus.routepreparationmenu.RouteOptionsBottomSheet;
|
||||
import net.osmand.plus.routepreparationmenu.RouteOptionsBottomSheet.DialogMode;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
|
@ -40,7 +41,7 @@ public class NavigationFragment extends BaseSettingsFragment implements OnSelect
|
|||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
routingProfileDataObjects = RoutingProfileDataObject.getRoutingProfiles(app);
|
||||
routingProfileDataObjects = ProfileDataUtils.getRoutingProfiles(app);
|
||||
setupOnBackPressedCallback();
|
||||
}
|
||||
|
||||
|
@ -174,7 +175,7 @@ public class NavigationFragment extends BaseSettingsFragment implements OnSelect
|
|||
@Override
|
||||
public void onProfileSelected(Bundle args) {
|
||||
if (args.getBoolean(IS_PROFILE_IMPORTED_ARG)) {
|
||||
routingProfileDataObjects = RoutingProfileDataObject.getRoutingProfiles(app);
|
||||
routingProfileDataObjects = ProfileDataUtils.getRoutingProfiles(app);
|
||||
}
|
||||
updateRoutingProfile(args.getString(PROFILE_KEY_ARG));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue