Skip to content

feature/battery optimization reminder#6235

Open
SeniorZhai wants to merge 6 commits intomasterfrom
codex/battery-optimization-reminder
Open

feature/battery optimization reminder#6235
SeniorZhai wants to merge 6 commits intomasterfrom
codex/battery-optimization-reminder

Conversation

@SeniorZhai
Copy link
Copy Markdown
Member

No description provided.

@SeniorZhai SeniorZhai added the testing Now testing, but you can review label Mar 19, 2026
@SeniorZhai SeniorZhai requested a review from Copilot March 19, 2026 05:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a battery-optimization reminder flow using the existing Compose bottom-sheet reminder system, replacing the prior dedicated dialog activity approach.

Changes:

  • Introduces a new BatteryOptimizationReminder popup type and UI copy (Battery_Optimization) across multiple locales.
  • Refactors ReminderPage to take pre-resolved content text (String) so callers can use stringResource(...) directly.
  • Centralizes battery optimization detection/navigation in ContextExtension and removes the old BatteryOptimizationDialogActivity + legacy triggers.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
app/src/main/res/values/strings.xml Adds Battery_Optimization string (default locale).
app/src/main/res/values-zh-rTW/strings.xml Adds Traditional Chinese translation for Battery_Optimization.
app/src/main/res/values-zh-rCN/strings.xml Adds Simplified Chinese translation for Battery_Optimization.
app/src/main/res/values-ru/strings.xml Adds Russian translation for Battery_Optimization.
app/src/main/res/values-ja/strings.xml Adds Japanese translation for Battery_Optimization.
app/src/main/res/values-es/strings.xml Adds Spanish translation for Battery_Optimization.
app/src/main/java/one/mixin/android/ui/home/reminder/VerifyMobileReminderBottomSheetDialogFragment.kt Updates reminder page content argument to pass a String via stringResource.
app/src/main/java/one/mixin/android/ui/home/reminder/ReminderPage.kt Changes content parameter from @StringRes Int to String; removes internal stringResource(content) lookup.
app/src/main/java/one/mixin/android/ui/home/reminder/ReminderBottomSheetDialogFragment.kt Adds battery optimization reminder selection + UI; updates other reminder content to pass strings.
app/src/main/java/one/mixin/android/ui/home/MainActivity.kt Removes legacy battery optimization check and related imports.
app/src/main/java/one/mixin/android/ui/common/BatteryOptimizationDialogActivity.kt Deletes the old dialog activity implementation.
app/src/main/java/one/mixin/android/job/BlazeMessageService.kt Removes background-triggered battery optimization dialog; centralizes restriction check.
app/src/main/java/one/mixin/android/extension/ContextExtension.kt Adds isBatteryOptimizationRestricted() and openBatteryOptimizationSetting() helpers.
app/src/main/AndroidManifest.xml Removes BatteryOptimizationDialogActivity registration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

import one.mixin.android.ui.common.MixinComposeBottomSheetDialogFragment
import one.mixin.android.ui.home.MainActivity
import one.mixin.android.ui.setting.SettingActivity
import one.mixin.android.util.RomUtil
Comment on lines +120 to +123
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
R.string.setting_battery_optimize_title_one_ui_above_s
} else {
R.string.setting_battery_optimize_title_one_ui_below_s
@SeniorZhai SeniorZhai removed the testing Now testing, but you can review label Mar 23, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new in-app “Battery Optimization” reminder surfaced via the existing reminder bottom sheet flow, replacing the previous dedicated dialog activity and consolidating battery optimization detection/navigation into Context extensions.

Changes:

  • Introduce a new BatteryOptimizationReminder popup type and reminder UI (new string + background image).
  • Refactor ReminderPage to accept pre-resolved String content (instead of a @StringRes id) and update call sites.
  • Remove BatteryOptimizationDialogActivity and migrate battery-optimization checks/open-settings behavior into ContextExtension.

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
app/src/main/res/values/strings.xml Adds Battery_Optimization title string (EN).
app/src/main/res/values-zh-rTW/strings.xml Adds Traditional Chinese translation for Battery_Optimization.
app/src/main/res/values-zh-rCN/strings.xml Adds Simplified Chinese translation for Battery_Optimization.
app/src/main/res/values-ru/strings.xml Adds Russian translation for Battery_Optimization.
app/src/main/res/values-ja/strings.xml Adds Japanese translation for Battery_Optimization.
app/src/main/res/values-es/strings.xml Adds Spanish translation for Battery_Optimization.
app/src/main/res/drawable-xxhdpi/bg_reminder_battery_optimization.png Adds new reminder background asset.
app/src/main/java/one/mixin/android/ui/home/reminder/VerifyMobileReminderBottomSheetDialogFragment.kt Updates reminder content argument to pass a resolved string via stringResource.
app/src/main/java/one/mixin/android/ui/home/reminder/ReminderPage.kt Changes API: content becomes String and is rendered directly.
app/src/main/java/one/mixin/android/ui/home/reminder/ReminderBottomSheetDialogFragment.kt Adds battery optimization reminder selection + UI, and opens battery optimization settings.
app/src/main/java/one/mixin/android/ui/home/MainActivity.kt Removes the legacy battery optimization check hook.
app/src/main/java/one/mixin/android/ui/common/BatteryOptimizationDialogActivity.kt Deletes the legacy dialog activity implementation.
app/src/main/java/one/mixin/android/job/BlazeMessageService.kt Uses the new Context.isBatteryOptimizationRestricted() helper and removes dialog activity trigger.
app/src/main/java/one/mixin/android/extension/ContextExtension.kt Adds isBatteryOptimizationRestricted() + openBatteryOptimizationSetting() and intent fallback logic.
app/src/main/AndroidManifest.xml Removes BatteryOptimizationDialogActivity registration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +118 to +125
@StringRes
private fun getBatteryOptimizationContentResId(): Int {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
R.string.setting_battery_optimize_title_one_ui_above_s
} else {
R.string.setting_battery_optimize_title_one_ui_below_s
}
}
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getBatteryOptimizationContentResId() always returns the One UI-specific instruction strings based solely on the Android version. This means non-One UI devices will see Samsung/One UI navigation text (e.g., Optimised/Unrestricted) even though there is already a generic setting_battery_optimize_title string.

Consider selecting the content string based on RomUtil.isOneUi (use the One UI strings only when true; otherwise fall back to R.string.setting_battery_optimize_title).

Copilot uses AI. Check for mistakes.
import one.mixin.android.ui.common.MixinComposeBottomSheetDialogFragment
import one.mixin.android.ui.home.MainActivity
import one.mixin.android.ui.setting.SettingActivity
import one.mixin.android.util.RomUtil
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RomUtil is imported but not referenced in this file. If you switch getBatteryOptimizationContentResId() to be One UI-aware you may end up using it; otherwise please remove the unused import to keep the file clean.

Suggested change
import one.mixin.android.util.RomUtil

Copilot uses AI. Check for mistakes.
Comment on lines +266 to +271
return getString(getBatteryOptimizationContentResId())
.replace("<b>", "")
.replace("</b>", "")
.replace("**", "")
}

Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

batteryOptimizationContent() strips <b> and ** markers by doing plain string replacements. This is brittle for localization (translators may legitimately use * characters) and also removes intended emphasis from the instruction text.

Prefer keeping these strings markup-free (plain text resources), or parse/render formatting explicitly (e.g., convert known markers into an AnnotatedString with bold spans in Compose).

Suggested change
return getString(getBatteryOptimizationContentResId())
.replace("<b>", "")
.replace("</b>", "")
.replace("**", "")
}
// Return the localized string as-is; any formatting markers should be
// interpreted explicitly at render time rather than stripped here.
return getString(getBatteryOptimizationContentResId())
}

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants