Define default colors as constants

It's confusing that app:played_color also modifies the colors
that derive from it, but the corresponding setter does not. It
seems generally clearer just to define constants.

PiperOrigin-RevId: 273249557
This commit is contained in:
olly 2019-10-07 10:48:24 +01:00 committed by Oliver Woodman
parent 97cfcb57e6
commit 904e3f8d47
2 changed files with 34 additions and 34 deletions

View File

@ -7,6 +7,14 @@
([#6203](https://github.com/google/ExoPlayer/issues/6203)). ([#6203](https://github.com/google/ExoPlayer/issues/6203)).
* Expose the raw ICY metadata through `IcyInfo` * Expose the raw ICY metadata through `IcyInfo`
([#6476](https://github.com/google/ExoPlayer/issues/6476)). ([#6476](https://github.com/google/ExoPlayer/issues/6476)).
* UI
* Setting `app:played_color` on `PlayerView` and `PlayerControlView` no longer
adjusts the colors of the scrubber handle , buffered and unplayed parts of
the time bar. These can be set separately using `app:scrubber_color`,
`app:buffered_color` and `app_unplayed_color` respectively.
* Setting `app:ad_marker_color` on `PlayerView` and `PlayerControlView` no
longer adjusts the color of played ad markers. The color of played ad
markers can be set separately using `app:played_ad_marker_color`.
### 2.10.5 (2019-09-20) ### ### 2.10.5 (2019-09-20) ###

View File

@ -98,19 +98,19 @@ import java.util.concurrent.CopyOnWriteArraySet;
* <li><b>{@code scrubber_color}</b> - Color for the scrubber handle. * <li><b>{@code scrubber_color}</b> - Color for the scrubber handle.
* <ul> * <ul>
* <li>Corresponding method: {@link #setScrubberColor(int)} * <li>Corresponding method: {@link #setScrubberColor(int)}
* <li>Default: see {@link #getDefaultScrubberColor(int)} * <li>Default: {@link #DEFAULT_SCRUBBER_COLOR}
* </ul> * </ul>
* <li><b>{@code buffered_color}</b> - Color for the portion of the time bar after the current * <li><b>{@code buffered_color}</b> - Color for the portion of the time bar after the current
* played position up to the current buffered position. * played position up to the current buffered position.
* <ul> * <ul>
* <li>Corresponding method: {@link #setBufferedColor(int)} * <li>Corresponding method: {@link #setBufferedColor(int)}
* <li>Default: see {@link #getDefaultBufferedColor(int)} * <li>Default: {@link #DEFAULT_BUFFERED_COLOR}
* </ul> * </ul>
* <li><b>{@code unplayed_color}</b> - Color for the portion of the time bar after the current * <li><b>{@code unplayed_color}</b> - Color for the portion of the time bar after the current
* buffered position. * buffered position.
* <ul> * <ul>
* <li>Corresponding method: {@link #setUnplayedColor(int)} * <li>Corresponding method: {@link #setUnplayedColor(int)}
* <li>Default: see {@link #getDefaultUnplayedColor(int)} * <li>Default: {@link #DEFAULT_UNPLAYED_COLOR}
* </ul> * </ul>
* <li><b>{@code ad_marker_color}</b> - Color for unplayed ad markers. * <li><b>{@code ad_marker_color}</b> - Color for unplayed ad markers.
* <ul> * <ul>
@ -120,7 +120,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
* <li><b>{@code played_ad_marker_color}</b> - Color for played ad markers. * <li><b>{@code played_ad_marker_color}</b> - Color for played ad markers.
* <ul> * <ul>
* <li>Corresponding method: {@link #setPlayedAdMarkerColor(int)} * <li>Corresponding method: {@link #setPlayedAdMarkerColor(int)}
* <li>Default: see {@link #getDefaultPlayedAdMarkerColor(int)} * <li>Default: {@link #DEFAULT_PLAYED_AD_MARKER_COLOR}
* </ul> * </ul>
* </ul> * </ul>
*/ */
@ -154,10 +154,16 @@ public class DefaultTimeBar extends View implements TimeBar {
* Default color for the played portion of the time bar. * Default color for the played portion of the time bar.
*/ */
public static final int DEFAULT_PLAYED_COLOR = 0xFFFFFFFF; public static final int DEFAULT_PLAYED_COLOR = 0xFFFFFFFF;
/** /** Default color for the played portion of the time bar. */
* Default color for ad markers. public static final int DEFAULT_UNPLAYED_COLOR = 0x33FFFFFF;
*/ /** Default color for the buffered portion of the time bar. */
public static final int DEFAULT_BUFFERED_COLOR = 0xCCFFFFFF;
/** Default color for the scrubber handle. */
public static final int DEFAULT_SCRUBBER_COLOR = 0xFFFFFFFF;
/** Default color for ad markers. */
public static final int DEFAULT_AD_MARKER_COLOR = 0xB2FFFF00; public static final int DEFAULT_AD_MARKER_COLOR = 0xB2FFFF00;
/** Default color for played ad markers. */
public static final int DEFAULT_PLAYED_AD_MARKER_COLOR = 0x33FFFF00;
/** /**
* The threshold in dps above the bar at which touch events trigger fine scrub mode. * The threshold in dps above the bar at which touch events trigger fine scrub mode.
@ -289,16 +295,17 @@ public class DefaultTimeBar extends View implements TimeBar {
scrubberDraggedSize = a.getDimensionPixelSize( scrubberDraggedSize = a.getDimensionPixelSize(
R.styleable.DefaultTimeBar_scrubber_dragged_size, defaultScrubberDraggedSize); R.styleable.DefaultTimeBar_scrubber_dragged_size, defaultScrubberDraggedSize);
int playedColor = a.getInt(R.styleable.DefaultTimeBar_played_color, DEFAULT_PLAYED_COLOR); int playedColor = a.getInt(R.styleable.DefaultTimeBar_played_color, DEFAULT_PLAYED_COLOR);
int scrubberColor = a.getInt(R.styleable.DefaultTimeBar_scrubber_color, int scrubberColor =
getDefaultScrubberColor(playedColor)); a.getInt(R.styleable.DefaultTimeBar_scrubber_color, DEFAULT_SCRUBBER_COLOR);
int bufferedColor = a.getInt(R.styleable.DefaultTimeBar_buffered_color, int bufferedColor =
getDefaultBufferedColor(playedColor)); a.getInt(R.styleable.DefaultTimeBar_buffered_color, DEFAULT_BUFFERED_COLOR);
int unplayedColor = a.getInt(R.styleable.DefaultTimeBar_unplayed_color, int unplayedColor =
getDefaultUnplayedColor(playedColor)); a.getInt(R.styleable.DefaultTimeBar_unplayed_color, DEFAULT_UNPLAYED_COLOR);
int adMarkerColor = a.getInt(R.styleable.DefaultTimeBar_ad_marker_color, int adMarkerColor = a.getInt(R.styleable.DefaultTimeBar_ad_marker_color,
DEFAULT_AD_MARKER_COLOR); DEFAULT_AD_MARKER_COLOR);
int playedAdMarkerColor = a.getInt(R.styleable.DefaultTimeBar_played_ad_marker_color, int playedAdMarkerColor =
getDefaultPlayedAdMarkerColor(adMarkerColor)); a.getInt(
R.styleable.DefaultTimeBar_played_ad_marker_color, DEFAULT_PLAYED_AD_MARKER_COLOR);
playedPaint.setColor(playedColor); playedPaint.setColor(playedColor);
scrubberPaint.setColor(scrubberColor); scrubberPaint.setColor(scrubberColor);
bufferedPaint.setColor(bufferedColor); bufferedPaint.setColor(bufferedColor);
@ -316,10 +323,11 @@ public class DefaultTimeBar extends View implements TimeBar {
scrubberDisabledSize = defaultScrubberDisabledSize; scrubberDisabledSize = defaultScrubberDisabledSize;
scrubberDraggedSize = defaultScrubberDraggedSize; scrubberDraggedSize = defaultScrubberDraggedSize;
playedPaint.setColor(DEFAULT_PLAYED_COLOR); playedPaint.setColor(DEFAULT_PLAYED_COLOR);
scrubberPaint.setColor(getDefaultScrubberColor(DEFAULT_PLAYED_COLOR)); scrubberPaint.setColor(DEFAULT_SCRUBBER_COLOR);
bufferedPaint.setColor(getDefaultBufferedColor(DEFAULT_PLAYED_COLOR)); bufferedPaint.setColor(DEFAULT_BUFFERED_COLOR);
unplayedPaint.setColor(getDefaultUnplayedColor(DEFAULT_PLAYED_COLOR)); unplayedPaint.setColor(DEFAULT_UNPLAYED_COLOR);
adMarkerPaint.setColor(DEFAULT_AD_MARKER_COLOR); adMarkerPaint.setColor(DEFAULT_AD_MARKER_COLOR);
playedAdMarkerPaint.setColor(DEFAULT_PLAYED_AD_MARKER_COLOR);
scrubberDrawable = null; scrubberDrawable = null;
} }
formatBuilder = new StringBuilder(); formatBuilder = new StringBuilder();
@ -856,22 +864,6 @@ public class DefaultTimeBar extends View implements TimeBar {
return Util.SDK_INT >= 23 && drawable.setLayoutDirection(layoutDirection); return Util.SDK_INT >= 23 && drawable.setLayoutDirection(layoutDirection);
} }
public static int getDefaultScrubberColor(int playedColor) {
return 0xFF000000 | playedColor;
}
public static int getDefaultUnplayedColor(int playedColor) {
return 0x33000000 | (playedColor & 0x00FFFFFF);
}
public static int getDefaultBufferedColor(int playedColor) {
return 0xCC000000 | (playedColor & 0x00FFFFFF);
}
public static int getDefaultPlayedAdMarkerColor(int adMarkerColor) {
return 0x33000000 | (adMarkerColor & 0x00FFFFFF);
}
private static int dpToPx(float density, int dps) { private static int dpToPx(float density, int dps) {
return (int) (dps * density + 0.5f); return (int) (dps * density + 0.5f);
} }