-
-
Notifications
You must be signed in to change notification settings - Fork 3
Refactor up navigation handling #164
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
Refactor up navigation handling #164
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codex Review: Here are some suggestions.
Reply with @codex fix comments to fix any unresolved comments.
About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".
| package com.d4rk.androidtutorials.java.ui.components.navigation; | ||
|
|
||
| import android.os.Bundle; | ||
|
|
||
| import androidx.annotation.Nullable; | ||
| import androidx.appcompat.app.ActionBar; | ||
| import androidx.appcompat.app.AppCompatActivity; | ||
| import androidx.core.app.NavUtils; | ||
|
|
||
| public abstract class UpNavigationActivity extends AppCompatActivity { | ||
| @Override | ||
| protected void onPostCreate(@Nullable Bundle savedInstanceState) { | ||
| super.onPostCreate(savedInstanceState); | ||
| ActionBar actionBar = getSupportActionBar(); | ||
| if (actionBar != null) { | ||
| actionBar.setDisplayHomeAsUpEnabled(true); | ||
| } | ||
| } | ||
|
|
||
| public abstract class UpNavigationActivity extends BaseActivity { | ||
| @Override | ||
| public boolean onSupportNavigateUp() { | ||
| NavUtils.navigateUpFromSameTask(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] Preserve custom edge-to-edge insets for bottom-nav activities
By switching UpNavigationActivity to extend BaseActivity, every subclass now runs BaseActivity.onPostCreate, which always calls EdgeToEdgeDelegate.apply(this, container) and installs a new window-insets listener. Activities like BottomNavigationActivity currently set up their own listener via EdgeToEdgeDelegate.applyBottomBar(...) in onCreate to pad the BottomNavigationView. The base class call happens afterward and overwrites that listener, so the bottom bar loses its padding and will overlap the system gesture/navigation bar on edge-to-edge devices. Consider letting subclasses opt out or have BaseActivity detect when insets are already handled before replacing the listener.
Useful? React with 👍 / 👎.
Summary
Testing
./gradlew test(fails: SDK location not found)https://chatgpt.com/codex/tasks/task_e_68c5dd63e638832d9dcff9070d422214