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

Also removed unused thumb resources.

PiperOrigin-RevId: 338184661
This commit is contained in:
insun 2020-10-21 03:38:26 +01:00 committed by Oliver Woodman
parent efaa2961ee
commit de2b58e7e1
8 changed files with 41 additions and 76 deletions

View File

@ -227,13 +227,22 @@ public class DefaultTimeBar extends View implements TimeBar {
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.
@SuppressWarnings("nullness:method.invocation.invalid")
public DefaultTimeBar(
Context context,
@Nullable AttributeSet attrs,
int defStyleAttr,
@Nullable AttributeSet timebarAttrs) {
@Nullable AttributeSet timebarAttrs,
int defStyleRes) {
super(context, attrs, defStyleAttr);
seekBounds = new Rect();
progressBar = new Rect();
@ -262,7 +271,10 @@ public class DefaultTimeBar extends View implements TimeBar {
int defaultScrubberDraggedSize = dpToPx(density, DEFAULT_SCRUBBER_DRAGGED_SIZE_DP);
if (timebarAttrs != null) {
TypedArray a =
context.getTheme().obtainStyledAttributes(timebarAttrs, R.styleable.DefaultTimeBar, 0, 0);
context
.getTheme()
.obtainStyledAttributes(
timebarAttrs, R.styleable.DefaultTimeBar, defStyleAttr, defStyleRes);
try {
scrubberDrawable = a.getDrawable(R.styleable.DefaultTimeBar_scrubber_drawable);
if (scrubberDrawable != null) {

View File

@ -570,7 +570,8 @@ public class StyledPlayerControlView extends FrameLayout {
} else if (timeBarPlaceholder != null) {
// Propagate attrs as timebarAttrs so that DefaultTimeBar's custom attributes are transferred,
// 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.setLayoutParams(timeBarPlaceholder.getLayoutParams());
ViewGroup parent = ((ViewGroup) timeBarPlaceholder.getParent());

View File

@ -125,8 +125,13 @@ import java.util.List;
}
Resources resources = styledPlayerControlView.getResources();
float progressBarHeight = resources.getDimension(R.dimen.exo_custom_progress_thumb_size);
float bottomBarHeight = resources.getDimension(R.dimen.exo_bottom_bar_height);
float bottomBarHeight =
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);
fadeOutAnimator.setInterpolator(new LinearInterpolator());
@ -590,7 +595,7 @@ import java.util.List;
int timeBarMarginBottom =
styledPlayerControlView
.getResources()
.getDimensionPixelSize(R.dimen.exo_custom_progress_margin_bottom);
.getDimensionPixelSize(R.dimen.exo_styled_progress_margin_bottom);
timeBarParams.bottomMargin = (isMinimalMode ? 0 : timeBarMarginBottom);
timeBar.setLayoutParams(timeBarParams);
if (timeBar instanceof DefaultTimeBar

View File

@ -1,36 +0,0 @@
<?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>

View File

@ -1,26 +0,0 @@
<?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>

View File

@ -123,15 +123,14 @@
android:layout_height="wrap_content"
android:orientation="vertical"
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">
</LinearLayout>
<View android:id="@id/exo_progress_placeholder"
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_marginBottom="@dimen/exo_custom_progress_margin_bottom"/>
android:layout_marginBottom="@dimen/exo_styled_progress_margin_bottom"/>
</merge>

View File

@ -35,11 +35,14 @@
<dimen name="exo_small_icon_padding_horizontal">12dp</dimen>
<dimen name="exo_small_icon_padding_vertical">12dp</dimen>
<dimen name="exo_custom_progress_max_size">2dp</dimen>
<dimen name="exo_custom_progress_thumb_size">24dp</dimen>
<dimen name="exo_custom_progress_margin_bottom">56dp</dimen>
<dimen name="exo_styled_progress_bar_height">2dp</dimen>
<dimen name="exo_styled_progress_enabled_thumb_size">10dp</dimen>
<dimen name="exo_styled_progress_dragged_thumb_size">14dp</dimen>
<dimen name="exo_styled_progress_layout_height">14dp</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">70dp</dimen>
<dimen name="exo_bottom_bar_height">60dp</dimen>
<dimen name="exo_bottom_bar_padding_bottom">4dp</dimen>
<dimen name="exo_time_view_padding">10dp</dimen>

View File

@ -185,4 +185,11 @@
<item name="android:contentDescription">@string/exo_controls_settings_description</item>
</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>