Skip to content

Conversation

@cavin-macwan
Copy link
Contributor

@cavin-macwan cavin-macwan commented Jul 26, 2025

Summary by CodeRabbit

  • New Features

    • Added configuration options to control displaying the alarm activity when the device is active or the app is in the foreground.
    • User preferences for these options are now saved and loaded automatically.
  • Improvements

    • Alarm service respects user preferences and app/device state, exiting early if conditions are not met.
    • Enhanced comments and documentation for clarity.
  • Other

    • Updated version to 1.0.0.

@cavin-macwan cavin-macwan self-assigned this Jul 26, 2025
@cavin-macwan cavin-macwan added enhancement New feature or request good first issue Good for newcomers labels Jul 26, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jul 26, 2025

Walkthrough

This update introduces two new configuration options to control whether the custom alarm activity should be shown when the device is active or when the app is in the foreground. The options are integrated into the configuration, persistence, and service logic. Additionally, version numbers are incremented to 1.0.0, and minor documentation and comment improvements are made.

Changes

File(s) Change Summary
.github/workflows/release.yaml, triggerx/build.gradle.kts Bumped version from 0.0.9 to 1.0.0 in workflow and build metadata.
app/src/main/java/com/meticha/triggerxexample/TriggerXApplication.kt Set showAlarmActivityWhenAppIsActive to false in the app's TriggerX configuration.
triggerx/src/main/java/com/meticha/triggerx/TriggerXAlarmScheduler.kt Minor comment clarifications in scheduleAlarm function.
triggerx/src/main/java/com/meticha/triggerx/dsl/TriggerX.kt Added two internal functions for checking alarm activity display preferences based on config.
triggerx/src/main/java/com/meticha/triggerx/dsl/TriggerXConfig.kt Added two public Boolean properties to control alarm activity display; updated usage example comment.
triggerx/src/main/java/com/meticha/triggerx/preference/TriggerXPreference.kt Added preference keys and logic to persist/load the two new Boolean config properties.
triggerx/src/main/java/com/meticha/triggerx/services/TriggerXForegroundService.kt Enhanced alarm service to respect new config options; added isAppInForeground() extension; improved notification manager retrieval.

Sequence Diagram(s)

sequenceDiagram
    participant App
    participant TriggerXConfig
    participant TriggerXPreference
    participant TriggerXForegroundService

    App->>TriggerXConfig: Set shouldShowAlarmActivityWhenDeviceIsActive / showAlarmActivityWhenAppIsActive
    App->>TriggerXPreference: Save config (including new flags)
    Note right of TriggerXPreference: Persist new Boolean flags
    TriggerXForegroundService->>TriggerXPreference: Load config
    TriggerXForegroundService->>TriggerXConfig: Read flags
    alt Device is interactive and flag disallows
        TriggerXForegroundService-->>TriggerXForegroundService: Stop service early
    else App is foreground and flag disallows
        TriggerXForegroundService-->>TriggerXForegroundService: Stop service early
    else
        TriggerXForegroundService->>TriggerXForegroundService: Continue alarm processing
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Suggested reviewers

  • meticha-admin

Poem

In the garden of code, a rabbit hops with glee,
Two new flags for alarms—what will the future be?
Now the app and device can rest or sound the bell,
With version one-point-oh, all is working well!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between df55321 and d0cf0e1.

📒 Files selected for processing (5)
  • app/src/main/java/com/meticha/triggerxexample/TriggerXApplication.kt (1 hunks)
  • triggerx/src/main/java/com/meticha/triggerx/dsl/TriggerX.kt (1 hunks)
  • triggerx/src/main/java/com/meticha/triggerx/dsl/TriggerXConfig.kt (2 hunks)
  • triggerx/src/main/java/com/meticha/triggerx/preference/TriggerXPreference.kt (4 hunks)
  • triggerx/src/main/java/com/meticha/triggerx/services/TriggerXForegroundService.kt (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • app/src/main/java/com/meticha/triggerxexample/TriggerXApplication.kt
  • triggerx/src/main/java/com/meticha/triggerx/dsl/TriggerX.kt
  • triggerx/src/main/java/com/meticha/triggerx/dsl/TriggerXConfig.kt
  • triggerx/src/main/java/com/meticha/triggerx/preference/TriggerXPreference.kt
  • triggerx/src/main/java/com/meticha/triggerx/services/TriggerXForegroundService.kt
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/customise-alarm-behavior

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Nitpick comments (6)
triggerx/build.gradle.kts (1)

103-110: Version bump looks correct, but consider removing hard-coded duplicates.

coordinates(... "1.0.0") and the explicit pom.version = "1.0.0" will need to be kept in sync with every future release, in addition to VERSION_NAME in the workflow. A single source of truth (e.g., VERSION_NAME declared in a gradle property and referenced here) eliminates the risk of drifting values.

.github/workflows/release.yaml (1)

9-10: Workflow still hard-codes the version string.

Now that the Gradle build script also carries a literal "1.0.0", the release process relies on two separate places being updated together. To avoid the inevitable mismatch at some point, fetch the version from gradle.properties (already created in the “Setup gradle.properties” step) and reuse it as the env variable instead of duplicating it here.

triggerx/src/main/java/com/meticha/triggerx/dsl/TriggerX.kt (1)

74-78: Well-implemented internal helper functions.

The functions correctly provide access to configuration flags with sensible fallback defaults. The true defaults ensure backward compatibility when configurations are not explicitly set.

Consider adding brief KDoc comments for better maintainability:

+    /**
+     * Returns whether alarm activity should be shown when app is in the foreground.
+     * Defaults to true if not configured.
+     */
     internal fun showAlarmActivityWhenAppIsActive(): Boolean =
         config?.showAlarmActivityWhenAppIsActive ?: true

+    /**
+     * Returns whether alarm activity should be shown when device is active/unlocked.
+     * Defaults to true if not configured.
+     */
     internal fun showAlarmActivityWhenDeviceIsActive(): Boolean =
         config?.shouldShowAlarmActivityWhenDeviceIsActive ?: true
triggerx/src/main/java/com/meticha/triggerx/dsl/TriggerXConfig.kt (2)

62-66: Fix documentation typos and improve clarity.

There are grammatical errors and the documentation could be clearer about what "device is active" means.

     /**
-     * This is used to know if the user's device is in the unlocked state, then weather they
-     * want to show the custom alarm dialog or not.
+     * Controls whether the custom alarm activity should be shown when the device is active/unlocked.
+     * When false, the alarm activity will not be shown if the device is currently interactive.
      */
     var shouldShowAlarmActivityWhenDeviceIsActive: Boolean = true

68-72: Fix documentation typos and improve naming consistency.

There are grammatical errors and inconsistent naming with the other property.

     /**
-     * This is used to know that if the user's App is running (in the foreground state),
-     * then weather they want to show the custom dialog or not.
+     * Controls whether the custom alarm activity should be shown when the app is in the foreground.
+     * When false, the alarm activity will not be shown if the app is currently visible to the user.
      */
-    var showAlarmActivityWhenAppIsActive: Boolean = true
+    var shouldShowAlarmActivityWhenAppIsActive: Boolean = true

Note: This naming change would require updating the corresponding references in other files for consistency.

triggerx/src/main/java/com/meticha/triggerx/services/TriggerXForegroundService.kt (1)

87-87: Update comment to be more comprehensive.

The comment mentions checking "if their App is open or not" but doesn't mention the device active state check that's also being added. Consider updating it to cover both conditions.

- * - Checks if the user wants to show the activity if their App is open or not
+ * - Checks user preferences for showing activity based on app foreground state and device active state
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0505dd1 and df55321.

📒 Files selected for processing (8)
  • .github/workflows/release.yaml (1 hunks)
  • app/src/main/java/com/meticha/triggerxexample/TriggerXApplication.kt (1 hunks)
  • triggerx/build.gradle.kts (1 hunks)
  • triggerx/src/main/java/com/meticha/triggerx/TriggerXAlarmScheduler.kt (2 hunks)
  • triggerx/src/main/java/com/meticha/triggerx/dsl/TriggerX.kt (1 hunks)
  • triggerx/src/main/java/com/meticha/triggerx/dsl/TriggerXConfig.kt (2 hunks)
  • triggerx/src/main/java/com/meticha/triggerx/preference/TriggerXPreference.kt (4 hunks)
  • triggerx/src/main/java/com/meticha/triggerx/services/TriggerXForegroundService.kt (5 hunks)
🔇 Additional comments (6)
app/src/main/java/com/meticha/triggerxexample/TriggerXApplication.kt (1)

36-36: LGTM! Clean demonstration of the new configuration option.

The addition of shouldShowAlarmActivityWhenDeviceIsActive = false properly demonstrates the usage of the new feature, showing how developers can configure the alarm behavior based on device state.

triggerx/src/main/java/com/meticha/triggerx/TriggerXAlarmScheduler.kt (2)

60-61: Improved comment clarity.

The updated comments provide better context about optional user notification and permission handling flow.


79-79: More precise AlarmClockInfo documentation.

The clarification that alarm clock behavior is "shown in the status bar" is more accurate and helpful.

triggerx/src/main/java/com/meticha/triggerx/preference/TriggerXPreference.kt (1)

22-22: Proper import addition.

The booleanPreferencesKey import is correctly added for the new boolean preference functionality.

triggerx/src/main/java/com/meticha/triggerx/services/TriggerXForegroundService.kt (2)

19-19: LGTM: Import added for ActivityManager.

The import is correctly added to support the new functionality for checking if the app is in foreground.


201-201: LGTM: Improved NotificationManager service retrieval.

Using getSystemService(NotificationManager::class.java) is more type-safe than casting from string service name.

…es where the && conditions were not properly setup
@cavin-macwan
Copy link
Contributor Author

Fixes #21

@meticha-admin meticha-admin merged commit 00e5ad3 into main Jul 26, 2025
1 check passed
@meticha-admin meticha-admin deleted the feature/customise-alarm-behavior branch July 26, 2025 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request good first issue Good for newcomers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants