Skip to content

Commit 9ae6b7f

Browse files
pubiqqkendrickumstattd
authored andcommitted
[Slider] Get default minTouchTargetSize from material attributes
Resolves #4546 - ceb3c6e by pubiqq <serj.ese@gmail.com> PiperOrigin-RevId: 760682756
1 parent ae68654 commit 9ae6b7f

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

lib/java/com/google/android/material/slider/BaseSlider.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@
8484
import androidx.annotation.ColorInt;
8585
import androidx.annotation.ColorRes;
8686
import androidx.annotation.DimenRes;
87-
import androidx.annotation.Dimension;
8887
import androidx.annotation.DrawableRes;
8988
import androidx.annotation.IntDef;
9089
import androidx.annotation.IntRange;
@@ -103,6 +102,7 @@
103102
import com.google.android.material.internal.ThemeEnforcement;
104103
import com.google.android.material.internal.ViewUtils;
105104
import com.google.android.material.motion.MotionUtils;
105+
import com.google.android.material.resources.MaterialAttributes;
106106
import com.google.android.material.resources.MaterialResources;
107107
import com.google.android.material.shape.MaterialShapeDrawable;
108108
import com.google.android.material.shape.ShapeAppearanceModel;
@@ -294,9 +294,6 @@ abstract class BaseSlider<
294294
private static final float RIGHT_LABEL_PIVOT_X = -0.2f;
295295
private static final float RIGHT_LABEL_PIVOT_Y = 0.5f;
296296

297-
@Dimension(unit = Dimension.DP)
298-
private static final int MIN_TOUCH_TARGET_DP = 48;
299-
300297
@NonNull private final Paint inactiveTrackPaint;
301298
@NonNull private final Paint activeTrackPaint;
302299
@NonNull private final Paint thumbPaint;
@@ -547,8 +544,7 @@ private void processAttributes(Context context, AttributeSet attrs, int defStyle
547544
setCentered(a.getBoolean(R.styleable.Slider_centered, false));
548545
stepSize = a.getFloat(R.styleable.Slider_android_stepSize, 0.0f);
549546

550-
float defaultMinTouchTargetSize =
551-
(float) Math.ceil(ViewUtils.dpToPx(getContext(), MIN_TOUCH_TARGET_DP));
547+
float defaultMinTouchTargetSize = MaterialAttributes.resolveMinimumAccessibleTouchTarget(context);
552548
minTouchTargetSize =
553549
(int)
554550
Math.ceil(

0 commit comments

Comments
 (0)