Feat: Add overlay permission guidance and persistence#19
Conversation
This commit introduces a dialog to guide users on enabling "display pop-up windows while running in the background" permission, particularly for devices like Xiaomi, Oppo, and Vivo. The user's acknowledgment of this dialog is now persisted using DataStore.
Key changes:
- **triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionComposable.kt**:
- Added `PermissionType.OVERLAY` and `PermissionType.OVERLAY_WHILE_BACKGROUND` to the default `permissions` list.
- Implemented `ShowPermissionGuidanceDialog` to display specific instructions for `OVERLAY_WHILE_BACKGROUND`.
- Integrated `TriggerXPermissionFlagManager` to save and check the acknowledgment state of the guidance dialog.
- Permission requests and dialog showings are now launched within a `CoroutineScope`.
- Added `ShowManualPermissionDialog` composable for generic manual permission guidance.
- **triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionManager.kt**:
- Added `OVERLAY_WHILE_BACKGROUND` to `PermissionType` enum, marking it as a `isManualPermissionType`.
- Implemented `isOverlayBackgroundPermissionEnabled` to check acknowledgment status via `TriggerXPermissionFlagManager`.
- `isGranted` now handles `OVERLAY_WHILE_BACKGROUND` by checking its acknowledgment status.
- `createPermissionIntent` now returns `null` for `PermissionType`s that are manually configured by the user (like `OVERLAY_WHILE_BACKGROUND`).
- Added `OverlayPermissionGuidanceDialog` composable (though currently unused directly, parts of its logic are adapted elsewhere).
- `PermissionState.requestPermission` now checks for `isManualPermissionType` to show `showPermissionGuidanceDialog` instead of launching an intent.
- `PermissionState.allRequiredGranted` and `PermissionState.isGranted` are now suspend functions.
- `PermissionState.next` is now a suspend function.
- **app/src/main/java/com/meticha/triggerxexample/home/HomeScreen.kt**:
- Permission requests (`permissionState.requestPermission()`) and checks (`permissionState.allRequiredGranted()`) are now called within a `CoroutineScope`.
- **triggerx/src/main/java/com/meticha/triggerx/permission/PermissionLifeCycleCheckEffect.kt**:
- `permissionState.requestPermission()` is now launched within a `CoroutineScope` in the lifecycle observer.
- **app/src/main/java/com/meticha/triggerxexample/home/HomeViewModel.kt**:
- `scheduleOneMinuteAlarm` and `cancelCurrentAlarm` now launch their operations within `viewModelScope`.
- **app/src/main/AndroidManifest.xml**:
- Added `android.permission.SYSTEM_ALERT_WINDOW` permission.
- **triggerx/src/main/java/com/meticha/triggerx/preference/TriggerXAlarmIdManager.kt**:
- Added `TriggerXPermissionFlagManager` object to save and retrieve boolean flags for permission dialog acknowledgments using DataStore.
- Implemented `savePermissionDialogResponse` and `isPermissionDialogAcknowledged`.
WalkthroughThis update introduces asynchronous coroutine-based permission handling throughout the app, adds support for new manual overlay permission types, and implements user guidance dialogs for permissions that require manual user action. The Android manifest is updated to declare the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant HomeScreen
participant HomeViewModel
participant PermissionState
participant TriggerXPermissionFlagManager
User->>HomeScreen: Clicks button
HomeScreen->>HomeScreen: Launch coroutine
HomeScreen->>PermissionState: requestPermission() (suspend)
alt Manual permission type
PermissionState->>HomeScreen: Show guidance dialog
User->>HomeScreen: Acknowledge dialog
HomeScreen->>TriggerXPermissionFlagManager: savePermissionDialogResponse()
else Standard permission
PermissionState->>PermissionState: Launch system intent
end
HomeScreen->>HomeViewModel: scheduleOneMinuteAlarm() (coroutine)
HomeViewModel->>HomeViewModel: Launch coroutine
HomeViewModel->>...: Schedule alarm asynchronously
Possibly related PRs
Suggested labels
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
✨ Finishing Touches🧪 Generate Unit Tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
…nePlus devices
This commit modifies the `TriggerXPermissionComposable` to conditionally add the `OVERLAY_WHILE_BACKGROUND` permission only for OnePlus devices. Previously, this permission was added for all devices.
Key changes:
- **triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionComposable.kt**:
- Wrapped the addition of `PermissionType.OVERLAY_WHILE_BACKGROUND` in a conditional check for `Build.MANUFACTURER.equals("oneplus", true)`.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionComposable.kt (2)
71-73: Clean up the commented OnePlus-specific code.The commented code suggests that
OVERLAY_WHILE_BACKGROUNDwas initially intended only for OnePlus devices, but it's now being added unconditionally. Please remove the commented code to avoid confusion about the implementation intent.-// if (Build.MANUFACTURER.equals("oneplus", true)) { add(PermissionType.OVERLAY_WHILE_BACKGROUND) -// }
192-212: Consider adding an explicit dismiss button.The
ShowManualPermissionDialogonly shows an "Acknowledge" button without an explicit dismiss/cancel option. Users can only dismiss via the back button or tapping outside, which might not be intuitive.confirmButton = { Button(onClick = onConfirm) { Text("Acknowledge") } + }, + dismissButton = { + Button(onClick = onDismiss) { + Text("Later") + } }triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionManager.kt (1)
394-406: Handle the case when createPermissionIntent returns null for non-manual permissions.When
createPermissionIntentreturns null for a non-manual permission type, the code silently moves to the next permission. Consider logging a warning or showing an error to help with debugging.} else { val intent = AlarmPermissionManager.createPermissionIntent( context, permission ) if (intent != null) { launcher?.launch(intent) } else { + // Log warning for debugging + android.util.Log.w("PermissionState", "No intent available for permission: $permission") next() } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
app/src/main/AndroidManifest.xml(1 hunks)app/src/main/java/com/meticha/triggerxexample/home/HomeScreen.kt(2 hunks)app/src/main/java/com/meticha/triggerxexample/home/HomeViewModel.kt(2 hunks)triggerx/src/main/java/com/meticha/triggerx/permission/PermissionLifeCycleCheckEffect.kt(2 hunks)triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionComposable.kt(6 hunks)triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionManager.kt(12 hunks)triggerx/src/main/java/com/meticha/triggerx/preference/TriggerXAlarmIdManager.kt(2 hunks)
🔇 Additional comments (11)
app/src/main/AndroidManifest.xml (1)
24-24: LGTM! Correctly adds overlay permission.The
SYSTEM_ALERT_WINDOWpermission is properly declared and necessary for the overlay functionality described in the PR objectives.triggerx/src/main/java/com/meticha/triggerx/permission/PermissionLifeCycleCheckEffect.kt (1)
20-20: LGTM! Proper coroutine integration for async permission requests.The addition of
rememberCoroutineScope()and launching the permission request within a coroutine is appropriate for non-blocking permission handling in Compose.Also applies to: 25-25, 45-45, 50-50
app/src/main/java/com/meticha/triggerxexample/home/HomeScreen.kt (1)
27-27: LGTM! Proper async handling for UI interactions.Wrapping the permission check and alarm scheduling logic in a coroutine scope ensures non-blocking UI interactions and proper handling of suspend functions.
Also applies to: 34-34, 42-42, 56-69
app/src/main/java/com/meticha/triggerxexample/home/HomeViewModel.kt (2)
21-21: LGTM! Proper async alarm scheduling using viewModelScope.The conversion to coroutine-based alarm scheduling is appropriate for potentially long-running operations and follows proper ViewModel coroutine patterns.
Also applies to: 24-24, 43-50, 55-55
37-37: No return-value dependencies for scheduleOneMinuteAlarmA search across the codebase found only two occurrences:
- Definition in HomeViewModel.kt (line 37)
- Invocation in HomeScreen.kt (line 63) as a standalone call
There are no assignments, conditional checks, or initializations relying on a Boolean return. The signature change is safe and requires no further updates.
triggerx/src/main/java/com/meticha/triggerx/preference/TriggerXAlarmIdManager.kt (1)
67-92: LGTM! Well-designed permission flag manager with proper DataStore usage.The
TriggerXPermissionFlagManagerfollows the same established patterns asTriggerXAlarmIdManagerand provides:
- Proper async persistence with suspend functions
- Reactive observation via Flow
- Appropriate key generation based on permission type
- Sensible default behavior (false for unacknowledged)
The shared DataStore usage is acceptable and keeps related preferences together.
triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionComposable.kt (2)
79-79: LGTM! Proper coroutine handling for async permission checks.The introduction of
rememberCoroutineScope()and wrapping the launcher callback incoroutineScope.launchis the correct approach for handling the new suspend functions in the permission system.Also applies to: 93-104
139-183: Well-implemented permission guidance dialog.The
ShowPermissionGuidanceDialogcomposable properly handles the manual permission flow with clear user instructions and persistence of user acknowledgment viaTriggerXPermissionFlagManager.triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionManager.kt (3)
142-146: Correct implementation of manual permission acknowledgment check.The
isOverlayBackgroundPermissionEnabledfunction properly checks the acknowledgment status from the DataStore-backed flag manager.
175-175: Appropriate nullable return type for manual permissions.The change to return
Intent?correctly handles manual permission types that don't have associated system intents.Also applies to: 216-219
357-361: Proper async conversion for permission handling.The conversion of permission methods to suspend functions correctly supports the new asynchronous permission checks while maintaining backward compatibility for synchronous permission types.
Also applies to: 372-376, 385-412, 421-428
This commit relocates `TriggerXPermissionFlagManager` to a new file `TriggerXManualPermissionStatusManager.kt` and renames it accordingly.
Additionally, it enhances the permission guidance dialog in `TriggerXPermissionComposable.kt`:
- The dialog is no longer dismissible by clicking outside.
- A "Later" button has been added to the dismiss action.
Key changes:
- **triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionComposable.kt**:
- Replaced `TriggerXPermissionFlagManager` with `TriggerXManualPermissionStatusManager`.
- Set `dismissOnClickOutside` to `false` in `DialogProperties` for the permission guidance dialog.
- Added a `dismissButton` with "Later" text to the permission guidance dialog.
- **triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionManager.kt**:
- Replaced `TriggerXPermissionFlagManager` with `TriggerXManualPermissionStatusManager`.
- Removed unused `OverlayPermissionGuidanceDialog` composable.
- **triggerx/src/main/java/com/meticha/triggerx/preference/TriggerXAlarmIdManager.kt**:
- Removed the `TriggerXPermissionFlagManager` object.
- **triggerx/src/main/java/com/meticha/triggerx/preference/TriggerXManualPermissionStatusManager.kt**:
- New file created.
- Contains the relocated and renamed `TriggerXPermissionFlagManager` (now `TriggerXManualPermissionStatusManager`).
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionManager.kt (1)
295-299: Async permission checking in batch operations.Converting
allRequiredGrantedto suspend is necessary for manual permission checking, but this could impact performance when checking multiple permissions.Consider parallel processing for better performance:
suspend fun allRequiredGranted(): Boolean { - isRequiredPermissionGranted = allPermissions - .all { isGranted(it) } + isRequiredPermissionGranted = allPermissions + .map { async { isGranted(it) } } + .awaitAll() + .all { it } return isRequiredPermissionGranted }Don't forget to import
kotlinx.coroutines.asyncandkotlinx.coroutines.awaitAll.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionComposable.kt(6 hunks)triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionManager.kt(12 hunks)triggerx/src/main/java/com/meticha/triggerx/preference/TriggerXAlarmIdManager.kt(1 hunks)triggerx/src/main/java/com/meticha/triggerx/preference/TriggerXManualPermissionStatusManager.kt(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- triggerx/src/main/java/com/meticha/triggerx/preference/TriggerXAlarmIdManager.kt
🚧 Files skipped from review as they are similar to previous changes (1)
- triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionComposable.kt
🔇 Additional comments (11)
triggerx/src/main/java/com/meticha/triggerx/preference/TriggerXManualPermissionStatusManager.kt (3)
13-13: DataStore initialization follows best practices.The use of
preferencesDataStoredelegate with a descriptive name is appropriate for managing permission dialog acknowledgment states.
28-37: Flow-based data access is well implemented.The function correctly returns a
Flow<Boolean>with appropriate default value handling. The use ofmapto transform preferences data is idiomatic.
39-41: Preference key generation is robust.Using the permission type name ensures unique keys per permission type, which prevents conflicts between different manual permissions.
triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionManager.kt (8)
36-37: Import additions support the new manual permission functionality.The imports for
TriggerXManualPermissionStatusManagerandkotlinx.coroutines.flow.firstare necessary for the manual permission status checking implementation.
126-130: Manual permission status checking is correctly implemented.The suspend function properly uses the manual permission status manager to check acknowledgment via DataStore. Using
.first()to get the current value from the Flow is appropriate for this use case.
159-204: Intent creation properly handles manual permissions.The function correctly returns
nullfor manual permission types since they don't have system intents. The logic properly distinguishes between system permissions that have intents and manual permissions that require user guidance.
212-231: Permission type architecture supports extensibility.The addition of
isManualPermissionTypeparameter to the enum constructor provides a clean way to distinguish between system and manual permissions. The newOVERLAY_WHILE_BACKGROUNDpermission type is properly flagged as manual.
265-265: State management for guidance dialog is appropriately added.The new
showPermissionGuidanceDialogstate variable follows the existing pattern and is necessary for controlling the display of manual permission guidance dialogs.
323-350: Permission request flow correctly handles manual permissions.The updated logic properly distinguishes between manual and system permissions, showing guidance dialogs for manual permissions and launching system intents for others. The error handling for null intents is appropriate.
359-366: Async next() function maintains proper flow control.Converting
next()to suspend and callingrequestPermission()maintains the permission flow while supporting async operations. The logic correctly processes the queue and handles the async permission checking.
138-147: Verify suspend overhead ofisGrantedOur search (
rg '\.isGranted\(') only uncovered the internal call toAlarmPermissionManager.isGranted(…)withinTriggerXPermissionManager.ktand no external consumers ofTriggerXPermissionManager.isGranted. Please confirm whether this suspend function ends up in performance-sensitive paths (e.g., UI loops, scrolling adapters). If it does, you may want to:
- Introduce a non-suspending API for system permissions:
fun isGrantedSync(context: Context, permission: PermissionType): Boolean- Reserve the
suspend fun isGrantedfor manual/DataStore-backed permission checks only.This hybrid approach avoids unnecessary coroutine overhead for simple system checks.
This commit introduces several improvements to permission management and logging within the `TriggerXPermissionManager`.
Key changes:
- **triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionManager.kt**:
- `createPermissionIntent` for `PermissionType.ALARM` now returns `null` for Android versions below S, as `ACTION_REQUEST_SCHEDULE_EXACT_ALARM` is only available from S onwards.
- `allRequiredGranted` now uses `coroutineScope` and `async/awaitAll` for concurrent permission checks, potentially improving performance.
- Added error logging in `checkAndRequestNextPermission` if an intent for a permission cannot be created.
- Minor formatting adjustment.
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (1)
triggerx/src/main/java/com/meticha/triggerx/preference/TriggerXManualPermissionStatusManager.kt (1)
17-26: Add error handling for DataStore operations.The function correctly uses
suspendand DataStore'seditoperation, but missing error handling could lead to unhandled exceptions during persistence operations.Consider wrapping the DataStore operation in a try-catch block:
suspend fun savePermissionDialogResponse( context: Context, permissionType: PermissionType, acknowledged: Boolean, ) { - val key = getPreferenceKeyForType(permissionType) - context.dataStore.edit { settings -> - settings[key] = acknowledged - } + try { + val key = getPreferenceKeyForType(permissionType) + context.dataStore.edit { settings -> + settings[key] = acknowledged + } + } catch (e: Exception) { + // Log error or handle gracefully based on your logging strategy + // Consider whether to rethrow or provide default behavior + throw e + } }
🧹 Nitpick comments (4)
app/src/main/java/com/meticha/triggerxexample/home/HomeViewModel.kt (1)
37-51: Good async conversion, but consider error handling implications.The conversion to
viewModelScope.launchproperly handles alarm scheduling asynchronously. However, removing the Boolean return value eliminates the ability for callers to determine if the operation succeeded.Consider whether you need to:
- Add error handling within the coroutine
- Provide alternative mechanisms (like StateFlow) to communicate operation results
- Log failures appropriately for debugging
triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionComposable.kt (2)
72-72: Consider using consistent manufacturer name casing.For consistency with the Xiaomi check above, consider using the proper casing for OnePlus.
- if (Build.MANUFACTURER.equals("oneplus", true)) { + if (Build.MANUFACTURER.equals("OnePlus", true)) {
152-157: Consider making the guidance message more generic and maintainable.The hardcoded settings navigation path may not be accurate across all device models, Android versions, and custom ROMs. Consider:
- Making the instructions more generic
- Moving the message to string resources for easier maintenance
- Using device-specific instructions if available
Example of a more generic message:
message = "For alarms to reliably appear when the app is in the background, " + "'$appName' needs an additional permission.\n\n" + "Please navigate to your device's app settings and ensure that background " + "pop-up or overlay permissions are enabled for '$appName'.\n\n" + "The exact location varies by device manufacturer."triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionManager.kt (1)
309-309: Remove redundant variable assignment.The
isRequiredPermissionGrantedvalue is already assigned on line 306.- isRequiredPermissionGranted + return isRequiredPermissionGranted
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
app/src/main/AndroidManifest.xml(1 hunks)app/src/main/java/com/meticha/triggerxexample/home/HomeScreen.kt(2 hunks)app/src/main/java/com/meticha/triggerxexample/home/HomeViewModel.kt(2 hunks)triggerx/src/main/java/com/meticha/triggerx/permission/PermissionLifeCycleCheckEffect.kt(2 hunks)triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionComposable.kt(6 hunks)triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionManager.kt(12 hunks)triggerx/src/main/java/com/meticha/triggerx/preference/TriggerXAlarmIdManager.kt(1 hunks)triggerx/src/main/java/com/meticha/triggerx/preference/TriggerXManualPermissionStatusManager.kt(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
app/src/main/java/com/meticha/triggerxexample/home/HomeScreen.kt (1)
triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionComposable.kt (1)
rememberAppPermissionState(56-138)
triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionComposable.kt (1)
triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionManager.kt (2)
isGranted(143-152)isGranted(321-325)
🔇 Additional comments (9)
triggerx/src/main/java/com/meticha/triggerx/preference/TriggerXAlarmIdManager.kt (1)
62-62: LGTM! Minor formatting cleanup.Removing the trailing newline is a trivial formatting improvement with no functional impact.
triggerx/src/main/java/com/meticha/triggerx/preference/TriggerXManualPermissionStatusManager.kt (2)
28-37: LGTM! Good reactive pattern for permission state.The Flow-based approach enables reactive UI updates when permission acknowledgment status changes. The default
falsevalue appropriately represents unacknowledged permissions.
39-41: LGTM! Proper key generation for unique permission types.Using the permission type name ensures unique DataStore keys for different permission types, preventing conflicts.
app/src/main/AndroidManifest.xml (1)
24-24: LGTM! Necessary permission for overlay functionality.Adding
SYSTEM_ALERT_WINDOWpermission aligns with the PR objectives to support overlay permissions and "display pop-up windows while running in the background" functionality.app/src/main/java/com/meticha/triggerxexample/home/HomeScreen.kt (2)
27-27: LGTM! Proper coroutine imports for async handling.Added necessary imports for coroutine scope management in the Composable context.
Also applies to: 34-34, 42-42
56-69: LGTM! Correct async conversion for permission handling.Wrapping the permission check and alarm scheduling logic in
coroutines.launchproperly handles the asynchronous nature of the updated permission system. This ensures UI interactions don't block the main thread while maintaining the same control flow.app/src/main/java/com/meticha/triggerxexample/home/HomeViewModel.kt (2)
21-21: LGTM! Proper coroutine imports for ViewModel scope.Added necessary imports for launching coroutines within the ViewModel's lifecycle-aware scope.
Also applies to: 24-24
55-55: LGTM! Consistent async pattern for alarm cancellation.Converting to
viewModelScope.launchmaintains consistency with the alarm scheduling method and properly handles the asynchronous nature of alarm cancellation.triggerx/src/main/java/com/meticha/triggerx/permission/PermissionLifeCycleCheckEffect.kt (1)
20-20: LGTM! Correct coroutine integration for suspend permission requests.The changes properly integrate coroutine support to handle the new suspend
requestPermission()function. The coroutine scope is correctly created usingrememberCoroutineScope()and the permission request is launched within it, maintaining proper lifecycle awareness.Also applies to: 25-25, 45-45, 50-50
This commit updates the text in the permission guidance dialog.
Key changes:
- **triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionComposable.kt**:
- Changed "Understood" to "Acknowledge" in the permission guidance dialog message.
This commit adds the Apache License, Version 2.0 to the `TriggerXManualPermissionStatusManager.kt` file.
Key changes:
- **triggerx/src/main/java/com/meticha/triggerx/preference/TriggerXManualPermissionStatusManager.kt**:
- Added the Apache License, Version 2.0 header.
This commit updates the `VERSION_NAME` environment variable in the release workflow.
Key changes:
- **.github/workflows/release.yaml**:
- Updated `VERSION_NAME` from `0.0.7` to `0.0.8`.
This commit introduces a dialog to guide users on enabling "display pop-up windows while running in the background" permission, particularly for devices like Xiaomi, Oppo, and Vivo. The user's acknowledgment of this dialog is now persisted using DataStore.
Key changes:
PermissionType.OVERLAYandPermissionType.OVERLAY_WHILE_BACKGROUNDto the defaultpermissionslist.ShowPermissionGuidanceDialogto display specific instructions forOVERLAY_WHILE_BACKGROUND.TriggerXPermissionFlagManagerto save and check the acknowledgment state of the guidance dialog.CoroutineScope.ShowManualPermissionDialogcomposable for generic manual permission guidance.OVERLAY_WHILE_BACKGROUNDtoPermissionTypeenum, marking it as aisManualPermissionType.isOverlayBackgroundPermissionEnabledto check acknowledgment status viaTriggerXPermissionFlagManager.isGrantednow handlesOVERLAY_WHILE_BACKGROUNDby checking its acknowledgment status.createPermissionIntentnow returnsnullforPermissionTypes that are manually configured by the user (likeOVERLAY_WHILE_BACKGROUND).OverlayPermissionGuidanceDialogcomposable (though currently unused directly, parts of its logic are adapted elsewhere).PermissionState.requestPermissionnow checks forisManualPermissionTypeto showshowPermissionGuidanceDialoginstead of launching an intent.PermissionState.allRequiredGrantedandPermissionState.isGrantedare now suspend functions.PermissionState.nextis now a suspend function.permissionState.requestPermission()) and checks (permissionState.allRequiredGranted()) are now called within aCoroutineScope.permissionState.requestPermission()is now launched within aCoroutineScopein the lifecycle observer.scheduleOneMinuteAlarmandcancelCurrentAlarmnow launch their operations withinviewModelScope.android.permission.SYSTEM_ALERT_WINDOWpermission.TriggerXPermissionFlagManagerobject to save and retrieve boolean flags for permission dialog acknowledgments using DataStore.savePermissionDialogResponseandisPermissionDialogAcknowledged.name: Pull Request
about: Propose changes to TriggerX
title: ''
labels: ''
assignees: ''
Description
Please include a summary of the change and which issue is fixed (if any).
e.g., Fixes # (issue)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.
Please also list any relevant details for your test configuration.
Test Configuration:
Screenshots (if applicable)
Summary by CodeRabbit
New Features
Improvements
Chores