Fix toolbar drawing under the status bar in 4 appbar screens#60
Merged
Conversation
The JSON config editor, QR scanner, assets manager, and STUN test screens rendered their toolbar title/actions underneath the system status bar (clock/wifi/battery overlap). Root cause: each layout's `<include layout="@layout/layout_appbar">` carried android:id="@+id/appbar_include", which overrides the included AppBarLayout's own R.id.appbar. ThemedActivity applies the top status-bar inset via findViewById<AppBarLayout>(R.id.appbar) — which returned null in these layouts, so no top padding was applied. Fix (matches layout_config_settings, which renders correctly): drop the android:id from the <include> so R.id.appbar survives and ThemedActivity pads it. The toolbar is now resolved via findViewById<Toolbar>(R.id.toolbar) instead of the removed binding.appbarInclude.toolbar accessor. Affected: layout_edit_config / ConfigEditActivity, layout_scanner / ScannerActivity, layout_assets / AssetsActivity, layout_stun / StunActivity. Verified on device (Redmi Note 9, A13): config editor toolbar now sits below the status bar; editor, themes, and extended keyboard unaffected.
📝 WalkthroughWalkthroughFour layout files have ChangesToolbar Lookup Refactor
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~4 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the toolbar (title + navigate-up/actions) rendering underneath the system status bar (clock/wifi/battery overlap) on four screens:
ConfigEditActivity)ScannerActivity)AssetsActivity)StunActivity)Root cause
Each of these layouts includes the shared appbar with an id on the
<include>:Putting
android:idon an<include>overrides the root id of the included layout, so the includedAppBarLayout's ownR.id.appbarno longer exists in these layouts.ThemedActivity(base class) applies the top status-bar inset like this:Because
R.id.appbarwas shadowed byappbar_include, thisfindViewByIdreturnednull, so no top padding was applied and the toolbar drew into the status-bar region.Screens like
layout_config_settings.xmlrender correctly precisely because their<include>has no id, soR.id.appbarsurvives.Fix
Drop the
android:id="@+id/appbar_include"from the<include>in all four layouts soR.id.appbarsurvives andThemedActivitypads it. Since that removes thebinding.appbarInclude.toolbaraccessor, the toolbar is now resolved viafindViewById<Toolbar>(R.id.toolbar)(the same patternProfileSettingsActivityalready uses).Scope note
This is a pre-existing bug on
main(theappbar_includeid was introduced in the earlier merged sora-editor PR #58), independent of the in-flight toolchain PR #59. Fixed here on its own branch to keep that PR focused.Testing
:app:compileOssDebugKotlin+:app:processOssDebugResources✅CodeRabbit CLI: no findings.
Greptile Summary
Removes
android:id="@+id/appbar_include"from four layout<include>tags so the includedAppBarLayout's ownR.id.appbaris preserved, allowingThemedActivity's inset listener to apply the correct top status-bar padding. The corresponding activity code switches from the generatedbinding.appbarInclude.toolbaraccessor tofindViewById<Toolbar>(R.id.toolbar), matching the pattern already used byProfileSettingsActivity.layout_assets,layout_edit_config,layout_scanner,layout_stun): remove theandroid:idfrom<include layout="@layout/layout_appbar">soR.id.appbaris not shadowed.AssetsActivity,ScannerActivity,StunActivity,ConfigEditActivity): replacebinding.appbarInclude.toolbarwithfindViewById<Toolbar>(R.id.toolbar)to compensate for the removed binding accessor.Confidence Score: 5/5
Safe to merge — the change is a targeted, well-understood layout fix with no logic changes and no new dependencies.
All eight files change only to remove one attribute from four XML includes and update four toolbar-lookup lines to match the already-established ProfileSettingsActivity pattern. No remaining appbarInclude references exist in the codebase, the fix is consistent across all affected screens, and setContentView is always called before findViewById, so no null-return risk is introduced.
No files require special attention.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A["Activity.onCreate()\nsetContentView(binding.root)"] --> B["ThemedActivity\nsetOnApplyWindowInsetsListener"] B --> C{"findViewById\nR.id.appbar"} C -- "BEFORE (appbar_include id shadowed R.id.appbar)" --> D["null — no padding applied\nToolbar draws under status bar ❌"] C -- "AFTER (no id on include)" --> E["AppBarLayout found\nupdatePadding(top = bars.top) ✅"] A --> F["setSupportActionBar(...)"] F -- "BEFORE" --> G["binding.appbarInclude.toolbar\n(binding accessor from shadowed id)"] F -- "AFTER" --> H["findViewById(R.id.toolbar)\n(direct lookup, always resolves)"]%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%% flowchart TD A["Activity.onCreate()\nsetContentView(binding.root)"] --> B["ThemedActivity\nsetOnApplyWindowInsetsListener"] B --> C{"findViewById\nR.id.appbar"} C -- "BEFORE (appbar_include id shadowed R.id.appbar)" --> D["null — no padding applied\nToolbar draws under status bar ❌"] C -- "AFTER (no id on include)" --> E["AppBarLayout found\nupdatePadding(top = bars.top) ✅"] A --> F["setSupportActionBar(...)"] F -- "BEFORE" --> G["binding.appbarInclude.toolbar\n(binding accessor from shadowed id)"] F -- "AFTER" --> H["findViewById(R.id.toolbar)\n(direct lookup, always resolves)"]Reviews (1): Last reviewed commit: "Fix toolbar drawing under the status bar..." | Re-trigger Greptile