Skip to content

Android update #130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open

Conversation

aeringamaroff
Copy link

@aeringamaroff aeringamaroff commented Mar 17, 2025

As it stands 7.1.6 isn't compatible with the latest version of android so this PR aims to fix that.
I am not an experienced java developer so please let me know if there are any issues with my solution. I also found an error in web.ts which I solved by making buttonStyle optional.

Summary by CodeRabbit

  • Chores
    • Updated version history with new release entries, breaking change notices, and dependency upgrades.
  • Documentation
    • Revised navigation bar customization guides to reflect that the styling option is now optional.
  • New Features
    • Enhanced navigation bar appearance on newer Android devices with refined light/dark mode behavior.
  • Bug Fixes
    • Resolved several issues including missing links and improved build reliability.

Copy link

coderabbitai bot commented Mar 17, 2025

Walkthrough

The pull request introduces new version entries and updates to the CHANGELOG, including breaking changes and dependency updates. It modifies the return type of the getNavigationBarColor function in both documentation and interface definitions, making the buttonStyle property optional. Additionally, the Android plugin’s setNavigationBarColor method now uses conditional logic based on the Android version: for API level 30 and above, it utilizes the WindowInsetsController to adjust the system bars’ appearance based on the buttonStyle value, while maintaining fallback behavior for earlier versions.

Changes

File(s) Change Summary
CHANGELOG.md Added version entries (8.0.1, 8.0.3, 8.0.4, 8.0.5) dated March 17, 2025; updated version 8.0.0 with breaking changes, new features (migration to capacitor v7, upgrades to capacitor 6, plugin v0), and bug fixes.
README.md, src/…/definitions.ts Updated getNavigationBarColor return type to make the buttonStyle property optional, reflecting the updated function signature and documentation.
android/src/…/NavigationBarPlugin.java Modified setNavigationBarColor to use WindowInsetsController on Android 11+; if buttonStyle equals #000000 sets light navigation bars, otherwise resets the appearance; retains fallback for pre-Android 11 versions.

Sequence Diagram(s)

sequenceDiagram
    participant App
    participant NavigationBarPlugin
    participant AndroidOS

    App->>NavigationBarPlugin: setNavigationBarColor(buttonStyle)
    alt Device API level >= 30
        NavigationBarPlugin->>AndroidOS: Get WindowInsetsController
        alt buttonStyle equals "#000000"
            NavigationBarPlugin->>AndroidOS: Set light navigation bars
        else buttonStyle not "#000000"
            NavigationBarPlugin->>AndroidOS: Reset system bar appearance
        end
    else Device API level < 30
        NavigationBarPlugin->>AndroidOS: Apply fallback UI flags based on buttonStyle
    end
Loading

Poem

Oh, how I hop with glee in code,
New versions bloom like spring's ode.
Shifting types and styles so right,
Android bars shine in the night.
A rabbit's cheer in each commit,
With every change, our path is lit!
🐇✨

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.
✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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

New, updated, and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@capacitor/[email protected]7.1.0 None 0 427 kB ionicjs
npm/@capacitor/[email protected]7.1.0 None 0 392 kB ionicjs
npm/[email protected]8.57.1 Transitive: eval, shell, unsafe +98 10.8 MB eslintbot
npm/[email protected]3.5.3 None 0 0 B
npm/[email protected], 5.9.0-dev.202503175.8.2 None 0 22.9 MB typescript-bot

🚮 Removed packages: npm/@capacitor/[email protected], npm/@capacitor/[email protected]

View full report↗︎

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: 1

🧹 Nitpick comments (2)
CHANGELOG.md (1)

5-58: Consider adjusting heading levels to satisfy markdown lint rules.

The markdown lint tool flags these lines for skipping a heading level (MD001). If desired, you may align the headings by promoting them from H3 (###) to H2 (##) or inserting an intermediate H2 heading. Example fix:

-### [8.0.5](...)
+## [8.0.5](...)
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

5-5: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)

README.md (1)

47-51: Documentation Update: Clear Optional Property Definition

The updated function signature for getNavigationBarColor() now reflects that buttonStyle is optional with the addition of the question mark. This aligns well with the changes made in the plugin interface and helps clarify to users that while a color is always returned, buttonStyle might not be provided.

If there are additional documentation references or usage examples that rely on the previous return type, please double-check and update them accordingly.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 392732f and bd6f80d.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (4)
  • CHANGELOG.md (1 hunks)
  • README.md (1 hunks)
  • android/src/main/java/ee/forgr/capacitor_navigation_bar/NavigationBarPlugin.java (2 hunks)
  • src/definitions.ts (1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
CHANGELOG.md

5-5: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)

🔇 Additional comments (2)
src/definitions.ts (1)

19-19: Marking buttonStyle as optional looks good.

This aligns well with the default value in your Android implementation (i.e., #FFFFFF) when buttonStyle is not provided.

android/src/main/java/ee/forgr/capacitor_navigation_bar/NavigationBarPlugin.java (1)

6-6: Import addition acknowledged.

Adding WindowInsetsController is necessary for managing system bars on newer Android versions.

Comment on lines 56 to +74
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
WindowInsetsController insetsController = getActivity()
.getWindow()
.getInsetsController();
if (insetsController != null) {
if (buttonStyle.equals("#000000")) {
insetsController.setSystemBarsAppearance(
WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS,
WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS
);
} else {
insetsController.setSystemBarsAppearance(
0,
WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS
);
}
}
} else {
// Fallback for devices running below Android 11
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Correct API level check for WindowInsetsController.

getWindow().getInsetsController() is introduced in API 30 (Android 11), but you are gating with Build.VERSION_CODES.O (Android 8.0). This can cause runtime issues on devices between API levels 26 and 29. Consider using Build.VERSION_CODES.R instead:

- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
WindowInsetsController insetsController = getActivity()
.getWindow()
.getInsetsController();
if (insetsController != null) {
if (buttonStyle.equals("#000000")) {
insetsController.setSystemBarsAppearance(
WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS,
WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS
);
} else {
insetsController.setSystemBarsAppearance(
0,
WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS
);
}
}
} else {
// Fallback for devices running below Android 11
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
WindowInsetsController insetsController = getActivity()
.getWindow()
.getInsetsController();
if (insetsController != null) {
if (buttonStyle.equals("#000000")) {
insetsController.setSystemBarsAppearance(
WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS,
WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS
);
} else {
insetsController.setSystemBarsAppearance(
0,
WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS
);
}
}
} else {
// Fallback for devices running below Android 11

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