Skip to content

Implement support for landscape layout for BraveWalletDAppsActivity - #38672

Open
simoarpe wants to merge 20 commits into
masterfrom
simone/tablet-orientation-brave-wallet-dapps-activity
Open

Implement support for landscape layout for BraveWalletDAppsActivity#38672
simoarpe wants to merge 20 commits into
masterfrom
simone/tablet-orientation-brave-wallet-dapps-activity

Conversation

@simoarpe

@simoarpe simoarpe commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Resolves brave/brave-browser#57723

This PR removes android:screenOrientation="sensorPortrait" from BraveWalletDAppsActivity (that will soon be ignored by the Android framework anyway).

BraveWalletDAppsActivity relies on WalletBottomSheetDialogFragment for showing different Dapp screens, the comprehensive list:

  • ApproveTxBottomSheetDialogFragment
  • SignMessageErrorFragment
  • SignMessageFragment
  • SignSolTransactionsFragment
  • SiweMessageFragment
  • TwoLineItemBottomSheetFragment

The solution adopted (Slack discussion) was picked in order to have the least amount of changes in order to avoid/reduce potential regressions.

The tablet layouts (for both orientations) remain the same, the smartphone layouts in portrait remain the same, the smartphone layouts in landscape adopt a bottom sheet dialog that takes the whole width available; and some layouts adopt a two column structure.

Portrait Landscape
Tablet ✅ Remains the same ✅ Remains the same
Smartphone ✅ Remains the same 🛠️ The bottom sheet dialog takes the full available width and where required the layout adopts a two column structure.

To keep the current implementation in a maintainable state the pre-existing views have been moved into separate components that are included using the <include> tag mechanism in the main layouts.

The main layouts reuse the components adopting a different structure for smartphones in landscape.
The views with their styles, and attributes have been not altered in any way and have been moved as they into components as they are.

General example:

Two column layout for smartphones in landscape

+<androidx.constraintlayout.widget.ConstraintLayout>
+    <androidx.constraintlayout.widget.Guideline
+        android:id="@+id/column_divider"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:orientation="vertical"
+        app:layout_constraintGuide_percent="0.5"/>
+
+    <include
+        android:id="@+id/header_container"
+        layout="@layout/sign_tx_message_header"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toStartOf="@id/column_divider"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <include
+        android:id="@+id/details_container"
+        layout="@layout/sign_tx_message_details"
+        android:layout_width="0dp"
+        android:layout_height="0dp"
+        app:layout_constraintStart_toEndOf="@id/column_divider"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintBottom_toBottomOf="parent" />
+</androidx.constraintlayout.widget.ConstraintLayout>

Single column layout

+<androidx.constraintlayout.widget.ConstraintLayout>
+
+    <include
+        android:id="@+id/header_container"
+        layout="@layout/sign_tx_message_header"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <include
+        android:id="@+id/details_container"
+        layout="@layout/sign_tx_message_details"
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toBottomOf="@id/header_container"
+        app:layout_constraintBottom_toBottomOf="parent" />
+</androidx.constraintlayout.widget.ConstraintLayout>

Demo

ApproveTxBottomSheetDialogFragment

Screenshot 2026-07-31 at 4 19 49 PM

SignMessageErrorFragment

Screenshot 2026-07-31 at 4 22 26 PM

SignMessageFragment

Screenshot 2026-07-31 at 4 23 19 PM

SignSolTransactionsFragment

Screenshot 2026-07-31 at 4 20 42 PM

SiweMessageFragment

Screenshot 2026-07-31 at 4 24 05 PM

TwoLineItemBottomSheetFragment

Screenshot 2026-07-31 at 4 24 32 PM

Other Notable Changes

  • In SignSolTransactionsFragment layout the Learn More link was not reacting to user taps. The click listener has been fixed but the link seems to point to an inactive URL. This is out of scope and it need to be fixed probably on Brave's backend.

  • Some pre-existing XML layouts didn't have the copyright header. The year has been inferred by checking their creation using git blame.

@simoarpe simoarpe self-assigned this Jul 31, 2026
@simoarpe simoarpe added CI/skip-ios Do not run CI builds for iOS CI/skip-windows-x64 Do not run CI builds for Windows x64 CI/skip-macos-arm64 Do not run CI builds for macOS arm64 CI/skip-origin Do not run CI builds for Origin labels Jul 31, 2026
@github-actions

Copy link
Copy Markdown
Contributor

[puLL-Merge] - brave/brave-core@38672

Description

Refactors Brave Wallet DApp confirmation layouts (approve tx, sign message, sign tx message, SIWE) into shared header/details/actions includes, adds landscape (layout-land, layout-sw600dp-land) variants for two-column layouts. Removes forced portrait orientation lock on BraveWalletDAppsActivity, enabling rotation. Adds config-change handling and landscape-specific bottom sheet behavior (full-width, cutout padding, expand-in-landscape).

Motivation: support landscape orientation for wallet DApp screens; previous lock (sensorPortrait) prevented rotation.

Possible Issues

  • transformSavedInstanceStateForOnCreate returns null, dropping all saved fragment/view state. Any transient user input in these fragments (scroll position, unsaved edits) lost on rotation. Comment justifies reconstruction from intent/pending requests — acceptable, but verify no user-entered state exists (e.g. sign message scroll, SIWE selections).
  • expandInLandscape defers expand via content.post(). If dialog dismissed before frame runs, behavior.setState on detached sheet possible. Low risk; post runnable typically cleared, but no null/attach guard.
  • WalletBottomSheetDialogFragment.onViewCreated sets OnApplyWindowInsetsListener on root view. Subclass TwoLineItemBottomSheetFragment also uses insets timing for expand — confirm no listener conflict/override. Insets listener replaces any prior listener on same view.
  • siwe_header.xml, sign_message_header.xml: dropped android:layout_alignStart/layout_alignBottom/layout_centerHorizontal attrs from ImageViews (were RelativeLayout attrs inside MaterialCardView, likely no-ops). Confirm image still centered.
  • SignMessageFragment: removed mSignMessageText.setLines(12) for unicode warning. New sign_message_details.xml uses 0dp height constraint layout instead of fixed lines — verify EditText still sizes correctly with warning visible.
  • fragment_siwe.xml land variant: header layout_width="0dp" with both start/end constraints to parent but no guideline in phone-land variant (unlike sw600dp). Verify intended single-column.
  • Copyright years inconsistent: new files use 2026, restored headers use 2021/2022. Cosmetic.
Changes

Changes

android/BUILD.gn
Registers new layout resources (land, sw600dp-land variants + split header/details/actions layouts).

android/java/AndroidManifest.xml
Removes screenOrientation="sensorPortrait" and tools:ignore from BraveWalletDAppsActivity, enabling rotation.

BraveWalletDAppsActivity.java
Adds transformSavedInstanceStateForOnCreate returning null to drop saved fragment state on config change, preventing crash before WalletModel init.

WalletBottomSheetDialogFragment.java
Adds onViewCreated (cutout inset padding, phones only) and onStart (full-width sheet on phones via setMaxWidth(-1)).

TwoLineItemBottomSheetFragment.java
Adds onCreateDialog + expandInLandscape: expands sheet in landscape, deferred one frame for insets.

ApproveTxBottomSheetDialogFragment.java
Adds missing super.onViewCreated() call.

SignMessageFragment.java
Removes setLines(12) on unicode warning.

SignSolTransactionsFragment.java
Replaces spanned "learn more" link with setOnClickListener. Adds class doc. Removes Spanned/LinkMovementMethod imports.

Layout XMLs
Extracts shared header/details/actions includes from approve_tx_bottom_sheet, fragment_sign_message, fragment_sign_tx_message, fragment_siwe. Adds land/sw600dp-land two-column variants. Fixes fragment_siwe tools:context (was SignMessageFragment, now SiweMessageFragment). Fixes fragment_sign_tx_message context to SignSolTransactionsFragment.

sequenceDiagram
    participant User
    participant Activity as BraveWalletDAppsActivity
    participant FM as FragmentManager
    participant Fragment as WalletBottomSheetDialogFragment
    participant TwoLine as TwoLineItemBottomSheetFragment
    participant Behavior as BottomSheetBehavior

    User->>Activity: Rotate device
    Activity->>Activity: transformSavedInstanceStateForOnCreate() returns null
    Note over Activity: Saved fragment state dropped
    Activity->>Activity: finishNativeInitialization (WalletModel ready)
    Activity->>FM: Rebuild fragment from pending request
    FM->>Fragment: onViewCreated()
    Fragment->>Fragment: setOnApplyWindowInsetsListener (cutout padding, phones)
    FM->>Fragment: onStart()
    Fragment->>Behavior: setMaxWidth(-1) (full-width, phones)
    FM->>TwoLine: onCreateDialog()
    TwoLine->>TwoLine: setOnShowListener
    User->>TwoLine: Dialog shown
    alt landscape
        TwoLine->>Behavior: setSkipCollapsed(true)
        TwoLine->>TwoLine: content.post()
        Note over TwoLine: next frame (insets applied)
        TwoLine->>Behavior: setState(STATE_EXPANDED)
    end
Loading

Comment on lines +2 to +6
<!-- Copyright (c) 2021 The Brave Authors. All rights reserved.
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this file,
You can obtain one at https://mozilla.org/MPL/2.0/.
-->

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Pre-existing layout without copyright header.

Comment on lines +2 to +6
<!-- Copyright (c) 2022 The Brave Authors. All rights reserved.
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this file,
You can obtain one at https://mozilla.org/MPL/2.0/.
-->

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Pre-existing layout without copyright header.

Comment on lines +2 to +6
<!-- Copyright (c) 2022 The Brave Authors. All rights reserved.
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this file,
You can obtain one at https://mozilla.org/MPL/2.0/.
-->

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Pre-existing layout without copyright header.

@simoarpe
simoarpe requested a review from samartnik July 31, 2026 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI/skip-ios Do not run CI builds for iOS CI/skip-macos-arm64 Do not run CI builds for macOS arm64 CI/skip-origin Do not run CI builds for Origin CI/skip-windows-x64 Do not run CI builds for Windows x64 feature/web3/wallet puLL-Merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix orientation lock issue for BraveWalletDAppsActivity

1 participant