Skip to content
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

Update bottomsheet behaviour (uplift to 1.14.x) #6543

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,20 @@ public void onCreate(Bundle savedInstanceState) {
public void setupDialog(Dialog dialog, int style) {
super.setupDialog(dialog, style);

View view = LayoutInflater.from(getContext()).inflate(R.layout.brave_stats_bottom_sheet, null);
final View view = LayoutInflater.from(getContext()).inflate(R.layout.brave_stats_bottom_sheet, null);

emptyDataLayout = view.findViewById(R.id.brave_stats_empty_layout);

getDialog().setOnShowListener(new DialogInterface.OnShowListener() {
getDialog().setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
BottomSheetDialog d = (BottomSheetDialog) dialog;
View bottomSheetInternal = d.findViewById(com.google.android.material.R.id.design_bottom_sheet);
bottomSheetInternal.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT;
View bottomSheetInternal = (View)view.getParent();
boolean isTablet = DeviceFormFactor.isNonMultiDisplayContextOnTablet(getActivity());
if (!isTablet) {
bottomSheetInternal.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT;
}
bottomSheetInternal.requestLayout();
}
});

Expand Down Expand Up @@ -166,27 +170,25 @@ public void onClick(View v) {
dialog.setContentView(view);
}

@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);

private void setWidthForDialog() {
boolean isTablet = DeviceFormFactor.isNonMultiDisplayContextOnTablet(getActivity());
if (isTablet || (!isTablet && newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)) {
if (isTablet) {
getDialog().getWindow().setLayout(dpToPx(getActivity(), 400), -1);
} else {
getDialog().getWindow().setLayout(-1, -1);
}
}

@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
setWidthForDialog();
}

@Override
public void onResume() {
super.onResume();
boolean isTablet = DeviceFormFactor.isNonMultiDisplayContextOnTablet(getActivity());
if (isTablet || (!isTablet && ConfigurationUtils.isLandscape(getActivity()))) {
getDialog().getWindow().setLayout(dpToPx(getActivity(), 400), -1);
} else {
getDialog().getWindow().setLayout(-1, -1);
}
setWidthForDialog();
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions android/java/res/layout/brave_stats_pager_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* 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 http://mozilla.org/MPL/2.0/. -->
<ScrollView
<androidx.core.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
Expand Down Expand Up @@ -220,4 +220,4 @@

</LinearLayout>

</ScrollView>
</androidx.core.widget.NestedScrollView>