Skip to content

prepare/release#7

Merged
meticha-admin merged 3 commits into
mainfrom
prepare/release
Jun 5, 2025
Merged

prepare/release#7
meticha-admin merged 3 commits into
mainfrom
prepare/release

Conversation

@cavin-macwan

@cavin-macwan cavin-macwan commented Jun 5, 2025

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added ProGuard configuration files to preserve key public API classes and Android components for the TriggerX library, ensuring proper functionality after code shrinking and obfuscation.
  • Bug Fixes

    • Improved permission state checks to avoid dependency on context availability.
    • Updated method for obtaining the PowerManager system service to use a more robust and type-safe approach.
  • Chores

    • Enabled code shrinking and optimization for release builds in both the app and library modules.
    • Updated dependency versions for improved stability and compatibility.
    • Added and updated IDE inspection profiles for enhanced Compose and Preview code quality.
    • Removed unused imports for cleaner code.
  • Style

    • Updated user-facing toast message to provide clearer feedback when scheduling an alarm.

This commit enables Proguard for release builds in both the `app` and `triggerx` modules and updates the toast message in `HomeScreen.kt`.

Key changes:

- **app/build.gradle.kts**:
    - Set `isMinifyEnabled` to `true` for release builds.
    - Added `signingConfig = signingConfigs.getByName("debug")` to release build type for now.
- **triggerx/build.gradle.kts**:
    - Set `isMinifyEnabled` to `true` for release builds.
- **app/src/main/java/com/meticha/triggerxexample/home/HomeScreen.kt**:
    - Changed the toast message from "Scheduled for 10 seconds" to "Scheduled for 1 minute. Now you can close the App and chill".
- **triggerx/consumer-rules.pro**:
    - Added comprehensive Proguard rules to keep necessary classes, methods, and members of the `triggerx` library, including Activities, Receivers, Services, DSL classes, Permission classes, and data providers.
    - Ensured Kotlin metadata and enum methods are preserved.
- **triggerx/proguard-rules.pro**:
    - Added the same comprehensive Proguard rules as in `consumer-rules.pro` to ensure library components are not stripped during minification.
- **app/proguard-rules.pro**:
    - Added a comment indicating temporary rules for diagnosing library issues.

These changes ensure that the application and library are properly minified for release, and the user receives a more informative message when scheduling an alarm.
This commit updates several dependencies to their latest versions and introduces a new inspection profile for the project.

Key changes:

- **Dependency Updates (`gradle/libs.versions.toml`):**
    - `lifecycleRuntimeKtx`: Updated from `2.9.0` to `2.9.1`
    - `composeBom`: Updated from `2024.09.00` to `2025.06.00`
    - `appcompat`: Updated from `1.6.1` to `1.7.1`

- **Inspection Profile (`.idea/inspectionProfiles/Project_Default.xml`):**
    - Added a new project-level inspection profile (`Project_Default.xml`). This file configures various Android lint and Jetpack Compose specific inspections, setting their severity levels (e.g., ERROR, WARNING).
    - Inspections for Compose Previews and Glance Previews are enabled, including checks for top-level functions, `@Composable` annotations, and parameter validity.
    - Several Markdown related inspections are explicitly disabled.

- **Build Script Cleanup (`app/build.gradle.kts`):**
    - Removed an unused import: `org.jetbrains.kotlin.gradle.internal.builtins.StandardNames.FqNames.target`.

These changes help maintain the project's health by using up-to-date libraries and enforcing code quality standards through inspections.
This commit updates the `getSystemService` calls to use the type-safe version and removes unused imports in several files.

Key changes:

- **triggerx/src/main/java/com/meticha/triggerx/services/TriggerXForegroundService.kt**:
    - Updated `getSystemService(Context.POWER_SERVICE) as PowerManager` to `getSystemService(PowerManager::class.java)` for improved type safety.

- **triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionComposable.kt**:
    - Removed unused imports: `DisposableEffect`, `Lifecycle`, `LifecycleEventObserver`, `LocalLifecycleOwner`, and `LoggerConfig`.

- **triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionManager.kt**:
    - Removed an unused `context` variable declaration within the `allRequiredGranted()` method.

- **app/src/main/java/com/meticha/triggerxexample/ui/theme/Theme.kt**:
    - Removed unused import: `android.app.Activity`.

These changes improve code cleanliness and maintainability.
@cavin-macwan cavin-macwan self-assigned this Jun 5, 2025
@cavin-macwan cavin-macwan added the enhancement New feature or request label Jun 5, 2025
@coderabbitai

coderabbitai Bot commented Jun 5, 2025

Copy link
Copy Markdown

Walkthrough

This update introduces new ProGuard rules for both the app and library modules, enabling code shrinking and obfuscation for release builds. It also updates several dependency versions, adjusts toast messaging, and removes unused imports. Additionally, a new IntelliJ inspection profile is added, and minor internal logic and API usage improvements are made in the permission and service components.

Changes

File(s) Change Summary
.idea/inspectionProfiles/Project_Default.xml Added IntelliJ IDEA inspection profile for Compose and Preview-related code checks.
app/build.gradle.kts, triggerx/build.gradle.kts Enabled code shrinking and minification for release builds; set signing config for app release.
app/proguard-rules.pro Appended comment about temporary ProGuard rules for diagnostics.
gradle/libs.versions.toml Updated versions: lifecycleRuntimeKtx (2.9.0 → 2.9.1), composeBom (2024.09.00 → 2025.06.00), appcompat (1.6.1 → 1.7.1).
app/src/main/java/com/meticha/triggerxexample/home/HomeScreen.kt Changed toast message after scheduling alarm to indicate a 1-minute duration and suggest closing the app.
app/src/main/java/com/meticha/triggerxexample/ui/theme/Theme.kt Removed unused import for android.app.Activity.
triggerx/consumer-rules.pro, triggerx/proguard-rules.pro Added and replaced ProGuard rules to explicitly keep public API classes, Android components, and key methods for the TriggerX library.
triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionComposable.kt Removed unused imports related to lifecycle and logging.
triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionManager.kt Removed null context check in allRequiredGranted(); now directly checks permission grant status.
triggerx/src/main/java/com/meticha/triggerx/services/TriggerXForegroundService.kt Switched to type-safe getSystemService(PowerManager::class.java) for obtaining PowerManager.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant HomeScreen
    participant AlarmScheduler

    User->>HomeScreen: Clicks "Schedule Alarm"
    HomeScreen->>AlarmScheduler: scheduleOneMinuteAlarm()
    AlarmScheduler-->>HomeScreen: Alarm scheduled
    HomeScreen->>User: Show toast "Scheduled for 1 minute. Now you can close the App and chill"
Loading
sequenceDiagram
    participant BuildSystem
    participant ProGuard
    participant App
    participant TriggerXLibrary

    BuildSystem->>ProGuard: Run with new rules (app/proguard-rules.pro, triggerx/proguard-rules.pro, consumer-rules.pro)
    ProGuard->>App: Shrink and obfuscate code, keep specified classes/methods
    ProGuard->>TriggerXLibrary: Preserve public APIs, Android components, and metadata
    App->>User: Release APK with optimized and preserved functionality
Loading

Poem

A rabbit hops through code so neat,
With ProGuard rules, no class defeat!
Toasts now tell you, "Chill a while,"
Shrinking builds with bunny style.
Imports trimmed, dependencies new—
Springy, safe, and snuggly too!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🔭 Outside diff range comments (1)
triggerx/src/main/java/com/meticha/triggerx/services/TriggerXForegroundService.kt (1)

108-113: ⚠️ Potential issue

Handle nullable result from getSystemService
getSystemService(PowerManager::class.java) may return null, leading to NPE on newWakeLock(). Add a null-check or fallback, e.g.:

val powerManager =
    ContextCompat.getSystemService(this, PowerManager::class.java)
    ?: throw IllegalStateException("PowerManager not available")
🧹 Nitpick comments (1)
app/proguard-rules.pro (1)

21-25: Remove or finalize temporary ProGuard comments
The “Temporary rules for app/proguard-rules.pro to diagnose library issue” comment is placeholder-only and there are no active rules. Remove or replace it with actual ProGuard directives before releasing.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0939acd and 7fe7032.

📒 Files selected for processing (12)
  • .idea/inspectionProfiles/Project_Default.xml (1 hunks)
  • app/build.gradle.kts (1 hunks)
  • app/proguard-rules.pro (1 hunks)
  • app/src/main/java/com/meticha/triggerxexample/home/HomeScreen.kt (1 hunks)
  • app/src/main/java/com/meticha/triggerxexample/ui/theme/Theme.kt (0 hunks)
  • gradle/libs.versions.toml (1 hunks)
  • triggerx/build.gradle.kts (1 hunks)
  • triggerx/consumer-rules.pro (1 hunks)
  • triggerx/proguard-rules.pro (1 hunks)
  • triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionComposable.kt (0 hunks)
  • triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionManager.kt (0 hunks)
  • triggerx/src/main/java/com/meticha/triggerx/services/TriggerXForegroundService.kt (1 hunks)
💤 Files with no reviewable changes (3)
  • app/src/main/java/com/meticha/triggerxexample/ui/theme/Theme.kt
  • triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionComposable.kt
  • triggerx/src/main/java/com/meticha/triggerx/permission/TriggerXPermissionManager.kt
🔇 Additional comments (6)
gradle/libs.versions.toml (1)

9-12: Dependency version bumps
lifecycle-runtime-ktx upgraded to 2.9.1, Compose BOM to 2025.06.00, and AppCompat to 1.7.1. These align with the release objective and should be safe to update.

triggerx/build.gradle.kts (1)

37-37: Verify ProGuard keep rules when minification is enabled
isMinifyEnabled = true can strip needed public API and lifecycle methods. Ensure proguard-rules.pro and consumer-rules.pro cover all TriggerX public interfaces and Android components.

app/build.gradle.kts (1)

42-42: Good practice: Enabling minification for release builds.

Enabling isMinifyEnabled = true for release builds is excellent for reducing APK size and code obfuscation. This aligns well with the comprehensive ProGuard rules added in the TriggerX library.

.idea/inspectionProfiles/Project_Default.xml (1)

1-69: Excellent addition: Comprehensive Compose inspection profile.

This inspection profile provides valuable code quality checks for Jetpack Compose development, including:

  • Preview dimension validation and constraints
  • Proper composable annotations enforcement
  • Unit test file restrictions for previews
  • Parameter provider validations

The severity levels are well-configured (ERROR for critical issues, WARNING/WEAK WARNING for others). Disabling Markdown inspections is reasonable to reduce noise.

triggerx/proguard-rules.pro (1)

1-65: Well-structured ProGuard rules for library protection.

These rules provide comprehensive protection for the TriggerX library's public API and Android components:

Strengths:

  • Preserves all main public API classes and interfaces
  • Protects Android lifecycle components with critical methods
  • Maintains Kotlin metadata for reflection and coroutines
  • Includes enum reflection methods (values(), valueOf())
  • Specific member preservation for key classes like TriggerXPreferences

The rules strike a good balance between enabling code optimization while preventing obfuscation of essential library functionality.

triggerx/consumer-rules.pro (1)

1-65: Appropriate consumer rules for library distribution.

These consumer rules ensure that when other projects include the TriggerX library, the same comprehensive API protection is automatically applied. This prevents common integration issues where consuming projects might inadvertently strip or obfuscate library classes during their own build process.

The identical content to proguard-rules.pro is correct - both the library build and consumer builds need the same protections.

Comment thread app/src/main/java/com/meticha/triggerxexample/home/HomeScreen.kt
Comment thread app/build.gradle.kts
@meticha-admin
meticha-admin merged commit 5c44645 into main Jun 5, 2025
1 check passed
@meticha-admin
meticha-admin deleted the prepare/release branch June 5, 2025 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants