The rest custom color implementations

This commit is contained in:
cepprice 2021-02-23 22:13:48 +05:00
parent 837219bebb
commit b0bb03fa8f
42 changed files with 329 additions and 157 deletions

View file

@ -333,6 +333,43 @@ public class AndroidUtils {
);
}
public static ColorStateList createCheckedColorIntStateList(@ColorInt int normal, @ColorInt int checked) {
return createCheckedColorIntStateList(false, normal, checked, 0, 0);
}
public static ColorStateList createCheckedColorIntStateList(boolean night,
@ColorInt int lightNormal, @ColorInt int lightChecked,
@ColorInt int darkNormal, @ColorInt int darkChecked) {
return createColorIntStateList(night, android.R.attr.state_checked,
lightNormal, lightChecked, darkNormal, darkChecked);
}
public static ColorStateList createEnabledColorIntStateList(@ColorInt int normal, @ColorInt int pressed) {
return createEnabledColorIntStateList(false, normal, pressed, 0, 0);
}
public static ColorStateList createEnabledColorIntStateList(boolean night,
@ColorInt int lightNormal, @ColorInt int lightPressed,
@ColorInt int darkNormal, @ColorInt int darkPressed) {
return createColorIntStateList(night, android.R.attr.state_enabled,
lightNormal, lightPressed, darkNormal, darkPressed);
}
private static ColorStateList createColorIntStateList(boolean night, int state,
@ColorInt int lightNormal, @ColorInt int lightState,
@ColorInt int darkNormal, @ColorInt int darkState) {
return new ColorStateList(
new int[][]{
new int[]{state},
new int[]{}
},
new int[]{
night ? darkState : lightState,
night ? darkNormal : lightNormal
}
);
}
public static StateListDrawable createCheckedStateListDrawable(Drawable normal, Drawable checked) {
return createStateListDrawable(normal, checked, android.R.attr.state_checked);
}

View file

@ -249,8 +249,7 @@ public class ContextMenuAdapter {
final ContextMenuItem item = getItem(position);
int layoutId = item.getLayout();
layoutId = layoutId != ContextMenuItem.INVALID_ID ? layoutId : DEFAULT_LAYOUT_ID;
int currentModeColorRes = app.getSettings().getApplicationMode().getIconColorInfo().getColor(nightMode);
int currentModeColor = ContextCompat.getColor(app, currentModeColorRes);
int currentModeColor = app.getSettings().getApplicationMode().getProfileColor(nightMode);
if (layoutId == R.layout.mode_toggles) {
final Set<ApplicationMode> selected = new LinkedHashSet<>();
return AppModeDialog.prepareAppModeDrawerView((Activity) getContext(),
@ -278,15 +277,20 @@ public class ContextMenuAdapter {
}
if (layoutId == R.layout.main_menu_drawer_btn_switch_profile ||
layoutId == R.layout.main_menu_drawer_btn_configure_profile) {
int colorResId = item.getColorRes();
int colorNoAlpha = ContextCompat.getColor(app, colorResId);
int colorNoAlpha;
if (item.getColor() != null) {
colorNoAlpha = item.getColor();
} else {
int colorResId = item.getColorRes();
colorNoAlpha = ContextCompat.getColor(app, colorResId);
}
TextView title = convertView.findViewById(R.id.title);
title.setText(item.getTitle());
if (layoutId == R.layout.main_menu_drawer_btn_switch_profile) {
ImageView icon = convertView.findViewById(R.id.icon);
icon.setImageDrawable(mIconsCache.getIcon(item.getIcon(), colorResId));
icon.setImageDrawable(mIconsCache.getPaintedIcon(item.getIcon(), colorNoAlpha));
ImageView icArrow = convertView.findViewById(R.id.ic_expand_list);
icArrow.setImageDrawable(mIconsCache.getIcon(item.getSecondaryIcon()));
TextView desc = convertView.findViewById(R.id.description);
@ -309,8 +313,13 @@ public class ContextMenuAdapter {
int tag = item.getTag();
int colorResId = item.getColorRes();
int colorNoAlpha = ContextCompat.getColor(app, colorResId);
int colorNoAlpha;
if (item.getColor() != null) {
colorNoAlpha = item.getColor();
} else {
int colorResId = item.getColorRes();
colorNoAlpha = ContextCompat.getColor(app, colorResId);
}
TextView title = convertView.findViewById(R.id.title);
TextView desc = convertView.findViewById(R.id.description);
ImageView icon = convertView.findViewById(R.id.icon);
@ -331,7 +340,7 @@ public class ContextMenuAdapter {
AndroidUiHelper.updateVisibility(icon, true);
AndroidUiHelper.updateVisibility(desc, true);
AndroidUtils.setTextPrimaryColor(app, title, nightMode);
icon.setImageDrawable(mIconsCache.getIcon(item.getIcon(), colorResId));
icon.setImageDrawable(mIconsCache.getPaintedIcon(item.getIcon(), colorNoAlpha));
desc.setText(item.getDescription());
boolean selectedMode = tag == PROFILES_CHOSEN_PROFILE_TAG;
if (selectedMode) {
@ -420,16 +429,19 @@ public class ContextMenuAdapter {
} else {
if (item.getIcon() != ContextMenuItem.INVALID_ID) {
int colorRes = item.getColorRes();
if (colorRes == ContextMenuItem.INVALID_ID) {
if (!item.shouldSkipPainting()) {
colorRes = lightTheme ? R.color.icon_color_default_light : R.color.icon_color_default_dark;
} else {
colorRes = 0;
Drawable drawable;
if (profileDependent) {
drawable = mIconsCache.getPaintedIcon(item.getIcon(), currentModeColor);
} else {
if (colorRes == ContextMenuItem.INVALID_ID) {
if (!item.shouldSkipPainting()) {
colorRes = lightTheme ? R.color.icon_color_default_light : R.color.icon_color_default_dark;
} else {
colorRes = 0;
}
}
} else if (profileDependent) {
colorRes = currentModeColorRes;
drawable = mIconsCache.getIcon(item.getIcon(), colorRes);
}
final Drawable drawable = mIconsCache.getIcon(item.getIcon(), colorRes);
((AppCompatImageView) convertView.findViewById(R.id.icon)).setImageDrawable(drawable);
convertView.findViewById(R.id.icon).setVisibility(View.VISIBLE);
} else if (convertView.findViewById(R.id.icon) != null) {

View file

@ -21,6 +21,8 @@ public class ContextMenuItem {
private int mIcon;
@ColorRes
private int colorRes;
@ColorInt
private Integer color;
@DrawableRes
private int secondaryIcon;
private Boolean selected;
@ -49,6 +51,7 @@ public class ContextMenuItem {
String title,
@DrawableRes int icon,
@ColorRes int colorRes,
@ColorInt Integer color,
@DrawableRes int secondaryIcon,
Boolean selected,
int progress,
@ -73,6 +76,7 @@ public class ContextMenuItem {
this.title = title;
this.mIcon = icon;
this.colorRes = colorRes;
this.color = color;
this.secondaryIcon = secondaryIcon;
this.selected = selected;
this.progress = progress;
@ -114,6 +118,11 @@ public class ContextMenuItem {
return colorRes;
}
@ColorInt
Integer getColor() {
return color;
}
@ColorRes
public int getThemedColorRes(Context context) {
if (skipPaintingWithoutColor || getColorRes() != INVALID_ID) {
@ -270,6 +279,8 @@ public class ContextMenuItem {
private int mIcon = INVALID_ID;
@ColorRes
private int mColorRes = INVALID_ID;
@ColorInt
private Integer mColor = null;
@DrawableRes
private int mSecondaryIcon = INVALID_ID;
private Boolean mSelected = null;
@ -312,6 +323,11 @@ public class ContextMenuItem {
return this;
}
public ItemBuilder setColorInt(@ColorInt int color) {
mColor = color;
return this;
}
public ItemBuilder setIcon(@DrawableRes int icon) {
mIcon = icon;
return this;
@ -422,7 +438,7 @@ public class ContextMenuItem {
}
public ContextMenuItem createItem() {
ContextMenuItem item = new ContextMenuItem(mTitleId, mTitle, mIcon, mColorRes, mSecondaryIcon,
ContextMenuItem item = new ContextMenuItem(mTitleId, mTitle, mIcon, mColorRes, mColor, mSecondaryIcon,
mSelected, mProgress, mLayout, mLoading, mIsCategory, mIsClickable, mSkipPaintingWithoutColor,
mOrder, mDescription, mOnUpdateCallback, mItemClickListener, mIntegerListener, mProgressListener,
mItemDeleteAction, mHideDivider, mHideCompoundButton, mMinHeight, mTag, mId);

View file

@ -749,7 +749,7 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.addItem(new ItemBuilder().setLayout(R.layout.profile_list_item)
.setIcon(appMode.getIconRes())
.setColor(appMode.getIconColorInfo().getColor(nightMode))
.setColorInt(appMode.getProfileColor(nightMode))
.setTag(tag)
.setTitle(appMode.toHumanString())
.setDescription(modeDescription)
@ -1059,7 +1059,7 @@ public class MapActivityActions implements DialogProvider {
.setId(DRAWER_SWITCH_PROFILE_ID)
.setIcon(currentMode.getIconRes())
.setSecondaryIcon(icArrowResId)
.setColor(currentMode.getIconColorInfo().getColor(nightMode))
.setColorInt(currentMode.getProfileColor(nightMode))
.setTitle(currentMode.toHumanString())
.setDescription(modeDescription)
.setListener(new ItemClickListener() {
@ -1073,7 +1073,7 @@ public class MapActivityActions implements DialogProvider {
.createItem());
optionsMenuHelper.addItem(new ItemBuilder().setLayout(R.layout.main_menu_drawer_btn_configure_profile)
.setId(DRAWER_CONFIGURE_PROFILE_ID)
.setColor(currentMode.getIconColorInfo().getColor(nightMode))
.setColorInt(currentMode.getProfileColor(nightMode))
.setTitle(getString(R.string.configure_profile))
.setListener(new ItemClickListener() {
@Override

View file

@ -10,6 +10,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
@ -91,6 +92,16 @@ public abstract class BottomSheetDialogFragment extends DialogFragment {
}
}
@Nullable
protected Drawable getPaintedIcon(@DrawableRes int drawableRes, @ColorInt int color) {
OsmandApplication app = getMyApplication();
if (app != null) {
return app.getUIUtilities().getPaintedIcon(drawableRes, color);
} else {
return null;
}
}
@Nullable
protected Drawable getContentIcon(@DrawableRes int drawableRes) {
OsmandApplication app = getMyApplication();

View file

@ -8,6 +8,7 @@ import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.LayoutRes;
import androidx.core.content.ContextCompat;
@ -22,6 +23,7 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri
private ColorStateList buttonTintList;
private OnCheckedChangeListener onCheckedChangeListener;
@ColorRes private int compoundButtonColorId;
@ColorInt private Integer compoundButtonColor;
private CompoundButton compoundButton;
@ -80,6 +82,10 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri
this.compoundButtonColorId = compoundButtonColorId;
}
public void setCompoundButtonColor(@ColorInt int compoundButtonColor) {
this.compoundButtonColor = compoundButtonColor;
}
public CompoundButton getCompoundButton() {
return compoundButton;
}
@ -91,7 +97,9 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri
if (compoundButton != null) {
compoundButton.setChecked(checked);
compoundButton.setOnCheckedChangeListener(onCheckedChangeListener);
if (compoundButtonColorId != INVALID_ID) {
if (compoundButtonColor != null) {
UiUtilities.setupCompoundButton(nightMode, compoundButtonColor, compoundButton);
} else if (compoundButtonColorId != INVALID_ID) {
UiUtilities.setupCompoundButton(nightMode, ContextCompat.getColor(context, compoundButtonColorId), compoundButton);
} else {
CompoundButtonCompat.setButtonTintList(compoundButton, buttonTintList);
@ -105,6 +113,7 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri
protected ColorStateList buttonTintList;
protected OnCheckedChangeListener onCheckedChangeListener;
@ColorRes protected int compoundButtonColorId = INVALID_ID;
@ColorInt protected Integer compoundButtonColor = null;
public Builder setChecked(boolean checked) {
this.checked = checked;
@ -125,6 +134,11 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri
this.compoundButtonColorId = compoundButtonColorId;
return this;
}
public Builder setCompoundButtonColor(@ColorInt int compoundButtonColor) {
this.compoundButtonColor = compoundButtonColor;
return this;
}
public BottomSheetItemWithCompoundButton create() {
return new BottomSheetItemWithCompoundButton(customView,

View file

@ -98,7 +98,7 @@ public class DetailsBottomSheet extends BasePreferenceBottomSheet {
@Override
public void createMenuItems(Bundle savedInstanceState) {
int selectedProfileColorRes = app.getSettings().APPLICATION_MODE.get().getIconColorInfo().getColor(nightMode);
int selectedProfileColor = app.getSettings().APPLICATION_MODE.get().getProfileColor(nightMode);
float spacing = getResources().getDimension(R.dimen.line_spacing_extra_description);
LinearLayout linearLayout = new LinearLayout(app);
linearLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
@ -139,7 +139,7 @@ public class DetailsBottomSheet extends BasePreferenceBottomSheet {
streetLightsNightPref.set(!onLeftClick);
}
})
.setCompoundButtonColorId(selectedProfileColorRes)
.setCompoundButtonColor(selectedProfileColor)
.setChecked(pref.get())
.setTitle(propertyName)
.setIconHidden(true)
@ -160,7 +160,7 @@ public class DetailsBottomSheet extends BasePreferenceBottomSheet {
} else if (!STREET_LIGHTING_NIGHT.equals(property.getAttrName())) {
final BottomSheetItemWithCompoundButton[] item = new BottomSheetItemWithCompoundButton[1];
item[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setCompoundButtonColorId(selectedProfileColorRes)
.setCompoundButtonColor(selectedProfileColor)
.setChecked(pref.get())
.setTitle(propertyName)
.setIconHidden(true)

View file

@ -174,8 +174,8 @@ public class SelectMapViewQuickActionsBottomSheet extends MenuBottomSheetDialogF
if (appMode != null) {
boolean selected = key.equals(selectedItem);
int iconId = appMode.getIconRes();
int colorId = appMode.getIconColorInfo().getColor(nightMode);
Drawable icon = getIcon(iconId, colorId);
int color = appMode.getProfileColor(nightMode);
Drawable icon = getPaintedIcon(iconId, color);
String translatedName = appMode.toHumanString();
createItemRow(selected, counter, icon, translatedName, key);
counter++;

View file

@ -55,7 +55,7 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
icon = getContentIcon(R.drawable.ic_action_split_interval);
} else {
description = routeAppMode.toHumanString();
icon = getIcon(routeAppMode.getIconRes(), routeAppMode.getIconColorInfo().getColor(nightMode));
icon = getPaintedIcon(routeAppMode.getIconRes(), routeAppMode.getProfileColor(nightMode));
}
} else {
description = getString(R.string.shared_string_undefined);

View file

@ -403,7 +403,7 @@ public class SelectedPointBottomSheetDialogFragment extends MenuBottomSheetDialo
if (MeasurementEditingContext.DEFAULT_APP_MODE.equals(routeAppMode)) {
icon = getContentIcon(R.drawable.ic_action_split_interval);
} else {
icon = getIcon(routeAppMode.getIconRes(), routeAppMode.getIconColorInfo().getColor(nightMode));
icon = getPaintedIcon(routeAppMode.getIconRes(), routeAppMode.getProfileColor(nightMode));
}
return icon;
}

View file

@ -121,7 +121,7 @@ public class EditTrackGroupDialogFragment extends MenuBottomSheetDialogFragment
final ApplicationMode mode = app.getSettings().getApplicationMode();
final BottomSheetItemWithCompoundButton[] showOnMapItem = new BottomSheetItemWithCompoundButton[1];
showOnMapItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setCompoundButtonColorId(mode.getIconColorInfo().getColor(nightMode))
.setCompoundButtonColor(mode.getProfileColor(nightMode))
.setChecked(checked)
.setTitle(getString(R.string.shared_string_show_on_map))
.setCustomView(getCustomButtonView(app, mode, checked, nightMode))

View file

@ -67,7 +67,7 @@ public class AppProfileArrayAdapter extends ArrayAdapter<ProfileDataObject> {
Drawable iconDrawable;
boolean lightContent = app.getSettings().isLightContent();
if (mode.isSelected()) {
iconDrawable = app.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColor(!lightContent));
iconDrawable = app.getUIUtilities().getPaintedIcon(mode.getIconRes(), mode.getIconColor(!lightContent));
} else {
iconDrawable = app.getUIUtilities().getIcon(mode.getIconRes(), lightContent);
}

View file

@ -6,10 +6,12 @@ import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.view.ContextThemeWrapper;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import net.osmand.PlatformUtil;
@ -35,8 +37,8 @@ public class ConfigureProfileMenuAdapter extends AbstractProfileMenuAdapter<Conf
@Nullable
private ProfileSelectedListener profileSelectedListener;
private final OsmandApplication app;
@ColorRes
private int selectedIconColorRes;
@ColorInt
private int selectedIconColor;
private boolean bottomButton;
private String bottomButtonText;
private static final String BUTTON_ITEM = "button_item";
@ -54,9 +56,10 @@ public class ConfigureProfileMenuAdapter extends AbstractProfileMenuAdapter<Conf
this.bottomButton = !Algorithms.isEmpty(bottomButtonText);
this.bottomButtonText = bottomButtonText;
this.nightMode = nightMode;
selectedIconColorRes = nightMode
int selectedIconColorRes = nightMode
? R.color.active_color_primary_dark
: R.color.active_color_primary_light;
selectedIconColor = ContextCompat.getColor(app, selectedIconColorRes);
}
public List<Object> getItems() {
@ -137,9 +140,9 @@ public class ConfigureProfileMenuAdapter extends AbstractProfileMenuAdapter<Conf
if (iconRes == 0 || iconRes == -1) {
iconRes = R.drawable.ic_action_world_globe;
}
selectedIconColorRes = mode.getIconColorInfo().getColor(nightMode);
selectedIconColor = mode.getProfileColor(nightMode);
if (selectedItems.contains(mode)) {
holder.icon.setImageDrawable(app.getUIUtilities().getIcon(iconRes, selectedIconColorRes));
holder.icon.setImageDrawable(app.getUIUtilities().getPaintedIcon(iconRes, selectedIconColor));
} else {
holder.icon.setImageDrawable(app.getUIUtilities().getIcon(iconRes, R.color.profile_icon_color_inactive));
}

View file

@ -14,6 +14,7 @@ import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
@ -241,7 +242,7 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
order = mode.getOrder();
}
profiles.add(new EditProfileDataObject(modeKey, mode.toHumanString(), ProfileDataUtils.getAppModeDescription(getContext(), mode),
mode.getIconRes(), false, mode.isCustomProfile(), deleted, mode.getIconColorInfo(), order));
mode.getIconRes(), false, mode.isCustomProfile(), deleted, mode.getProfileColor(false), mode.getProfileColor(true), order));
}
}
Collections.sort(profiles, new Comparator<EditProfileDataObject>() {
@ -274,8 +275,9 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
private boolean deleted;
private boolean customProfile;
EditProfileDataObject(String stringKey, String name, String descr, int iconRes, boolean isSelected, boolean customProfile, boolean deleted, ProfileIconColors iconColor, int order) {
super(name, descr, stringKey, iconRes, isSelected, iconColor);
EditProfileDataObject(String stringKey, String name, String descr, int iconRes, boolean isSelected,
boolean customProfile, boolean deleted, @ColorInt int iconColorLight, @ColorInt int iconColorDark, int order) {
super(name, descr, stringKey, iconRes, isSelected, iconColorLight, iconColorDark);
this.customProfile = customProfile;
this.deleted = deleted;
this.order = order;
@ -365,10 +367,9 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
if (iconRes == 0 || iconRes == -1) {
iconRes = R.drawable.ic_action_world_globe;
}
int profileColorResId = mode.getIconColor(nightMode);
int colorNoAlpha = ContextCompat.getColor(app, profileColorResId);
int colorNoAlpha = mode.getIconColor(nightMode);
profileViewHolder.icon.setImageDrawable(uiUtilities.getIcon(iconRes, profileColorResId));
profileViewHolder.icon.setImageDrawable(uiUtilities.getPaintedIcon(iconRes, colorNoAlpha));
//set up cell color
Drawable drawable = UiUtilities.getColoredSelectableDrawable(app, colorNoAlpha, 0.3f);

View file

@ -12,7 +12,7 @@ public class OnlineRoutingEngineDataObject extends ProfileDataObject {
String description,
String stringKey,
int order) {
super(name, description, stringKey, R.drawable.ic_world_globe_dark, false, null);
super(name, description, stringKey, R.drawable.ic_world_globe_dark, false, null, null);
this.order = order;
}

View file

@ -1,5 +1,6 @@
package net.osmand.plus.profiles;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.NonNull;
@ -12,15 +13,20 @@ public class ProfileDataObject implements Comparable<ProfileDataObject> {
private String stringKey;
private boolean isSelected;
private boolean isEnabled;
private ProfileIconColors iconColor;
@ColorInt
private Integer iconColorLight;
@ColorInt
private Integer iconColorDark;
public ProfileDataObject(String name, String description, String stringKey, int iconRes, boolean isSelected, ProfileIconColors iconColor) {
public ProfileDataObject(String name, String description, String stringKey, int iconRes, boolean isSelected,
@ColorInt Integer iconColorLight, @ColorInt Integer iconColorDark) {
this.name = name;
this.iconRes = iconRes;
this.description = description;
this.isSelected = isSelected;
this.stringKey = stringKey;
this.iconColor = iconColor;
this.iconColorLight = iconColorLight;
this.iconColorDark = iconColorDark;
}
public String getName() {
@ -55,8 +61,9 @@ public class ProfileDataObject implements Comparable<ProfileDataObject> {
return stringKey;
}
@ColorRes public int getIconColor(boolean isNightMode) {
return iconColor.getColor(isNightMode);
@ColorInt
public int getIconColor(boolean isNightMode) {
return isNightMode ? iconColorDark : iconColorLight;
}
@Override

View file

@ -33,7 +33,7 @@ public class ProfileDataUtils {
description = getAppModeDescription(app, mode);
}
profiles.add(new ProfileDataObject(mode.toHumanString(), description,
mode.getStringKey(), mode.getIconRes(), false, mode.getIconColorInfo()));
mode.getStringKey(), mode.getIconRes(), false, mode.getProfileColor(false), mode.getProfileColor(true)));
}
return profiles;
}

View file

@ -31,6 +31,7 @@ public enum ProfileIconColors {
return name;
}
@ColorRes
public int getColor(boolean nightMode) {
return nightMode ? nightColor : dayColor;
}

View file

@ -11,7 +11,7 @@ public class RoutingProfileDataObject extends ProfileDataObject {
private String fileName;
public RoutingProfileDataObject(String stringKey, String name, String descr, int iconRes, boolean isSelected, String fileName) {
super(name, descr, stringKey, iconRes, isSelected, null);
super(name, descr, stringKey, iconRes, isSelected, null, null);
this.fileName = fileName;
}

View file

@ -77,11 +77,12 @@ public class SelectMultipleProfilesBottomSheet extends BasePreferenceBottomSheet
View itemView = UiUtilities.getInflater(app, nightMode)
.inflate(R.layout.bottom_sheet_item_with_descr_and_checkbox_56dp, null);
int profileColorId = profile.getIconColor(nightMode);
int profileColor = profile.getIconColor(nightMode);
int activeColorId = nightMode ?
R.color.active_color_primary_dark : R.color.active_color_primary_light;
int disableColorId = nightMode ?
R.color.icon_color_default_dark : R.color.icon_color_default_light;
int disableColor = ContextCompat.getColor(app, disableColorId);
boolean enable = profile.isEnabled();
TextView tvTitle = itemView.findViewById(R.id.title);
@ -97,8 +98,8 @@ public class SelectMultipleProfilesBottomSheet extends BasePreferenceBottomSheet
tvDescription.setTextColor(ContextCompat.getColor(app, disableColorId));
}
Drawable drawableIcon = app.getUIUtilities().getIcon(
profile.getIconRes(), enable ? profileColorId : disableColorId);
Drawable drawableIcon = app.getUIUtilities().getPaintedIcon(
profile.getIconRes(), enable ? profileColor : disableColor);
ivIcon.setImageDrawable(drawableIcon);
UiUtilities.setupCompoundButton(nightMode, ContextCompat.getColor(app,
enable ? activeColorId : disableColorId), compoundButton);

View file

@ -254,12 +254,13 @@ public class SelectProfileBottomSheet extends BasePreferenceBottomSheet {
boolean isSelected = setupSelected && Algorithms.objectEquals(profile.getStringKey(), selectedItemKey);
int iconColor;
if (dialogMode == DialogMode.NAVIGATION_PROFILE) {
iconColor = isSelected ? activeColorResId : iconDefaultColorResId;
int iconColorResId = isSelected ? activeColorResId : iconDefaultColorResId;
iconColor = ContextCompat.getColor(app, iconColorResId);
} else {
iconColor = profile.getIconColor(nightMode);
}
Drawable drawableIcon = app.getUIUtilities().getIcon(profile.getIconRes(), iconColor);
Drawable drawableIcon = app.getUIUtilities().getPaintedIcon(profile.getIconRes(), iconColor);
ivIcon.setImageDrawable(drawableIcon);
compoundButton.setChecked(isSelected);
UiUtilities.setupCompoundButton(compoundButton, nightMode, UiUtilities.CompoundButtonType.GLOBAL);

View file

@ -6,19 +6,12 @@ import android.graphics.drawable.LayerDrawable;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.ColorRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.view.ContextThemeWrapper;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
@ -26,6 +19,13 @@ import org.apache.commons.logging.Log;
import java.util.ArrayList;
import java.util.List;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.view.ContextThemeWrapper;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
public class SelectProfileMenuAdapter extends AbstractProfileMenuAdapter<SelectProfileMenuAdapter.SelectProfileViewHolder> {
private static final Log LOG = PlatformUtil.getLog(SelectProfileMenuAdapter.class);
@ -33,8 +33,8 @@ public class SelectProfileMenuAdapter extends AbstractProfileMenuAdapter<SelectP
private List<Object> items = new ArrayList<>();
private final OsmandApplication app;
private ApplicationMode appMode;
@ColorRes
private int selectedIconColorRes;
@ColorInt
private int selectedIconColor;
private boolean bottomButton;
private String bottomButtonText;
private static final String BUTTON_ITEM = "button_item";
@ -53,9 +53,8 @@ public class SelectProfileMenuAdapter extends AbstractProfileMenuAdapter<SelectP
this.bottomButton = !Algorithms.isEmpty(bottomButtonText);
this.bottomButtonText = bottomButtonText;
this.nightMode = nightMode;
selectedIconColorRes = nightMode
? R.color.active_color_primary_dark
: R.color.active_color_primary_light;
int selectedIconColorRes = nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light;
selectedIconColor = ContextCompat.getColor(app, selectedIconColorRes);
}
public List<Object> getItems() {
@ -101,7 +100,7 @@ public class SelectProfileMenuAdapter extends AbstractProfileMenuAdapter<SelectP
holder.descr.setText(ProfileDataUtils.getAppModeDescription(app, item));
int colorNoAlpha = item.getProfileColor(nightMode);
holder.icon.setImageDrawable(app.getUIUtilities().getPaintedIcon(selectedIconColorRes, colorNoAlpha));
holder.icon.setImageDrawable(app.getUIUtilities().getPaintedIcon(item.getIconRes(), colorNoAlpha));
//set up cell color
boolean selectedMode = appMode == item;
@ -145,8 +144,8 @@ public class SelectProfileMenuAdapter extends AbstractProfileMenuAdapter<SelectP
if (iconRes == 0 || iconRes == -1) {
iconRes = R.drawable.ic_action_world_globe;
}
selectedIconColorRes = mode.getIconColorInfo().getColor(nightMode);
holder.icon.setImageDrawable(app.getUIUtilities().getIcon(iconRes, selectedIconColorRes));
selectedIconColor = mode.getProfileColor(nightMode);
holder.icon.setImageDrawable(app.getUIUtilities().getPaintedIcon(iconRes, selectedIconColor));
}
class SelectProfileViewHolder extends ProfileAbstractViewHolder {

View file

@ -12,10 +12,12 @@ import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.DrawableRes;
import androidx.annotation.StringRes;
import androidx.appcompat.widget.SwitchCompat;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentManager;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.RecyclerView;
@ -161,8 +163,8 @@ public abstract class SwitchableAction<T> extends QuickAction {
OsmandApplication app = (OsmandApplication) context.getApplicationContext();
Drawable icon = app.getUIUtilities().getIcon(
getItemIconRes(app, item), getItemIconColorRes(app, item));
Drawable icon = app.getUIUtilities().getPaintedIcon(
getItemIconRes(app, item), getItemIconColor(app, item));
holder.icon.setImageDrawable(icon);
holder.title.setText(getItemName(context, item));
@ -310,10 +312,11 @@ public abstract class SwitchableAction<T> extends QuickAction {
return R.drawable.ic_map;
}
@ColorRes
protected int getItemIconColorRes(OsmandApplication app, T item) {
@ColorInt
protected int getItemIconColor(OsmandApplication app, T item) {
boolean nightMode = !app.getSettings().isLightContent();
return nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light;
int colorRes = nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light;
return ContextCompat.getColor(app, colorRes);
}
protected abstract

View file

@ -5,6 +5,7 @@ import android.text.TextUtils;
import android.view.View;
import android.widget.Toast;
import androidx.annotation.ColorInt;
import androidx.appcompat.widget.SwitchCompat;
import com.google.gson.Gson;
@ -182,13 +183,14 @@ public class SwitchProfileAction extends SwitchableAction<String> {
}
@Override
protected int getItemIconColorRes(OsmandApplication app, String item) {
@ColorInt
protected int getItemIconColor(OsmandApplication app, String item) {
ApplicationMode appMode = getModeForKey(item);
if (appMode != null) {
boolean nightMode = !app.getSettings().isLightContent();
return appMode.getIconColorInfo().getColor(nightMode);
return appMode.getProfileColor(nightMode);
}
return super.getItemIconColorRes(app, item);
return super.getItemIconColor(app, item);
}
@Override

View file

@ -11,6 +11,7 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -66,6 +67,8 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr
private boolean hideImpassableRoads;
@ColorRes
private int compoundButtonColorId = INVALID_ID;
@ColorInt
private Integer compoundButtonColor = null;
private ApplicationMode appMode;
public void setHideImpassableRoads(boolean hideImpassableRoads) {
@ -237,6 +240,7 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr
final BottomSheetItemWithCompoundButton[] item = new BottomSheetItemWithCompoundButton[1];
item[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setCompoundButtonColorId(compoundButtonColorId)
.setCompoundButtonColor(compoundButtonColor)
.setChecked(selected)
.setTitle(parameterName)
.setLayoutId(R.layout.bottom_sheet_item_with_switch_no_icon)
@ -258,6 +262,10 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr
this.compoundButtonColorId = compoundButtonColorId;
}
public void setCompoundButtonColor(@ColorInt int compoundButtonColor) {
this.compoundButtonColor = compoundButtonColor;
}
@Override
public void onResume() {
super.onResume();

View file

@ -11,6 +11,7 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.appcompat.widget.SwitchCompat;
import androidx.core.content.ContextCompat;
@ -84,8 +85,8 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
private RoutingHelper routingHelper;
private RoutingOptionsHelper routingOptionsHelper;
private ApplicationMode applicationMode;
@ColorRes
private int selectedModeColorId;
@ColorInt
private int selectedModeColor;
private boolean currentMuteState;
private boolean currentUseHeightState;
private MapActivity mapActivity;
@ -149,7 +150,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
if (dialogMode == null) {
dialogMode = DialogMode.DIRECTIONS;
}
selectedModeColorId = applicationMode.getIconColorInfo().getColor(nightMode);
selectedModeColor = applicationMode.getProfileColor(nightMode);
voiceMuteChangeListener = new StateChangedListener<Boolean>() {
@Override
public void stateChanged(Boolean change) {
@ -271,7 +272,6 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
private BaseBottomSheetItem createMuteSoundItem(final LocalRoutingParameter optionsItem) {
boolean active = !routingHelper.getVoiceRouter().isMuteForMode(applicationMode);
int selectedModeColor = ContextCompat.getColor(app, selectedModeColorId);
final View itemView = UiUtilities.getInflater(app, nightMode).inflate(
R.layout.bottom_sheet_item_with_descr_switch_and_additional_button_56dp, null, false);
final ImageView icon = itemView.findViewById(R.id.icon);
@ -310,7 +310,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
Drawable drawable = app.getUIUtilities().getIcon(R.drawable.ic_action_settings,
nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
if (Build.VERSION.SDK_INT >= 21) {
Drawable activeDrawable = app.getUIUtilities().getIcon(R.drawable.ic_action_settings, selectedModeColorId);
Drawable activeDrawable = app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_settings, selectedModeColor);
drawable = AndroidUtils.createPressedStateListDrawable(drawable, activeDrawable);
}
voicePromptsBtnImage.setImageDrawable(drawable);
@ -358,7 +358,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
item[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setChecked(!active)
.setCompoundButtonColorId(selectedModeColorId)
.setCompoundButtonColor(selectedModeColor)
.setDescription(getElevationDescription(parameter))
.setIcon(getContentIcon(active ? parameter.getActiveIconId() : parameter.getDisabledIconId()))
.setTitle(getString(R.string.routing_attr_height_obstacles_name))
@ -387,7 +387,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
private BaseBottomSheetItem createTimeConditionalRoutingItem(final LocalRoutingParameter optionsItem) {
final BottomSheetItemWithCompoundButton[] timeConditionalRoutingItem = new BottomSheetItemWithCompoundButton[1];
timeConditionalRoutingItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setCompoundButtonColorId(selectedModeColorId)
.setCompoundButtonColor(selectedModeColor)
.setChecked(settings.ENABLE_TIME_CONDITIONAL_ROUTING.getModeValue(applicationMode))
.setIcon(getContentIcon((optionsItem.getActiveIconId())))
.setTitle(getString(R.string.temporary_conditional_routing))
@ -433,7 +433,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
private BaseBottomSheetItem createRouteSimulationItem(final LocalRoutingParameter optionsItem) {
final BottomSheetItemWithCompoundButton[] simulateNavigationItem = new BottomSheetItemWithCompoundButton[1];
simulateNavigationItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setCompoundButtonColorId(selectedModeColorId)
.setCompoundButtonColor(selectedModeColor)
.setChecked(settings.simulateNavigation)
.setIcon(getContentIcon(R.drawable.ic_action_start_navigation))
.setTitle(getString(R.string.simulate_navigation))
@ -470,7 +470,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem);
AvoidRoadsBottomSheetDialogFragment avoidRoadsFragment = new AvoidRoadsBottomSheetDialogFragment();
avoidRoadsFragment.setTargetFragment(RouteOptionsBottomSheet.this, AvoidRoadsBottomSheetDialogFragment.REQUEST_CODE);
avoidRoadsFragment.setCompoundButtonColorId(selectedModeColorId);
avoidRoadsFragment.setCompoundButtonColor(selectedModeColor);
avoidRoadsFragment.setApplicationMode(applicationMode);
avoidRoadsFragment.show(mapActivity.getSupportFragmentManager(), AvoidRoadsBottomSheetDialogFragment.TAG);
updateMenu();
@ -492,7 +492,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
AvoidRoadsBottomSheetDialogFragment avoidRoadsFragment = new AvoidRoadsBottomSheetDialogFragment();
avoidRoadsFragment.setHideImpassableRoads(true);
avoidRoadsFragment.setTargetFragment(RouteOptionsBottomSheet.this, AvoidRoadsBottomSheetDialogFragment.REQUEST_CODE);
avoidRoadsFragment.setCompoundButtonColorId(selectedModeColorId);
avoidRoadsFragment.setCompoundButtonColor(selectedModeColor);
avoidRoadsFragment.show(mapActivity.getSupportFragmentManager(), AvoidRoadsBottomSheetDialogFragment.TAG);
updateMenu();
}
@ -565,7 +565,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
if (parameter != null) {
final BottomSheetItemWithCompoundButton[] item = new BottomSheetItemWithCompoundButton[1];
BottomSheetItemWithCompoundButton.Builder builder = new BottomSheetItemWithCompoundButton.Builder();
builder.setCompoundButtonColorId(selectedModeColorId);
builder.setCompoundButtonColor(selectedModeColor);
int iconId = -1;
if (parameter.routingParameter != null || parameter instanceof RoutingOptionsHelper.OtherLocalRoutingParameter) {
builder.setTitle(parameter.getText(mapActivity));

View file

@ -467,12 +467,11 @@ public class ApplicationMode {
@ColorInt
public int getProfileColor(boolean nightMode) {
int index = getCustomIconColorIndex();
List<String> customColors = getCustomIconColors();
if (index < 0 || index >= customColors.size()) {
return ContextCompat.getColor(app, getIconColorInfo().getColor(nightMode));
Integer customProfileColor = getCustomIconColor();
if (customProfileColor != null) {
return customProfileColor;
}
return Algorithms.parseColor(customColors.get(index));
return ContextCompat.getColor(app, getIconColorInfo().getColor(nightMode));
}
public void setLocationIcon(LocationIcon locationIcon) {
@ -499,12 +498,14 @@ public class ApplicationMode {
app.getSettings().CUSTOM_ICON_COLORS.setModeValues(this, customColors);
}
public Integer getCustomIconColorIndex() {
return app.getSettings().CUSTOM_ICON_COLOR_INDEX.getModeValue(this);
public Integer getCustomIconColor() {
String customColor = app.getSettings().CUSTOM_ICON_COLOR.getModeValue(this);
return customColor == null ? null : Integer.valueOf(customColor);
}
public void setCustomIconColorIndex(int colorIndex) {
app.getSettings().CUSTOM_ICON_COLOR_INDEX.setModeValue(this, colorIndex);
public void setCustomIconColor(Integer customIconColor) {
String valueToSave = customIconColor == null ? null : String.valueOf(customIconColor);
app.getSettings().CUSTOM_ICON_COLOR.setModeValue(this, valueToSave);
}
public int getOrder() {
@ -605,7 +606,7 @@ public class ApplicationMode {
mode.setRouteService(builder.routeService);
mode.setIconColor(builder.iconColor);
mode.setCustomIconColors(builder.customIconColors);
mode.setCustomIconColorIndex(builder.customIconColorIndex);
mode.setCustomIconColor(builder.customIconColor);
mode.setLocationIcon(builder.locationIcon);
mode.setNavigationIcon(builder.navigationIcon);
mode.setOrder(builder.order);
@ -628,6 +629,7 @@ public class ApplicationMode {
builder.setUserProfileName(modeBean.userProfileName);
builder.setIconResName(modeBean.iconName);
builder.setIconColor(modeBean.iconColor);
builder.setCustomIconColor(modeBean.customIconColor);
builder.setRoutingProfile(modeBean.routingProfile);
builder.setRouteService(modeBean.routeService);
builder.setLocationIcon(modeBean.locIcon);
@ -647,6 +649,7 @@ public class ApplicationMode {
mb.stringKey = stringKey;
mb.userProfileName = getUserProfileName();
mb.iconColor = getIconColorInfo();
mb.customIconColor = getCustomIconColor();
mb.iconName = getIconName();
mb.parent = parentAppMode != null ? parentAppMode.getStringKey() : null;
mb.routeService = getRouteService();
@ -724,7 +727,7 @@ public class ApplicationMode {
private String iconResName;
private ProfileIconColors iconColor;
private List<String> customIconColors;
private int customIconColorIndex;
private Integer customIconColor;
private LocationIcon locationIcon;
private NavigationIcon navigationIcon;
private int order = -1;
@ -749,7 +752,7 @@ public class ApplicationMode {
applicationMode.setRoutingProfile(routingProfile);
applicationMode.setIconResName(iconResName);
applicationMode.setCustomIconColors(customIconColors);
applicationMode.setCustomIconColorIndex(customIconColorIndex);
applicationMode.setCustomIconColor(customIconColor);
applicationMode.setIconColor(iconColor);
applicationMode.setLocationIcon(locationIcon);
applicationMode.setNavigationIcon(navigationIcon);
@ -803,8 +806,8 @@ public class ApplicationMode {
return this;
}
public ApplicationModeBuilder setCustomIconColorIndex(int index) {
this.customIconColorIndex = index;
public ApplicationModeBuilder setCustomIconColor(Integer customIconColor) {
this.customIconColor = customIconColor;
return this;
}
@ -836,6 +839,8 @@ public class ApplicationMode {
@Expose
public ProfileIconColors iconColor = ProfileIconColors.DEFAULT;
@Expose
public Integer customIconColor = null;
@Expose
public String routingProfile = null;
@Expose
public RouteService routeService = RouteService.OSMAND;

View file

@ -986,7 +986,7 @@ public class OsmandSettings {
public final ListStringPreference CUSTOM_ICON_COLORS = (ListStringPreference) new ListStringPreference(this, "custom_icon_colors", null, ",").makeProfile().cache();
public final CommonPreference<Integer> CUSTOM_ICON_COLOR_INDEX = new IntPreference(this, "custom_icon_color_index", -1).makeProfile().cache();
public final CommonPreference<String> CUSTOM_ICON_COLOR = new StringPreference(this, "custom_icon_color", null).makeProfile().cache();
public final CommonPreference<String> USER_PROFILE_NAME = new StringPreference(this, "user_profile_name", "").makeProfile().cache();

View file

@ -301,6 +301,7 @@ public class ProfileSettingsItem extends OsmandSettingsItem {
OsmandSettings settings = app.getSettings();
return new String[] {
settings.ICON_COLOR.getId(),
settings.CUSTOM_ICON_COLOR.getId(),
settings.ICON_RES_NAME.getId(),
settings.PARENT_APP_MODE.getId(),
settings.ROUTING_PROFILE.getId(),

View file

@ -103,7 +103,7 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet {
})
.create();
if (isProfileDependent()) {
preferenceBtn[0].setCompoundButtonColorId(getAppMode().getIconColorInfo().getColor(nightMode));
preferenceBtn[0].setCompoundButtonColor(getAppMode().getProfileColor(nightMode));
}
items.add(preferenceBtn[0]);
@ -133,8 +133,7 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet {
Context themedCtx = UiUtilities.getThemedContext(app, nightMode);
View buttonView = customView.findViewById(R.id.button_container);
int colorRes = mode.getIconColorInfo().getColor(nightMode);
int color = checked ? ContextCompat.getColor(themedCtx, colorRes) : AndroidUtils.getColorFromAttr(themedCtx, R.attr.divider_color_basic);
int color = checked ? mode.getProfileColor(nightMode) : AndroidUtils.getColorFromAttr(themedCtx, R.attr.divider_color_basic);
int bgColor = UiUtilities.getColorWithAlpha(color, checked ? 0.1f : 0.5f);
int selectedColor = UiUtilities.getColorWithAlpha(color, checked ? 0.3f : 0.5f);

View file

@ -5,6 +5,7 @@ import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
@ -65,6 +66,7 @@ public class ElevationDateBottomSheet extends MenuBottomSheetDialogFragment {
private int checkedColor;
private int uncheckedColor;
private int disabledColor;
@ColorInt
private int appModeColor;
@Override
@ -101,7 +103,7 @@ public class ElevationDateBottomSheet extends MenuBottomSheetDialogFragment {
on = getString(R.string.shared_string_enabled);
off = getString(R.string.shared_string_disabled);
appModeColor = appMode.getIconColorInfo().getColor(nightMode);
appModeColor = appMode.getProfileColor(nightMode);
activeColor = AndroidUtils.resolveAttribute(themedCtx, R.attr.active_color_basic);
disabledColor = AndroidUtils.resolveAttribute(themedCtx, android.R.attr.textColorSecondary);
checkedColor = (nightMode ? app.getResources().getColor(R.color.text_color_primary_dark) : app.getResources().getColor(R.color.text_color_primary_light));
@ -123,7 +125,7 @@ public class ElevationDateBottomSheet extends MenuBottomSheetDialogFragment {
private void createUseHeightButton(Context context) {
boolean checked = useHeightPref.getModeValue(appMode);
useHeightButton = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setCompoundButtonColorId(appModeColor)
.setCompoundButtonColor(appModeColor)
.setChecked(checked)
.setTitle(checked ? on : off)
.setTitleColorId(checked ? activeColor : disabledColor)

View file

@ -89,7 +89,7 @@ public class MultiSelectPreferencesBottomSheet extends BasePreferenceBottomSheet
.setTag(prefId)
.create();
if (isProfileDependent()) {
item[0].setCompoundButtonColorId(getAppMode().getIconColorInfo().getColor(nightMode));
item[0].setCompoundButtonColor(getAppMode().getProfileColor(nightMode));
}
items.add(item[0]);
}

View file

@ -107,7 +107,7 @@ public class RecalculateRouteInDeviationBottomSheet extends BooleanPreferenceBot
final BottomSheetItemWithCompoundButton[] preferenceBtn = new BottomSheetItemWithCompoundButton[1];
preferenceBtn[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setChecked(enabled)
.setCompoundButtonColorId(appModeColorId)
.setCompoundButtonColor(appModeColor)
.setTitle(enabled ? on : off)
.setTitleColorId(enabled ? activeColor : disabledColor)
.setCustomView(getCustomButtonView(app, getAppMode(), enabled, nightMode))

View file

@ -45,10 +45,10 @@ public class ResetProfilePrefsBottomSheet extends BasePreferenceBottomSheet {
BaseBottomSheetItem profileItem = new BottomSheetItemWithCompoundButton.Builder()
.setChecked(true)
.setCompoundButtonColorId(profileColor)
.setButtonTintList(ColorStateList.valueOf(getResolvedColor(profileColor)))
.setCompoundButtonColor(colorNoAlpha)
.setButtonTintList(ColorStateList.valueOf(colorNoAlpha))
.setDescription(ProfileDataUtils.getAppModeDescription(ctx, mode))
.setIcon(getIcon(mode.getIconRes(), profileColor))
.setIcon(getPaintedIcon(mode.getIconRes(), colorNoAlpha))
.setTitle(mode.toHumanString())
.setBackground(new LayerDrawable(layers))
.setLayoutId(R.layout.preference_profile_item_with_radio_btn)

View file

@ -6,6 +6,7 @@ import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
@ -69,8 +70,11 @@ public class SingleSelectPreferenceBottomSheet extends BasePreferenceBottomSheet
final BaseBottomSheetItem[] preferenceItem = new BottomSheetItemWithCompoundButton[1];
preferenceItem[0] = new BottomSheetItemWithCompoundButton.Builder()
.setChecked(i == selectedEntryIndex)
.setButtonTintList(AndroidUtils.createCheckedColorStateList(ctx, R.color.icon_color_default_light,
isProfileDependent() ? getAppMode().getIconColorInfo().getColor(nightMode) : getActiveColorId()))
.setButtonTintList(AndroidUtils.createCheckedColorIntStateList(
ContextCompat.getColor(ctx,R.color.icon_color_default_light),
isProfileDependent() ?
getAppMode().getProfileColor(nightMode) :
ContextCompat.getColor(ctx, getActiveColorId())))
.setTitle(entries[i])
.setTag(i)
.setLayoutId(R.layout.bottom_sheet_item_with_radio_btn_left)

View file

@ -680,12 +680,9 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
@ColorInt
protected int getActiveProfileColor() {
return ContextCompat.getColor(app, getActiveProfileColorRes());
}
@ColorRes
protected int getActiveProfileColorRes() {
return isProfileDependent() ? getSelectedAppMode().getIconColorInfo().getColor(isNightMode()) : R.color.icon_color_active_light;
return isProfileDependent() ?
getSelectedAppMode().getProfileColor(isNightMode()) :
ContextCompat.getColor(app, R.color.icon_color_active_light);
}
@ColorRes
@ -801,7 +798,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
protected Drawable getActiveIcon(@DrawableRes int id) {
UiUtilities cache = getIconsCache();
return cache != null ? cache.getIcon(id, getActiveProfileColorRes()) : null;
return cache != null ? cache.getPaintedIcon(id, getActiveProfileColor()) : null;
}
protected Drawable getIcon(@DrawableRes int id, @ColorRes int colorId) {
@ -829,7 +826,8 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
Drawable icon = AndroidUtils.createEnabledStateListDrawable(disabled, enabled);
if (Build.VERSION.SDK_INT < 21) {
ColorStateList colorStateList = AndroidUtils.createEnabledColorStateList(app, R.color.icon_color_default_light, getActiveProfileColorRes());
int defaultColor = ContextCompat.getColor(app, R.color.icon_color_default_light);
ColorStateList colorStateList = AndroidUtils.createEnabledColorIntStateList(defaultColor, getActiveProfileColor());
icon = DrawableCompat.wrap(icon);
DrawableCompat.setTintList(icon, colorStateList);
return icon;

View file

@ -6,7 +6,9 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import alice.tuprolog.Int;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import net.osmand.AndroidUtils;
@ -121,7 +123,10 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter<RecyclerView
}
int profileIconRes = AndroidUtils.getDrawableId(app, modeBean.iconName);
ProfileIconColors iconColor = modeBean.iconColor;
itemHolder.icon.setImageDrawable(uiUtilities.getIcon(profileIconRes, iconColor.getColor(nightMode)));
Integer customIconColor = modeBean.customIconColor;
int actualIconColor = customIconColor != null ?
customIconColor : ContextCompat.getColor(app, iconColor.getColor(nightMode));
itemHolder.icon.setImageDrawable(uiUtilities.getPaintedIcon(profileIconRes, actualIconColor));
} else if (currentItem instanceof QuickAction) {
QuickAction action = (QuickAction) currentItem;
itemHolder.title.setText(action.getName(app));

View file

@ -306,7 +306,10 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment {
}
int profileIconRes = AndroidUtils.getDrawableId(app, modeBean.iconName);
ProfileIconColors iconColor = modeBean.iconColor;
builder.setIcon(uiUtilities.getIcon(profileIconRes, iconColor.getColor(nightMode)));
Integer customIconColor = modeBean.customIconColor;
int actualIconColor = customIconColor != null ?
customIconColor : ContextCompat.getColor(app, iconColor.getColor(nightMode));
builder.setIcon(uiUtilities.getPaintedIcon(profileIconRes, actualIconColor));
} else if (object instanceof QuickAction) {
QuickAction quickAction = (QuickAction) object;
builder.setTitle(quickAction.getName(app));

View file

@ -24,6 +24,7 @@ import android.widget.ImageView;
import android.widget.TextView;
import androidx.activity.OnBackPressedCallback;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
@ -94,7 +95,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
private static final String PROFILE_STRINGKEY_KEY = "profile_stringkey_key";
private static final String PROFILE_ICON_RES_KEY = "profile_icon_res_key";
private static final String PROFILE_COLOR_KEY = "profile_color_key";
private static final String PROFILE_CUSTOM_COLOR_INDEX_KEY = "profile_custom_color_index_key";
private static final String PROFILE_CUSTOM_COLOR_KEY = "profile_custom_color_key";
private static final String PROFILE_PARENT_KEY = "profile_parent_key";
private static final String PROFILE_LOCATION_ICON_KEY = "profile_location_icon_key";
private static final String PROFILE_NAVIGATION_ICON_KEY = "profile_navigation_icon_key";
@ -151,7 +152,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
changedProfile.name = profile.name;
}
changedProfile.color = profile.color;
changedProfile.customColorIndex = profile.customColorIndex;
changedProfile.customColor = profile.customColor;
changedProfile.iconRes = profile.iconRes;
changedProfile.routingProfile = profile.routingProfile;
changedProfile.routeService = profile.routeService;
@ -171,7 +172,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
profile.parent = baseModeForNewProfile.getParent();
profile.name = baseModeForNewProfile.toHumanString();
profile.color = baseModeForNewProfile.getIconColorInfo();
profile.customColorIndex = baseModeForNewProfile.getCustomIconColorIndex();
profile.customColor = baseModeForNewProfile.getCustomIconColor();
profile.iconRes = baseModeForNewProfile.getIconRes();
profile.routingProfile = baseModeForNewProfile.getRoutingProfile();
profile.routeService = baseModeForNewProfile.getRouteService();
@ -308,7 +309,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
outState.putString(PROFILE_STRINGKEY_KEY, changedProfile.stringKey);
outState.putInt(PROFILE_ICON_RES_KEY, changedProfile.iconRes);
outState.putSerializable(PROFILE_COLOR_KEY, changedProfile.color);
outState.putInt(PROFILE_CUSTOM_COLOR_INDEX_KEY, changedProfile.customColorIndex);
outState.putInt(PROFILE_CUSTOM_COLOR_KEY, changedProfile.customColor);
if (changedProfile.parent != null) {
outState.putString(PROFILE_PARENT_KEY, changedProfile.parent.getStringKey());
}
@ -323,7 +324,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
changedProfile.stringKey = savedInstanceState.getString(PROFILE_STRINGKEY_KEY);
changedProfile.iconRes = savedInstanceState.getInt(PROFILE_ICON_RES_KEY);
changedProfile.color = (ProfileIconColors) savedInstanceState.getSerializable(PROFILE_COLOR_KEY);
changedProfile.customColorIndex = savedInstanceState.getInt(PROFILE_CUSTOM_COLOR_INDEX_KEY);
changedProfile.customColor = savedInstanceState.getInt(PROFILE_CUSTOM_COLOR_KEY);
String parentStringKey = savedInstanceState.getString(PROFILE_PARENT_KEY);
changedProfile.parent = ApplicationMode.valueOfStringKey(parentStringKey, null);
isBaseProfileImported = savedInstanceState.getBoolean(IS_BASE_PROFILE_IMPORTED);
@ -748,7 +749,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
mode.setRoutingProfile(changedProfile.routingProfile);
mode.setRouteService(changedProfile.routeService);
mode.setIconColor(changedProfile.color);
mode.setCustomIconColorIndex(changedProfile.customColorIndex);
mode.setCustomIconColor(changedProfile.customColor);
mode.setLocationIcon(changedProfile.locationIcon);
mode.setNavigationIcon(changedProfile.navigationIcon);
@ -769,7 +770,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
.setRoutingProfile(changedProfile.routingProfile)
.setRouteService(changedProfile.routeService)
.setIconColor(changedProfile.color)
.setCustomIconColorIndex(changedProfile.customColorIndex)
.setCustomIconColor(changedProfile.customColor)
.setLocationIcon(changedProfile.locationIcon)
.setNavigationIcon(changedProfile.navigationIcon);
@ -941,10 +942,10 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
if (cardOfColors.isBaseColor(color)) {
changedProfile.customColorIndex = -1;
changedProfile.customColor = null;
changedProfile.color = changedProfile.getProfileColorByColorValue(color);
} else {
changedProfile.customColorIndex = cardOfColors.getIndexOfSelectedColor();
changedProfile.customColor = cardOfColors.getSelectedColor();
changedProfile.color = null;
}
@ -998,17 +999,17 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
ApplicationMode parent = null;
String name;
ProfileIconColors color;
int customColorIndex = -1;
Integer customColor = null;
int iconRes;
String routingProfile;
RouteProvider.RouteService routeService;
NavigationIcon navigationIcon;
LocationIcon locationIcon;
@ColorInt
public int getActualColor() {
return customColorIndex != -1 ?
Algorithms.parseColor(settings.CUSTOM_ICON_COLORS.getStringsListForProfile(getSelectedAppMode()).get(customColorIndex)) :
ContextCompat.getColor(app, color.getColor(isNightMode()));
return customColor != null ?
customColor : ContextCompat.getColor(app, color.getColor(isNightMode()));
}
public ProfileIconColors getProfileColorByColorValue(int colorValue) {
@ -1034,7 +1035,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
if (parent != null ? !parent.equals(that.parent) : that.parent != null) return false;
if (name != null ? !name.equals(that.name) : that.name != null) return false;
if (color != that.color) return false;
if (customColorIndex != that.customColorIndex) return false;
if (customColor != null ? !customColor.equals(that.customColor) : that.customColor != null) return false;
if (routingProfile != null ? !routingProfile.equals(that.routingProfile) : that.routingProfile != null)
return false;
if (routeService != that.routeService) return false;
@ -1048,7 +1049,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
result = 31 * result + (parent != null ? parent.hashCode() : 0);
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (color != null ? color.hashCode() : 0);
result = 31 * result + customColorIndex;
result = 31 * result + (customColor != null ? customColor.hashCode() : 0);
result = 31 * result + iconRes;
result = 31 * result + (routingProfile != null ? routingProfile.hashCode() : 0);
result = 31 * result + (routeService != null ? routeService.hashCode() : 0);

View file

@ -20,6 +20,7 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.content.res.AppCompatResources;
@ -888,7 +889,7 @@ public class MapControlsLayer extends OsmandMapLayer {
compassHud.updateVisibility(!forceHideCompass && shouldShowCompass());
ApplicationMode appMode = settings.getApplicationMode();
layersHud.setIconColorId(appMode.getIconColorInfo().getColor(isNight));
layersHud.setIconColor(appMode.getProfileColor(isNight));
if (layersHud.setIconResId(appMode.getIconRes())) {
layersHud.update(app, isNight);
}
@ -1114,6 +1115,10 @@ public class MapControlsLayer extends OsmandMapLayer {
private int resDarkId;
private int resClrLight = R.color.map_button_icon_color_light;
private int resClrDark = R.color.map_button_icon_color_dark;
@ColorInt
private Integer clrIntLight = null;
@ColorInt
private Integer clrIntDark = null;
private String id;
private boolean flipIconForRtl;
@ -1222,11 +1227,14 @@ public class MapControlsLayer extends OsmandMapLayer {
}
public boolean resetIconColors() {
if (resClrLight == R.color.map_button_icon_color_light && resClrDark == R.color.map_button_icon_color_dark) {
if (resClrLight == R.color.map_button_icon_color_light && resClrDark == R.color.map_button_icon_color_dark
&& clrIntLight == null && clrIntDark == null) {
return false;
}
resClrLight = R.color.map_button_icon_color_light;
resClrDark = R.color.map_button_icon_color_dark;
clrIntLight = null;
clrIntDark = null;
f = true;
return true;
}
@ -1241,6 +1249,16 @@ public class MapControlsLayer extends OsmandMapLayer {
return this;
}
public MapHudButton setIconColor(@ColorInt Integer clr) {
if (clrIntLight == clr && clrIntDark == clr) {
return this;
}
clrIntLight = clr;
clrIntDark = clr;
f = true;
return this;
}
public MapHudButton setIconsId(int icnLight, int icnDark) {
if (resLightId == icnLight && resDarkId == icnDark) {
return this;
@ -1261,6 +1279,17 @@ public class MapControlsLayer extends OsmandMapLayer {
return this;
}
public MapHudButton setIconColor(@ColorInt int clrLight, @ColorInt int clrDark) {
if (clrIntLight == clrLight && clrIntDark == clrDark) {
return this;
}
clrIntLight = clrLight;
clrIntDark = clrDark;
f = true;
return this;
}
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
public void update(OsmandApplication ctx, boolean night) {
@ -1282,7 +1311,11 @@ public class MapControlsLayer extends OsmandMapLayer {
} else if (resLightId != 0 && !nightMode) {
d = ctx.getUIUtilities().getIcon(resLightId);
} else if (resId != 0) {
d = ctx.getUIUtilities().getIcon(resId, nightMode ? resClrDark : resClrLight);
if (clrIntLight != null && clrIntDark != null) {
d = ctx.getUIUtilities().getPaintedIcon(resId, nightMode ? clrIntDark : clrIntLight);
} else {
d = ctx.getUIUtilities().getIcon(resId, nightMode ? resClrDark : resClrLight);
}
if (flipIconForRtl) {
d = AndroidUtils.getDrawableForDirection(ctx, d);
}

View file

@ -1,5 +1,6 @@
package net.osmand.plus.views.layers;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
@ -11,6 +12,7 @@ import android.graphics.PorterDuffColorFilter;
import android.graphics.RectF;
import android.graphics.drawable.LayerDrawable;
import androidx.annotation.ColorInt;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat;
@ -48,7 +50,8 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
private OsmandMapTileView view;
private ApplicationMode appMode;
private int colorId;
@ColorInt
private int color;
private LayerDrawable navigationIcon;
private int navigationIconId;
private LayerDrawable locationIcon;
@ -160,30 +163,32 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
}
private void updateIcons(ApplicationMode appMode, boolean nighMode, boolean locationOutdated) {
int colorId = locationOutdated ? ProfileIconColors.getOutdatedLocationColor(nighMode) : appMode.getIconColorInfo().getColor(nighMode);
Context ctx = view.getContext();
int color = locationOutdated ?
ContextCompat.getColor(ctx, ProfileIconColors.getOutdatedLocationColor(nighMode)) :
appMode.getProfileColor(nighMode);
int locationIconId = appMode.getLocationIcon().getIconId();
int navigationIconId = appMode.getNavigationIcon().getIconId();
int headingIconId = appMode.getLocationIcon().getHeadingIconId();
if (appMode != this.appMode || this.nm != nighMode || this.locationOutdated != locationOutdated
|| this.colorId != colorId
|| this.color != color
|| this.locationIconId != locationIconId
|| this.headingIconId != headingIconId
|| this.navigationIconId != navigationIconId) {
this.appMode = appMode;
this.colorId = colorId;
this.color = color;
this.nm = nighMode;
this.locationOutdated = locationOutdated;
this.locationIconId = locationIconId;
this.headingIconId = headingIconId;
this.navigationIconId = navigationIconId;
int color = ContextCompat.getColor(view.getContext(), colorId);
navigationIcon = (LayerDrawable) AppCompatResources.getDrawable(view.getContext(), navigationIconId);
navigationIcon = (LayerDrawable) AppCompatResources.getDrawable(ctx, navigationIconId);
if (navigationIcon != null) {
DrawableCompat.setTint(navigationIcon.getDrawable(1), color);
}
headingIcon = BitmapFactory.decodeResource(view.getResources(), headingIconId);
headingPaint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));
locationIcon = (LayerDrawable) AppCompatResources.getDrawable(view.getContext(), locationIconId);
locationIcon = (LayerDrawable) AppCompatResources.getDrawable(ctx, locationIconId);
if (locationIcon != null) {
DrawableCompat.setTint(DrawableCompat.wrap(locationIcon.getDrawable(1)), color);
}

View file

@ -71,7 +71,7 @@ public class SelectWikiLanguagesBottomSheet extends MenuBottomSheetDialogFragmen
public void createMenuItems(Bundle savedInstanceState) {
final int activeColorResId = nightMode ?
R.color.active_color_primary_dark : R.color.active_color_primary_light;
final int profileColorResId = appMode.getIconColorInfo().getColor(nightMode);
final int profileColor = appMode.getProfileColor(nightMode);
final int contentPadding = app.getResources().getDimensionPixelSize(R.dimen.content_padding);
final int contentPaddingSmall = app.getResources().getDimensionPixelSize(R.dimen.content_padding_small);
@ -86,7 +86,7 @@ public class SelectWikiLanguagesBottomSheet extends MenuBottomSheetDialogFragmen
final BottomSheetItemWithCompoundButton[] btnSelectAll = new BottomSheetItemWithCompoundButton[1];
btnSelectAll[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setChecked(this.isGlobalWikiPoiEnabled)
.setCompoundButtonColorId(profileColorResId)
.setCompoundButtonColor(profileColor)
.setTitle(getString(R.string.shared_string_all_languages))
.setTitleColorId(activeColorResId)
.setCustomView(getCustomButtonView())
@ -174,15 +174,15 @@ public class SelectWikiLanguagesBottomSheet extends MenuBottomSheetDialogFragmen
int disableColorId = nightMode ?
R.color.active_buttons_and_links_text_disabled_dark :
R.color.active_buttons_and_links_text_disabled_light;
int profileColorId = appMode.getIconColorInfo().getColor(nightMode);
int profileColor = appMode.getProfileColor(nightMode);
int disableColor = ContextCompat.getColor(app, disableColorId);
for (BottomSheetItemWithCompoundButton item : languageItems) {
item.getView().setEnabled(enable);
item.setTitleColorId(enable ? textColorPrimaryId : disableColorId);
CompoundButton cb = item.getCompoundButton();
if (cb != null) {
cb.setEnabled(enable);
UiUtilities.setupCompoundButton(nightMode, ContextCompat.getColor(app, enable ?
profileColorId : disableColorId), cb);
UiUtilities.setupCompoundButton(nightMode, enable ? profileColor : disableColor, cb);
}
}
}
@ -254,7 +254,7 @@ public class SelectWikiLanguagesBottomSheet extends MenuBottomSheetDialogFragmen
Drawable bgDrawable = app.getUIUtilities().getPaintedIcon(bgResId, bgColor);
AndroidUtils.setBackground(buttonView, bgDrawable);
int selectedModeColorId = appMode.getIconColorInfo().getColor(nightMode);
int selectedModeColorId = appMode.getProfileColor(nightMode);
UiUtilities.setupCompoundButton(nightMode, selectedModeColorId, cb);
return buttonView;