Fixed resources in dark theme.

This commit is contained in:
GaidamakUA 2016-03-30 15:17:29 +03:00
parent 75d874136a
commit aec531c381
2 changed files with 14 additions and 12 deletions

View file

@ -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<ApplicationMode> 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

View file

@ -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;