Add Xiaomi HyperIsland Support#183
Add Xiaomi HyperIsland Support#183google-labs-jules[bot] wants to merge 31 commits intobeta_0.6.5from
Conversation
This commit introduces support for Xiaomi HyperIsland notifications for pre-reminders. - A new `HyperIslandUtil.kt` class encapsulates all the logic for checking device support and building the specific `Bundle` of extras required by the HyperIsland API. - The `PreReminderForegroundService` has been modified to call this new utility and attach the resulting `Bundle` to the pre-reminder notification. - The `NotificationScheduler` and `ReminderSchedulingWorker` have been updated to pass the necessary medication color and form data to the service.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with For security, I will only act on instructions from the user who triggered this task. New to Jules? Learn more at jules.google/docs. |
This commit introduces support for Xiaomi HyperIsland notifications for pre-reminders. - A new `HyperIslandUtil.kt` class encapsulates all the logic for checking device support and building the specific `Bundle` of extras required by the HyperIsland API. - The `PreReminderForegroundService` has been modified to call this new utility and attach the resulting `Bundle` to the pre-reminder notification. - The `NotificationScheduler` and `ReminderSchedulingWorker` have been updated to pass the necessary medication color and form data to the service.
This commit introduces support for Xiaomi HyperIsland notifications for pre-reminders. - A new `HyperIslandUtil.kt` class encapsulates all the logic for checking device support and building the specific `Bundle` of extras required by the HyperIsland API. - The `PreReminderForegroundService` has been modified to call this new utility and attach the resulting `Bundle` to the pre-reminder notification. - The `NotificationScheduler` and `ReminderSchedulingWorker` have been updated to pass the necessary medication color and form data to the service. - Vector drawables are converted to bitmaps to ensure compatibility with the HyperIsland framework.
This commit introduces support for Xiaomi HyperIsland notifications for pre-reminders. - A new `HyperIslandUtil.kt` class encapsulates all the logic for checking device support and building the specific `Bundle` of extras required by the HyperIsland API. - The `PreReminderForegroundService` has been modified to call this new utility and attach the resulting `Bundle` to the pre-reminder notification. - The `NotificationScheduler` and `ReminderSchedulingWorker` have been updated to pass the necessary medication color and form data to the service. - Vector drawables are converted to bitmaps to ensure compatibility with the HyperIsland framework. - Enhanced device checks have been added to ensure the feature only runs on supported devices with the correct permissions.
This commit introduces support for Xiaomi HyperIsland notifications for pre-reminders. - A new `HyperIslandUtil.kt` class encapsulates all the logic for checking device support and building the specific `Bundle` of extras required by the HyperIsland API. - The `PreReminderForegroundService` has been modified to call this new utility and attach the resulting `Bundle` to the pre-reminder notification. - The `NotificationScheduler` and `ReminderSchedulingWorker` have been updated to pass the necessary medication color and form data to the service. - Vector drawables are converted to bitmaps to ensure compatibility with the HyperIsland framework. - Enhanced device checks have been added to ensure the feature only runs on supported devices with the correct permissions. - Detailed logging has been added to the HyperIsland support checks to help diagnose any issues.
This commit introduces support for Xiaomi HyperIsland notifications for pre-reminders. - A new `HyperIslandUtil.kt` class encapsulates all the logic for checking device support and building the specific `Bundle` of extras required by the HyperIsland API. - The `PreReminderForegroundService` has been modified to call this new utility and attach the resulting `Bundle` to the pre-reminder notification. - The `NotificationScheduler` and `ReminderSchedulingWorker` have been updated to pass the necessary medication color and form data to the service. - Vector drawables are converted to bitmaps to ensure compatibility with the HyperIsland framework. - Enhanced device checks have been added to ensure the feature only runs on supported devices with the correct permissions. - Detailed logging has been added to the HyperIsland support checks to help diagnose any issues. - The incorrect SDK version check that was preventing the feature from running has been removed.
This commit introduces support for Xiaomi HyperIsland notifications for pre-reminders. - A `HyperIslandUtil.kt` class has been added to encapsulate all vendor-specific logic, including device support checks and payload creation. - The data flow has been updated to pass medication color and form from `ReminderSchedulingWorker` to `PreReminderForegroundService`. - Corrected the API level checks to `BAKLAVA` (API 36) for styled progress notifications. - Added extensive logging for easier debugging of the feature.
This commit relaxes the support check for Xiaomi HyperIsland notifications by removing the protocol version check. The logs indicated that the `isHyperIslandProtocolSupported` check was failing on a device that passed all other compatibility checks. This was preventing the feature from being enabled. By removing this check, the feature will now be enabled on devices that are otherwise compatible, which should resolve the issue of the notifications not appearing.
This commit adds debugging tools to help diagnose issues with Xiaomi HyperIsland notifications. - In `PreReminderForegroundService`, a log has been added to print the full content of the generated HyperIsland `Bundle`. - A separate test notification is now sent when a pre-reminder starts, using a static, known-good payload from the Xiaomi documentation. This will help determine if the issue is with the payload generation or the notification sending process.
This commit refactors the pre-reminder notification logic to support Xiaomi HyperIsland devices. Previously, adding HyperIsland extras to the existing progress-style notification caused the notification to fail. Debugging revealed that HyperIsland notifications are incompatible with other notification styles like `setOngoing(true)` and `setStyle(Notification.ProgressStyle)`. To resolve this, the service now performs a check for HyperIsland compatibility. - If the device is supported, a new, dedicated, simplified notification is built, containing only the necessary content and the HyperIsland extras. - If the device is not supported, it falls back to the original styled progress notification for API 36+ or the standard compatibility notification for older versions. This ensures that users with compatible Xiaomi devices get the enhanced HyperIsland experience, while all other users retain the existing live-updating notification feature.
This commit introduces full support for Xiaomi HyperIsland notifications for pre-reminders. After extensive debugging, it was determined that HyperIsland notifications are incompatible with standard Android notification styles like `setOngoing(true)` and `setStyle(Notification.ProgressStyle)`. To resolve this, the `PreReminderForegroundService` now implements a conditional notification strategy: - It checks for HyperIsland compatibility using a dedicated `HyperIslandUtil`. - If the device is supported, a new, simplified notification is built. This notification uses a custom JSON payload to create a two-sided layout, displaying the medication name on the left and the time remaining on the right. - If the device is not supported, it falls back to the original styled progress notification (for API 36+) or a standard compatibility notification. Additionally, this commit restores the `contentIntent` to all notification-building paths, ensuring that all pre-reminder notifications are tappable and open the application, fixing a regression introduced during the refactor.
This commit finalizes the implementation of Xiaomi HyperIsland notifications, providing a complete and polished user experience. The `HyperIslandUtil.kt` now generates a comprehensive JSON payload that includes: - `baseInfo`: Populates the standard, expandable notification in the notification shade with the medication name and details. - `bigIslandArea`: Displays a two-sided layout with the medication name/icon on the left and a formatted countdown timer on the right. - `smallIslandArea`: Shows the medication icon and a compact countdown timer when the island is in its small state. This is integrated into the conditional logic in `PreReminderForegroundService.kt`, which displays this enhanced notification on supported devices while seamlessly falling back to the existing progress-style notification for all other users. This ensures a great experience for all users without any regressions.
This commit refactors the pre-reminder scheduling logic to ensure the `PreReminderForegroundService` can be reliably started from the background, even when the app is in a stopped state. Previously, an `AlarmManager` trigger would send a broadcast to a `BroadcastReceiver`, which would then attempt to start the service. This pattern is unreliable on modern Android versions and custom OSes with strict background restrictions, causing notifications to fail unless the app had been recently opened. The new implementation now uses `PendingIntent.getForegroundService()` to allow the `AlarmManager` to directly start the `PreReminderForegroundService`. This is the recommended and more robust approach for background-to-foreground transitions. The redundant `PreReminderBroadcastReceiver` has been removed to simplify the codebase.
This commit fixes a critical performance issue where the check for HyperIsland support was being performed every minute during a pre-reminder. This caused system instability and crashes. The `PreReminderForegroundService` has been refactored to cache the result of the `HyperIslandUtil.isSupported()` check. The check is now performed only once when the service is first started for a reminder. This cached value is then used for all subsequent notification updates, eliminating the performance bottleneck. The cache is reset when the service is stopped, ensuring a fresh check for the next pre-reminder.
…ative countdown This commit delivers a complete and polished HyperIsland notification experience, incorporating a native countdown, interactive actions, and a refined design. Key enhancements include: - **Native Countdown:** The JSON payload now uses the `type: 3` countdown timer, providing a smooth, second-by-second countdown without needing the service to update every second. The service's update interval has been reverted to one minute for efficiency. - **Interactive Actions:** The notification now includes "Mark as Taken" and "Stop Reminder" buttons. This was achieved by creating `PendingIntent`s for each action and attaching them to the notification via a `miui.focus.actions` bundle. - **Refined Design:** The layout now follows the user's specification, with the medication icon, the first word of the medication name, the countdown, and action buttons clearly displayed in the `bigIslandArea`. This commit finalizes the HyperIsland feature, making it not only functional and performant but also visually rich and interactive.
This commit fixes a critical lifecycle bug in the `PreReminderForegroundService` where the service would not stop correctly when displaying a HyperIsland notification. Previously, the update runnable would return early for HyperIsland devices, which prevented the self-stopping logic from executing. This would leave the service running in the background unnecessarily. The logic has been refactored to ensure the runnable always checks if it's time to stop the service. The notification content update is now conditionally skipped for HyperIsland devices, while the lifecycle management and self-stopping logic runs for all device types. This ensures the service is both efficient and correctly terminates when its work is done.
This commit introduces support for Xiaomi HyperIsland notifications for pre-reminders.
It includes:
- A new `HyperIslandUtil.kt` to handle vendor-specific logic.
- Conditional notification building in `PreReminderForegroundService.kt` to show HyperIsland notifications on supported devices and fallback to standard notifications on others.
- Caching of the `isSupported` check to prevent performance issues.
- A native countdown timer and interactive actions ("Mark as Taken", "Stop Reminder") for the HyperIsland notification.
- Restoration of the reliable `AlarmManager -> BroadcastReceiver -> ForegroundService` pattern for starting the pre-reminder service from the background.
This commit corrects the JSON payload structure for Xiaomi HyperIsland notifications in `HyperIslandUtil.kt`. - Replaced `picInfo` and `textInfo` keys with `picInfoLeft` and `textInfoRight` respectively. This change is necessary for the operating system to correctly parse and render the notification content as intended, fixing a bug where the HyperIsland notification would not appear.
This commit fixes an issue where action buttons on Xiaomi HyperIsland notifications were not working. The root cause was an incorrect notification construction order. Based on the vendor's example, the `actions` and `pics` bundles must be added to the `Notification.Builder` *before* the notification is built. The main JSON payload (`miui.focus.param`) must then be added to the extras of the final `Notification` object *after* the build process. This commit refactors the logic in `HyperIslandUtil.kt` and `PreReminderForegroundService.kt` to follow this specific build sequence, ensuring that action buttons are correctly registered and functional.
This commit introduces a temporary test button to the Profile screen for debugging Xiaomi HyperIsland notifications. - Adds a `showTestNotification` function to `HyperIslandUtil.kt` containing the sample notification code provided by the vendor. - Adds a button to `ProfileScreen.kt` that, when clicked, triggers this test notification. This feature is for development and testing purposes and should be removed after the HyperIsland notification functionality is fully validated.
This commit updates the JSON payload for the temporary HyperIsland test notification in `HyperIslandUtil.kt`. The new JSON string provided by the user corrects the layout of the `bigIslandArea` to properly display text on the right side. This change is part of the ongoing debugging process for the HyperIsland feature.
This commit updates the temporary HyperIsland test notification based on user feedback. - The JSON payload in `showTestNotification` has been updated to the latest version provided by the user. - The image loading logic has been changed to use the full-color app launcher icon (`R.mipmap.ic_launcher_round`) instead of the monochrome `ic_stat_medication` vector. This is to fix an issue where the icon was not visible.
This commit rewrites the `buildHyperIslandJson` function in `HyperIslandUtil.kt` to correctly implement the desired "Template 6" layout. - The JSON structure is now corrected to feature an icon on the left (`picInfoLeft`) and a native countdown timer on the right (`textInfoRight` with `type: 3`). - Hardcoded test values have been removed and replaced with dynamic data from the function parameters (`medicationName`, `actualTakeTimeMillis`). - The `protocol` and `business` fields in the JSON have been corrected to use the appropriate constants for the app. This change fixes the main HyperIsland notification, which was previously using a broken and hardcoded JSON payload. The separate test notification is unaffected.
This commit refactors the JSON configuration for the HyperOS Dynamic Island feature to enhance its appearance and functionality.
- **`HyperIslandUtil.kt`**:
- Changed the `business` parameter from `"taxi"` to `"pillpal"` for better identification.
- Removed unused AOD (Always-On Display) properties (`aodTitle`, `aodPic`) to clean up the configuration.
- Replaced a static text display with a `sameWidthDigitInfo` component, which implements a countdown timer.
- Standardized the timer properties (`timerType`, `timerTotal`, `timerWhen`, `timerCurrent`) across different sections for consistency.
- Removed superfluous `extraInfo` like `carType` and `carColor`.
- Updated the notification `type` from `1` to `11`.
This commit updates the `buildHyperIslandJson` function in `HyperIslandUtil.kt` to use a new design for the `baseInfo` section of the notification. - The `baseInfo` type has been changed to `11`. - The JSON now includes an `iconInfo` block to display the app icon on the left side of the standard notification. - A `buttonInfo` array has been added to define two action buttons: a standard "Stop Reminder" button and a progress-style "Mark as Taken" button. - The progress button is linked to a `timerInfo` object that reflects the 30-minute pre-reminder countdown. This change enhances the user experience for HyperIsland notifications when they are viewed in the standard notification shade.
This commit updates the `showTestNotification` function in `HyperIslandUtil.kt` to use the new `baseInfo` design (type 11). - The `baseInfo` block in the test notification's JSON payload has been replaced with a structure that includes an `iconInfo` and a `buttonInfo` array. - The `buttonInfo` array defines two buttons for testing: one standard button and one progress-style button with a hardcoded 30-minute timer. - A second action key and `PendingIntent` have been added to handle the new button. This change brings the test notification in line with the latest design of the real notification, allowing for accurate debugging.
This commit adds a minimal `param_island` block back into the test notification's JSON payload. This is an attempt to fix a bug where the icon and buttons in the `baseInfo` (type 11) were not visible. It is suspected that the `baseInfo` type 11 might have a dependency on the presence of the `param_island` object, even if it's empty.
This commit adds support for the drag-to-open small window feature for Xiaomi HyperIsland notifications. - A `smallWindowInfo` block has been added to the JSON payloads in both the `buildHyperIslandJson` and `showTestNotification` functions in `HyperIslandUtil.kt`. - The `targetPage` is set to the app's `MainActivity`, which will be launched in a floating window when the user drags the notification.
- Refactors the `buildHyperIslandJson` function to use the `chatInfo` layout, aligning with the user-approved test notification. - Updates the notification content to be dynamic, using translatable string resources. - Passes the `Context` from `PreReminderForegroundService` to the utility function to enable string resource resolution. - This change applies the final, polished design to the production pre-reminder notifications.
Implements a unique notification ID system and drag-to-open deep linking for Xiaomi HyperIsland pre-reminders.
- **Unique Notification IDs:** Refactors the pre-reminder notification ID generation to use a hash of the medication name and scheduled time. This prevents notifications for different reminders from overwriting each other, a critical issue on Xiaomi devices.
- **Drag-to-Open Deep Link:** Implements a deep link (`pillpal://medication/{medicationId}`) that is triggered when the user drags the HyperIsland notification. This opens the corresponding `MedicationDetailsScreen`.
- **Data Plumbing:** The `medicationId` is now passed from the `ReminderSchedulingWorker` through the `NotificationScheduler` and `PreReminderBroadcastReceiver` to the `PreReminderForegroundService` to enable deep linking.
- **Navigation:** The `AppNavigation.kt` graph is updated to handle the new `pillpal://` deep link URI.
- **Timer Verification:** Confirmed that the native HyperIsland countdown timer is correctly configured for efficient per-minute updates.
…logic
This commit refactors the implementation for Xiaomi's HyperIsland (Live Activities) notifications and adjusts the related foreground service.
Key changes:
- **`HyperIslandUtil.kt`**:
- Updated the JSON payload structure for HyperIsland notifications to `param_v2` with `protocol: 3`, aligning with newer API requirements.
- Refactored the timer logic to use `timerWhen`, `timerTotal`, and `timerSystemCurrent` based on system time, replacing the previous duration-based calculation.
- Restructured the `chatInfo` and `actions` sections of the payload to support progress indicators and interactive elements correctly.
- Removed hardcoded highlight colors and simplified some UI text elements to be handled by the system.
- Introduced a test notification (`showTestNotification`) with an updated payload structure for debugging.
- **`PreReminderForegroundService.kt`**:
- Removed the `setOngoing(true)` property from the notification builder, as this is managed by the foreground service lifecycle itself.
- Simplified the notification update logic by removing a redundant check for HyperIsland devices, allowing content updates to proceed consistently.
- **`AndroidManifest.xml`**:
- Minor code formatting cleanup.
This commit introduces support for Xiaomi HyperIsland notifications for pre-reminders, as per the user's request. It includes a new utility class for handling HyperIsland-specific logic, as well as modifications to the existing notification scheduling and service classes to support this new feature. The implementation is designed to be robust and only activate on supported devices, ensuring a seamless user experience.
PR created automatically by Jules for task 15572525840136114449