From 660fe3b42d0ad41eb148d6b9932287a457743aa8 Mon Sep 17 00:00:00 2001 From: crvdgc Date: Mon, 6 May 2024 09:46:06 +0100 Subject: [PATCH 1/3] fix user settings button color in dark mode --- .../openscale/gui/preferences/UserSettingsFragment.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/android_app/app/src/main/java/com/health/openscale/gui/preferences/UserSettingsFragment.java b/android_app/app/src/main/java/com/health/openscale/gui/preferences/UserSettingsFragment.java index e07e21674..6d966f700 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/preferences/UserSettingsFragment.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/preferences/UserSettingsFragment.java @@ -48,6 +48,7 @@ import com.health.openscale.core.OpenScale; import com.health.openscale.core.datatypes.ScaleUser; import com.health.openscale.core.utils.Converters; +import com.health.openscale.gui.utils.ColorUtil; import java.text.DateFormat; import java.util.Calendar; @@ -105,9 +106,9 @@ public void onCreateMenu(@NonNull Menu menu, @NonNull MenuInflater menuInflater) final Drawable wrapped = DrawableCompat.wrap(drawable.mutate()); if (item.getItemId() == R.id.saveButton) { - DrawableCompat.setTint(wrapped, Color.parseColor("#FFFFFF")); + DrawableCompat.setTint(wrapped, ColorUtil.getPrimaryColor(context)); } else if (item.getItemId() == R.id.deleteButton) { - DrawableCompat.setTint(wrapped, Color.parseColor("#FF4444")); + DrawableCompat.setTint(wrapped, ColorUtil.getTintColor(context)); } item.setIcon(wrapped); From 4f351665502be94fa054180b371ec1dfc44af38d Mon Sep 17 00:00:00 2001 From: crvdgc Date: Mon, 6 May 2024 09:55:17 +0100 Subject: [PATCH 2/3] fix measurement fragment text color in dark mode --- .../gui/measurement/MeasurementEntryFragment.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/android_app/app/src/main/java/com/health/openscale/gui/measurement/MeasurementEntryFragment.java b/android_app/app/src/main/java/com/health/openscale/gui/measurement/MeasurementEntryFragment.java index eb6ef489f..66eb5645a 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/measurement/MeasurementEntryFragment.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/measurement/MeasurementEntryFragment.java @@ -42,6 +42,7 @@ import com.health.openscale.R; import com.health.openscale.core.OpenScale; import com.health.openscale.core.datatypes.ScaleMeasurement; +import com.health.openscale.gui.utils.ColorUtil; import java.text.DateFormat; import java.util.Date; @@ -159,13 +160,13 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { final Drawable wrapped = DrawableCompat.wrap(drawable.mutate()); if (item.getItemId() == R.id.saveButton) { - DrawableCompat.setTint(wrapped, Color.parseColor("#FFFFFF")); + DrawableCompat.setTint(wrapped, ColorUtil.getPrimaryColor(context)); } else if (item.getItemId() == R.id.editButton) { - DrawableCompat.setTint(wrapped, Color.parseColor("#99CC00")); + DrawableCompat.setTint(wrapped, ColorUtil.COLOR_GREEN); } else if (item.getItemId() == R.id.expandButton) { - DrawableCompat.setTint(wrapped, Color.parseColor("#FFBB33")); + DrawableCompat.setTint(wrapped, ColorUtil.COLOR_ORANGE); } else if (item.getItemId() == R.id.deleteButton) { - DrawableCompat.setTint(wrapped, Color.parseColor("#FF4444")); + DrawableCompat.setTint(wrapped, ColorUtil.COLOR_RED); } item.setIcon(wrapped); From 706e8518f232dda6898b514822edcab5a87fc312 Mon Sep 17 00:00:00 2001 From: crvdgc Date: Mon, 6 May 2024 11:17:39 +0100 Subject: [PATCH 3/3] fix AlertDialog dark mode text color --- .../health/openscale/gui/MainActivity.java | 26 +++++++++---------- .../openscale/gui/graph/GraphFragment.java | 2 +- .../measurement/MeasurementEntryFragment.java | 2 +- .../gui/overview/OverviewAdapter.java | 2 +- .../BluetoothSettingsFragment.java | 8 +++--- .../preferences/MeasurementPreferences.java | 2 +- .../gui/preferences/ReminderPreferences.java | 4 +-- .../gui/preferences/UserSettingsFragment.java | 2 +- .../gui/statistic/StatisticsFragment.java | 2 +- .../app/src/main/res/values-night/themes.xml | 11 ++++++++ 10 files changed, 36 insertions(+), 25 deletions(-) diff --git a/android_app/app/src/main/java/com/health/openscale/gui/MainActivity.java b/android_app/app/src/main/java/com/health/openscale/gui/MainActivity.java index 6e57cc35b..51b5e1ca6 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/MainActivity.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/MainActivity.java @@ -273,7 +273,7 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) { // ask the user once for feedback on the 15th app launch if(launchCount == 15){ - AlertDialog.Builder builder = new AlertDialog.Builder(this); + AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppTheme_Dialog); builder.setMessage(R.string.label_feedback_message_enjoying) .setPositiveButton(R.string.label_feedback_message_yes, new DialogInterface.OnClickListener() { @@ -324,7 +324,7 @@ public void onSharedPreferenceChanged(SharedPreferences preferences, String key) } private void positiveFeedbackDialog() { - AlertDialog.Builder builder = new AlertDialog.Builder(this); + AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppTheme_Dialog); builder.setMessage(R.string.label_feedback_message_rate_app) .setPositiveButton(R.string.label_feedback_message_positive, new DialogInterface.OnClickListener() { @@ -355,7 +355,7 @@ public void onClick(DialogInterface dialog, int id) { } private void negativeFeedbackDialog() { - AlertDialog.Builder builder = new AlertDialog.Builder(this); + AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppTheme_Dialog); builder.setMessage(R.string.label_feedback_message_issue) .setPositiveButton(R.string.label_feedback_message_positive, new DialogInterface.OnClickListener() { @@ -375,7 +375,7 @@ public void onClick(DialogInterface dialog, int id) { } private void showNoSelectedUserDialog() { - AlertDialog.Builder infoDialog = new AlertDialog.Builder(this); + AlertDialog.Builder infoDialog = new AlertDialog.Builder(this, R.style.AppTheme_Dialog); infoDialog.setMessage(getResources().getString(R.string.info_no_selected_user)); infoDialog.setPositiveButton(getResources().getString(R.string.label_ok), null); @@ -435,7 +435,7 @@ public boolean onOptionsItemSelected(MenuItem item) { } private void showAssistedWeighingDialog(boolean manuelEntry) { - AlertDialog.Builder builder = new AlertDialog.Builder(this); + AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppTheme_Dialog); LinearLayout linearLayout = new LinearLayout(this); linearLayout.setOrientation(LinearLayout.VERTICAL); @@ -556,7 +556,7 @@ else if (firstAppStart && prefs.getBoolean("btEnable", false)) { private void invokeConnectToBluetoothDevice() { if (BuildConfig.BUILD_TYPE == "light") { - AlertDialog infoDialog = new AlertDialog.Builder(this) + AlertDialog infoDialog = new AlertDialog.Builder(this, R.style.AppTheme_Dialog) .setMessage(Html.fromHtml(getResources().getString(R.string.label_upgrade_to_openScale_pro) + "

Install openScale pro version")) .setPositiveButton(getResources().getString(R.string.label_ok), null) .setIcon(R.drawable.ic_launcher_openscale_light) @@ -605,7 +605,7 @@ private void invokeConnectToBluetoothDevice() { if (!(locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER) || locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER))) { Timber.d("No GPS or Network location service is enabled, ask user for permission"); - AlertDialog.Builder builder = new AlertDialog.Builder(this); + AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppTheme_Dialog); builder.setTitle(R.string.permission_bluetooth_info_title); builder.setIcon(R.drawable.ic_preferences_about); builder.setMessage(R.string.permission_location_service_info); @@ -652,7 +652,7 @@ public void onClick(DialogInterface dialogInterface, int i) { if (hasPermissions(requiredPermissions)) { connectToBluetooth(); } else if (shouldShowRequestPermissionRationale(Manifest.permission.ACCESS_FINE_LOCATION)) { - AlertDialog.Builder builder = new AlertDialog.Builder(this); + AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppTheme_Dialog); Timber.d("No access fine location permission granted"); builder.setMessage(R.string.permission_bluetooth_info) @@ -669,7 +669,7 @@ public void onClick(DialogInterface dialog, int id) { alertDialog.setCanceledOnTouchOutside(false); alertDialog.show(); } else if (shouldShowRequestPermissionRationale(Manifest.permission.BLUETOOTH_SCAN)) { - AlertDialog.Builder builder = new AlertDialog.Builder(this); + AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppTheme_Dialog); Timber.d("No access Bluetooth scan permission granted"); builder.setMessage(R.string.permission_bluetooth_info) @@ -782,7 +782,7 @@ public void handleMessage(Message msg) { }; private void chooseScaleUser(Message msg) { - AlertDialog.Builder mBuilder = new AlertDialog.Builder(MainActivity.this); + AlertDialog.Builder mBuilder = new AlertDialog.Builder(MainActivity.this, R.style.AppTheme_Dialog); Pair choices = (Pair)msg.obj; mBuilder.setTitle(getResources().getString(R.string.info_select_scale_user)); @@ -808,7 +808,7 @@ private void enterScaleUserConsent(Message msg) { final int scaleUserIndex = msg.arg2; final int[] consentCode = {-1}; - AlertDialog.Builder mBuilder = new AlertDialog.Builder(MainActivity.this); + AlertDialog.Builder mBuilder = new AlertDialog.Builder(MainActivity.this, R.style.AppTheme_Dialog); mBuilder.setTitle(getResources().getString(R.string.info_enter_consent_code_for_scale_user, Integer.toString(scaleUserIndex))); final EditText input = new EditText(this); @@ -866,7 +866,7 @@ private void importCsvFile() { int selectedUserId = OpenScale.getInstance().getSelectedScaleUserId(); if (selectedUserId == -1) { - AlertDialog.Builder infoDialog = new AlertDialog.Builder(this); + AlertDialog.Builder infoDialog = new AlertDialog.Builder(this, R.style.AppTheme_Dialog); infoDialog.setMessage(getResources().getString(R.string.info_no_selected_user)); infoDialog.setPositiveButton(getResources().getString(R.string.label_ok), null); @@ -938,7 +938,7 @@ private void exportCsvFile() { return; } - AlertDialog.Builder exportDialog = new AlertDialog.Builder(this); + AlertDialog.Builder exportDialog = new AlertDialog.Builder(this, R.style.AppTheme_Dialog); exportDialog.setTitle(R.string.label_export); exportDialog.setMessage(getResources().getString(R.string.label_export_overwrite, openScale.getFilenameFromUri(uri))); diff --git a/android_app/app/src/main/java/com/health/openscale/gui/graph/GraphFragment.java b/android_app/app/src/main/java/com/health/openscale/gui/graph/GraphFragment.java index 43464d9c5..61896d702 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/graph/GraphFragment.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/graph/GraphFragment.java @@ -437,7 +437,7 @@ private void deleteMeasurement() { boolean deleteConfirmationEnable = prefs.getBoolean("deleteConfirmationEnable", true); if (deleteConfirmationEnable) { - AlertDialog.Builder deleteAllDialog = new AlertDialog.Builder(graphView.getContext()); + AlertDialog.Builder deleteAllDialog = new AlertDialog.Builder(graphView.getContext(), R.style.AppTheme_Dialog); deleteAllDialog.setMessage(getResources().getString(R.string.question_really_delete)); deleteAllDialog.setPositiveButton(getResources().getString(R.string.label_yes), new DialogInterface.OnClickListener() { diff --git a/android_app/app/src/main/java/com/health/openscale/gui/measurement/MeasurementEntryFragment.java b/android_app/app/src/main/java/com/health/openscale/gui/measurement/MeasurementEntryFragment.java index 66eb5645a..e63fc896f 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/measurement/MeasurementEntryFragment.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/measurement/MeasurementEntryFragment.java @@ -357,7 +357,7 @@ private void deleteMeasurement() { boolean deleteConfirmationEnable = prefs.getBoolean("deleteConfirmationEnable", true); if (deleteConfirmationEnable) { - AlertDialog.Builder deleteAllDialog = new AlertDialog.Builder(context); + AlertDialog.Builder deleteAllDialog = new AlertDialog.Builder(context, R.style.AppTheme_Dialog); deleteAllDialog.setMessage(getResources().getString(R.string.question_really_delete)); deleteAllDialog.setPositiveButton(getResources().getString(R.string.label_yes), new DialogInterface.OnClickListener() { diff --git a/android_app/app/src/main/java/com/health/openscale/gui/overview/OverviewAdapter.java b/android_app/app/src/main/java/com/health/openscale/gui/overview/OverviewAdapter.java index 80256bfe4..735113b02 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/overview/OverviewAdapter.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/overview/OverviewAdapter.java @@ -62,7 +62,7 @@ private void deleteMeasurement(int measurementId) { boolean deleteConfirmationEnable = prefs.getBoolean("deleteConfirmationEnable", true); if (deleteConfirmationEnable) { - AlertDialog.Builder deleteAllDialog = new AlertDialog.Builder(activity); + AlertDialog.Builder deleteAllDialog = new AlertDialog.Builder(activity, R.style.AppTheme_Dialog); deleteAllDialog.setMessage(activity.getResources().getString(R.string.question_really_delete)); deleteAllDialog.setPositiveButton(activity.getResources().getString(R.string.label_yes), new DialogInterface.OnClickListener() { diff --git a/android_app/app/src/main/java/com/health/openscale/gui/preferences/BluetoothSettingsFragment.java b/android_app/app/src/main/java/com/health/openscale/gui/preferences/BluetoothSettingsFragment.java index 20fbe7aa6..7ec56284a 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/preferences/BluetoothSettingsFragment.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/preferences/BluetoothSettingsFragment.java @@ -142,7 +142,7 @@ public void onResume() { if (!(locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER) || locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER))) { Timber.d("No GPS or Network location service is enabled, ask user for permission"); - AlertDialog.Builder builder = new AlertDialog.Builder(context); + AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.AppTheme_Dialog); builder.setTitle(R.string.permission_bluetooth_info_title); builder.setIcon(R.drawable.ic_preferences_about); builder.setMessage(R.string.permission_location_service_info); @@ -182,7 +182,7 @@ public void onClick(DialogInterface dialogInterface, int i) { if (hasPermissions(requiredPermissions)) { startBluetoothDiscovery(); } else if (shouldShowRequestPermissionRationale(Manifest.permission.ACCESS_FINE_LOCATION)) { - AlertDialog.Builder builder = new AlertDialog.Builder(context); + AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.AppTheme_Dialog); Timber.d("No access fine location permission granted"); builder.setMessage(R.string.permission_bluetooth_info) @@ -200,7 +200,7 @@ public void onClick(DialogInterface dialog, int id) { alertDialog.show(); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && targetSdkVersion >= Build.VERSION_CODES.S && shouldShowRequestPermissionRationale(Manifest.permission.BLUETOOTH_SCAN)) { - AlertDialog.Builder builder = new AlertDialog.Builder(context); + AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.AppTheme_Dialog); Timber.d("No access Bluetooth scan permission granted"); builder.setMessage(R.string.permission_bluetooth_info) @@ -352,7 +352,7 @@ public void onClick(View view) { } private void getDebugInfo(final BluetoothDevice device) { - AlertDialog.Builder builder = new AlertDialog.Builder(requireContext()); + AlertDialog.Builder builder = new AlertDialog.Builder(requireContext(), R.style.AppTheme_Dialog); builder.setTitle("Fetching info") .setMessage("Please wait while we fetch extended info from your scale...") .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { diff --git a/android_app/app/src/main/java/com/health/openscale/gui/preferences/MeasurementPreferences.java b/android_app/app/src/main/java/com/health/openscale/gui/preferences/MeasurementPreferences.java index 7e6a09c25..572a05bc6 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/preferences/MeasurementPreferences.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/preferences/MeasurementPreferences.java @@ -102,7 +102,7 @@ private class onClickListenerDeleteAll implements Preference.OnPreferenceClickLi @Override public boolean onPreferenceClick(Preference preference) { - AlertDialog.Builder deleteAllDialog = new AlertDialog.Builder(getActivity()); + AlertDialog.Builder deleteAllDialog = new AlertDialog.Builder(getActivity(), R.style.AppTheme_Dialog); deleteAllDialog.setMessage(getResources().getString(R.string.question_really_delete_all)); diff --git a/android_app/app/src/main/java/com/health/openscale/gui/preferences/ReminderPreferences.java b/android_app/app/src/main/java/com/health/openscale/gui/preferences/ReminderPreferences.java index 42be67296..afa6fea8f 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/preferences/ReminderPreferences.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/preferences/ReminderPreferences.java @@ -165,7 +165,7 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { if (!isGranted) { if (Build.VERSION.SDK_INT >= 33) { if (shouldShowRequestPermissionRationale(android.Manifest.permission.POST_NOTIFICATIONS)) { - AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); + AlertDialog.Builder builder = new AlertDialog.Builder(getContext(), R.style.AppTheme_Dialog); builder.setTitle(R.string.permission_bluetooth_info_title); builder.setIcon(R.drawable.ic_preferences_about); builder.setMessage(R.string.permission_notification_info); @@ -179,7 +179,7 @@ public void onClick(DialogInterface dialogInterface, int i) { alertDialog.setCanceledOnTouchOutside(false); alertDialog.show(); } else { - AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); + AlertDialog.Builder builder = new AlertDialog.Builder(getContext(), R.style.AppTheme_Dialog); builder.setTitle(R.string.permission_bluetooth_info_title); builder.setIcon(R.drawable.ic_preferences_about); builder.setMessage(R.string.permission_notification_info); diff --git a/android_app/app/src/main/java/com/health/openscale/gui/preferences/UserSettingsFragment.java b/android_app/app/src/main/java/com/health/openscale/gui/preferences/UserSettingsFragment.java index 6d966f700..8eb666177 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/preferences/UserSettingsFragment.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/preferences/UserSettingsFragment.java @@ -391,7 +391,7 @@ public void onPositiveButtonClick(Long selection) { }; private void deleteUser() { - AlertDialog.Builder deleteAllDialog = new AlertDialog.Builder(context); + AlertDialog.Builder deleteAllDialog = new AlertDialog.Builder(context, R.style.AppTheme_Dialog); deleteAllDialog.setMessage(getResources().getString(R.string.question_really_delete_user)); diff --git a/android_app/app/src/main/java/com/health/openscale/gui/statistic/StatisticsFragment.java b/android_app/app/src/main/java/com/health/openscale/gui/statistic/StatisticsFragment.java index e6fe5c650..45ec4819d 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/statistic/StatisticsFragment.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/statistic/StatisticsFragment.java @@ -74,7 +74,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa datePickerView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.AppTheme_Dialog); builder.setTitle(R.string.label_time_period) .setItems(R.array.range_options_entries, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { diff --git a/android_app/app/src/main/res/values-night/themes.xml b/android_app/app/src/main/res/values-night/themes.xml index a988d38aa..c420f83c2 100644 --- a/android_app/app/src/main/res/values-night/themes.xml +++ b/android_app/app/src/main/res/values-night/themes.xml @@ -37,6 +37,17 @@ + + +