use of com.google.android.material.shape.ShapeAppearanceModel in project Carbon by ZieIony.
the class Carbon method initCornerCutRadius.
public static void initCornerCutRadius(ShapeModelView shapeModelView, TypedArray a, int[] ids) {
int carbon_cornerRadiusTopStart = ids[0];
int carbon_cornerRadiusTopEnd = ids[1];
int carbon_cornerRadiusBottomStart = ids[2];
int carbon_cornerRadiusBottomEnd = ids[3];
int carbon_cornerRadius = ids[4];
int carbon_cornerCutTopStart = ids[5];
int carbon_cornerCutTopEnd = ids[6];
int carbon_cornerCutBottomStart = ids[7];
int carbon_cornerCutBottomEnd = ids[8];
int carbon_cornerCut = ids[9];
float cornerRadius = Math.max(a.getDimension(carbon_cornerRadius, 0), 0.1f);
float cornerRadiusTopStart = a.getDimension(carbon_cornerRadiusTopStart, cornerRadius);
float cornerRadiusTopEnd = a.getDimension(carbon_cornerRadiusTopEnd, cornerRadius);
float cornerRadiusBottomStart = a.getDimension(carbon_cornerRadiusBottomStart, cornerRadius);
float cornerRadiusBottomEnd = a.getDimension(carbon_cornerRadiusBottomEnd, cornerRadius);
float cornerCut = a.getDimension(carbon_cornerCut, 0);
float cornerCutTopStart = a.getDimension(carbon_cornerCutTopStart, cornerCut);
float cornerCutTopEnd = a.getDimension(carbon_cornerCutTopEnd, cornerCut);
float cornerCutBottomStart = a.getDimension(carbon_cornerCutBottomStart, cornerCut);
float cornerCutBottomEnd = a.getDimension(carbon_cornerCutBottomEnd, cornerCut);
ShapeAppearanceModel model = ShapeAppearanceModel.builder().setTopLeftCorner(cornerCutTopStart >= cornerRadiusTopStart ? new CutCornerTreatment(cornerCutTopStart) : new RoundedCornerTreatment(cornerRadiusTopStart)).setTopRightCorner(cornerCutTopEnd >= cornerRadiusTopEnd ? new CutCornerTreatment(cornerCutTopEnd) : new RoundedCornerTreatment(cornerRadiusTopEnd)).setBottomLeftCorner(cornerCutBottomStart >= cornerRadiusBottomStart ? new CutCornerTreatment(cornerCutBottomStart) : new RoundedCornerTreatment(cornerRadiusBottomStart)).setBottomRightCorner(cornerCutBottomEnd >= cornerRadiusBottomEnd ? new CutCornerTreatment(cornerCutBottomEnd) : new RoundedCornerTreatment(cornerRadiusBottomEnd)).build();
shapeModelView.setShapeModel(model);
}
use of com.google.android.material.shape.ShapeAppearanceModel 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;
}
use of com.google.android.material.shape.ShapeAppearanceModel 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