Override modal bottom sheet peekHeight
This commit is contained in:
parent
069bf39ab8
commit
20db6156ca
@ -53,18 +53,6 @@ public abstract class BaseTimePickerDialog extends BottomSheetDialogFragment {
|
||||
// getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
||||
final View view = inflater.inflate(contentLayout(), container, false);
|
||||
ButterKnife.bind(this, view);
|
||||
|
||||
// // We're past onCreateDialog() in the lifecycle, so getDialog() will return something.
|
||||
// getDialog().setOnShowListener(new DialogInterface.OnShowListener() {
|
||||
// @Override
|
||||
// public void onShow(DialogInterface dialog) {
|
||||
// BottomSheetBehavior behavior = BottomSheetBehavior.from((View) view.getParent());
|
||||
// // Every time we show, show at our full height.
|
||||
// // TODO: This is the cause of our anchored FAB and number grid not showing!
|
||||
// behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||
// }
|
||||
// });
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@ -98,12 +86,13 @@ public abstract class BaseTimePickerDialog extends BottomSheetDialogFragment {
|
||||
// return builder.create();
|
||||
// }
|
||||
|
||||
// Code for BottomSheetDialogs only. To uncomment, highlight and CTRL + /
|
||||
// This was an unsatisfactory solution to forcing the bottom sheet to show at its
|
||||
// fully expanded state. Our anchored FAB and GridLayout buttons would not be visible.
|
||||
// @Override
|
||||
// public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
// Dialog dialog = super.onCreateDialog(savedInstanceState);
|
||||
// //dialog = new BottomSheetDialog(getActivity(), R.style.AppTheme_AppCompatDialog/*crashes our app!*/);
|
||||
// // We're past onCreate() in the lifecycle, so we can safely retrieve the host activity.
|
||||
// // We're past onCreate() in the lifecycle, so the activity is alive.
|
||||
// View view = LayoutInflater.from(getActivity()).inflate(contentLayout(), null);
|
||||
// /**
|
||||
// * Adds our view to a ViewGroup that has a BottomSheetBehavior attached. The ViewGroup
|
||||
@ -114,16 +103,18 @@ public abstract class BaseTimePickerDialog extends BottomSheetDialogFragment {
|
||||
// // Bind this fragment, not the internal dialog! (There is a bind(Dialog) API.)
|
||||
// ButterKnife.bind(this, view);
|
||||
// final BottomSheetBehavior behavior = BottomSheetBehavior.from((View) view.getParent());
|
||||
|
||||
// // When we collapse, collapse all the way. Do not be misled by the "docs" in
|
||||
// // https://android-developers.blogspot.com.au/2016/02/android-support-library-232.html
|
||||
// // when it says:
|
||||
// // "STATE_COLLAPSED: ... the app:behavior_peekHeight attribute (defaults to 0)"
|
||||
// // While it is true by default, BottomSheetDialogs override this default height.
|
||||
// // See http://stackoverflow.com/a/35634293/5055032 for an alternative solution involving
|
||||
// // defining a style that overrides the attribute.
|
||||
// // TODO: If the sheet is dragged out of view, then the screen remains darkened until
|
||||
// // a subsequent touch on the screen. Consider doing the alt. soln.?
|
||||
|
||||
// This means the sheet is considered "open" even at a height of 0! This is why
|
||||
// // when you swipe to hide the sheet, the screen remains darkened--indicative
|
||||
// // of an open dialog.
|
||||
// behavior.setPeekHeight(0);
|
||||
|
||||
// dialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
||||
// @Override
|
||||
// public void onShow(DialogInterface dialog) {
|
||||
|
||||
@ -323,12 +323,12 @@ public class EditAlarmActivity extends BaseActivity implements
|
||||
// last inputted time.
|
||||
// TODO: Read preferences to see what time picker style to show.
|
||||
BaseTimePickerDialog dialog;
|
||||
// dialog = NumberGridTimePickerDialog.newInstance(
|
||||
// this, // OnTimeSetListener
|
||||
// 0, // Initial hour of day
|
||||
// 0, // Initial minute
|
||||
// DateFormat.is24HourFormat(this));
|
||||
dialog = NumpadTimePickerDialog.newInstance(this);
|
||||
dialog = NumberGridTimePickerDialog.newInstance(
|
||||
this, // OnTimeSetListener
|
||||
0, // Initial hour of day
|
||||
0, // Initial minute
|
||||
DateFormat.is24HourFormat(this));
|
||||
// dialog = NumpadTimePickerDialog.newInstance(this);
|
||||
dialog.show(getSupportFragmentManager(), TAG_TIME_PICKER);
|
||||
}
|
||||
|
||||
|
||||
@ -24,4 +24,8 @@
|
||||
<!-- Bottom sheet specs -->
|
||||
<dimen name="bottom_sheet_edge_margin">24dp</dimen>
|
||||
<dimen name="bottom_sheet_vertical_space">16dp</dimen>
|
||||
<!-- If the total height of the contents of a bottom sheet does not exceed this limit,
|
||||
then the sheet will show fully expanded; the contents are not stretched to match this height.
|
||||
This is large enough to accommodate most, if not all, of our layouts. -->
|
||||
<dimen name="peek_height_upper_limit">500dp</dimen>
|
||||
</resources>
|
||||
|
||||
@ -7,7 +7,8 @@
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
<!-- TODO: This doesn't work for BottomSheetDialogs. Verify this works for other types of dialogs. -->
|
||||
<item name="dialogTheme">@style/AppTheme.AppCompatDialog</item>
|
||||
<item name="dialogTheme">@style/AppCompatDialogTheme</item>
|
||||
<item name="bottomSheetDialogTheme">@style/BottomSheetDialogTheme</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
|
||||
@ -85,8 +86,16 @@
|
||||
</style>
|
||||
|
||||
<!-- Style for AppCompatDialog from the v7 support library -->
|
||||
<style name="AppTheme.AppCompatDialog" parent="Theme.AppCompat.Light.Dialog">
|
||||
<style name="AppCompatDialogTheme" parent="Theme.AppCompat.Light.Dialog">
|
||||
<item name="colorAccent">?android:attr/colorAccent</item>
|
||||
</style>
|
||||
|
||||
<style name="BottomSheetDialogTheme" parent="Theme.Design.Light.BottomSheetDialog">
|
||||
<item name="bottomSheetStyle">@style/ModalStyle</item>
|
||||
</style>
|
||||
|
||||
<style name="ModalStyle" parent="Widget.Design.BottomSheet.Modal">
|
||||
<item name="behavior_peekHeight">@dimen/peek_height_upper_limit</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user