Skip to content

Commit

Permalink
Merge pull request #6543 from brave/pr6537_privacy_report_bottom_shee…
Browse files Browse the repository at this point in the history
…t_behaviour_1.14.x

Update bottomsheet behaviour (uplift to 1.14.x)
  • Loading branch information
kjozwiak authored Sep 1, 2020
2 parents 180e09f + 4163c36 commit dc87b8a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,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() {
@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 @@ -168,27 +172,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>

0 comments on commit dc87b8a

Please sign in to comment.