Implement support for landscape layout for BraveWalletDAppsActivity - #38672
Implement support for landscape layout for BraveWalletDAppsActivity#38672simoarpe wants to merge 20 commits into
Conversation
|
[puLL-Merge] - brave/brave-core@38672 DescriptionRefactors Brave Wallet DApp confirmation layouts (approve tx, sign message, sign tx message, SIWE) into shared header/details/actions includes, adds landscape ( Motivation: support landscape orientation for wallet DApp screens; previous lock ( Possible Issues
ChangesChangesandroid/BUILD.gn android/java/AndroidManifest.xml BraveWalletDAppsActivity.java WalletBottomSheetDialogFragment.java TwoLineItemBottomSheetFragment.java ApproveTxBottomSheetDialogFragment.java SignMessageFragment.java SignSolTransactionsFragment.java Layout XMLs 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
|
| <!-- 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/. | ||
| --> |
There was a problem hiding this comment.
Pre-existing layout without copyright header.
| <!-- 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/. | ||
| --> |
There was a problem hiding this comment.
Pre-existing layout without copyright header.
| <!-- 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/. | ||
| --> |
There was a problem hiding this comment.
Pre-existing layout without copyright header.
Resolves brave/brave-browser#57723
This PR removes
android:screenOrientation="sensorPortrait"fromBraveWalletDAppsActivity(that will soon be ignored by the Android framework anyway).BraveWalletDAppsActivityrelies onWalletBottomSheetDialogFragmentfor showing different Dapp screens, the comprehensive list:ApproveTxBottomSheetDialogFragmentSignMessageErrorFragmentSignMessageFragmentSignSolTransactionsFragmentSiweMessageFragmentTwoLineItemBottomSheetFragmentThe 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.
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
Single column layout
Demo
ApproveTxBottomSheetDialogFragment
SignMessageErrorFragment
SignMessageFragment
SignSolTransactionsFragment
SiweMessageFragment
TwoLineItemBottomSheetFragment
Other Notable Changes
In
SignSolTransactionsFragmentlayout 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.