Search in sources :

Example 21 with MaterialShapeDrawable

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;
}
Also used : Window(android.view.Window) BottomSheetDialog(com.google.android.material.bottomsheet.BottomSheetDialog) MaterialShapeDrawable(com.google.android.material.shape.MaterialShapeDrawable) BottomSheetBehavior(com.google.android.material.bottomsheet.BottomSheetBehavior) KeyboardPageSearchView(org.thoughtcrime.securesms.keyboard.emoji.KeyboardPageSearchView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) EmojiPageView(org.thoughtcrime.securesms.components.emoji.EmojiPageView) ShapeAppearanceModel(com.google.android.material.shape.ShapeAppearanceModel) NonNull(androidx.annotation.NonNull)

Aggregations

MaterialShapeDrawable (com.google.android.material.shape.MaterialShapeDrawable)21 View (android.view.View)2 Window (android.view.Window)2 NonNull (androidx.annotation.NonNull)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 BottomSheetBehavior (com.google.android.material.bottomsheet.BottomSheetBehavior)2 BottomSheetDialog (com.google.android.material.bottomsheet.BottomSheetDialog)2 ShapeAppearanceModel (com.google.android.material.shape.ShapeAppearanceModel)2 EmojiPageView (org.thoughtcrime.securesms.components.emoji.EmojiPageView)2 KeyboardPageSearchView (org.thoughtcrime.securesms.keyboard.emoji.KeyboardPageSearchView)2 TypedValue (android.util.TypedValue)1