Fix for api 16, code cleanup ApplicationMode
This commit is contained in:
parent
533571724b
commit
20320ddc07
4 changed files with 62 additions and 44 deletions
|
@ -1,9 +1,9 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
<shape android:shape="rectangle"
|
android:shape="rectangle">
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
<solid android:color="@android:color/transparent" />
|
||||||
<corners android:radius="2dp" />
|
<corners android:radius="2dp" />
|
||||||
<stroke
|
<stroke
|
||||||
android:radius="5dp"
|
android:radius="5dp"
|
||||||
android:width="2dp"
|
android:width="2dp"
|
||||||
android:color="@color/A400red" />
|
android:color="@color/divider_color_light" />
|
||||||
</shape>
|
</shape>
|
|
@ -133,16 +133,26 @@ public class ApplicationMode {
|
||||||
.setRoutingProfile("ski").description(R.string.base_profile_descr_ski).reg();
|
.setRoutingProfile("ski").description(R.string.base_profile_descr_ski).reg();
|
||||||
|
|
||||||
private static class ApplicationModeBean {
|
private static class ApplicationModeBean {
|
||||||
@Expose String stringKey;
|
@Expose
|
||||||
@Expose String userProfileName;
|
String stringKey;
|
||||||
@Expose String parent;
|
@Expose
|
||||||
@Expose String iconName = "map_world_globe_dark";
|
String userProfileName;
|
||||||
@Expose ProfileIconColors iconColor = ProfileIconColors.DEFAULT;
|
@Expose
|
||||||
@Expose String routingProfile = null;
|
String parent;
|
||||||
@Expose RouteService routeService = RouteService.OSMAND;
|
@Expose
|
||||||
@Expose LocationIcon locationIcon = LocationIcon.DEFAULT;
|
String iconName = "map_world_globe_dark";
|
||||||
@Expose NavigationIcon navigationIcon = NavigationIcon.CAR;
|
@Expose
|
||||||
@Expose int order;
|
ProfileIconColors iconColor = ProfileIconColors.DEFAULT;
|
||||||
|
@Expose
|
||||||
|
String routingProfile = null;
|
||||||
|
@Expose
|
||||||
|
RouteService routeService = RouteService.OSMAND;
|
||||||
|
@Expose
|
||||||
|
LocationIcon locationIcon = LocationIcon.DEFAULT;
|
||||||
|
@Expose
|
||||||
|
NavigationIcon navigationIcon = NavigationIcon.CAR;
|
||||||
|
@Expose
|
||||||
|
int order;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initRegVisibility() {
|
private static void initRegVisibility() {
|
||||||
|
@ -554,11 +564,13 @@ public class ApplicationMode {
|
||||||
return routingProfile;
|
return routingProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@DrawableRes public int getIconRes() {
|
@DrawableRes
|
||||||
|
public int getIconRes() {
|
||||||
return iconRes;
|
return iconRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@DrawableRes public int getMapIconRes() {
|
@DrawableRes
|
||||||
|
public int getMapIconRes() {
|
||||||
return iconMapRes;
|
return iconMapRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -650,7 +662,8 @@ public class ApplicationMode {
|
||||||
|
|
||||||
private static void initDefaultModesParams(OsmandApplication app) {
|
private static void initDefaultModesParams(OsmandApplication app) {
|
||||||
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
||||||
Type t = new TypeToken<ArrayList<ApplicationModeBean>>() {}.getType();
|
Type t = new TypeToken<ArrayList<ApplicationModeBean>>() {
|
||||||
|
}.getType();
|
||||||
List<ApplicationModeBean> defaultAppModeBeans = gson.fromJson(app.getSettings().DEFAULT_APP_PROFILES.get(), t);
|
List<ApplicationModeBean> defaultAppModeBeans = gson.fromJson(app.getSettings().DEFAULT_APP_PROFILES.get(), t);
|
||||||
|
|
||||||
if (!Algorithms.isEmpty(defaultAppModeBeans)) {
|
if (!Algorithms.isEmpty(defaultAppModeBeans)) {
|
||||||
|
@ -672,7 +685,8 @@ public class ApplicationMode {
|
||||||
|
|
||||||
private static void initCustomModes(OsmandApplication app) {
|
private static void initCustomModes(OsmandApplication app) {
|
||||||
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
||||||
Type t = new TypeToken<ArrayList<ApplicationModeBean>>() {}.getType();
|
Type t = new TypeToken<ArrayList<ApplicationModeBean>>() {
|
||||||
|
}.getType();
|
||||||
List<ApplicationModeBean> customProfiles = gson.fromJson(app.getSettings().CUSTOM_APP_PROFILES.get(), t);
|
List<ApplicationModeBean> customProfiles = gson.fromJson(app.getSettings().CUSTOM_APP_PROFILES.get(), t);
|
||||||
|
|
||||||
if (!Algorithms.isEmpty(customProfiles)) {
|
if (!Algorithms.isEmpty(customProfiles)) {
|
||||||
|
@ -812,9 +826,12 @@ public class ApplicationMode {
|
||||||
DARK_YELLOW(R.string.rendering_value_darkyellow_name, R.color.profile_icon_color_yellow_light, R.color.profile_icon_color_yellow_dark),
|
DARK_YELLOW(R.string.rendering_value_darkyellow_name, R.color.profile_icon_color_yellow_light, R.color.profile_icon_color_yellow_dark),
|
||||||
MAGENTA(R.string.shared_string_color_magenta, R.color.profile_icon_color_magenta_light, R.color.profile_icon_color_magenta_dark);
|
MAGENTA(R.string.shared_string_color_magenta, R.color.profile_icon_color_magenta_light, R.color.profile_icon_color_magenta_dark);
|
||||||
|
|
||||||
@StringRes private int name;
|
@StringRes
|
||||||
@ColorRes private int dayColor;
|
private int name;
|
||||||
@ColorRes private int nightColor;
|
@ColorRes
|
||||||
|
private int dayColor;
|
||||||
|
@ColorRes
|
||||||
|
private int nightColor;
|
||||||
|
|
||||||
ProfileIconColors(@StringRes int name, @ColorRes int dayColor, @ColorRes int nightColor) {
|
ProfileIconColors(@StringRes int name, @ColorRes int dayColor, @ColorRes int nightColor) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@ -920,6 +937,7 @@ public class ApplicationMode {
|
||||||
public int getIconId() {
|
public int getIconId() {
|
||||||
return iconId;
|
return iconId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getHeadingIconId() {
|
public int getHeadingIconId() {
|
||||||
return headingIconId;
|
return headingIconId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -491,7 +491,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
|
||||||
int changedProfileColor = ContextCompat.getColor(app, changedProfile.color.getColor(
|
int changedProfileColor = ContextCompat.getColor(app, changedProfile.color.getColor(
|
||||||
app.getDaynightHelper().isNightModeForMapControls()));
|
app.getDaynightHelper().isNightModeForMapControls()));
|
||||||
LayerDrawable locationIconDrawable = (LayerDrawable) app.getResources().getDrawable(locationIcon.getIconId());
|
LayerDrawable locationIconDrawable = (LayerDrawable) app.getResources().getDrawable(locationIcon.getIconId());
|
||||||
DrawableCompat.setTint(locationIconDrawable.getDrawable(1), changedProfileColor);
|
DrawableCompat.setTint(DrawableCompat.wrap(locationIconDrawable.getDrawable(1)), changedProfileColor);
|
||||||
locationIconView.<ImageView>findViewById(R.id.icon).setImageDrawable(locationIconDrawable);
|
locationIconView.<ImageView>findViewById(R.id.icon).setImageDrawable(locationIconDrawable);
|
||||||
ImageView headingIcon = locationIconView.findViewById(R.id.headingIcon);
|
ImageView headingIcon = locationIconView.findViewById(R.id.headingIcon);
|
||||||
headingIcon.setImageDrawable(ContextCompat.getDrawable(app, locationIcon.getHeadingIconId()));
|
headingIcon.setImageDrawable(ContextCompat.getDrawable(app, locationIcon.getHeadingIconId()));
|
||||||
|
@ -531,8 +531,8 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
|
||||||
FrameLayout navigationIconView = (FrameLayout) UiUtilities.getInflater(getContext(), isNightMode())
|
FrameLayout navigationIconView = (FrameLayout) UiUtilities.getInflater(getContext(), isNightMode())
|
||||||
.inflate(R.layout.preference_select_icon_button, rootView, false);
|
.inflate(R.layout.preference_select_icon_button, rootView, false);
|
||||||
LayerDrawable navigationIconDrawable = (LayerDrawable) app.getResources().getDrawable(navigationIcon.getIconId());
|
LayerDrawable navigationIconDrawable = (LayerDrawable) app.getResources().getDrawable(navigationIcon.getIconId());
|
||||||
DrawableCompat.setTint(navigationIconDrawable.getDrawable(1), ContextCompat.getColor(app, changedProfile.color.getColor(
|
DrawableCompat.setTint(DrawableCompat.wrap(navigationIconDrawable.getDrawable(1)),
|
||||||
app.getDaynightHelper().isNightModeForMapControls())));
|
ContextCompat.getColor(app, changedProfile.color.getColor(app.getDaynightHelper().isNightModeForMapControls())));
|
||||||
ImageView imageView = navigationIconView.findViewById(R.id.icon);
|
ImageView imageView = navigationIconView.findViewById(R.id.icon);
|
||||||
imageView.setImageDrawable(navigationIconDrawable);
|
imageView.setImageDrawable(navigationIconDrawable);
|
||||||
Matrix matrix = new Matrix();
|
Matrix matrix = new Matrix();
|
||||||
|
|
|
@ -165,7 +165,7 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
|
||||||
headingIcon = BitmapFactory.decodeResource(view.getResources(), appMode.getLocationIcon().getHeadingIconId());
|
headingIcon = BitmapFactory.decodeResource(view.getResources(), appMode.getLocationIcon().getHeadingIconId());
|
||||||
headingPaint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));
|
headingPaint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));
|
||||||
locationIcon = (LayerDrawable) view.getResources().getDrawable(appMode.getLocationIcon().getIconId());
|
locationIcon = (LayerDrawable) view.getResources().getDrawable(appMode.getLocationIcon().getIconId());
|
||||||
DrawableCompat.setTint(locationIcon.getDrawable(1), color);
|
DrawableCompat.setTint(DrawableCompat.wrap(locationIcon.getDrawable(1)), color);
|
||||||
area.setColor(UiUtilities.getColorWithAlpha(color, 0.16f));
|
area.setColor(UiUtilities.getColorWithAlpha(color, 0.16f));
|
||||||
aroundArea.setColor(color);
|
aroundArea.setColor(color);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue