Merge branch 'master' into 7051_expand_coordnates

This commit is contained in:
madwasp79 2019-06-20 13:15:07 +03:00
commit b55363cf53
19 changed files with 445 additions and 130 deletions

View file

@ -155,41 +155,10 @@
</net.osmand.plus.widgets.OsmandTextFieldBoxes> </net.osmand.plus.widgets.OsmandTextFieldBoxes>
<LinearLayout
android:id="@+id/profile_icon_layout"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginEnd="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding"
android:clickable="true"
android:focusable="true"
android:gravity="center"
android:orientation="vertical"
>
<TextView
android:id="@+id/select_icon_btn_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="2dp"
android:text="Icon"
android:textSize="12sp"/>
<ImageView
android:id="@+id/select_icon_btn_img"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
tools:src="@drawable/ic_action_car_dark"/>
</LinearLayout>
</LinearLayout> </LinearLayout>
<FrameLayout
android:id="@+id/click_block_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="false"/>
</FrameLayout> </FrameLayout>
@ -238,6 +207,101 @@
</FrameLayout> </FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/context_menu_action_buttons_h"
android:layout_marginTop="8dp"
android:layout_marginBottom="@dimen/list_content_padding"
android:layout_marginLeft="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/divider_light"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
android:layout_gravity="center_vertical">
<LinearLayout
android:id="@+id/select_icon_button"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:layout_weight="1"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:layout_weight="1"
android:textSize="@dimen/default_list_text_size"
android:text="@string/shared_string_icon"
android:textColor="?attr/main_font_color_basic"/>
<ImageView
android:id="@+id/profile_icon_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/list_content_padding"
tools:src="@drawable/ic_action_horse"
tools:tint="@color/A400red"/>
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="36dp"
android:layout_gravity="center_vertical"
android:background="@color/divider_light"/>
<LinearLayout
android:id="@+id/select_icon_color_button"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:paddingLeft="@dimen/list_content_padding"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:textSize="@dimen/default_list_text_size"
android:text="@string/shared_string_color"
android:textColor="?attr/main_font_color_basic"/>
<ImageView
android:id="@+id/color_sample_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/list_content_padding"
tools:src = "@drawable/ic_action_circle"
tools:tint="@color/A400red"/>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/divider_light"/>
</LinearLayout>
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -248,6 +312,12 @@
android:layout_marginRight="@dimen/list_content_padding" android:layout_marginRight="@dimen/list_content_padding"
android:text="@string/osmand_routing_promo"/> android:text="@string/osmand_routing_promo"/>
<FrameLayout
android:id="@+id/click_block_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="false"/>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout

View file

@ -59,7 +59,6 @@
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin" android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin" android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:tint="?attr/primary_icon_color"
tools:src="@drawable/ic_action_coordinates_latitude"/> tools:src="@drawable/ic_action_coordinates_latitude"/>
<LinearLayout <LinearLayout
@ -103,6 +102,12 @@
</LinearLayout> </LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_bottom"/>
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" > android:layout_height="match_parent" >

View file

@ -40,7 +40,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="2" android:maxLines="2"
android:textColor="@color/main_font_dark" android:textColor="?attr/main_font_color_basic"
android:textSize="@dimen/default_list_text_size" android:textSize="@dimen/default_list_text_size"
tools:text="Bicycle" /> tools:text="Bicycle" />
@ -51,6 +51,7 @@
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
android:textSize="@dimen/default_desc_text_size" android:textSize="@dimen/default_desc_text_size"
android:textColor="@color/description_font_and_bottom_sheet_icons"
tools:text="Type: Bicycle" /> tools:text="Type: Bicycle" />
</LinearLayout> </LinearLayout>
@ -70,7 +71,7 @@
android:paddingEnd="10dp" android:paddingEnd="10dp"
android:paddingRight="10dp" android:paddingRight="10dp"
android:src="@drawable/ic_action_additional_option" android:src="@drawable/ic_action_additional_option"
android:tint="?attr/primary_icon_color" /> android:tint="@color/description_font_and_bottom_sheet_icons" />
<android.support.v7.widget.SwitchCompat <android.support.v7.widget.SwitchCompat
android:id="@+id/compound_button" android:id="@+id/compound_button"
@ -89,7 +90,7 @@
android:id="@+id/divider_bottom" android:id="@+id/divider_bottom"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:background="@color/settings_divider" /> android:background="?attr/list_divider" />
</LinearLayout> </LinearLayout>

View file

@ -3472,4 +3472,6 @@
<string name="poi_charcoal_pile">Куча для выжига угля</string> <string name="poi_charcoal_pile">Куча для выжига угля</string>
<string name="poi_historic_tank">Танк</string>
</resources> </resources>

View file

@ -497,5 +497,22 @@
<color name="active_buttons_and_links_text_light">#ffffff</color> <color name="active_buttons_and_links_text_light">#ffffff</color>
<color name="active_buttons_and_links_text_dark">#cccccc</color> <color name="active_buttons_and_links_text_dark">#cccccc</color>
<color name="profile_icon_color_blue_light_default">#237BFF</color>
<color name="profile_icon_color_purple_light">#732EEB</color>
<color name="profile_icon_color_green_light">#0EBE92</color>
<color name="profile_icon_color_blue_light">#007EB3</color>
<color name="profile_icon_color_red_light">#FF2200</color>
<color name="profile_icon_color_yellow_light">#F0B400</color>
<color name="profile_icon_color_magenta_light">#CC0063</color>
<color name="profile_icon_color_blue_dark_default">#B3237BFF</color>
<color name="profile_icon_color_purple_dark">#B3732EEB</color>
<color name="profile_icon_color_green_dark">#B30EBE92</color>
<color name="profile_icon_color_blue_dark">#B3007EB3</color>
<color name="profile_icon_color_red_dark">#B3FF2200</color>
<color name="profile_icon_color_yellow_dark">#B3F0B400</color>
<color name="profile_icon_color_magenta_dark">#B3CC0063</color>
<color name="profile_icon_color_inactive">#727272</color>
</resources> </resources>

View file

@ -3963,4 +3963,6 @@
<string name="poi_charcoal_pile">Charcoal pile</string> <string name="poi_charcoal_pile">Charcoal pile</string>
<string name="poi_historic_tank">Historic tank</string>
</resources> </resources>

View file

@ -12,6 +12,8 @@
--> -->
<string name="process_downloading_service">OsmAnd downloading service</string> <string name="process_downloading_service">OsmAnd downloading service</string>
<string name="shared_string_color_magenta">Magenta</string>
<string name="shared_string_icon">Icon</string>
<string name="app_profile_custom_nav_subtitle"></string> <string name="app_profile_custom_nav_subtitle"></string>
<string name="rate_dialog_descr">Please give us 30 seconds, share feedback and rate our work on Google Play.</string> <string name="rate_dialog_descr">Please give us 30 seconds, share feedback and rate our work on Google Play.</string>
<string name="button_rate">Rate</string> <string name="button_rate">Rate</string>

View file

@ -114,7 +114,7 @@
<item name="ctx_menu_card_btn">@color/ctx_menu_card_btn_light</item> <item name="ctx_menu_card_btn">@color/ctx_menu_card_btn_light</item>
<item name="searchbar_text">@color/searchbar_text_light</item> <item name="searchbar_text">@color/searchbar_text_light</item>
<item name="searchbar_text_hint">@color/searchbar_text_hint_light</item> <item name="searchbar_text_hint">@color/searchbar_text_hint_light</item>
<item name="list_divider">@color/list_divider_dark</item> <item name="list_divider">@color/divider_light</item>
<item name="expandable_category_color">?android:attr/colorBackground</item> <item name="expandable_category_color">?android:attr/colorBackground</item>
<item name="bottomToolBarColor">@color/tool_bar_color_light</item> <item name="bottomToolBarColor">@color/tool_bar_color_light</item>
<item name="downloadButtonBackground">@drawable/download_light</item> <item name="downloadButtonBackground">@drawable/download_light</item>
@ -368,7 +368,7 @@
<item name="ctx_menu_card_btn">@color/ctx_menu_card_btn_dark</item> <item name="ctx_menu_card_btn">@color/ctx_menu_card_btn_dark</item>
<item name="searchbar_text">@color/searchbar_text_dark</item> <item name="searchbar_text">@color/searchbar_text_dark</item>
<item name="searchbar_text_hint">@color/searchbar_text_hint_dark</item> <item name="searchbar_text_hint">@color/searchbar_text_hint_dark</item>
<item name="list_divider">@color/list_divider_light</item> <item name="list_divider">@color/divider_dark</item>
<item name="expandable_category_color">?android:attr/colorBackground</item> <item name="expandable_category_color">?android:attr/colorBackground</item>
<item name="bottomToolBarColor">@color/tool_bar_color_dark</item> <item name="bottomToolBarColor">@color/tool_bar_color_dark</item>
<item name="downloadButtonBackground">@drawable/download_dark</item> <item name="downloadButtonBackground">@drawable/download_dark</item>

View file

@ -2,8 +2,9 @@ package net.osmand.plus;
import android.content.Context; import android.content.Context;
import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes; import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull; import android.support.annotation.StringRes;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.google.gson.annotations.Expose; import com.google.gson.annotations.Expose;
@ -152,6 +153,7 @@ public class ApplicationMode {
applicationMode.locationIconNight = R.drawable.map_car_location_night; applicationMode.locationIconNight = R.drawable.map_car_location_night;
applicationMode.locationIconDayLost = R.drawable.map_car_location_lost; applicationMode.locationIconDayLost = R.drawable.map_car_location_lost;
applicationMode.locationIconNightLost = R.drawable.map_car_location_lost_night; applicationMode.locationIconNightLost = R.drawable.map_car_location_lost_night;
applicationMode.locationIconsSet = LocationIconsSet.CAR;
return this; return this;
} }
@ -164,6 +166,7 @@ public class ApplicationMode {
applicationMode.locationIconNight = R.drawable.map_bicycle_location_night; applicationMode.locationIconNight = R.drawable.map_bicycle_location_night;
applicationMode.locationIconDayLost = R.drawable.map_bicycle_location_lost; applicationMode.locationIconDayLost = R.drawable.map_bicycle_location_lost;
applicationMode.locationIconNightLost = R.drawable.map_bicycle_location_lost_night; applicationMode.locationIconNightLost = R.drawable.map_bicycle_location_lost_night;
applicationMode.locationIconsSet = LocationIconsSet.BICYCLE;
return this; return this;
} }
@ -176,6 +179,7 @@ public class ApplicationMode {
applicationMode.locationIconNight = R.drawable.map_pedestrian_location_night; applicationMode.locationIconNight = R.drawable.map_pedestrian_location_night;
applicationMode.locationIconDayLost = R.drawable.map_pedestrian_location_lost; applicationMode.locationIconDayLost = R.drawable.map_pedestrian_location_lost;
applicationMode.locationIconNightLost = R.drawable.map_pedestrian_location_lost_night; applicationMode.locationIconNightLost = R.drawable.map_pedestrian_location_lost_night;
applicationMode.locationIconsSet = LocationIconsSet.DEFAULT;
return this; return this;
} }
@ -186,6 +190,7 @@ public class ApplicationMode {
applicationMode.headingIconNight = R.drawable.map_nautical_location_view_angle_night; applicationMode.headingIconNight = R.drawable.map_nautical_location_view_angle_night;
applicationMode.locationIconDay = R.drawable.map_nautical_location; applicationMode.locationIconDay = R.drawable.map_nautical_location;
applicationMode.locationIconNight = R.drawable.map_nautical_location_night; applicationMode.locationIconNight = R.drawable.map_nautical_location_night;
applicationMode.locationIconsSet = LocationIconsSet.NAUTICAL;
return this; return this;
} }
@ -219,6 +224,11 @@ public class ApplicationMode {
applicationMode.routeService = service; applicationMode.routeService = service;
return this; return this;
} }
public ApplicationModeBuilder setColor(ProfileIconColors colorData) {
applicationMode.iconColor = colorData;
return this;
}
} }
private static ApplicationModeBuilder create(int key, String stringKey) { private static ApplicationModeBuilder create(int key, String stringKey) {
@ -364,7 +374,6 @@ public class ApplicationMode {
} }
public int getResourceBearingNight() { public int getResourceBearingNight() {
//return bearingIconDay;
return bearingIconNight; return bearingIconNight;
} }
@ -381,7 +390,6 @@ public class ApplicationMode {
} }
public int getResourceLocationNight() { public int getResourceLocationNight() {
//return locationIconDay;
return locationIconNight; return locationIconNight;
} }
@ -472,6 +480,7 @@ public class ApplicationMode {
@Expose private String userProfileName; @Expose private String userProfileName;
@Expose private ApplicationMode parent; @Expose private ApplicationMode parent;
@Expose private String iconName = "map_world_globe_dark"; @Expose private String iconName = "map_world_globe_dark";
@Expose private ProfileIconColors iconColor = ProfileIconColors.DEFAULT;
@Expose private int mapIconId = R.drawable.map_world_globe_dark; @Expose private int mapIconId = R.drawable.map_world_globe_dark;
@Expose private int smallIconDark = R.drawable.ic_world_globe_dark; @Expose private int smallIconDark = R.drawable.ic_world_globe_dark;
@Expose private float defaultSpeed = 10f; @Expose private float defaultSpeed = 10f;
@ -486,6 +495,7 @@ public class ApplicationMode {
@Expose private int locationIconNight = R.drawable.map_pedestrian_location_night; @Expose private int locationIconNight = R.drawable.map_pedestrian_location_night;
@Expose private int locationIconDayLost = R.drawable.map_pedestrian_location_lost; @Expose private int locationIconDayLost = R.drawable.map_pedestrian_location_lost;
@Expose private int locationIconNightLost = R.drawable.map_pedestrian_location_lost_night; @Expose private int locationIconNightLost = R.drawable.map_pedestrian_location_lost_night;
@Expose private LocationIconsSet locationIconsSet = LocationIconsSet.DEFAULT;
@Expose private String routingProfile = null; @Expose private String routingProfile = null;
@Expose private RouteService routeService = RouteService.OSMAND; @Expose private RouteService routeService = RouteService.OSMAND;
private static StateChangedListener<String> listener; private static StateChangedListener<String> listener;
@ -511,12 +521,60 @@ public class ApplicationMode {
if (!Algorithms.isEmpty(customProfiles)) { if (!Algorithms.isEmpty(customProfiles)) {
for (ApplicationMode m : customProfiles) { for (ApplicationMode m : customProfiles) {
if (!values.contains(m)) { if (!values.contains(m)) {
values.add(m); if (m.locationIconsSet != null) {
values.add(ApplicationMode.setBearingIconsSet(m));
} else {
values.add(m);
}
} }
} }
} }
} }
private static ApplicationMode setBearingIconsSet(ApplicationMode mode) {
switch (mode.locationIconsSet) {
case CAR:
mode.bearingIconDay = R.drawable.map_car_bearing;
mode.bearingIconNight = R.drawable.map_car_bearing_night;
mode.headingIconDay = R.drawable.map_car_location_view_angle;
mode.headingIconNight = R.drawable.map_car_location_view_angle_night;
mode.locationIconDay = R.drawable.map_car_location;
mode.locationIconNight = R.drawable.map_car_location_night;
mode.locationIconDayLost = R.drawable.map_car_location_lost;
mode.locationIconNightLost = R.drawable.map_car_location_lost_night;
break;
case BICYCLE:
mode.bearingIconDay = R.drawable.map_bicycle_bearing;
mode.bearingIconNight = R.drawable.map_bicycle_bearing_night;
mode.headingIconDay = R.drawable.map_bicycle_location_view_angle;
mode.headingIconNight = R.drawable.map_bicycle_location_view_angle_night;
mode.locationIconDay = R.drawable.map_bicycle_location;
mode.locationIconNight = R.drawable.map_bicycle_location_night;
mode.locationIconDayLost = R.drawable.map_bicycle_location_lost;
mode.locationIconNightLost = R.drawable.map_bicycle_location_lost_night;
break;
case DEFAULT:
mode.bearingIconDay = R.drawable.map_pedestrian_bearing;
mode.bearingIconNight = R.drawable.map_pedestrian_bearing_night;
mode.headingIconDay = R.drawable.map_default_location_view_angle;
mode.headingIconNight = R.drawable.map_default_location_view_angle_night;
mode.locationIconDay = R.drawable.map_pedestrian_location;
mode.locationIconNight = R.drawable.map_pedestrian_location_night;
mode.locationIconDayLost = R.drawable.map_pedestrian_location_lost;
mode.locationIconNightLost = R.drawable.map_pedestrian_location_lost_night;
break;
case NAUTICAL:
mode.bearingIconDay = R.drawable.map_nautical_bearing;
mode.bearingIconNight = R.drawable.map_nautical_bearing_night;
mode.headingIconDay = R.drawable.map_nautical_location_view_angle;
mode.headingIconNight = R.drawable.map_nautical_location_view_angle_night;
mode.locationIconDay = R.drawable.map_nautical_location;
mode.locationIconNight = R.drawable.map_nautical_location_night;
break;
}
return mode;
}
public static void deleteCustomMode(String userModeTitle, OsmandApplication app) { public static void deleteCustomMode(String userModeTitle, OsmandApplication app) {
Iterator<ApplicationMode> it = values.iterator(); Iterator<ApplicationMode> it = values.iterator();
while (it.hasNext()) { while (it.hasNext()) {
@ -556,4 +614,51 @@ public class ApplicationMode {
return R.drawable.map_world_globe_dark; return R.drawable.map_world_globe_dark;
} }
} }
public ProfileIconColors getIconColorInfo() {
if (iconColor != null) {
return iconColor;
} else {
return ProfileIconColors.DEFAULT;
}
}
public enum ProfileIconColors{
DEFAULT(R.string.rendering_value_default_name, R.color.profile_icon_color_blue_light_default, R.color.profile_icon_color_blue_dark_default),
PURPLE(R.string.rendering_value_purple_name, R.color.profile_icon_color_purple_light, R.color.profile_icon_color_purple_dark),
GREEN(R.string.rendering_value_green_name, R.color.profile_icon_color_green_light, R.color.profile_icon_color_green_dark),
BLUE(R.string.rendering_value_blue_name, R.color.profile_icon_color_blue_light, R.color.profile_icon_color_blue_dark),
RED(R.string.rendering_value_red_name, R.color.profile_icon_color_red_light, R.color.profile_icon_color_red_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);
@StringRes private int name;
@ColorRes private int dayColor;
@ColorRes private int nightColor;
ProfileIconColors(@StringRes int name, @ColorRes int dayColor, @ColorRes int nightColor) {
this.name = name;
this.dayColor = dayColor;
this.nightColor = nightColor;
}
public int getName() {
return name;
}
public int getColor(boolean nightMode) {
if (nightMode) {
return nightColor;
} else {
return dayColor;
}
}
}
public enum LocationIconsSet {
DEFAULT,
CAR,
NAUTICAL,
BICYCLE
}
} }

View file

@ -367,7 +367,8 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
getAppModeDescription(am), getAppModeDescription(am),
am.getStringKey(), am.getStringKey(),
am.getIconRes(getMyApplication()), am.getIconRes(getMyApplication()),
isSelected isSelected,
am.getIconColorInfo()
)); ));
} }
} }
@ -403,22 +404,19 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
} }
void updateModeButton(ApplicationMode mode) { void updateModeButton(ApplicationMode mode) {
boolean nightMode = !getMyApplication().getSettings().isLightContent();
String title = Algorithms.isEmpty(mode.getUserProfileName()) String title = Algorithms.isEmpty(mode.getUserProfileName())
? mode.toHumanString(SettingsBaseActivity.this) ? mode.toHumanString(SettingsBaseActivity.this)
: mode.getUserProfileName(); : mode.getUserProfileName();
getModeTitleTV().setText(title); getModeTitleTV().setText(title);
getModeSubTitleTV().setText(getAppModeDescription(mode)); getModeSubTitleTV().setText(getAppModeDescription(mode));
getModeIconIV().setImageDrawable(getMyApplication().getUIUtilities().getIcon(mode.getIconRes(this),
getMyApplication().getSettings().isLightContent()
? R.color.active_buttons_and_links_light
: R.color.active_buttons_and_links_dark));
getDropDownArrow().setImageDrawable(getMyApplication().getUIUtilities().getIcon(R.drawable.ic_action_arrow_drop_down,
getMyApplication().getSettings().isLightContent()
? R.color.active_buttons_and_links_light
: R.color.active_buttons_and_links_dark));
settings.APPLICATION_MODE.set(mode); settings.APPLICATION_MODE.set(mode);
previousAppMode = mode; previousAppMode = mode;
getModeIconIV().setImageDrawable(getMyApplication().getUIUtilities().getIcon(mode.getIconRes(this),
mode.getIconColorInfo().getColor(nightMode)));
getDropDownArrow().setImageDrawable(getMyApplication().getUIUtilities().getIcon(R.drawable.ic_action_arrow_drop_down,
R.color.icon_color));
isModeSelected = true; isModeSelected = true;
updateAllSettings(); updateAllSettings();
} }

View file

@ -86,12 +86,12 @@ public class AppModeDialog {
final boolean checked = selected.contains(mode); final boolean checked = selected.contains(mode);
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(ctx), nightMode ? R.color.active_buttons_and_links_dark : R.color.route_info_checked_mode_icon_color_light)); iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(ctx), 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), ctx.getString(R.string.item_checked)));
tb.findViewById(R.id.selection).setVisibility(View.VISIBLE); tb.findViewById(R.id.selection).setVisibility(View.VISIBLE);
} else { } else {
if (useMapTheme) { if (useMapTheme) {
iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(ctx), R.color.description_font_and_bottom_sheet_icons)); iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(ctx), mode.getIconColorInfo().getColor(nightMode)));
iv.setBackgroundResource(AndroidUtils.resolveAttribute(ctx, android.R.attr.selectableItemBackground)); iv.setBackgroundResource(AndroidUtils.resolveAttribute(ctx, android.R.attr.selectableItemBackground));
} else { } else {
iv.setImageDrawable(ctx.getUIUtilities().getThemedIcon(mode.getIconRes(ctx))); iv.setImageDrawable(ctx.getUIUtilities().getThemedIcon(mode.getIconRes(ctx)));
@ -136,12 +136,10 @@ public class AppModeDialog {
final boolean checked = selected.contains(mode); final boolean checked = selected.contains(mode);
ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon); ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon);
View selection = tb.findViewById(R.id.selection); View selection = tb.findViewById(R.id.selection);
Drawable drawable = ctx.getUIUtilities().getIcon(mode.getIconRes(ctx), mode.getIconColorInfo().getColor(nightMode));
if (checked) { if (checked) {
Drawable drawable = ctx.getUIUtilities().getIcon(mode.getIconRes(ctx), nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
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), 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_border_light, R.drawable.btn_border_dark); AndroidUtils.setBackground(ctx, iv, nightMode, R.drawable.btn_border_light, R.drawable.btn_border_dark);
AndroidUtils.setBackground(ctx, selection, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark); AndroidUtils.setBackground(ctx, selection, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
@ -150,9 +148,8 @@ public class AppModeDialog {
} }
} else { } else {
if (useMapTheme) { if (useMapTheme) {
Drawable drawable = ctx.getUIUtilities().getIcon(mode.getIconRes(ctx), nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
if (Build.VERSION.SDK_INT >= 21) { if (Build.VERSION.SDK_INT >= 21) {
Drawable active = ctx.getUIUtilities().getIcon(mode.getIconRes(ctx), nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light); Drawable active = ctx.getUIUtilities().getIcon(mode.getIconRes(ctx), mode.getIconColorInfo().getColor(nightMode));
drawable = AndroidUtils.createPressedStateListDrawable(drawable, active); drawable = AndroidUtils.createPressedStateListDrawable(drawable, active);
} }
iv.setImageDrawable(drawable); iv.setImageDrawable(drawable);
@ -163,7 +160,7 @@ public class AppModeDialog {
AndroidUtils.setBackground(ctx, selection, nightMode, R.drawable.btn_border_pressed_trans_light, R.drawable.btn_border_pressed_trans_dark); AndroidUtils.setBackground(ctx, selection, nightMode, R.drawable.btn_border_pressed_trans_light, R.drawable.btn_border_pressed_trans_dark);
} }
} else { } else {
iv.setImageDrawable(ctx.getUIUtilities().getThemedIcon(mode.getIconRes(ctx))); iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(ctx), 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), ctx.getString(R.string.item_unchecked)));
} }
@ -200,7 +197,7 @@ public class AppModeDialog {
int metricsY = (int) ctx.getResources().getDimension(R.dimen.route_info_modes_height); int metricsY = (int) ctx.getResources().getDimension(R.dimen.route_info_modes_height);
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(ctx), isNightMode(ctx, useMapTheme) ? R.color.active_buttons_and_links_dark : R.color.route_info_checked_mode_icon_color_light)); iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(ctx), mode.getIconColorInfo().getColor(isNightMode(ctx, useMapTheme))));
iv.setContentDescription(mode.toHumanString(ctx)); iv.setContentDescription(mode.toHumanString(ctx));
// 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);

View file

@ -21,13 +21,14 @@ public class AppProfileArrayAdapter extends ArrayAdapter<ProfileDataObject> {
private Activity context; private Activity context;
private List<ProfileDataObject> modes; private List<ProfileDataObject> modes;
private int layout; private int layout;
private int colorRes; private OsmandApplication app;
public AppProfileArrayAdapter(@NonNull Activity context, int resource, @NonNull List<ProfileDataObject> objects) { public AppProfileArrayAdapter(@NonNull Activity context, int resource, @NonNull List<ProfileDataObject> objects) {
super(context, resource, objects); super(context, resource, objects);
this.context = context; this.context = context;
this.modes = objects; this.modes = objects;
this.layout = resource; this.layout = resource;
app = (OsmandApplication) context.getApplication();
} }
public long getItemId(int position) { public long getItemId(int position) {
@ -61,19 +62,10 @@ public class AppProfileArrayAdapter extends ArrayAdapter<ProfileDataObject> {
ProfileDataObject mode = modes.get(position); ProfileDataObject mode = modes.get(position);
Drawable iconDrawable; Drawable iconDrawable;
if (getMyApp(context) != null) { if (mode.isSelected()) {
if (mode.isSelected()) { iconDrawable = app.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColor(!app.getSettings().isLightContent()));
iconDrawable = getMyApp(context).getUIUtilities().getIcon(mode.getIconRes(),
getMyApp(context).getSettings().isLightContent()
? R.color.ctx_menu_direction_color_light
: R.color.active_buttons_and_links_dark
);
} else {
iconDrawable = getMyApp(context).getUIUtilities()
.getIcon(mode.getIconRes(), R.color.icon_color);
}
} else { } else {
iconDrawable = context.getDrawable(mode.getIconRes()); iconDrawable = app.getUIUtilities().getIcon(mode.getIconRes(), R.color.profile_icon_color_inactive);
} }
viewHolder.title.setText(mode.getName()); viewHolder.title.setText(mode.getName());
@ -83,13 +75,4 @@ public class AppProfileArrayAdapter extends ArrayAdapter<ProfileDataObject> {
return rowView; return rowView;
} }
private OsmandApplication getMyApp(Activity context) {
Application app = context.getApplication();
if (app instanceof OsmandApplication) {
return (OsmandApplication) app;
} else {
return null;
}
}
} }

View file

@ -11,30 +11,37 @@ import static net.osmand.plus.profiles.SettingsProfileFragment.IS_USER_PROFILE;
import static net.osmand.plus.profiles.SettingsProfileFragment.PROFILE_STRING_KEY; import static net.osmand.plus.profiles.SettingsProfileFragment.PROFILE_STRING_KEY;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener; import android.content.DialogInterface.OnDismissListener;
import android.content.Intent; import android.content.Intent;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.drawable.GradientDrawable; import android.os.Build;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.app.AlertDialog.Builder; import android.support.v7.app.AlertDialog.Builder;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewTreeObserver.OnGlobalLayoutListener; import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button; import android.widget.Button;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ListPopupWindow;
import android.widget.ScrollView; import android.widget.ScrollView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -42,8 +49,10 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.plus.ApplicationMode; import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ApplicationMode.ProfileIconColors;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
@ -88,6 +97,8 @@ public class EditProfileFragment extends BaseOsmAndFragment {
private ImageView profileIcon; private ImageView profileIcon;
private LinearLayout profileIconBtn; private LinearLayout profileIconBtn;
private ImageView colorSample;
private LinearLayout selectColorBtn;
private ExtendedEditText profileNameEt; private ExtendedEditText profileNameEt;
private OsmandTextFieldBoxes profileNameTextBox; private OsmandTextFieldBoxes profileNameTextBox;
private ExtendedEditText navTypeEt; private ExtendedEditText navTypeEt;
@ -127,11 +138,13 @@ public class EditProfileFragment extends BaseOsmAndFragment {
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) { @Nullable Bundle savedInstanceState) {
final EditProfileActivity activity = (EditProfileActivity) getActivity();
final View view = inflater.inflate(R.layout.fragment_selected_profile, container, false); final View view = inflater.inflate(R.layout.fragment_selected_profile, container, false);
profileIcon = view.findViewById(R.id.select_icon_btn_img); profileIcon = view.findViewById(R.id.profile_icon_img);
profileIconBtn = view.findViewById(R.id.profile_icon_layout); profileIconBtn = view.findViewById(R.id.select_icon_button);
colorSample = view.findViewById(R.id.color_sample_img);
selectColorBtn = view.findViewById(R.id.select_icon_color_button);
profileNameEt = view.findViewById(R.id.profile_name_et); profileNameEt = view.findViewById(R.id.profile_name_et);
profileNameTextBox = view.findViewById(R.id.profile_name_otfb); profileNameTextBox = view.findViewById(R.id.profile_name_otfb);
navTypeEt = view.findViewById(R.id.navigation_type_et); navTypeEt = view.findViewById(R.id.navigation_type_et);
@ -154,13 +167,6 @@ public class EditProfileFragment extends BaseOsmAndFragment {
profileNameEt.setFocusable(true); profileNameEt.setFocusable(true);
profileNameEt.setSelectAllOnFocus(true); profileNameEt.setSelectAllOnFocus(true);
profileIconBtn.setBackgroundResource(R.drawable.rounded_background_3dp);
GradientDrawable selectIconBtnBackground = (GradientDrawable) profileIconBtn.getBackground();
if (nightMode) {
selectIconBtnBackground.setColor(ContextCompat.getColor(app, R.color.text_field_box_dark));
} else {
selectIconBtnBackground.setColor(ContextCompat.getColor(app, R.color.text_field_box_light));
}
String title = "New Profile"; String title = "New Profile";
@ -239,16 +245,10 @@ public class EditProfileFragment extends BaseOsmAndFragment {
((EditProfileActivity) getActivity()).getSupportActionBar().setElevation(5.0f); ((EditProfileActivity) getActivity()).getSupportActionBar().setElevation(5.0f);
} }
int iconColor; int iconColor = profile.iconColor.getColor(nightMode);
if (!isUserProfile) {
iconColor = R.color.icon_color;
} else {
iconColor = nightMode
? R.color.active_buttons_and_links_dark
: R.color.active_buttons_and_links_light;
}
profileIcon.setImageDrawable(app.getUIUtilities().getIcon(startIconId, iconColor)); profileIcon.setImageDrawable(app.getUIUtilities().getIcon(startIconId, iconColor));
colorSample.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_circle, iconColor));
profileNameEt.addTextChangedListener(new TextWatcher() { profileNameEt.addTextChangedListener(new TextWatcher() {
@Override @Override
@ -297,21 +297,59 @@ public class EditProfileFragment extends BaseOsmAndFragment {
} }
}); });
profileIconBtn.setOnClickListener(new OnClickListener() { if (isUserProfile || isNew) {
@Override profileIconBtn.setOnClickListener(new OnClickListener() {
public void onClick(View v) { @Override
final SelectProfileBottomSheetDialogFragment iconSelectDialog = new SelectProfileBottomSheetDialogFragment(); public void onClick(View v) {
Bundle bundle = new Bundle(); final SelectProfileBottomSheetDialogFragment iconSelectDialog = new SelectProfileBottomSheetDialogFragment();
bundle.putString(DIALOG_TYPE, TYPE_ICON); Bundle bundle = new Bundle();
bundle.putString(SELECTED_ICON, profile.iconStringName); bundle.putString(DIALOG_TYPE, TYPE_ICON);
iconSelectDialog.setArguments(bundle); bundle.putString(SELECTED_ICON, profile.iconStringName);
if (getActivity() != null) { iconSelectDialog.setArguments(bundle);
getActivity().getSupportFragmentManager().beginTransaction() if (getActivity() != null) {
.add(iconSelectDialog, "select_icon") getActivity().getSupportFragmentManager().beginTransaction()
.commitAllowingStateLoss(); .add(iconSelectDialog, "select_icon")
.commitAllowingStateLoss();
}
} }
});
selectColorBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final ListPopupWindow popupWindow = new ListPopupWindow(activity);
popupWindow.setAnchorView(selectColorBtn);
popupWindow.setContentWidth(AndroidUtils.dpToPx(activity, 200f));
popupWindow.setModal(true);
popupWindow.setDropDownGravity(Gravity.TOP | Gravity.RIGHT);
popupWindow.setVerticalOffset(AndroidUtils.dpToPx(activity, -48f));
popupWindow.setHorizontalOffset(AndroidUtils.dpToPx(activity, -6f));
final ProfileColorAdapter profileColorAdapter = new ProfileColorAdapter(activity, mode.getIconColorInfo());
popupWindow.setAdapter(profileColorAdapter);
popupWindow.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
isDataChanged = true;
profile.iconColor = ProfileIconColors.values()[position];
profileIcon.setImageDrawable(app.getUIUtilities().getIcon(profile.iconId, profile.iconColor.getColor(nightMode)));
colorSample.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_circle, profile.iconColor.getColor(nightMode)));
popupWindow.dismiss();
}
});
popupWindow.show();
}
});
} else {
if (VERSION.SDK_INT > VERSION_CODES.LOLLIPOP) {
selectColorBtn.setBackground(null);
profileIconBtn.setBackground(null);
} else {
selectColorBtn.setBackgroundDrawable(null);
profileIconBtn.setBackgroundDrawable(null);
} }
});
}
mapConfigBtn.setOnClickListener(new OnClickListener() { mapConfigBtn.setOnClickListener(new OnClickListener() {
@Override @Override
@ -451,8 +489,8 @@ public class EditProfileFragment extends BaseOsmAndFragment {
profile.iconId = pos; profile.iconId = pos;
profile.iconStringName = stringRes; profile.iconStringName = stringRes;
profileIcon.setImageDrawable(app.getUIUtilities().getIcon(pos, profileIcon.setImageDrawable(app.getUIUtilities().getIcon(pos,
nightMode ? R.color.active_buttons_and_links_dark profile.iconColor.getColor(nightMode)));
: R.color.active_buttons_and_links_light));
} }
}; };
} }
@ -601,6 +639,8 @@ public class EditProfileFragment extends BaseOsmAndFragment {
builder.setRoutingProfile(profile.routingProfileDataObject.getStringKey()); builder.setRoutingProfile(profile.routingProfileDataObject.getStringKey());
} }
builder.setColor(profile.iconColor);
ApplicationMode mode = builder.customReg(); ApplicationMode mode = builder.customReg();
ApplicationMode.saveCustomModeToSettings(getSettings()); ApplicationMode.saveCustomModeToSettings(getSettings());
@ -618,7 +658,6 @@ public class EditProfileFragment extends BaseOsmAndFragment {
getSettings().ROUTER_SERVICE.setModeValue(mode, RouteService.OSMAND); getSettings().ROUTER_SERVICE.setModeValue(mode, RouteService.OSMAND);
} }
} }
} }
isDataChanged = false; isDataChanged = false;
isCancelAllowed = true; isCancelAllowed = true;
@ -773,6 +812,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
ApplicationMode parent = null; ApplicationMode parent = null;
int iconId = R.drawable.map_world_globe_dark; int iconId = R.drawable.map_world_globe_dark;
String iconStringName = "map_world_globe_dark"; String iconStringName = "map_world_globe_dark";
ProfileIconColors iconColor = ProfileIconColors.DEFAULT;
RoutingProfileDataObject routingProfileDataObject = null; RoutingProfileDataObject routingProfileDataObject = null;
ApplicationProfileObject(ApplicationMode mode, boolean isNew, boolean isUserProfile) { ApplicationProfileObject(ApplicationMode mode, boolean isNew, boolean isUserProfile) {
@ -785,6 +825,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
parent = mode.getParent(); parent = mode.getParent();
iconId = mode.getIconRes(getMyApplication()); iconId = mode.getIconRes(getMyApplication());
iconStringName = Algorithms.isEmpty(mode.getIconName())? "map_world_globe_dark" : mode.getIconName(); iconStringName = Algorithms.isEmpty(mode.getIconName())? "map_world_globe_dark" : mode.getIconName();
iconColor = mode.getIconColorInfo() == null ? ProfileIconColors.DEFAULT : mode.getIconColorInfo();
userProfileTitle = mode.getUserProfileName(); userProfileTitle = mode.getUserProfileName();
} else { } else {
key = mode.getStringResource(); key = mode.getStringResource();
@ -794,4 +835,85 @@ public class EditProfileFragment extends BaseOsmAndFragment {
} }
} }
} }
public static class ProfileColorAdapter extends ArrayAdapter<ColorListItem> {
private OsmandApplication app;
private ProfileIconColors currentColorData;
public ProfileColorAdapter(Context context, ProfileIconColors iconColorData) {
super(context, R.layout.rendering_prop_menu_item);
this.app = (OsmandApplication) getContext().getApplicationContext();
this.currentColorData = iconColorData;
init();
}
public void init() {
boolean nightMode = !app.getSettings().isLightContent();
String currentColorName = app.getString(ProfileIconColors.DEFAULT.getName());
ColorListItem item = new ColorListItem(currentColorName, currentColorName, ProfileIconColors.DEFAULT.getColor(nightMode));
add(item);
for (ProfileIconColors pic : ProfileIconColors.values()) {
if (pic != ProfileIconColors.DEFAULT) {
item = new ColorListItem(currentColorName, app.getString(pic.getName()), pic.getColor(nightMode));
add(item);
}
}
item.setLastItem(true);
}
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
ColorListItem item = getItem(position);
View v = convertView;
if (v == null) {
v = LayoutInflater.from(getContext()).inflate(R.layout.rendering_prop_menu_item, null);
}
if (item != null) {
TextView textView = (TextView) v.findViewById(R.id.text1);
textView.setText(item.valueName);
if (item.color == -1) {
textView.setCompoundDrawablesWithIntrinsicBounds(null, null,
app.getUIUtilities().getThemedIcon(R.drawable.ic_action_circle), null);
} else {
textView.setCompoundDrawablesWithIntrinsicBounds(null, null,
app.getUIUtilities().getIcon(R.drawable.ic_action_circle, item.color), null);
}
textView.setCompoundDrawablePadding(AndroidUtils.dpToPx(getContext(), 10f));
v.findViewById(R.id.divider).setVisibility(item.lastItem
&& position < getCount() - 1 ? View.VISIBLE : View.GONE);
}
return v;
}
}
public static class ColorListItem {
private String currentValueName;
private String valueName;
private int color;
private boolean lastItem;
public ColorListItem(String currentValueName, String valueName, int color) {
this.currentValueName = currentValueName;
this.valueName = valueName;
this.color = color;
}
public int getColor() {
return color;
}
public boolean isLastItem() {
return lastItem;
}
public void setLastItem(boolean lastItem) {
this.lastItem = lastItem;
}
}
} }

View file

@ -1,5 +1,8 @@
package net.osmand.plus.profiles; package net.osmand.plus.profiles;
import android.support.annotation.ColorRes;
import net.osmand.plus.ApplicationMode.ProfileIconColors;
public class ProfileDataObject { public class ProfileDataObject {
private String name; private String name;
@ -7,13 +10,15 @@ public class ProfileDataObject {
private int iconRes; private int iconRes;
private String stringKey; private String stringKey;
private boolean isSelected; private boolean isSelected;
private ProfileIconColors iconColor;
public ProfileDataObject(String name, String description, String stringKey, int iconRes, boolean isSelected) { public ProfileDataObject(String name, String description, String stringKey, int iconRes, boolean isSelected, ProfileIconColors iconColor) {
this.name = name; this.name = name;
this.iconRes = iconRes; this.iconRes = iconRes;
this.description = description; this.description = description;
this.isSelected = isSelected; this.isSelected = isSelected;
this.stringKey = stringKey; this.stringKey = stringKey;
this.iconColor = iconColor;
} }
public String getName() { public String getName() {
@ -39,4 +44,8 @@ public class ProfileDataObject {
public String getStringKey() { public String getStringKey() {
return stringKey; return stringKey;
} }
@ColorRes public int getIconColor(boolean isNightMode) {
return iconColor.getColor(isNightMode);
}
} }

View file

@ -6,7 +6,6 @@ import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SwitchCompat; import android.support.v7.widget.SwitchCompat;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -18,15 +17,19 @@ import android.widget.TextView;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import net.osmand.PlatformUtil;
import net.osmand.plus.ApplicationMode; import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.profiles.ProfileMenuAdapter.ProfileViewHolder; import net.osmand.plus.profiles.ProfileMenuAdapter.ProfileViewHolder;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder> { public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder> {
private static final Log LOG = PlatformUtil.getLog(ProfileMenuAdapter.class);
private List<Object> items = new ArrayList<>(); private List<Object> items = new ArrayList<>();
private Set<ApplicationMode> selectedItems; private Set<ApplicationMode> selectedItems;
@Nullable @Nullable
@ -139,14 +142,15 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder>
} }
private void updateViewHolder(ProfileViewHolder holder, ApplicationMode mode) { private void updateViewHolder(ProfileViewHolder holder, ApplicationMode mode) {
int iconRes = mode.getParent() == null ? mode.getSmallIconDark() : mode.getIconRes(app); int iconRes = mode.getIconRes(app);
if (iconRes == 0 || iconRes == -1) { if (iconRes == 0 || iconRes == -1) {
iconRes = R.drawable.ic_action_world_globe; iconRes = R.drawable.ic_action_world_globe;
} }
selectedIconColorRes = mode.getIconColorInfo().getColor(isNightMode(app));
if (selectedItems.contains(mode)) { if (selectedItems.contains(mode)) {
holder.icon.setImageDrawable(app.getUIUtilities().getIcon(iconRes, selectedIconColorRes)); holder.icon.setImageDrawable(app.getUIUtilities().getIcon(iconRes, mode.getIconColorInfo().getColor(isNightMode(app))));
} else { } else {
holder.icon.setImageDrawable(app.getUIUtilities().getIcon(iconRes, R.color.icon_color)); holder.icon.setImageDrawable(app.getUIUtilities().getIcon(iconRes, R.color.profile_icon_color_inactive));
} }
} }

View file

@ -1,6 +1,7 @@
package net.osmand.plus.profiles; package net.osmand.plus.profiles;
import android.os.Parcel; import android.os.Parcel;
import net.osmand.plus.ApplicationMode.ProfileIconColors;
public class RoutingProfileDataObject extends ProfileDataObject { public class RoutingProfileDataObject extends ProfileDataObject {
@ -8,7 +9,7 @@ public class RoutingProfileDataObject extends ProfileDataObject {
private String fileName; private String fileName;
public RoutingProfileDataObject(String stringKey, String name, String descr, int iconRes, boolean isSelected, String fileName) { public RoutingProfileDataObject(String stringKey, String name, String descr, int iconRes, boolean isSelected, String fileName) {
super(name, descr, stringKey, iconRes, isSelected); super(name, descr, stringKey, iconRes, isSelected, null);
this.fileName = fileName; this.fileName = fileName;
} }

View file

@ -152,7 +152,7 @@ public class SettingsProfileFragment extends BaseOsmAndFragment {
if (mode != ApplicationMode.DEFAULT) { if (mode != ApplicationMode.DEFAULT) {
profiles.add(new ProfileDataObject( mode.toHumanString(ctx), profiles.add(new ProfileDataObject( mode.toHumanString(ctx),
ctx.getString(BaseProfilesDescr.valueOf(mode.getStringKey().toUpperCase()).getDescrRes()), ctx.getString(BaseProfilesDescr.valueOf(mode.getStringKey().toUpperCase()).getDescrRes()),
mode.getStringKey(), mode.getSmallIconDark(), false)); mode.getStringKey(), mode.getSmallIconDark(), false, mode.getIconColorInfo()));
} }
} }
return profiles; return profiles;
@ -177,7 +177,4 @@ public class SettingsProfileFragment extends BaseOsmAndFragment {
return descrRes; return descrRes;
} }
} }
} }

View file

@ -83,7 +83,7 @@ public class NavStartStopAction extends QuickAction {
if (context instanceof MapActivity) { if (context instanceof MapActivity) {
RoutingHelper helper = ((MapActivity) context).getRoutingHelper(); RoutingHelper helper = ((MapActivity) context).getRoutingHelper();
if (!helper.isRoutePlanningMode() && !helper.isFollowingMode()) { if (!helper.isRoutePlanningMode() && !helper.isFollowingMode()) {
return ((MapActivity) context).getMapActions().getRouteMode(null).getSmallIconDark(); return ((MapActivity) context).getMapActions().getRouteMode(null).getIconRes(context);
} }
return helper.getAppMode().getIconRes(context); return helper.getAppMode().getIconRes(context);
} }

View file

@ -780,7 +780,7 @@ public class MapControlsLayer extends OsmandMapLayer {
compassHud.forceHideCompass = forceHideCompass; compassHud.forceHideCompass = forceHideCompass;
compassHud.updateVisibility(!forceHideCompass && shouldShowCompass()); compassHud.updateVisibility(!forceHideCompass && shouldShowCompass());
if (layersHud.setIconResId(settings.getApplicationMode().getMapIconId())) { if (layersHud.setIconResId(settings.getApplicationMode().getIconRes(app))) {
layersHud.update(app, isNight); layersHud.update(app, isNight);
} }
layersHud.updateVisibility(!routeDialogOpened && !trackDialogOpened && !isInMeasurementToolMode() && !isInPlanRouteMode() layersHud.updateVisibility(!routeDialogOpened && !trackDialogOpened && !isInMeasurementToolMode() && !isInPlanRouteMode()