Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1038 dark mode dialog text color issue #1046

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) + "<br><br> <a href=\"https://play.google.com/store/apps/details?id=com.health.openscale.pro\">Install openScale pro version</a>"))
.setPositiveButton(getResources().getString(R.string.label_ok), null)
.setIcon(R.drawable.ic_launcher_openscale_light)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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<CharSequence[], int[]> choices = (Pair<CharSequence[], int[]>)msg.obj;

mBuilder.setTitle(getResources().getString(R.string.info_select_scale_user));
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -356,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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -390,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));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 11 additions & 0 deletions android_app/app/src/main/res/values-night/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@

<style name="AppTheme.Dialog" parent="Theme.MaterialComponents.DayNight.Dialog">
<item name="colorPrimary">@color/md_theme_dark_onBackground</item>
<item name="colorAccent">@color/md_theme_dark_onPrimary</item>
<item name="android:background">@color/md_theme_dark_background</item>
<item name="android:buttonBarNegativeButtonStyle">@style/NegativeButtonStyle</item>
<item name="android:buttonBarPositiveButtonStyle">@style/PositiveButtonStyle</item>
</style>
<style name="NegativeButtonStyle" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
<item name="android:textColor">@color/md_theme_dark_error</item>
</style>

<style name="PositiveButtonStyle" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
<item name="android:textColor">@color/md_theme_dark_onBackground</item>
</style>

<style name="AppTheme.RadioButton" parent="Widget.Material3.CompoundButton.RadioButton">
Expand Down