Commit 12187c90 by olly Committed by kim-vde

Apply minimal layout change according to view size

 - Add method to scale scrubber handle of DefaultTimeBar

PiperOrigin-RevId: 294366734
parent 363599dd
...@@ -204,6 +204,7 @@ public class DefaultTimeBar extends View implements TimeBar { ...@@ -204,6 +204,7 @@ public class DefaultTimeBar extends View implements TimeBar {
private int lastCoarseScrubXPosition; private int lastCoarseScrubXPosition;
private @MonotonicNonNull Rect lastExclusionRectangle; private @MonotonicNonNull Rect lastExclusionRectangle;
private float scrubberScale;
private boolean scrubbing; private boolean scrubbing;
private long scrubPosition; private long scrubPosition;
private long duration; private long duration;
...@@ -327,6 +328,7 @@ public class DefaultTimeBar extends View implements TimeBar { ...@@ -327,6 +328,7 @@ public class DefaultTimeBar extends View implements TimeBar {
(Math.max(scrubberDisabledSize, Math.max(scrubberEnabledSize, scrubberDraggedSize)) + 1) (Math.max(scrubberDisabledSize, Math.max(scrubberEnabledSize, scrubberDraggedSize)) + 1)
/ 2; / 2;
} }
scrubberScale = 1.0f;
duration = C.TIME_UNSET; duration = C.TIME_UNSET;
keyTimeIncrement = C.TIME_UNSET; keyTimeIncrement = C.TIME_UNSET;
keyCountIncrement = DEFAULT_INCREMENT_COUNT; keyCountIncrement = DEFAULT_INCREMENT_COUNT;
...@@ -358,6 +360,18 @@ public class DefaultTimeBar extends View implements TimeBar { ...@@ -358,6 +360,18 @@ public class DefaultTimeBar extends View implements TimeBar {
} }
/** /**
* Sets the scale factor for the scrubber handle. Scrubber enabled size, scrubber disabled size,
* scrubber dragged size are scaled by the scale factor. If scrubber drawable is set, the scale
* factor isn't applied.
*
* @param scrubberScale The scale factor for the scrubber handle.
*/
public void setScrubberScale(float scrubberScale) {
this.scrubberScale = scrubberScale;
invalidate(seekBounds);
}
/**
* Sets the color for the portion of the time bar after the current played position up to the * Sets the color for the portion of the time bar after the current played position up to the
* current buffered position. * current buffered position.
* *
...@@ -816,7 +830,7 @@ public class DefaultTimeBar extends View implements TimeBar { ...@@ -816,7 +830,7 @@ public class DefaultTimeBar extends View implements TimeBar {
if (scrubberDrawable == null) { if (scrubberDrawable == null) {
int scrubberSize = (scrubbing || isFocused()) ? scrubberDraggedSize int scrubberSize = (scrubbing || isFocused()) ? scrubberDraggedSize
: (isEnabled() ? scrubberEnabledSize : scrubberDisabledSize); : (isEnabled() ? scrubberEnabledSize : scrubberDisabledSize);
int playheadRadius = scrubberSize / 2; int playheadRadius = (int) ((scrubberSize * scrubberScale) / 2);
canvas.drawCircle(playheadX, playheadY, playheadRadius, scrubberPaint); canvas.drawCircle(playheadX, playheadY, playheadRadius, scrubberPaint);
} else { } else {
int scrubberDrawableWidth = scrubberDrawable.getIntrinsicWidth(); int scrubberDrawableWidth = scrubberDrawable.getIntrinsicWidth();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment