Refactor colors
This commit is contained in:
parent
958dfa0250
commit
861db6ba94
4 changed files with 27 additions and 17 deletions
|
@ -525,15 +525,17 @@ public class UiUtilities {
|
|||
int activeDisableColor = getColorWithAlpha(activeColor, 0.25f);
|
||||
ColorStateList activeCsl = new ColorStateList(states,
|
||||
new int[] {activeColor, activeDisableColor});
|
||||
int inactiveColor = AndroidUtils.getColorFromAttr(ctx, R.attr.default_icon_color);
|
||||
int inactiveColor = ContextCompat.getColor(ctx,
|
||||
nightMode ? R.color.icon_color_default_dark : R.color.icon_color_secondary_light);
|
||||
ColorStateList inactiveCsl = new ColorStateList(states,
|
||||
new int[] {inactiveColor, inactiveColor});
|
||||
slider.setTrackColorActive(activeCsl);
|
||||
slider.setTrackColorInactive(inactiveCsl);
|
||||
slider.setHaloColor(activeCsl);
|
||||
slider.setThumbColor(activeCsl);
|
||||
int ticksColor = showTicks ? ContextCompat.getColor(ctx,
|
||||
nightMode ? R.color.color_black : R.color.color_white) :
|
||||
int colorBlack = ContextCompat.getColor(ctx, R.color.color_black);
|
||||
int ticksColor = showTicks ?
|
||||
(nightMode ? colorBlack : getColorWithAlpha(colorBlack, 0.5f)) :
|
||||
Color.TRANSPARENT;
|
||||
slider.setTickColor(new ColorStateList(states, new int[] {ticksColor, ticksColor}));
|
||||
|
||||
|
|
|
@ -706,8 +706,9 @@ public class MapActivityActions implements DialogProvider {
|
|||
public ContextMenuAdapter createMainOptionsMenu() {
|
||||
final OsmandMapTileView mapView = mapActivity.getMapView();
|
||||
final OsmandApplication app = mapActivity.getMyApplication();
|
||||
ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter(app);
|
||||
boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||
ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter(app);
|
||||
optionsMenuHelper.setNightMode(nightMode);
|
||||
|
||||
if (drawerMode == DRAWER_MODE_SWITCH_PROFILE) {
|
||||
return createSwitchProfileOptionsMenu(app, optionsMenuHelper, nightMode);
|
||||
|
|
|
@ -17,6 +17,7 @@ import androidx.core.content.ContextCompat;
|
|||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording;
|
||||
import net.osmand.plus.audionotes.NotesFragment;
|
||||
|
||||
|
@ -66,6 +67,8 @@ public class NotesAdapter extends ArrayAdapter<Object> {
|
|||
@NonNull
|
||||
@Override
|
||||
public View getView(final int position, View row, @NonNull ViewGroup parent) {
|
||||
boolean nightMode = !app.getSettings().isLightContent();
|
||||
Context themedCtx = UiUtilities.getThemedContext(getContext(), nightMode);
|
||||
if (portrait) {
|
||||
final int type = getItemViewType(position);
|
||||
boolean header = type == TYPE_DATE_HEADER
|
||||
|
@ -74,7 +77,7 @@ public class NotesAdapter extends ArrayAdapter<Object> {
|
|||
|| type == TYPE_VIDEO_HEADER;
|
||||
|
||||
if (row == null) {
|
||||
LayoutInflater inflater = (LayoutInflater) app.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
LayoutInflater inflater = UiUtilities.getInflater(app, nightMode);
|
||||
if (header) {
|
||||
row = inflater.inflate(R.layout.list_item_header, parent, false);
|
||||
HeaderViewHolder hHolder = new HeaderViewHolder(row);
|
||||
|
@ -97,16 +100,16 @@ public class NotesAdapter extends ArrayAdapter<Object> {
|
|||
|
||||
return row;
|
||||
} else {
|
||||
LayoutInflater inflater = (LayoutInflater) app.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
LayoutInflater inflater = UiUtilities.getInflater(app, nightMode);
|
||||
boolean lastCard = getCardsCount() == position + 1;
|
||||
int margin = app.getResources().getDimensionPixelSize(R.dimen.content_padding);
|
||||
int sideMargin = app.getResources().getDisplayMetrics().widthPixels / 10;
|
||||
|
||||
FrameLayout fl = new FrameLayout(getContext());
|
||||
LinearLayout ll = new LinearLayout(getContext());
|
||||
FrameLayout fl = new FrameLayout(themedCtx);
|
||||
LinearLayout ll = new LinearLayout(themedCtx);
|
||||
fl.addView(ll);
|
||||
ll.setOrientation(LinearLayout.VERTICAL);
|
||||
ll.setBackgroundResource(app.getSettings().isLightContent() ? R.drawable.bg_card_light : R.drawable.bg_card_dark);
|
||||
ll.setBackgroundResource(nightMode ? R.drawable.bg_card_dark : R.drawable.bg_card_light);
|
||||
((FrameLayout.LayoutParams) ll.getLayoutParams()).setMargins(sideMargin, margin, sideMargin, lastCard ? margin : 0);
|
||||
|
||||
if (position == 0 && hasShareLocationItem()) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.osmand.plus.osmedit;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.SpannableString;
|
||||
|
@ -22,6 +23,7 @@ import androidx.core.content.ContextCompat;
|
|||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.render.RenderingIcons;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -71,14 +73,16 @@ public class OsmEditsAdapter extends ArrayAdapter<Object> {
|
|||
@NonNull
|
||||
@Override
|
||||
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
|
||||
boolean nightMode = !app.getSettings().isLightContent();
|
||||
Context themedCtx = UiUtilities.getThemedContext(getContext(), nightMode);
|
||||
if (portrait) {
|
||||
if (convertView == null) {
|
||||
if (position == 0) {
|
||||
convertView = LayoutInflater.from(getContext()).inflate(R.layout.list_item_header, parent, false);
|
||||
convertView = LayoutInflater.from(themedCtx).inflate(R.layout.list_item_header, parent, false);
|
||||
HeaderViewHolder holder = new HeaderViewHolder(convertView);
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
convertView = LayoutInflater.from(getContext()).inflate(R.layout.note_list_item, parent, false);
|
||||
convertView = LayoutInflater.from(themedCtx).inflate(R.layout.note_list_item, parent, false);
|
||||
OsmEditViewHolder holder = new OsmEditViewHolder(convertView);
|
||||
convertView.setTag(holder);
|
||||
}
|
||||
|
@ -98,21 +102,21 @@ public class OsmEditsAdapter extends ArrayAdapter<Object> {
|
|||
int margin = app.getResources().getDimensionPixelSize(R.dimen.content_padding);
|
||||
int sideMargin = app.getResources().getDisplayMetrics().widthPixels / 10;
|
||||
|
||||
FrameLayout fl = new FrameLayout(getContext());
|
||||
LinearLayout ll = new LinearLayout(getContext());
|
||||
FrameLayout fl = new FrameLayout(themedCtx);
|
||||
LinearLayout ll = new LinearLayout(themedCtx);
|
||||
ll.setOrientation(LinearLayout.VERTICAL);
|
||||
ll.setBackgroundResource(app.getSettings().isLightContent() ? R.drawable.bg_card_light : R.drawable.bg_card_dark);
|
||||
fl.addView(ll);
|
||||
((FrameLayout.LayoutParams) ll.getLayoutParams()).setMargins(sideMargin, margin, sideMargin, margin);
|
||||
|
||||
HeaderViewHolder headerViewHolder = new HeaderViewHolder(LayoutInflater.from(getContext()).inflate(R.layout.list_item_header, parent, false));
|
||||
HeaderViewHolder headerViewHolder = new HeaderViewHolder(LayoutInflater.from(themedCtx).inflate(R.layout.list_item_header, parent, false));
|
||||
bindHeaderViewHolder(headerViewHolder);
|
||||
ll.addView(headerViewHolder.mainView);
|
||||
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
Object item = getItem(i);
|
||||
if (item instanceof OsmPoint) {
|
||||
OsmEditViewHolder viewHolder = new OsmEditViewHolder(LayoutInflater.from(getContext()).inflate(R.layout.note_list_item, parent, false));
|
||||
OsmEditViewHolder viewHolder = new OsmEditViewHolder(LayoutInflater.from(themedCtx).inflate(R.layout.note_list_item, parent, false));
|
||||
bindOsmEditViewHolder(viewHolder, (OsmPoint) item, i);
|
||||
ll.addView(viewHolder.mainView);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue