Skip to content

Conversation

@Hamza417
Copy link
Owner

@Hamza417 Hamza417 commented Aug 5, 2025

closes #329

Summary by CodeRabbit

  • New Features

    • Introduced a new seekable shared axis transition animation for smoother and more interactive navigation effects.
    • Enabled predictive back navigation support on supported Android versions.
  • Improvements

    • Enhanced back gesture responsiveness by updating view transparency during navigation.
    • Updated fragment transitions to use the new animation for a more seamless user experience.
  • Bug Fixes

    • Corrected fragment navigation logic to improve initial screen display.
  • Chores

    • Updated application settings to support advanced back navigation features.

@coderabbitai
Copy link

coderabbitai bot commented Aug 5, 2025

Walkthrough

The changes enable predictive back navigation by setting android:enableOnBackInvokedCallback to true in both manifest files, introduce a custom SeekableSharedAxisZTransition class for seekable back animations, update fragment transitions to use this new class, and make minor fragment transaction and UI gesture adjustments.

Changes

Cohort / File(s) Change Summary
Manifest: Enable Predictive Back
app/src/github/AndroidManifest.xml, app/src/main/AndroidManifest.xml
Set android:enableOnBackInvokedCallback attribute to true in both manifest files to enable predictive back navigation support.
Main Activity Default Fragment
app/src/main/java/app/simple/inure/activities/app/MainActivity.kt
Changed default fragment in openPanel method from SplashScreen to Home for unspecified intent actions; added unused import.
Custom Seekable Transition
app/src/main/java/app/simple/inure/decorations/transitions/SeekableSharedAxisZTransition.java
Added new SeekableSharedAxisZTransition class implementing a seekable Z-axis shared transition for predictive back navigation, with custom scaling and alpha animations.
Fragment Transition & Transaction Updates
app/src/main/java/app/simple/inure/extensions/fragments/ScopedFragment.kt
Updated to use SeekableSharedAxisZTransition for Z-axis transitions; enabled gesture-driven alpha updates; changed fragment transactions from replace() to add() in openFragmentArc.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SystemUI
    participant MainActivity
    participant Fragment
    participant SeekableTransition

    User->>SystemUI: Initiate back gesture
    SystemUI->>MainActivity: onBackInvoked callback (predictive)
    MainActivity->>Fragment: Handle back navigation
    Fragment->>SeekableTransition: Animate transition (seekable)
    SeekableTransition-->>Fragment: Update view scale/alpha per gesture progress
    SystemUI->>User: Show predictive back animation
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Assessment against linked issues

Objective Addressed Explanation
Enable predictive back navigation by setting enableOnBackInvokedCallback to true (#329)
Implement seekable/shared axis Z transition for predictive back animation (#329)
Update fragment transitions and gesture handling for predictive back (#329)

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Change of default fragment from SplashScreen to Home in openPanel (MainActivity.kt) This change is unrelated to predictive back navigation or transition animation as described in #329.
Addition of unused import (HomeSp) in MainActivity.kt The import is not related to predictive back navigation or transitions and is not used in the code.

Poem

A hop, a skip, predictive back is here,
With seekable transitions—crystal clear!
Fragments now dance on Z’s gentle breeze,
Home appears first, SplashScreen takes its ease.
With every back gesture, smooth as can be—
This bunny’s app hops with new harmony! 🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

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

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch predictive_back

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

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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

🧹 Nitpick comments (3)
app/src/main/java/app/simple/inure/decorations/transitions/SeekableSharedAxisZTransition.java (2)

34-36: Consider narrowing the ImageView exclusion scope.

Returning null for all ImageView instances might cause inconsistent visual behavior where some views animate while images don't. Consider either:

  1. Allowing ImageView animations but with different parameters
  2. Adding a more specific condition (e.g., checking for specific tags or IDs)
  3. Documenting why ImageViews are excluded

15-18: Consider making animation parameters configurable.

The scale values and duration are hardcoded, which limits customization. Consider adding setter methods or constructor parameters for these values to make the transition more flexible.

app/src/main/java/app/simple/inure/activities/app/MainActivity.kt (1)

6-6: Remove unused import.

The import android.net.wifi.hotspot2.pps.HomeSp is not used anywhere in the file and should be removed to keep the code clean.

-import android.net.wifi.hotspot2.pps.HomeSp
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 49acb90 and 8c5fe55.

📒 Files selected for processing (5)
  • app/src/github/AndroidManifest.xml (1 hunks)
  • app/src/main/AndroidManifest.xml (1 hunks)
  • app/src/main/java/app/simple/inure/activities/app/MainActivity.kt (2 hunks)
  • app/src/main/java/app/simple/inure/decorations/transitions/SeekableSharedAxisZTransition.java (1 hunks)
  • app/src/main/java/app/simple/inure/extensions/fragments/ScopedFragment.kt (5 hunks)
🔇 Additional comments (6)
app/src/github/AndroidManifest.xml (1)

65-65: LGTM! Correctly enables predictive back callback.

This change properly enables the OnBackInvokedCallback feature for Android 14+ predictive back gestures, which aligns with the PR objective to support predictive back animations.

app/src/main/AndroidManifest.xml (1)

64-64: LGTM! Consistent with github variant.

Correctly enables predictive back callbacks for the main build variant, maintaining consistency with the github variant manifest.

app/src/main/java/app/simple/inure/extensions/fragments/ScopedFragment.kt (4)

44-44: LGTM! Correctly imports the new transition class.


297-300: LGTM! Proper integration of seekable transition.

The transition type configuration correctly uses the new SeekableSharedAxisZTransition with appropriate direction flags for each transition phase (enter, exit, reenter, return).


626-626: LGTM! Enables visual feedback during back gestures.

Uncommenting this line provides important visual feedback during predictive back gestures by updating the view's alpha based on progress.


752-752: Verify intentional use of add() instead of replace()

A global search confirms that every other fragment transaction against R.id.app_container uses replace(). This one-off switch to add() changes the lifecycle and back-stack semantics—existing fragments aren’t removed, and callbacks like onPause()/onStop() won’t fire on the hidden instance.

Please confirm this is deliberate and that you’ve tested:

  • Memory usage when stacking fragments rather than replacing
  • Proper invocation of lifecycle callbacks on both old and new fragments
  • Back-navigation behavior and UI layering (especially for arc transitions)

Also consider adding a brief code comment or updating documentation to explain why add() is required here.

if (AppUtils.isDebug()) {
supportFragmentManager.beginTransaction()
.replace(R.id.app_container, SplashScreen.newInstance(false), SplashScreen.TAG)
.replace(R.id.app_container, Home.newInstance(), SplashScreen.TAG)
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify fragment tag consistency with the new fragment type.

The code now instantiates Home.newInstance() but still uses SplashScreen.TAG as the fragment tag. This creates a mismatch between the actual fragment type and its tag, which could lead to confusion when debugging or managing fragment transactions.

Consider either:

  1. Using Home.TAG instead of SplashScreen.TAG for consistency
  2. Or keeping SplashScreen.TAG if there's a specific reason (e.g., maintaining backward compatibility with existing fragment management logic)

Also applies to: 250-250


🏁 Script executed:

#!/bin/bash
# Search for usage of SplashScreen.TAG to understand if this tag is used elsewhere
# and whether changing it would break existing functionality
rg -A 3 -B 3 "SplashScreen\.TAG"

# Also check if Home.TAG exists and how it's used
rg -A 3 -B 3 "Home\.TAG"

Length of output: 2252


Align Home fragment tag with its type in MainActivity

The debug and non-debug branches for isNewIntent are still using SplashScreen.TAG when replacing with Home.newInstance(). Update both occurrences to use Home.TAG for clarity and consistency.

• File: app/src/main/java/app/simple/inure/activities/app/MainActivity.kt
– Around lines 246 and 250

Diff:

- .replace(R.id.app_container, Home.newInstance(), SplashScreen.TAG)
+ .replace(R.id.app_container, Home.newInstance(), Home.TAG)

If there’s a deliberate reason to continue using SplashScreen.TAG here (e.g., legacy logic), please document it in a comment.

🤖 Prompt for AI Agents
In app/src/main/java/app/simple/inure/activities/app/MainActivity.kt around
lines 246 and 250, the fragment replacement calls for Home.newInstance()
incorrectly use SplashScreen.TAG as the tag. Update both occurrences to use
Home.TAG instead to maintain clarity and consistency with the fragment type. If
there is a specific reason to keep using SplashScreen.TAG, add a comment
explaining this decision.

Comment on lines +32 to +51
private Animator createAnimator(final View view, final float startScale, final float endScale,
final float startAlpha, final float endAlpha) {
if (view instanceof ImageView) {
return null;
}

ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f);
animator.setDuration(DEFAULT_DURATION);
animator.setInterpolator(new DecelerateInterpolator(DECELERATE_FACTOR));
animator.addUpdateListener(animation -> {
float progress = (float) animation.getAnimatedValue();
float scale = startScale + (endScale - startScale) * progress;
float alpha = startAlpha + (endAlpha - startAlpha) * progress;
view.setScaleX(scale);
view.setScaleY(scale);
view.setAlpha(alpha);
});

return animator;
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add null safety check for the view parameter.

The createAnimator method should validate the view parameter to prevent potential NPEs.

 private Animator createAnimator(final View view, final float startScale, final float endScale,
         final float startAlpha, final float endAlpha) {
+    if (view == null) {
+        return null;
+    }
     if (view instanceof ImageView) {
         return null;
     }
📝 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
private Animator createAnimator(final View view, final float startScale, final float endScale,
final float startAlpha, final float endAlpha) {
if (view instanceof ImageView) {
return null;
}
ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f);
animator.setDuration(DEFAULT_DURATION);
animator.setInterpolator(new DecelerateInterpolator(DECELERATE_FACTOR));
animator.addUpdateListener(animation -> {
float progress = (float) animation.getAnimatedValue();
float scale = startScale + (endScale - startScale) * progress;
float alpha = startAlpha + (endAlpha - startAlpha) * progress;
view.setScaleX(scale);
view.setScaleY(scale);
view.setAlpha(alpha);
});
return animator;
}
private Animator createAnimator(final View view, final float startScale, final float endScale,
final float startAlpha, final float endAlpha) {
if (view == null) {
return null;
}
if (view instanceof ImageView) {
return null;
}
ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f);
animator.setDuration(DEFAULT_DURATION);
animator.setInterpolator(new DecelerateInterpolator(DECELERATE_FACTOR));
animator.addUpdateListener(animation -> {
float progress = (float) animation.getAnimatedValue();
float scale = startScale + (endScale - startScale) * progress;
float alpha = startAlpha + (endAlpha - startAlpha) * progress;
view.setScaleX(scale);
view.setScaleY(scale);
view.setAlpha(alpha);
});
return animator;
}
🤖 Prompt for AI Agents
In
app/src/main/java/app/simple/inure/decorations/transitions/SeekableSharedAxisZTransition.java
around lines 32 to 51, the createAnimator method lacks a null check for the view
parameter, which can cause NullPointerExceptions. Add a null check at the start
of the method to return null or handle the case appropriately if view is null
before proceeding with any operations on it.

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.

enableOnBackInvokedCallback true

2 participants