Skip to content

Add battery optimization to setup wizard#7

Merged
GeiserX merged 2 commits intomainfrom
feat/battery-setup
Apr 4, 2026
Merged

Add battery optimization to setup wizard#7
GeiserX merged 2 commits intomainfrom
feat/battery-setup

Conversation

@GeiserX
Copy link
Copy Markdown
Owner

@GeiserX GeiserX commented Apr 4, 2026

Summary

  • Adds Step 4 (Battery Optimization) to the setup wizard
  • Detects opt-out status via PowerManager.isIgnoringBatteryOptimizations
  • "Continue to Dashboard" requires all 4 steps complete (server, notification, usage, battery)
  • Skip still available for users who want to configure later

Test plan

  • Fresh install shows 4 setup steps
  • Battery step shows checkmark after disabling optimization
  • Continue button enables only when all 4 steps are green

Summary by CodeRabbit

Release Notes

  • New Features
    • Added a new setup step for battery optimization that guides users to disable battery optimization settings. This ensures the app's background service continues running and prevents interruptions to critical functionality when the device screen is off.

Detects whether battery optimization is disabled via PowerManager
and shows it as a required step before continuing to dashboard.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 4, 2026

Warning

Rate limit exceeded

@GeiserX has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 3 minutes and 41 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 3 minutes and 41 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 84a554e3-b962-46da-bcd7-06f089b9ccc5

📥 Commits

Reviewing files that changed from the base of the PR and between a24a5d2 and bc139cc.

📒 Files selected for processing (1)
  • app/src/main/java/com/cashpilot/android/ui/MainActivity.kt
📝 Walkthrough

Walkthrough

This pull request adds battery optimization permission checking to the app's setup flow. A new StateFlow in MainViewModel tracks whether battery optimization is disabled, the permission check is integrated into the existing permission validation logic, and a new setup screen step guides users to disable battery optimization to maintain service reliability.

Changes

Cohort / File(s) Summary
ViewModel Battery State
app/src/main/java/com/cashpilot/android/ui/MainViewModel.kt
Added hasBatteryOptOut: StateFlow<Boolean> property and extended checkPermissions() to query PowerManager.isIgnoringBatteryOptimizations(), setting the state based on the result.
Setup Screen UI
app/src/main/java/com/cashpilot/android/ui/screen/SetupScreen.kt
Added new "Step 4: Battery optimization" card displaying battery opt-out state. Extended "Continue" button enabled condition to require battery optimization to be disabled. Introduced openBatteryOptimizationSettings() helper to launch Android battery optimization settings, with corresponding UI button.
String Resources
app/src/main/res/values/strings.xml
Added two new string resources (setup_battery_title and setup_battery_desc) describing the battery optimization step and its importance for service reliability.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A battery block, to let us thrive,
No optimization to kill our drive,
The heartbeat steady, the service alive,
Through darkened screens, our apps will survive!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a battery optimization step to the setup wizard, which is the primary focus of all file modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/battery-setup

Comment @coderabbitai help to get the list of available commands and usage tips.

MainActivity needsSetup now includes hasBatteryOptOut check,
matching SetupScreen's Continue button requirement.
@GeiserX GeiserX merged commit f20aa0e into main Apr 4, 2026
3 checks passed
@GeiserX GeiserX deleted the feat/battery-setup branch April 4, 2026 21:00
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.

1 participant