icon color list adapter
This commit is contained in:
parent
c77b2b09ec
commit
765ae42e5b
5 changed files with 96 additions and 62 deletions
|
@ -293,7 +293,7 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="@dimen/list_content_padding"
|
android:padding="@dimen/list_content_padding"
|
||||||
tools:src = "@drawable/h_blue_ellipse_1_road_shield"
|
tools:src = "@drawable/ic_action_circle"
|
||||||
tools:tint="@color/A400red"/>
|
tools:tint="@color/A400red"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -497,5 +497,12 @@
|
||||||
<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>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
|
@ -11,6 +11,7 @@
|
||||||
Thx - Hardy
|
Thx - Hardy
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
<string name="shared_string_color_magenta">Magenta</string>
|
||||||
<string name="shared_string_icon">Icon</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>
|
||||||
|
|
|
@ -6,6 +6,7 @@ import android.graphics.Color;
|
||||||
import android.support.annotation.ColorRes;
|
import android.support.annotation.ColorRes;
|
||||||
import android.support.annotation.DrawableRes;
|
import android.support.annotation.DrawableRes;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.StringRes;
|
||||||
import 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;
|
||||||
|
@ -474,7 +475,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 String iconColor = "#237BFF";
|
@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;
|
||||||
|
@ -560,11 +561,35 @@ public class ApplicationMode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getIconColorRes(Context app) {
|
public ProfileIconColors getIconColorInfo() {
|
||||||
try {
|
return iconColor;
|
||||||
return Color.parseColor(iconColor);
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
return app.getResources().getColor(R.color.active_buttons_and_links_light);
|
public enum ProfileIconColors{
|
||||||
|
DEFAULT(R.string.rendering_value_default_name, R.color.profile_icon_color_blue_light_default),
|
||||||
|
PURPLE(R.string.rendering_value_purple_name, R.color.profile_icon_color_purple_light),
|
||||||
|
GREEN(R.string.rendering_value_green_name, R.color.profile_icon_color_green_light),
|
||||||
|
BLUE(R.string.rendering_value_blue_name, R.color.profile_icon_color_blue_light),
|
||||||
|
RED(R.string.rendering_value_red_name, R.color.profile_icon_color_red_light),
|
||||||
|
DARK_YELLOW(R.string.rendering_value_darkyellow_name, R.color.profile_icon_color_yellow_light),
|
||||||
|
MAGENTA(R.string.shared_string_color_magenta, R.color.profile_icon_color_magenta_light);
|
||||||
|
|
||||||
|
@StringRes private int name;
|
||||||
|
@ColorRes private int color;
|
||||||
|
|
||||||
|
ProfileIconColors(@StringRes int name, @ColorRes int color) {
|
||||||
|
this.name = name;
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getColor() {
|
||||||
|
return color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -16,27 +16,29 @@ 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.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.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;
|
||||||
|
@ -47,22 +49,16 @@ import java.util.Map.Entry;
|
||||||
import net.osmand.AndroidUtils;
|
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;
|
||||||
import net.osmand.plus.activities.OsmandActionBarActivity;
|
import net.osmand.plus.activities.OsmandActionBarActivity;
|
||||||
import net.osmand.plus.activities.SettingsActivity;
|
|
||||||
import net.osmand.plus.activities.SettingsNavigationActivity;
|
import net.osmand.plus.activities.SettingsNavigationActivity;
|
||||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||||
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
|
||||||
import net.osmand.plus.dialogs.ConfigureMapMenu.AppearanceListItem;
|
|
||||||
import net.osmand.plus.dialogs.ConfigureMapMenu.GpxAppearanceAdapter;
|
|
||||||
import net.osmand.plus.dialogs.ConfigureMapMenu.GpxAppearanceAdapter.GpxAppearanceAdapterType;
|
|
||||||
import net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.SelectProfileListener;
|
import net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.SelectProfileListener;
|
||||||
import net.osmand.plus.routing.RouteProvider.RouteService;
|
import net.osmand.plus.routing.RouteProvider.RouteService;
|
||||||
import net.osmand.plus.widgets.OsmandTextFieldBoxes;
|
import net.osmand.plus.widgets.OsmandTextFieldBoxes;
|
||||||
import net.osmand.render.RenderingRuleProperty;
|
|
||||||
import net.osmand.render.RenderingRulesStorage;
|
|
||||||
import net.osmand.router.GeneralRouter;
|
import net.osmand.router.GeneralRouter;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -141,7 +137,7 @@ 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.profile_icon_img);
|
profileIcon = view.findViewById(R.id.profile_icon_img);
|
||||||
|
@ -170,13 +166,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";
|
||||||
|
|
||||||
|
@ -259,12 +248,11 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
if (!isUserProfile) {
|
if (!isUserProfile) {
|
||||||
iconColor = R.color.icon_color;
|
iconColor = R.color.icon_color;
|
||||||
} else {
|
} else {
|
||||||
iconColor = nightMode
|
iconColor = profile.iconColor;
|
||||||
? 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
|
||||||
|
@ -329,6 +317,28 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
popupWindow.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
mapConfigBtn.setOnClickListener(new OnClickListener() {
|
mapConfigBtn.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -789,7 +799,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";
|
||||||
int iconColor = R.color.;
|
int iconColor = R.color.active_buttons_and_links_light;
|
||||||
RoutingProfileDataObject routingProfileDataObject = null;
|
RoutingProfileDataObject routingProfileDataObject = null;
|
||||||
|
|
||||||
ApplicationProfileObject(ApplicationMode mode, boolean isNew, boolean isUserProfile) {
|
ApplicationProfileObject(ApplicationMode mode, boolean isNew, boolean isUserProfile) {
|
||||||
|
@ -802,8 +812,8 @@ 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 ? R.color.profile_icon_color_blue_light_default : mode.getIconColorInfo().getColor();
|
||||||
userProfileTitle = mode.getUserProfileName();
|
userProfileTitle = mode.getUserProfileName();
|
||||||
userProfileTitle = mode.getIconColorRes(getMyApplication());
|
|
||||||
} else {
|
} else {
|
||||||
key = mode.getStringResource();
|
key = mode.getStringResource();
|
||||||
stringKey = mode.getStringKey();
|
stringKey = mode.getStringKey();
|
||||||
|
@ -816,41 +826,40 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
public static class ProfileColorAdapter extends ArrayAdapter<ColorListItem> {
|
public static class ProfileColorAdapter extends ArrayAdapter<ColorListItem> {
|
||||||
|
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
private int currentColor;
|
private ProfileIconColors currentColorData;
|
||||||
|
|
||||||
public ProfileColorAdapter(Context context, int currentColor) {
|
|
||||||
|
public ProfileColorAdapter(Context context, ProfileIconColors iconColorData) {
|
||||||
super(context, R.layout.rendering_prop_menu_item);
|
super(context, R.layout.rendering_prop_menu_item);
|
||||||
this.app = (OsmandApplication) getContext().getApplicationContext();
|
this.app = (OsmandApplication) getContext().getApplicationContext();
|
||||||
this.currentColor = currentColor;
|
this.currentColorData = iconColorData;
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
AppearanceListItem item = new AppearanceListItem(CURRENT_PROFILE_COLOR_ATTR, "",
|
String currentColorName = app.getString(ProfileIconColors.DEFAULT.getName());
|
||||||
SettingsActivity.getStringPropertyValue(getContext(), trackColorProp.getDefaultValueDescription()),
|
ColorListItem item = new ColorListItem(currentColorName, currentColorName, ProfileIconColors.DEFAULT.getColor());
|
||||||
parseTrackColor(renderer, ""));
|
|
||||||
add(item);
|
add(item);
|
||||||
for (int j = 0; j < trackColorProp.getPossibleValues().length; j++) {
|
for (ProfileIconColors pic : ProfileIconColors.values()) {
|
||||||
item = new AppearanceListItem(CURRENT_PROFILE_COLOR_ATTR,
|
if (pic != ProfileIconColors.DEFAULT) {
|
||||||
trackColorProp.getPossibleValues()[j],
|
item = new ColorListItem(currentColorName, app.getString(pic.getName()), pic.getColor());
|
||||||
SettingsActivity.getStringPropertyValue(getContext(), trackColorProp.getPossibleValues()[j]),
|
|
||||||
parseTrackColor(renderer, trackColorProp.getPossibleValues()[j]));
|
|
||||||
add(item);
|
add(item);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
item.setLastItem(true);
|
item.setLastItem(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
|
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
|
||||||
AppearanceListItem item = getItem(position);
|
ColorListItem item = getItem(position);
|
||||||
View v = convertView;
|
View v = convertView;
|
||||||
if (v == null) {
|
if (v == null) {
|
||||||
v = LayoutInflater.from(getContext()).inflate(R.layout.rendering_prop_menu_item, null);
|
v = LayoutInflater.from(getContext()).inflate(R.layout.rendering_prop_menu_item, null);
|
||||||
}
|
}
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
TextView textView = (TextView) v.findViewById(R.id.text1);
|
TextView textView = (TextView) v.findViewById(R.id.text1);
|
||||||
textView.setText(item.localizedValue);
|
textView.setText(item.valueName);
|
||||||
if (item.color == -1) {
|
if (item.color == -1) {
|
||||||
textView.setCompoundDrawablesWithIntrinsicBounds(null, null,
|
textView.setCompoundDrawablesWithIntrinsicBounds(null, null,
|
||||||
app.getUIUtilities().getThemedIcon(R.drawable.ic_action_circle), null);
|
app.getUIUtilities().getThemedIcon(R.drawable.ic_action_circle), null);
|
||||||
|
@ -867,32 +876,24 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ColorListItem {
|
public static class ColorListItem {
|
||||||
private String attrName;
|
private String currentValueName;
|
||||||
private String value;
|
private String valueName;
|
||||||
private String localizedValue;
|
|
||||||
private int color;
|
private int color;
|
||||||
private boolean lastItem;
|
private boolean lastItem;
|
||||||
|
|
||||||
|
public ColorListItem(String currentValueName, String valueName, int color) {
|
||||||
|
this.currentValueName = currentValueName;
|
||||||
public ColorListItem(String attrName, String value, String localizedValue, int color) {
|
this.valueName = valueName;
|
||||||
this.attrName = attrName;
|
|
||||||
this.value = value;
|
|
||||||
this.localizedValue = localizedValue;
|
|
||||||
this.color = color;
|
this.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAttrName() {
|
public String getCurrentValueName() {
|
||||||
return attrName;
|
return currentValueName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValue() {
|
public String getValueName() {
|
||||||
return value;
|
return valueName;
|
||||||
}
|
|
||||||
|
|
||||||
public String getLocalizedValue() {
|
|
||||||
return localizedValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getColor() {
|
public int getColor() {
|
||||||
|
|
Loading…
Reference in a new issue