Commit de2b58e7 by insun Committed by Oliver Woodman

Fix bottom area to have even paddings and make seekbar slimmer.

Also removed unused thumb resources.

PiperOrigin-RevId: 338184661
parent efaa2961
...@@ -227,13 +227,22 @@ public class DefaultTimeBar extends View implements TimeBar { ...@@ -227,13 +227,22 @@ public class DefaultTimeBar extends View implements TimeBar {
this(context, attrs, defStyleAttr, attrs); this(context, attrs, defStyleAttr, attrs);
} }
public DefaultTimeBar(
Context context,
@Nullable AttributeSet attrs,
int defStyleAttr,
@Nullable AttributeSet timebarAttrs) {
this(context, attrs, defStyleAttr, timebarAttrs, 0);
}
// Suppress warnings due to usage of View methods in the constructor. // Suppress warnings due to usage of View methods in the constructor.
@SuppressWarnings("nullness:method.invocation.invalid") @SuppressWarnings("nullness:method.invocation.invalid")
public DefaultTimeBar( public DefaultTimeBar(
Context context, Context context,
@Nullable AttributeSet attrs, @Nullable AttributeSet attrs,
int defStyleAttr, int defStyleAttr,
@Nullable AttributeSet timebarAttrs) { @Nullable AttributeSet timebarAttrs,
int defStyleRes) {
super(context, attrs, defStyleAttr); super(context, attrs, defStyleAttr);
seekBounds = new Rect(); seekBounds = new Rect();
progressBar = new Rect(); progressBar = new Rect();
...@@ -262,7 +271,10 @@ public class DefaultTimeBar extends View implements TimeBar { ...@@ -262,7 +271,10 @@ public class DefaultTimeBar extends View implements TimeBar {
int defaultScrubberDraggedSize = dpToPx(density, DEFAULT_SCRUBBER_DRAGGED_SIZE_DP); int defaultScrubberDraggedSize = dpToPx(density, DEFAULT_SCRUBBER_DRAGGED_SIZE_DP);
if (timebarAttrs != null) { if (timebarAttrs != null) {
TypedArray a = TypedArray a =
context.getTheme().obtainStyledAttributes(timebarAttrs, R.styleable.DefaultTimeBar, 0, 0); context
.getTheme()
.obtainStyledAttributes(
timebarAttrs, R.styleable.DefaultTimeBar, defStyleAttr, defStyleRes);
try { try {
scrubberDrawable = a.getDrawable(R.styleable.DefaultTimeBar_scrubber_drawable); scrubberDrawable = a.getDrawable(R.styleable.DefaultTimeBar_scrubber_drawable);
if (scrubberDrawable != null) { if (scrubberDrawable != null) {
......
...@@ -570,7 +570,8 @@ public class StyledPlayerControlView extends FrameLayout { ...@@ -570,7 +570,8 @@ public class StyledPlayerControlView extends FrameLayout {
} else if (timeBarPlaceholder != null) { } else if (timeBarPlaceholder != null) {
// Propagate attrs as timebarAttrs so that DefaultTimeBar's custom attributes are transferred, // Propagate attrs as timebarAttrs so that DefaultTimeBar's custom attributes are transferred,
// but standard attributes (e.g. background) are not. // but standard attributes (e.g. background) are not.
DefaultTimeBar defaultTimeBar = new DefaultTimeBar(context, null, 0, playbackAttrs); DefaultTimeBar defaultTimeBar =
new DefaultTimeBar(context, null, 0, playbackAttrs, R.style.ExoStyledControls_TimeBar);
defaultTimeBar.setId(R.id.exo_progress); defaultTimeBar.setId(R.id.exo_progress);
defaultTimeBar.setLayoutParams(timeBarPlaceholder.getLayoutParams()); defaultTimeBar.setLayoutParams(timeBarPlaceholder.getLayoutParams());
ViewGroup parent = ((ViewGroup) timeBarPlaceholder.getParent()); ViewGroup parent = ((ViewGroup) timeBarPlaceholder.getParent());
......
...@@ -125,8 +125,13 @@ import java.util.List; ...@@ -125,8 +125,13 @@ import java.util.List;
} }
Resources resources = styledPlayerControlView.getResources(); Resources resources = styledPlayerControlView.getResources();
float progressBarHeight = resources.getDimension(R.dimen.exo_custom_progress_thumb_size); float bottomBarHeight =
float bottomBarHeight = resources.getDimension(R.dimen.exo_bottom_bar_height); resources.getDimension(R.dimen.exo_bottom_bar_height)
- resources.getDimension(R.dimen.exo_styled_progress_bar_height);
float progressBarHeight =
resources.getDimension(R.dimen.exo_styled_progress_margin_bottom)
+ resources.getDimension(R.dimen.exo_styled_progress_layout_height)
- bottomBarHeight;
ValueAnimator fadeOutAnimator = ValueAnimator.ofFloat(1.0f, 0.0f); ValueAnimator fadeOutAnimator = ValueAnimator.ofFloat(1.0f, 0.0f);
fadeOutAnimator.setInterpolator(new LinearInterpolator()); fadeOutAnimator.setInterpolator(new LinearInterpolator());
...@@ -590,7 +595,7 @@ import java.util.List; ...@@ -590,7 +595,7 @@ import java.util.List;
int timeBarMarginBottom = int timeBarMarginBottom =
styledPlayerControlView styledPlayerControlView
.getResources() .getResources()
.getDimensionPixelSize(R.dimen.exo_custom_progress_margin_bottom); .getDimensionPixelSize(R.dimen.exo_styled_progress_margin_bottom);
timeBarParams.bottomMargin = (isMinimalMode ? 0 : timeBarMarginBottom); timeBarParams.bottomMargin = (isMinimalMode ? 0 : timeBarMarginBottom);
timeBar.setLayoutParams(timeBarParams); timeBar.setLayoutParams(timeBarParams);
if (timeBar instanceof DefaultTimeBar if (timeBar instanceof DefaultTimeBar
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2020 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@android:id/background">
<shape android:shape="rectangle" >
<solid android:color="#26000000" />
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape android:shape="rectangle" >
<solid android:color="#5Cffffff" />
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape android:shape="rectangle" >
<solid android:color="#ffffff" />
</shape>
</clip>
</item>
</layer-list>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2020 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:scaleWidth="100%"
android:scaleHeight="100%"
android:scaleGravity="center"
android:level="10000">
<shape android:shape="oval" >
<solid android:color="#ffffff" />
<size android:height="@dimen/exo_custom_progress_thumb_size"
android:width="@dimen/exo_custom_progress_thumb_size" />
</shape>
</scale>
...@@ -123,15 +123,14 @@ ...@@ -123,15 +123,14 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:layout_gravity="bottom|end" android:layout_gravity="bottom|end"
android:layout_marginBottom="@dimen/exo_custom_progress_thumb_size" android:layout_marginBottom="@dimen/exo_styled_progress_layout_height"
android:visibility="invisible"> android:visibility="invisible">
</LinearLayout> </LinearLayout>
<View android:id="@id/exo_progress_placeholder" <View android:id="@id/exo_progress_placeholder"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/exo_custom_progress_thumb_size" android:layout_height="@dimen/exo_styled_progress_layout_height"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:layout_marginBottom="@dimen/exo_custom_progress_margin_bottom"/> android:layout_marginBottom="@dimen/exo_styled_progress_margin_bottom"/>
</merge> </merge>
...@@ -35,11 +35,14 @@ ...@@ -35,11 +35,14 @@
<dimen name="exo_small_icon_padding_horizontal">12dp</dimen> <dimen name="exo_small_icon_padding_horizontal">12dp</dimen>
<dimen name="exo_small_icon_padding_vertical">12dp</dimen> <dimen name="exo_small_icon_padding_vertical">12dp</dimen>
<dimen name="exo_custom_progress_max_size">2dp</dimen> <dimen name="exo_styled_progress_bar_height">2dp</dimen>
<dimen name="exo_custom_progress_thumb_size">24dp</dimen> <dimen name="exo_styled_progress_enabled_thumb_size">10dp</dimen>
<dimen name="exo_custom_progress_margin_bottom">56dp</dimen> <dimen name="exo_styled_progress_dragged_thumb_size">14dp</dimen>
<dimen name="exo_styled_progress_layout_height">14dp</dimen>
<dimen name="exo_bottom_bar_height">70dp</dimen> <dimen name="exo_styled_progress_touch_target_height">14dp</dimen>
<dimen name="exo_styled_progress_margin_bottom">52dp</dimen>
<dimen name="exo_bottom_bar_height">60dp</dimen>
<dimen name="exo_bottom_bar_padding_bottom">4dp</dimen> <dimen name="exo_bottom_bar_padding_bottom">4dp</dimen>
<dimen name="exo_time_view_padding">10dp</dimen> <dimen name="exo_time_view_padding">10dp</dimen>
......
...@@ -185,4 +185,11 @@ ...@@ -185,4 +185,11 @@
<item name="android:contentDescription">@string/exo_controls_settings_description</item> <item name="android:contentDescription">@string/exo_controls_settings_description</item>
</style> </style>
<style name="ExoStyledControls.TimeBar">
<item name="bar_height">@dimen/exo_styled_progress_bar_height</item>
<item name="touch_target_height">@dimen/exo_styled_progress_touch_target_height</item>
<item name="scrubber_enabled_size">@dimen/exo_styled_progress_enabled_thumb_size</item>
<item name="scrubber_dragged_size">@dimen/exo_styled_progress_dragged_thumb_size</item>
<item name="android:layout_height">@dimen/exo_styled_progress_layout_height</item>
</style>
</resources> </resources>
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