Profiles list color fix

QuickActionListFragment "delete dialog" color fix
This commit is contained in:
Nazar 2019-08-27 12:27:51 +03:00
parent 6b9b76d851
commit cdc8331ca5
3 changed files with 37 additions and 15 deletions

View file

@ -104,7 +104,7 @@ public class AppModesBottomSheetDialogFragment extends MenuBottomSheetDialogFrag
public void createMenuItems(Bundle savedInstanceState) { public void createMenuItems(Bundle savedInstanceState) {
themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
adapter = new ProfileMenuAdapter(allModes, selectedModes, getMyApplication(), getString(R.string.shared_string_manage)); adapter = new ProfileMenuAdapter(allModes, selectedModes, getMyApplication(), getString(R.string.shared_string_manage), true);
recyclerView = new RecyclerView(getContext()); recyclerView = new RecyclerView(getContext());
recyclerView = (RecyclerView) View recyclerView = (RecyclerView) View
.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.recyclerview, null); .inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.recyclerview, null);

View file

@ -41,19 +41,27 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder>
private String bottomButtonText; private String bottomButtonText;
private static final String BUTTON_ITEM = "button_item"; private static final String BUTTON_ITEM = "button_item";
private boolean usedOnMap;
public ProfileMenuAdapter(List<ApplicationMode> items, Set<ApplicationMode> selectedItems, public ProfileMenuAdapter(List<ApplicationMode> items, Set<ApplicationMode> selectedItems,
OsmandApplication app, String bottomButtonText) { OsmandApplication app, String bottomButtonText) {
this(items, selectedItems, app, bottomButtonText, false);
}
public ProfileMenuAdapter(List<ApplicationMode> items, Set<ApplicationMode> selectedItems,
OsmandApplication app, String bottomButtonText, boolean usedOnMap) {
this.items.addAll(items); this.items.addAll(items);
if (bottomButton) { if (bottomButton) {
this.items.add(BUTTON_ITEM); this.items.add(BUTTON_ITEM);
} }
this.usedOnMap = usedOnMap;
this.app = app; this.app = app;
this.selectedItems = selectedItems; this.selectedItems = selectedItems;
this.bottomButton = !Algorithms.isEmpty(bottomButtonText); this.bottomButton = !Algorithms.isEmpty(bottomButtonText);
this.bottomButtonText = bottomButtonText; this.bottomButtonText = bottomButtonText;
selectedIconColorRes = isNightMode(app) selectedIconColorRes = isNightMode(app, usedOnMap)
? R.color.active_color_primary_dark ? R.color.active_color_primary_dark
: R.color.active_color_primary_light; : R.color.active_color_primary_light;
} }
public List<Object> getItems() { public List<Object> getItems() {
@ -80,6 +88,14 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder>
return super.getItemViewType(position); return super.getItemViewType(position);
} }
public boolean isUsedOnMap() {
return usedOnMap;
}
public void setUsedOnMap(boolean usedOnMap) {
this.usedOnMap = usedOnMap;
}
@NonNull @NonNull
@Override @Override
public ProfileViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { public ProfileViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
@ -99,7 +115,7 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder>
holder.menuIcon.setVisibility(View.VISIBLE); holder.menuIcon.setVisibility(View.VISIBLE);
final ApplicationMode item = (ApplicationMode) obj; final ApplicationMode item = (ApplicationMode) obj;
if (bottomButton) { if (bottomButton) {
holder.divider.setBackgroundColor(isNightMode(app) holder.divider.setBackgroundColor(isNightMode(app, usedOnMap)
? app.getResources().getColor(R.color.divider_color_dark) ? app.getResources().getColor(R.color.divider_color_dark)
: app.getResources().getColor(R.color.divider_color_light)); : app.getResources().getColor(R.color.divider_color_light));
} }
@ -111,7 +127,7 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder>
holder.descr.setText(R.string.profile_type_base_string); holder.descr.setText(R.string.profile_type_base_string);
} }
holder.title.setTextColor(app.getResources().getColor(isNightMode(app) holder.title.setTextColor(app.getResources().getColor(isNightMode(app, usedOnMap)
? R.color.text_color_primary_dark ? R.color.text_color_primary_dark
: R.color.text_color_primary_light)); : R.color.text_color_primary_light));
@ -129,7 +145,7 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder>
holder.switcher.setVisibility(View.GONE); holder.switcher.setVisibility(View.GONE);
holder.menuIcon.setVisibility(View.GONE); holder.menuIcon.setVisibility(View.GONE);
holder.title.setTextColor(app.getResources().getColor( holder.title.setTextColor(app.getResources().getColor(
isNightMode(app) isNightMode(app, usedOnMap)
? R.color.active_color_primary_dark ? R.color.active_color_primary_dark
: R.color.active_color_primary_light)); : R.color.active_color_primary_light));
holder.title.setText(bottomButtonText); holder.title.setText(bottomButtonText);
@ -146,16 +162,19 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder>
if (iconRes == 0 || iconRes == -1) { if (iconRes == 0 || iconRes == -1) {
iconRes = R.drawable.ic_action_world_globe; iconRes = R.drawable.ic_action_world_globe;
} }
selectedIconColorRes = mode.getIconColorInfo().getColor(isNightMode(app)); selectedIconColorRes = mode.getIconColorInfo().getColor(isNightMode(app, usedOnMap));
if (selectedItems.contains(mode)) { if (selectedItems.contains(mode)) {
holder.icon.setImageDrawable(app.getUIUtilities().getIcon(iconRes, mode.getIconColorInfo().getColor(isNightMode(app)))); holder.icon.setImageDrawable(app.getUIUtilities().getIcon(iconRes, mode.getIconColorInfo().getColor(isNightMode(app, usedOnMap))));
} else { } else {
holder.icon.setImageDrawable(app.getUIUtilities().getIcon(iconRes, R.color.profile_icon_color_inactive)); holder.icon.setImageDrawable(app.getUIUtilities().getIcon(iconRes, R.color.profile_icon_color_inactive));
} }
} }
private static boolean isNightMode(OsmandApplication ctx) { private static boolean isNightMode(OsmandApplication ctx, boolean useMapTheme) {
return !ctx.getSettings().isLightContent(); if (useMapTheme) {
return ctx.getDaynightHelper().isNightModeForMapControls();
}
return !ctx.getSettings().isLightContent();
} }
class ProfileViewHolder extends RecyclerView.ViewHolder { class ProfileViewHolder extends RecyclerView.ViewHolder {

View file

@ -157,7 +157,9 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick
} }
void createAndShowDeleteDialog(final int itemPosition, final String itemName) { void createAndShowDeleteDialog(final int itemPosition, final String itemName) {
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(getContext(), R.style.OsmandLightTheme)); boolean isLightContent = getMyApplication().getSettings().isLightContent();
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(getContext(),
isLightContent ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme));
builder.setTitle(R.string.quick_actions_delete); builder.setTitle(R.string.quick_actions_delete);
builder.setMessage(getResources().getString(R.string.quick_actions_delete_text, itemName)); builder.setMessage(getResources().getString(R.string.quick_actions_delete_text, itemName));
builder.setIcon(getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_action_delete_dark)); builder.setIcon(getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_action_delete_dark));
@ -173,8 +175,9 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick
} }
}); });
AlertDialog dialog = builder.show(); AlertDialog dialog = builder.show();
dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setTextColor(ContextCompat.getColor(getContext(), R.color.active_color_primary_light)); int activeColorPrimaryResId = isLightContent ? R.color.active_color_primary_light : R.color.active_color_primary_dark;
dialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextColor(ContextCompat.getColor(getContext(), R.color.active_color_primary_light)); dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setTextColor(ContextCompat.getColor(getContext(), activeColorPrimaryResId));
dialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextColor(ContextCompat.getColor(getContext(), activeColorPrimaryResId));
} }
@Override @Override