use of com.google.android.material.shape.MaterialShapeDrawable in project Signal-Android by signalapp.
the class ReactWithAnyEmojiBottomSheetDialogFragment method onCreateDialog.
@Override
@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
BottomSheetDialog dialog = (BottomSheetDialog) super.onCreateDialog(savedInstanceState);
dialog.getBehavior().setPeekHeight((int) (getResources().getDisplayMetrics().heightPixels * 0.50));
ShapeAppearanceModel shapeAppearanceModel = ShapeAppearanceModel.builder().setTopLeftCorner(CornerFamily.ROUNDED, ViewUtil.dpToPx(requireContext(), 18)).setTopRightCorner(CornerFamily.ROUNDED, ViewUtil.dpToPx(requireContext(), 18)).build();
MaterialShapeDrawable dialogBackground = new MaterialShapeDrawable(shapeAppearanceModel);
dialogBackground.setTint(ContextCompat.getColor(requireContext(), R.color.react_with_any_background));
dialog.getBehavior().addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
if (bottomSheet.getBackground() != dialogBackground) {
ViewCompat.setBackground(bottomSheet, dialogBackground);
}
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
}
});
boolean shadows = requireArguments().getBoolean(ARG_SHADOWS, true);
if (!shadows) {
Window window = dialog.getWindow();
if (window != null) {
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
}
}
return dialog;
}
Aggregations