From 2744ca8927743a57146dd3083dc7bba8338eb60b Mon Sep 17 00:00:00 2001 From: Nazar Date: Wed, 19 Feb 2020 13:20:46 +0200 Subject: [PATCH 1/4] Fix text color / Colors refactoring --- ...heet_item_in_frame_with_descr_and_icon.xml | 1 + .../res/layout/download_build_list_item.xml | 2 ++ .../fragment_data_storage_place_dialog.xml | 1 + OsmAnd/res/layout/map_marker_item.xml | 4 +-- OsmAnd/res/layout/map_marker_item_header.xml | 2 ++ OsmAnd/src/net/osmand/AndroidUtils.java | 13 ------- OsmAnd/src/net/osmand/plus/UiUtilities.java | 35 +++++++++++++++++++ .../CoordinateInputDialogFragment.java | 5 +-- .../mapmarkers/MapMarkersDialogFragment.java | 5 +-- .../mapmarkers/MapMarkersGroupsFragment.java | 2 +- .../mapmarkers/MapMarkersHistoryFragment.java | 3 +- ...ptCategoriesBottomSheetDialogFragment.java | 3 ++ .../adapters/MapMarkersActiveAdapter.java | 9 +++-- .../adapters/MapMarkersGroupsAdapter.java | 11 +++--- .../adapters/MapMarkersHistoryAdapter.java | 8 ++--- .../plus/myplaces/TrackPointFragment.java | 3 +- ...electProfileBottomSheetDialogFragment.java | 2 +- .../mapwidgets/MapInfoWidgetsFactory.java | 3 +- .../explore/SavedArticlesRvAdapter.java | 5 ++- 19 files changed, 75 insertions(+), 42 deletions(-) diff --git a/OsmAnd/res/layout/bottom_sheet_item_in_frame_with_descr_and_icon.xml b/OsmAnd/res/layout/bottom_sheet_item_in_frame_with_descr_and_icon.xml index a4748728f0..6e64f26691 100644 --- a/OsmAnd/res/layout/bottom_sheet_item_in_frame_with_descr_and_icon.xml +++ b/OsmAnd/res/layout/bottom_sheet_item_in_frame_with_descr_and_icon.xml @@ -46,6 +46,7 @@ android:ellipsize="end" android:maxLines="2" android:lineSpacingMultiplier="@dimen/text_button_line_spacing_multiplier" + android:textColor="?android:textColorSecondary" android:textSize="@dimen/default_sub_text_size" tools:text="Some description" /> diff --git a/OsmAnd/res/layout/download_build_list_item.xml b/OsmAnd/res/layout/download_build_list_item.xml index c1d1d8f783..75171d28c9 100644 --- a/OsmAnd/res/layout/download_build_list_item.xml +++ b/OsmAnd/res/layout/download_build_list_item.xml @@ -13,6 +13,7 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" + android:textColor="?android:textColorPrimary" android:textSize="@dimen/default_list_text_size"/> diff --git a/OsmAnd/res/layout/fragment_data_storage_place_dialog.xml b/OsmAnd/res/layout/fragment_data_storage_place_dialog.xml index d0d9d30d29..c62ee0a14a 100644 --- a/OsmAnd/res/layout/fragment_data_storage_place_dialog.xml +++ b/OsmAnd/res/layout/fragment_data_storage_place_dialog.xml @@ -64,6 +64,7 @@ android:layout_gravity="fill_horizontal" android:layout_marginBottom="24dp" android:layout_marginTop="4dp" + android:textColor="?android:textColorSecondary" android:text="@string/application_dir_description" android:textSize="16sp"/> diff --git a/OsmAnd/res/layout/map_marker_item.xml b/OsmAnd/res/layout/map_marker_item.xml index 0ad46644e0..1bb0b74cb4 100644 --- a/OsmAnd/res/layout/map_marker_item.xml +++ b/OsmAnd/res/layout/map_marker_item.xml @@ -74,7 +74,7 @@ android:layout_marginLeft="6dp" android:drawablePadding="2dp" android:maxLines="1" - android:textColor="@color/text_color_secondary_dark" + android:textColor="?android:textColorSecondary" android:textSize="@dimen/default_sub_text_size"/> Build.VERSION_CODES.LOLLIPOP) { diff --git a/OsmAnd/src/net/osmand/plus/UiUtilities.java b/OsmAnd/src/net/osmand/plus/UiUtilities.java index 8ac7996f92..a8c08752ba 100644 --- a/OsmAnd/src/net/osmand/plus/UiUtilities.java +++ b/OsmAnd/src/net/osmand/plus/UiUtilities.java @@ -15,6 +15,7 @@ import android.support.annotation.ColorInt; import android.support.annotation.ColorRes; import android.support.annotation.DrawableRes; import android.support.annotation.StringRes; +import android.support.design.widget.Snackbar; import android.support.v4.content.ContextCompat; import android.support.v4.graphics.drawable.DrawableCompat; import android.support.v4.text.TextUtilsCompat; @@ -343,6 +344,40 @@ public class UiUtilities { return screenOrientation; } + public static void setupSnackbar(Snackbar snackbar, boolean nightMode) { + setupSnackbar(snackbar, nightMode, null, null, null, null); + } + + public static void setupSnackbar(Snackbar snackbar, boolean nightMode, Integer maxLines) { + setupSnackbar(snackbar, nightMode, null, null, null, maxLines); + } + + public static void setupSnackbar(Snackbar snackbar, boolean nightMode, @ColorRes Integer backgroundColor, + @ColorRes Integer messageColor, @ColorRes Integer actionColor, Integer maxLines) { + if (snackbar == null) { + return; + } + View view = snackbar.getView(); + Context ctx = view.getContext(); + TextView tvMessage = (TextView) view.findViewById(android.support.design.R.id.snackbar_text); + TextView tvAction = (TextView) view.findViewById(android.support.design.R.id.snackbar_action); + if (messageColor == null) { + messageColor = nightMode ? R.color.text_color_primary_dark : R.color.text_color_primary_light; + } + tvMessage.setTextColor(ContextCompat.getColor(ctx, messageColor)); + if (actionColor == null) { + actionColor = nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light; + } + tvAction.setTextColor(ContextCompat.getColor(ctx, actionColor)); + if (maxLines != null) { + tvMessage.setMaxLines(maxLines); + } + if (backgroundColor == null) { + backgroundColor = nightMode ? R.color.list_background_color_dark : R.color.list_background_color_light; + } + view.setBackgroundColor(ContextCompat.getColor(ctx, backgroundColor)); + } + public static void setupLayoutDirection(View layout) { Context ctx = layout.getContext(); Locale currentLocale = ctx.getResources().getConfiguration().locale; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java index acaceda8a7..3ed13c1ffd 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java @@ -65,6 +65,7 @@ import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; import net.osmand.plus.Version; import net.osmand.plus.activities.SavingTrackHelper; import net.osmand.plus.activities.TrackActivity; @@ -1092,7 +1093,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm startActivity(intent); } }); - AndroidUtils.setSnackbarTextColor(snackbar, R.color.active_color_primary_dark); + UiUtilities.setupSnackbar(snackbar, !lightTheme); snackbar.show(); } }; @@ -1119,7 +1120,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm adapter.notifyDataSetChanged(); } }); - AndroidUtils.setSnackbarTextColor(snackbar, R.color.active_color_primary_dark); + UiUtilities.setupSnackbar(snackbar, !lightTheme); snackbar.show(); } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java index ff628d377e..0caa56c355 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java @@ -33,6 +33,7 @@ import net.osmand.plus.MapMarkersHelper.OnGroupSyncedListener; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.mapmarkers.CoordinateInputDialogFragment.OnPointsSavedListener; @@ -449,7 +450,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm } } }); - AndroidUtils.setSnackbarTextColor(snackbar, R.color.active_color_primary_dark); + UiUtilities.setupSnackbar(snackbar, !lightTheme); snackbar.show(); } } @@ -494,7 +495,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm startActivity(intent); } }); - AndroidUtils.setSnackbarTextColor(snackbar, R.color.active_color_primary_dark); + UiUtilities.setupSnackbar(snackbar, !lightTheme); snackbar.show(); } }; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java index 1ed6666726..f176c016c2 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java @@ -207,7 +207,7 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL updateAdapter(); } }); - AndroidUtils.setSnackbarTextColor(snackbar, R.color.active_color_primary_dark); + UiUtilities.setupSnackbar(snackbar, night); snackbar.show(); } } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java index 260efd704d..5729e38bbf 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java @@ -171,8 +171,7 @@ public class MapMarkersHistoryFragment extends Fragment implements MapMarkersHel } } }); - AndroidUtils.setSnackbarTextColor(snackbar, night ? R.color.active_color_primary_dark : R.color.active_color_primary_light); - snackbar.getView().setBackgroundColor(ContextCompat.getColor(app, night ? R.color.list_background_color_dark : R.color.list_background_color_light)); + UiUtilities.setupSnackbar(snackbar, night); snackbar.show(); } } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/SelectWptCategoriesBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/SelectWptCategoriesBottomSheetDialogFragment.java index df26ab2561..83f23ac7e9 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/SelectWptCategoriesBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/SelectWptCategoriesBottomSheetDialogFragment.java @@ -48,6 +48,7 @@ public class SelectWptCategoriesBottomSheetDialogFragment extends MenuBottomShee if (gpxFile == null) { return; } + int activeColorResId = nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light; isUpdateMode = getArguments().getBoolean(UPDATE_CATEGORIES_KEY); List categories = getArguments().getStringArrayList(ACTIVE_CATEGORIES_KEY); @@ -58,6 +59,7 @@ public class SelectWptCategoriesBottomSheetDialogFragment extends MenuBottomShee final BottomSheetItemWithCompoundButton[] selectAllItem = new BottomSheetItemWithCompoundButton[1]; selectAllItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() .setChecked(!isUpdateMode || categories!=null&&categories.size() == gpxFile.getPointsByCategories().size()) + .setCompoundButtonColorId(activeColorResId) .setDescription(getString(R.string.shared_string_total) + ": " + gpxFile.getPoints().size()) .setIcon(getContentIcon(R.drawable.ic_action_group_select_all)) .setTitle(getString(R.string.shared_string_select_all)) @@ -93,6 +95,7 @@ public class SelectWptCategoriesBottomSheetDialogFragment extends MenuBottomShee } } }) + .setCompoundButtonColorId(activeColorResId) .setDescription(String.valueOf(pointsByCategories.get(category).size())) .setIcon(getContentIcon(R.drawable.ic_action_folder)) .setTitle(category.equals("") ? getString(R.string.shared_string_waypoints) : category) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java index 37c41b14cd..3d487e3831 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java @@ -74,6 +74,7 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter Date: Wed, 19 Feb 2020 13:40:32 +0200 Subject: [PATCH 2/4] Fix text color of list items from "Builds" screen --- OsmAnd/res/layout/download_build_list_item.xml | 2 -- .../net/osmand/plus/activities/ContributionVersionActivity.java | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/OsmAnd/res/layout/download_build_list_item.xml b/OsmAnd/res/layout/download_build_list_item.xml index 75171d28c9..c1d1d8f783 100644 --- a/OsmAnd/res/layout/download_build_list_item.xml +++ b/OsmAnd/res/layout/download_build_list_item.xml @@ -13,7 +13,6 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" - android:textColor="?android:textColorPrimary" android:textSize="@dimen/default_list_text_size"/> diff --git a/OsmAnd/src/net/osmand/plus/activities/ContributionVersionActivity.java b/OsmAnd/src/net/osmand/plus/activities/ContributionVersionActivity.java index 6cbdf7641d..7dde1b05c7 100644 --- a/OsmAnd/src/net/osmand/plus/activities/ContributionVersionActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/ContributionVersionActivity.java @@ -264,7 +264,7 @@ public class ContributionVersionActivity extends OsmandListActivity { StringBuilder format = new StringBuilder(); format.append(AndroidUtils.formatDateTime(getMyApplication(), build.date.getTime()))/*.append(" : ").append(build.size).append(" MB")*/; description.setText(format.toString()); - int color = getResources().getColor(R.color.color_unknown); + int color = getResources().getColor(R.color.text_color_secondary_dark); if (currentInstalledDate != null) { if (currentInstalledDate.before(build.date)) { color = getResources().getColor(R.color.color_update); From b0fd81cf9f812b05c1dd648ee8550e4bdcccf107 Mon Sep 17 00:00:00 2001 From: Nazar Date: Wed, 19 Feb 2020 14:11:08 +0200 Subject: [PATCH 3/4] Fix text color of "Searching for the corresponding of wiki article" progress dialog --- .../src/net/osmand/plus/wikipedia/WikiArticleHelper.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleHelper.java b/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleHelper.java index ef96f89671..2857330a82 100644 --- a/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleHelper.java @@ -11,6 +11,7 @@ import android.support.annotation.Nullable; import android.support.v4.app.FragmentActivity; import android.text.Html; import android.util.Log; +import android.view.ContextThemeWrapper; import net.osmand.IndexConstants; import net.osmand.ResultMatcher; @@ -86,7 +87,7 @@ public class WikiArticleHelper { activityRef = new WeakReference<>(activity); this.isNightMode = nightMode; this.url = url; - dialog = createProgressDialog(activity); + dialog = createProgressDialog(activity, isNightMode); } @Override @@ -215,9 +216,9 @@ public class WikiArticleHelper { return ""; } - private static ProgressDialog createProgressDialog(@NonNull FragmentActivity activity) { + private static ProgressDialog createProgressDialog(@NonNull FragmentActivity activity, boolean nightMode) { if (activity != null) { - ProgressDialog dialog = new ProgressDialog(activity); + ProgressDialog dialog = new ProgressDialog(new ContextThemeWrapper(activity, nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme)); dialog.setCancelable(false); dialog.setMessage(activity.getString(R.string.wiki_article_search_text)); return dialog; From 816986be7a49ce3d6ecf4381b7e05f0ec11454dc Mon Sep 17 00:00:00 2001 From: Nazar Date: Wed, 19 Feb 2020 14:52:00 +0200 Subject: [PATCH 4/4] Fix text color of purchase dialog --- OsmAnd/res/layout/purchase_dialog_card.xml | 2 +- OsmAnd/res/layout/purchase_dialog_card_button_active_ex.xml | 4 ++-- OsmAnd/res/layout/purchase_dialog_card_button_ex.xml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/OsmAnd/res/layout/purchase_dialog_card.xml b/OsmAnd/res/layout/purchase_dialog_card.xml index 2dde98ac32..3e03867225 100644 --- a/OsmAnd/res/layout/purchase_dialog_card.xml +++ b/OsmAnd/res/layout/purchase_dialog_card.xml @@ -32,7 +32,7 @@ android:layout_marginRight="@dimen/list_content_padding_large" android:layout_marginTop="@dimen/list_header_padding" android:gravity="center" - android:textColor="?attr/card_description_text_color" + android:textColor="?attr/dialog_text_description_color" android:textSize="@dimen/default_desc_text_size" osmand:typeface="@string/font_roboto_regular" tools:text="@string/osm_live_payment_desc"/> diff --git a/OsmAnd/res/layout/purchase_dialog_card_button_active_ex.xml b/OsmAnd/res/layout/purchase_dialog_card_button_active_ex.xml index 4d1b662dc3..15ac723740 100644 --- a/OsmAnd/res/layout/purchase_dialog_card_button_active_ex.xml +++ b/OsmAnd/res/layout/purchase_dialog_card_button_active_ex.xml @@ -46,7 +46,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/osm_live_payment_contribute_descr" - android:textColor="?attr/card_description_text_color" + android:textColor="?attr/dialog_text_description_color" android:textSize="@dimen/default_desc_text_size" android:visibility="gone" osmand:typeface="@string/font_roboto_regular" @@ -56,7 +56,7 @@ android:id="@+id/description" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:textColor="?attr/card_description_text_color" + android:textColor="?attr/dialog_text_description_color" android:textSize="@dimen/default_desc_text_size" osmand:typeface="@string/font_roboto_regular" tools:text="Monthly payment" /> diff --git a/OsmAnd/res/layout/purchase_dialog_card_button_ex.xml b/OsmAnd/res/layout/purchase_dialog_card_button_ex.xml index 05465c67db..4af46efd8b 100644 --- a/OsmAnd/res/layout/purchase_dialog_card_button_ex.xml +++ b/OsmAnd/res/layout/purchase_dialog_card_button_ex.xml @@ -38,7 +38,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/osm_live_payment_contribute_descr" - android:textColor="?attr/card_description_text_color" + android:textColor="?attr/dialog_text_description_color" android:textSize="@dimen/default_desc_text_size" android:visibility="gone" osmand:typeface="@string/font_roboto_regular" @@ -48,7 +48,7 @@ android:id="@+id/description" android:layout_width="match_parent" android:layout_height="wrap_content" - android:textColor="?attr/card_description_text_color" + android:textColor="?attr/dialog_text_description_color" android:textSize="@dimen/default_desc_text_size" osmand:typeface="@string/font_roboto_regular" tools:text="$0.62 / month • Save 68%" />