From aec531c38120b6fc73a7eb86ef1cda39abb02f86 Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Wed, 30 Mar 2016 15:17:29 +0300 Subject: [PATCH] Fixed resources in dark theme. --- .../net/osmand/plus/ContextMenuAdapter.java | 8 ++++---- .../src/net/osmand/plus/ContextMenuItem.java | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java index 5fb3864302..6ef57a0226 100644 --- a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java +++ b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java @@ -109,7 +109,7 @@ public class ContextMenuAdapter { // User super class to create the View final ContextMenuItem item = getItem(position); int layoutId = item.getLayout(); - layoutId = layoutId != -1 ? layoutId : DEFAULT_LAYOUT_ID; + layoutId = layoutId != ContextMenuItem.INVALID_ID ? layoutId : DEFAULT_LAYOUT_ID; if (layoutId == R.layout.mode_toggles) { final Set selected = new LinkedHashSet<>(); return AppModeDialog.prepareAppModeDrawerView((Activity) getContext(), @@ -153,7 +153,7 @@ public class ContextMenuAdapter { tv.setCompoundDrawables(imageId, null, null, null); tv.setCompoundDrawablePadding(paddingInPixels); } else { - if (item.getIcon() != -1) { + if (item.getIcon() != ContextMenuItem.INVALID_ID) { Drawable drawable = ContextCompat.getDrawable(getContext(), item.getIcon()); DrawableCompat.setTint(drawable, item.getThemedColor(getContext())); ((AppCompatImageView) convertView.findViewById(R.id.icon)).setImageDrawable(drawable); @@ -164,7 +164,7 @@ public class ContextMenuAdapter { } @DrawableRes int secondaryDrawable = item.getSecondaryIcon(); - if (secondaryDrawable != -1) { + if (secondaryDrawable != ContextMenuItem.INVALID_ID) { int color = ContextCompat.getColor(getContext(), holoLight ? R.color.icon_color : R.color.dashboard_subheader_text_dark); Drawable drawable = ContextCompat.getDrawable(getContext(), item.getSecondaryIcon()); @@ -206,7 +206,7 @@ public class ContextMenuAdapter { if (convertView.findViewById(R.id.seekbar) != null) { SeekBar seekBar = (SeekBar) convertView.findViewById(R.id.seekbar); - if (item.getProgress() != -1) { + if (item.getProgress() != ContextMenuItem.INVALID_ID) { seekBar.setProgress(item.getProgress()); seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuItem.java b/OsmAnd/src/net/osmand/plus/ContextMenuItem.java index f81ba4c79f..b7d7f61500 100644 --- a/OsmAnd/src/net/osmand/plus/ContextMenuItem.java +++ b/OsmAnd/src/net/osmand/plus/ContextMenuItem.java @@ -10,6 +10,8 @@ import android.support.annotation.StringRes; import android.support.v4.content.ContextCompat; public class ContextMenuItem { + public static final int INVALID_ID = 0; + @StringRes private final int titleId; private String title; @@ -81,7 +83,7 @@ public class ContextMenuItem { @ColorRes public int getThemedColorRes(Context context) { - if (getColorRes() != -1) { + if (getColorRes() != INVALID_ID) { return getColorRes(); } else { return getDefaultColorRes(context); @@ -97,7 +99,7 @@ public class ContextMenuItem { public static int getDefaultColorRes(Context context) { final OsmandApplication app = (OsmandApplication) context.getApplicationContext(); boolean light = app.getSettings().isLightContent(); - return light ? R.color.icon_color : 0; + return light ? R.color.icon_color : R.color.color_white; } @DrawableRes @@ -175,18 +177,18 @@ public class ContextMenuItem { private int mTitleId; private String mTitle; @DrawableRes - private int mIcon = -1; + private int mIcon = INVALID_ID; @ColorRes - private int mColor = -1; + private int mColor = INVALID_ID; @DrawableRes - private int mSecondaryIcon = -1; + private int mSecondaryIcon = INVALID_ID; private Boolean mSelected = null; - private int mProgress = -1; + private int mProgress = INVALID_ID; @LayoutRes - private int mLayout = -1; + private int mLayout = INVALID_ID; private boolean mLoading = false; private boolean mIsCategory = false; - private int mPosition = -1; + private int mPosition = INVALID_ID; private String mDescription = null; private ContextMenuAdapter.ItemClickListener mItemClickListener = null; private ContextMenuAdapter.OnIntegerValueChangedListener mIntegerListener = null;