Search in sources :

Example 6 with MaterialShapeDrawable

use of com.google.android.material.shape.MaterialShapeDrawable in project Carbon by ZieIony.

the class Toolbar method setShapeModel.

@Override
public void setShapeModel(@NotNull ShapeAppearanceModel model) {
    this.shapeModel = model;
    shadowDrawable = new MaterialShapeDrawable(shapeModel);
    if (getWidth() > 0 && getHeight() > 0)
        updateCorners();
    if (!Carbon.IS_LOLLIPOP_OR_HIGHER)
        postInvalidate();
}
Also used : MaterialShapeDrawable(com.google.android.material.shape.MaterialShapeDrawable)

Example 7 with MaterialShapeDrawable

use of com.google.android.material.shape.MaterialShapeDrawable in project Signal-Android by WhisperSystems.

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)

Example 8 with MaterialShapeDrawable

use of com.google.android.material.shape.MaterialShapeDrawable in project ForPDA by RadiationX.

the class BottomSheetBehaviorFixed method createMaterialShapeDrawable.

private void createMaterialShapeDrawable(@NonNull Context context, AttributeSet attrs, boolean hasBackgroundTint, @Nullable ColorStateList bottomSheetColor) {
    if (this.shapeThemingEnabled) {
        this.shapeAppearanceModelDefault = ShapeAppearanceModel.builder(context, attrs, R.attr.bottomSheetStyle, DEF_STYLE_RES).build();
        this.materialShapeDrawable = new MaterialShapeDrawable(shapeAppearanceModelDefault);
        this.materialShapeDrawable.initializeElevationOverlay(context);
        if (hasBackgroundTint && bottomSheetColor != null) {
            materialShapeDrawable.setFillColor(bottomSheetColor);
        } else {
            // If the tint isn't set, use the theme default background color.
            TypedValue defaultColor = new TypedValue();
            context.getTheme().resolveAttribute(android.R.attr.colorBackground, defaultColor, true);
            materialShapeDrawable.setTint(defaultColor.data);
        }
    }
}
Also used : MaterialShapeDrawable(com.google.android.material.shape.MaterialShapeDrawable) TypedValue(android.util.TypedValue)

Example 9 with MaterialShapeDrawable

use of com.google.android.material.shape.MaterialShapeDrawable in project Carbon by ZieIony.

the class CollapsingToolbarLayout method setShapeModel.

@Override
public void setShapeModel(@NotNull ShapeAppearanceModel model) {
    this.shapeModel = model;
    shadowDrawable = new MaterialShapeDrawable(shapeModel);
    if (getWidth() > 0 && getHeight() > 0)
        updateCorners();
    if (!Carbon.IS_LOLLIPOP_OR_HIGHER)
        postInvalidate();
}
Also used : MaterialShapeDrawable(com.google.android.material.shape.MaterialShapeDrawable)

Example 10 with MaterialShapeDrawable

use of com.google.android.material.shape.MaterialShapeDrawable in project Carbon by ZieIony.

the class MotionLayout method setShapeModel.

@Override
public void setShapeModel(@NotNull ShapeAppearanceModel model) {
    this.shapeModel = model;
    shadowDrawable = new MaterialShapeDrawable(shapeModel);
    if (getWidth() > 0 && getHeight() > 0)
        updateCorners();
    if (!Carbon.IS_LOLLIPOP_OR_HIGHER)
        postInvalidate();
}
Also used : MaterialShapeDrawable(com.google.android.material.shape.MaterialShapeDrawable)

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