diff --git a/OsmAnd/res/layout/profile_list_item.xml b/OsmAnd/res/layout/profile_list_item.xml index f8ff9338b3..11fe345e9c 100644 --- a/OsmAnd/res/layout/profile_list_item.xml +++ b/OsmAnd/res/layout/profile_list_item.xml @@ -51,7 +51,7 @@ android:ellipsize="end" android:maxLines="1" android:textSize="@dimen/default_desc_text_size" - android:textColor="@color/description_font_and_bottom_sheet_icons" + android:textColor="?android:textColorSecondary" tools:text="Type: Bicycle" /> diff --git a/OsmAnd/src/net/osmand/plus/profiles/AppModesBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/profiles/AppModesBottomSheetDialogFragment.java index 5f0e08867c..f76ae5d694 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/AppModesBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/profiles/AppModesBottomSheetDialogFragment.java @@ -104,7 +104,7 @@ public class AppModesBottomSheetDialogFragment extends MenuBottomSheetDialogFrag public void createMenuItems(Bundle savedInstanceState) { 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), nightMode); recyclerView = new RecyclerView(getContext()); recyclerView = (RecyclerView) View .inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.recyclerview, null); diff --git a/OsmAnd/src/net/osmand/plus/profiles/ProfileMenuAdapter.java b/OsmAnd/src/net/osmand/plus/profiles/ProfileMenuAdapter.java index 2694227662..4c3e9e7a5d 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/ProfileMenuAdapter.java +++ b/OsmAnd/src/net/osmand/plus/profiles/ProfileMenuAdapter.java @@ -3,9 +3,9 @@ package net.osmand.plus.profiles; import android.support.annotation.ColorRes; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.v7.view.ContextThemeWrapper; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.SwitchCompat; -import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; @@ -41,8 +41,10 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter private String bottomButtonText; private static final String BUTTON_ITEM = "button_item"; + private boolean nightMode; + public ProfileMenuAdapter(List items, Set selectedItems, - OsmandApplication app, String bottomButtonText) { + OsmandApplication app, String bottomButtonText, boolean nightMode) { this.items.addAll(items); if (bottomButton) { this.items.add(BUTTON_ITEM); @@ -51,9 +53,10 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter this.selectedItems = selectedItems; this.bottomButton = !Algorithms.isEmpty(bottomButtonText); this.bottomButtonText = bottomButtonText; - selectedIconColorRes = isNightMode(app) - ? R.color.active_color_primary_dark - : R.color.active_color_primary_light; + this.nightMode = nightMode; + selectedIconColorRes = nightMode + ? R.color.active_color_primary_dark + : R.color.active_color_primary_light; } public List getItems() { @@ -83,8 +86,9 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter @NonNull @Override public ProfileViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - View itemView = - LayoutInflater.from(parent.getContext()).inflate(R.layout.profile_list_item, parent, false); + int themeResId = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; + View itemView = + View.inflate(new ContextThemeWrapper(parent.getContext(), themeResId), R.layout.profile_list_item, null); return new ProfileViewHolder(itemView); } @@ -98,11 +102,6 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter holder.switcher.setVisibility(View.VISIBLE); holder.menuIcon.setVisibility(View.VISIBLE); final ApplicationMode item = (ApplicationMode) obj; - if (bottomButton) { - holder.divider.setBackgroundColor(isNightMode(app) - ? app.getResources().getColor(R.color.divider_color_dark) - : app.getResources().getColor(R.color.divider_color_light)); - } holder.title.setText(item.toHumanString(app)); if (item.isCustomProfile()) { holder.descr.setText(String.format(app.getString(R.string.profile_type_descr_string), @@ -111,10 +110,6 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter holder.descr.setText(R.string.profile_type_base_string); } - holder.title.setTextColor(app.getResources().getColor(isNightMode(app) - ? R.color.text_color_primary_dark - : R.color.text_color_primary_light)); - holder.initSwitcher = true; holder.switcher.setChecked(selectedItems.contains(item)); holder.initSwitcher = false; @@ -129,7 +124,7 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter holder.switcher.setVisibility(View.GONE); holder.menuIcon.setVisibility(View.GONE); holder.title.setTextColor(app.getResources().getColor( - isNightMode(app) + nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light)); holder.title.setText(bottomButtonText); @@ -146,18 +141,14 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter if (iconRes == 0 || iconRes == -1) { iconRes = R.drawable.ic_action_world_globe; } - selectedIconColorRes = mode.getIconColorInfo().getColor(isNightMode(app)); + selectedIconColorRes = mode.getIconColorInfo().getColor(nightMode); if (selectedItems.contains(mode)) { - holder.icon.setImageDrawable(app.getUIUtilities().getIcon(iconRes, mode.getIconColorInfo().getColor(isNightMode(app)))); + holder.icon.setImageDrawable(app.getUIUtilities().getIcon(iconRes, selectedIconColorRes)); } else { holder.icon.setImageDrawable(app.getUIUtilities().getIcon(iconRes, R.color.profile_icon_color_inactive)); } } - private static boolean isNightMode(OsmandApplication ctx) { - return !ctx.getSettings().isLightContent(); - } - class ProfileViewHolder extends RecyclerView.ViewHolder { TextView title, descr; diff --git a/OsmAnd/src/net/osmand/plus/profiles/SettingsProfileFragment.java b/OsmAnd/src/net/osmand/plus/profiles/SettingsProfileFragment.java index 957e0d9e93..74ebc7ed8d 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/SettingsProfileFragment.java +++ b/OsmAnd/src/net/osmand/plus/profiles/SettingsProfileFragment.java @@ -85,7 +85,7 @@ public class SettingsProfileFragment extends BaseOsmAndFragment { } }); - adapter = new ProfileMenuAdapter(allAppModes, availableAppModes, getMyApplication(), null); + adapter = new ProfileMenuAdapter(allAppModes, availableAppModes, getMyApplication(), null, !getMyApplication().getSettings().isLightContent()); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setAdapter(adapter); return view; diff --git a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java index a441e033b9..93f460ce05 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java @@ -163,7 +163,9 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick } 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.setMessage(getResources().getString(R.string.quick_actions_delete_text, itemName)); builder.setIcon(getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_action_delete_dark)); @@ -179,8 +181,9 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick } }); AlertDialog dialog = builder.show(); - dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setTextColor(ContextCompat.getColor(getContext(), R.color.active_color_primary_light)); - dialog.getButton(DialogInterface.BUTTON_POSITIVE).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_NEGATIVE).setTextColor(ContextCompat.getColor(getContext(), activeColorPrimaryResId)); + dialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextColor(ContextCompat.getColor(getContext(), activeColorPrimaryResId)); } @Override