Change night colors for markers list

This commit is contained in:
Alexander Sytnyk 2018-02-20 13:46:00 +02:00
parent 7766e73f20
commit ab7845e092

View file

@ -1,13 +1,16 @@
package net.osmand.plus.mapmarkers.adapters;
import android.graphics.drawable.Drawable;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import net.osmand.AndroidUtils;
import net.osmand.data.LatLon;
import net.osmand.plus.IconsCache;
import net.osmand.plus.MapMarkersHelper.MapMarker;
@ -64,13 +67,12 @@ public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemVi
final MapMarker mapMarker = getItem(position);
holder.iconDirection.setVisibility(View.VISIBLE);
holder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, MapMarker.getColorId(mapMarker.colorIndex)));
holder.mainLayout.setBackgroundColor(getResolvedColor(nightTheme ? R.color.bg_color_dark : R.color.bg_color_light));
holder.title.setTextColor(getResolvedColor(nightTheme ? R.color.color_white : R.color.color_black));
holder.divider.setBackgroundColor(getResolvedColor(nightTheme ? R.color.actionbar_dark_color : R.color.dashboard_divider_light));
holder.optionsBtn.setBackgroundDrawable(ContextCompat.getDrawable(mapActivity, nightTheme
? R.drawable.marker_circle_background_dark_with_inset : R.drawable.marker_circle_background_light_with_inset));
holder.optionsBtn.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_remove_dark));
holder.icon.setImageDrawable(getColoredIcon(R.drawable.ic_action_flag_dark, MapMarker.getColorId(mapMarker.colorIndex)));
holder.mainLayout.setBackgroundColor(getResolvedColor(nightTheme ? R.color.ctx_menu_bg_dark : R.color.bg_color_light));
holder.title.setTextColor(getResolvedColor(nightTheme ? R.color.ctx_menu_title_color_dark : R.color.color_black));
holder.divider.setBackgroundColor(getResolvedColor(nightTheme ? R.color.route_info_divider_dark : R.color.dashboard_divider_light));
holder.optionsBtn.setBackgroundDrawable(getRemoveBtnBgSelector());
holder.optionsBtn.setImageDrawable(getColoredIcon(R.drawable.ic_action_remove_small, R.color.icon_color));
holder.iconReorder.setVisibility(View.GONE);
holder.numberText.setVisibility(View.VISIBLE);
holder.numberText.setText(String.valueOf(position + 1));
@ -116,6 +118,20 @@ public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemVi
return mapMarkers.get(position);
}
private Drawable getRemoveBtnBgSelector() {
if (nightTheme) {
return AndroidUtils.createStateListDrawable(
getColoredIcon(R.drawable.marker_circle_background_dark_n_with_inset, R.color.keyboard_item_control_dark_bg),
ContextCompat.getDrawable(mapActivity, R.drawable.marker_circle_background_p_with_inset)
);
}
return ContextCompat.getDrawable(mapActivity, R.drawable.marker_circle_background_light_with_inset);
}
private Drawable getColoredIcon(@DrawableRes int resId, @ColorRes int colorResId) {
return iconsCache.getIcon(resId, colorResId);
}
@ColorInt
private int getResolvedColor(@ColorRes int colorResId) {
return ContextCompat.getColor(mapActivity, colorResId);