From bfa5f15ffab0a6b94f11ee837d143b96d443905c Mon Sep 17 00:00:00 2001 From: Nazar Date: Tue, 14 Jan 2020 10:00:48 +0200 Subject: [PATCH] Fix text color, padding and CompoundButton color for a few dialogs --- .../layout/close_measurement_tool_dialog.xml | 3 ++ .../layout/dashboard_settings_dialog_item.xml | 1 + .../show_dashboard_on_start_dialog_item.xml | 1 + OsmAnd/res/layout/waypoint_reached.xml | 2 +- .../DashboardSettingsDialogFragment.java | 31 +++++++++++++------ .../MeasurementToolFragment.java | 8 +++++ 6 files changed, 36 insertions(+), 10 deletions(-) diff --git a/OsmAnd/res/layout/close_measurement_tool_dialog.xml b/OsmAnd/res/layout/close_measurement_tool_dialog.xml index 66d2b6fa42..a115022164 100644 --- a/OsmAnd/res/layout/close_measurement_tool_dialog.xml +++ b/OsmAnd/res/layout/close_measurement_tool_dialog.xml @@ -10,6 +10,9 @@ android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" + android:textColor="?android:textColorPrimary" + android:layout_marginLeft="@dimen/content_padding_small" + android:layout_marginStart="@dimen/content_padding_small" android:text="@string/keep_showing_on_map"/> diff --git a/OsmAnd/res/layout/show_dashboard_on_start_dialog_item.xml b/OsmAnd/res/layout/show_dashboard_on_start_dialog_item.xml index fdc43a96db..0c5a467c10 100644 --- a/OsmAnd/res/layout/show_dashboard_on_start_dialog_item.xml +++ b/OsmAnd/res/layout/show_dashboard_on_start_dialog_item.xml @@ -2,6 +2,7 @@ diff --git a/OsmAnd/res/layout/waypoint_reached.xml b/OsmAnd/res/layout/waypoint_reached.xml index 873a1441a8..f9519ca4be 100644 --- a/OsmAnd/res/layout/waypoint_reached.xml +++ b/OsmAnd/res/layout/waypoint_reached.xml @@ -48,7 +48,7 @@ android:layout_gravity="center_vertical" android:ellipsize="end" android:maxLines="2" - android:textColor="?android:textColorSecondary" + android:textColor="?android:textColorPrimary" android:textSize="@dimen/default_list_text_size" tools:text="Some waypoint text"/> diff --git a/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java index 6b052bf38d..38c918dcef 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java @@ -27,6 +27,7 @@ import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings.CommonPreference; import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.dashboard.DashboardOnMap; @@ -67,7 +68,7 @@ public class DashboardSettingsDialogFragment extends DialogFragment TypedValue typedValue = new TypedValue(); FragmentActivity activity = requireActivity(); OsmandApplication app = (OsmandApplication) activity.getApplication(); - boolean nightMode = app.getDaynightHelper().isNightModeForMapControls(); + boolean nightMode = isNightMode(); context = new ContextThemeWrapper(activity, !nightMode ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme); Theme theme = context.getTheme(); theme.resolveAttribute(android.R.attr.textColorPrimary, typedValue, true); @@ -132,14 +133,13 @@ public class DashboardSettingsDialogFragment extends DialogFragment subtextView.setText(description); final CompoundButton compoundButton = (CompoundButton) view.findViewById(R.id.toggle_item); compoundButton.setChecked(pref.get()); - textView.setTextColor(pref.get() ? textColorPrimary : textColorSecondary); - compoundButton.setOnCheckedChangeListener( - new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton compoundButton, boolean b) { - textView.setTextColor(b ? textColorPrimary : textColorSecondary); - } - }); + view.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + compoundButton.setChecked(!compoundButton.isChecked()); + } + }); + UiUtilities.setupCompoundButton(compoundButton, isNightMode(), UiUtilities.CompoundButtonType.GLOBAL); return view; } @@ -244,6 +244,7 @@ public class DashboardSettingsDialogFragment extends DialogFragment } private class DashViewHolder { + final View view; final TextView textView; final CompoundButton compoundButton; final TextView numberOfRowsTextView; @@ -252,6 +253,7 @@ public class DashboardSettingsDialogFragment extends DialogFragment private DashFragmentAdapter dashFragmentAdapter; public DashViewHolder(DashFragmentAdapter dashFragmentAdapter, View view, Context ctx) { + this.view = view; this.dashFragmentAdapter = dashFragmentAdapter; this.numberOfRowsTextView = (TextView) view.findViewById(R.id.numberOfRowsTextView); this.textView = (TextView) view.findViewById(R.id.text); @@ -277,9 +279,16 @@ public class DashboardSettingsDialogFragment extends DialogFragment textColorSecondary); this.position = position; + view.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + compoundButton.setChecked(!compoundButton.isChecked()); + } + }); compoundButton.setChecked(dashFragmentAdapter.isChecked(position)); compoundButton.setTag(this); compoundButton.setOnCheckedChangeListener(dashFragmentAdapter.onTurnedOnOffListener); + UiUtilities.setupCompoundButton(compoundButton, isNightMode(), UiUtilities.CompoundButtonType.GLOBAL); numberOfRowsTextView.setTag(this); numberOfRowsTextView.setOnClickListener(dashFragmentAdapter.onNumberClickListener); @@ -287,4 +296,8 @@ public class DashboardSettingsDialogFragment extends DialogFragment } + + private boolean isNightMode() { + return mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls(); + } } diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java index 13fdaa5270..ea909bfb72 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java @@ -1512,6 +1512,13 @@ public class MeasurementToolFragment extends BaseOsmAndFragment { final View view = UiUtilities.getInflater(mapActivity, nightMode).inflate(R.layout.close_measurement_tool_dialog, null); final SwitchCompat showOnMapToggle = (SwitchCompat) view.findViewById(R.id.toggle_show_on_map); + view.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + showOnMapToggle.setChecked(!showOnMapToggle.isChecked()); + } + }); + builder.setView(view); builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() { @Override @@ -1531,6 +1538,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment { } } }); + UiUtilities.setupCompoundButton(showOnMapToggle, nightMode, UiUtilities.CompoundButtonType.GLOBAL); } else { builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() { @Override