Skip to content

Commit

Permalink
fix: Use more generic message
Browse files Browse the repository at this point in the history
  • Loading branch information
LisoUseInAIKyrios committed Dec 10, 2024
1 parent 590f242 commit c4e6d75
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ private static void open(String queryOrLink) {
}

private static void showBatteryOptimizationDialog(Activity context,
String dialogMessage,
String positiveButtonText,
String dialogMessageRef,
String positiveButtonTextRef,
DialogInterface.OnClickListener onPositiveClickListener) {
// Use a delay to allow the activity to finish initializing.
// Otherwise, if device is in dark mode the dialog is shown with wrong color scheme.
Expand All @@ -63,8 +63,8 @@ private static void showBatteryOptimizationDialog(Activity context,
// just in case the battery change can never be satisfied.
var dialog = new AlertDialog.Builder(context)
.setTitle(str("gms_core_dialog_title"))
.setMessage(dialogMessage)
.setPositiveButton(positiveButtonText, onPositiveClickListener)
.setMessage(str(dialogMessageRef))
.setPositiveButton(str(positiveButtonTextRef), onPositiveClickListener)
.create();
Utils.showDialog(context, dialog);
}, 100);
Expand Down Expand Up @@ -109,13 +109,9 @@ public static void checkGmsCore(Activity context) {
if (batteryOptimizationsEnabled(context)) {
Logger.printInfo(() -> "GmsCore is not whitelisted from battery optimizations");

String message = str(
"gms_core_dialog_not_whitelisted_using_battery_optimizations_message",
Utils.getApplicationName()
);
showBatteryOptimizationDialog(context,
message,
str("gms_core_dialog_continue_text"),
"gms_core_dialog_not_whitelisted_using_battery_optimizations_message",
"gms_core_dialog_continue_text",
(dialog, id) -> openGmsCoreDisableBatteryOptimizationsIntent(context));
return;
}
Expand All @@ -126,8 +122,8 @@ public static void checkGmsCore(Activity context) {
Logger.printInfo(() -> "GmsCore is not running in the background");

showBatteryOptimizationDialog(context,
str("gms_core_dialog_not_whitelisted_not_allowed_in_background_message"),
str("gms_core_dialog_open_website_text"),
"gms_core_dialog_not_whitelisted_not_allowed_in_background_message",
"gms_core_dialog_open_website_text",
(dialog, id) -> open(DONT_KILL_MY_APP_LINK));
}
}
Expand Down
2 changes: 1 addition & 1 deletion patches/src/main/resources/addresources/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ This is because Crowdin requires temporarily flattening this file and removing t
<string name="gms_core_dialog_title">Action needed</string>
<string name="gms_core_dialog_not_whitelisted_not_allowed_in_background_message">MicroG GmsCore does not have permission to run in the background.\n\nFollow the \"Don\'t kill my app\" guide for your phone, and apply the instructions to your MicroG installation.\n\nThis is required for the app to work.</string>
<string name="gms_core_dialog_open_website_text">Open website</string>
<string name="gms_core_dialog_not_whitelisted_using_battery_optimizations_message">MicroG GmsCore battery optimizations must be disabled to prevent issues.\n\nDisabling battery optimizations for MicroG will not change the battery usage of %s.\n\nTap the continue button and allow optimization changes.</string>
<string name="gms_core_dialog_not_whitelisted_using_battery_optimizations_message">MicroG GmsCore battery optimizations must be disabled to prevent issues.\n\nDisabling battery optimizations for MicroG will not not negatively affect your device.\n\nTap the continue button and allow optimization changes.</string>
<string name="gms_core_dialog_continue_text">Continue</string>
</patch>
</app>
Expand Down

0 comments on commit c4e6d75

Please sign in to comment.