mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
StyledPlayerControlView: Simplify layout
- Replace some magic constants with use of layout gravity where possible - Remove some attributes that are set in code anyway - Remove some attributes that are set to their default values - Inline transport controls - Minor naming cleanup PiperOrigin-RevId: 346980595
This commit is contained in:
parent
7aeeb8dd22
commit
7d478a9f5a
4 changed files with 43 additions and 79 deletions
|
|
@ -49,7 +49,7 @@ import java.util.List;
|
||||||
|
|
||||||
private final StyledPlayerControlView styledPlayerControlView;
|
private final StyledPlayerControlView styledPlayerControlView;
|
||||||
|
|
||||||
@Nullable private final ViewGroup embeddedTransportControls;
|
@Nullable private final ViewGroup centerControls;
|
||||||
@Nullable private final ViewGroup bottomBar;
|
@Nullable private final ViewGroup bottomBar;
|
||||||
@Nullable private final ViewGroup minimalControls;
|
@Nullable private final ViewGroup minimalControls;
|
||||||
@Nullable private final ViewGroup basicControls;
|
@Nullable private final ViewGroup basicControls;
|
||||||
|
|
@ -99,8 +99,7 @@ import java.util.List;
|
||||||
|
|
||||||
// Relating to Center View
|
// Relating to Center View
|
||||||
ViewGroup centerView = styledPlayerControlView.findViewById(R.id.exo_center_view);
|
ViewGroup centerView = styledPlayerControlView.findViewById(R.id.exo_center_view);
|
||||||
embeddedTransportControls =
|
centerControls = styledPlayerControlView.findViewById(R.id.exo_center_controls);
|
||||||
styledPlayerControlView.findViewById(R.id.exo_embedded_transport_controls);
|
|
||||||
|
|
||||||
// Relating to Minimal Layout
|
// Relating to Minimal Layout
|
||||||
minimalControls = styledPlayerControlView.findViewById(R.id.exo_minimal_controls);
|
minimalControls = styledPlayerControlView.findViewById(R.id.exo_minimal_controls);
|
||||||
|
|
@ -126,7 +125,7 @@ import java.util.List;
|
||||||
|
|
||||||
Resources resources = styledPlayerControlView.getResources();
|
Resources resources = styledPlayerControlView.getResources();
|
||||||
float bottomBarHeight =
|
float bottomBarHeight =
|
||||||
resources.getDimension(R.dimen.exo_bottom_bar_height)
|
resources.getDimension(R.dimen.exo_styled_bottom_bar_height)
|
||||||
- resources.getDimension(R.dimen.exo_styled_progress_bar_height);
|
- resources.getDimension(R.dimen.exo_styled_progress_bar_height);
|
||||||
float progressBarHeight =
|
float progressBarHeight =
|
||||||
resources.getDimension(R.dimen.exo_styled_progress_margin_bottom)
|
resources.getDimension(R.dimen.exo_styled_progress_margin_bottom)
|
||||||
|
|
@ -563,10 +562,8 @@ import java.util.List;
|
||||||
- styledPlayerControlView.getPaddingBottom()
|
- styledPlayerControlView.getPaddingBottom()
|
||||||
- styledPlayerControlView.getPaddingTop();
|
- styledPlayerControlView.getPaddingTop();
|
||||||
int defaultModeWidth =
|
int defaultModeWidth =
|
||||||
Math.max(
|
Math.max(getWidth(centerControls), getWidth(timeView) + getWidth(overflowShowButton));
|
||||||
getWidth(embeddedTransportControls), getWidth(timeView) + getWidth(overflowShowButton));
|
int defaultModeHeight = getHeight(centerControls) + getHeight(timeBar) + getHeight(bottomBar);
|
||||||
int defaultModeHeight =
|
|
||||||
getHeight(embeddedTransportControls) + getHeight(timeBar) + getHeight(bottomBar);
|
|
||||||
|
|
||||||
return (width <= defaultModeWidth || height <= defaultModeHeight);
|
return (width <= defaultModeWidth || height <= defaultModeHeight);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,38 +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.
|
|
||||||
-->
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="center"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:visibility="visible">
|
|
||||||
|
|
||||||
<ImageButton android:id="@+id/exo_prev"
|
|
||||||
style="@style/ExoStyledControls.Button.Center.Previous"/>
|
|
||||||
|
|
||||||
<Button android:id="@+id/exo_rew_with_amount"
|
|
||||||
style="@style/ExoStyledControls.Button.Center.RewWithAmount"/>
|
|
||||||
|
|
||||||
<ImageButton android:id="@+id/exo_play_pause"
|
|
||||||
style="@style/ExoStyledControls.Button.Center.PlayPause"/>
|
|
||||||
|
|
||||||
<Button android:id="@+id/exo_ffwd_with_amount"
|
|
||||||
style="@style/ExoStyledControls.Button.Center.FfwdWithAmount"/>
|
|
||||||
|
|
||||||
<ImageButton android:id="@+id/exo_next"
|
|
||||||
style="@style/ExoStyledControls.Button.Center.Next"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
@ -27,30 +27,46 @@
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:background="@color/exo_black_opacity_60"/>
|
android:background="@color/exo_black_opacity_60"/>
|
||||||
|
|
||||||
<include android:id="@+id/exo_embedded_transport_controls"
|
<LinearLayout android:id="@+id/exo_center_controls"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
layout="@layout/exo_styled_embedded_transport_controls"/>
|
android:gravity="center">
|
||||||
|
|
||||||
|
<ImageButton android:id="@+id/exo_prev"
|
||||||
|
style="@style/ExoStyledControls.Button.Center.Previous"/>
|
||||||
|
|
||||||
|
<Button android:id="@+id/exo_rew_with_amount"
|
||||||
|
style="@style/ExoStyledControls.Button.Center.RewWithAmount"/>
|
||||||
|
|
||||||
|
<ImageButton android:id="@+id/exo_play_pause"
|
||||||
|
style="@style/ExoStyledControls.Button.Center.PlayPause"/>
|
||||||
|
|
||||||
|
<Button android:id="@+id/exo_ffwd_with_amount"
|
||||||
|
style="@style/ExoStyledControls.Button.Center.FfwdWithAmount"/>
|
||||||
|
|
||||||
|
<ImageButton android:id="@+id/exo_next"
|
||||||
|
style="@style/ExoStyledControls.Button.Center.Next"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<FrameLayout android:id="@+id/exo_bottom_bar"
|
<FrameLayout android:id="@+id/exo_bottom_bar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/exo_bottom_bar_height"
|
android:layout_height="@dimen/exo_styled_bottom_bar_height"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
android:background="@color/exo_bottom_bar_background"
|
android:background="@color/exo_bottom_bar_background"
|
||||||
android:paddingBottom="@dimen/exo_bottom_bar_padding_bottom"
|
|
||||||
android:layoutDirection="ltr">
|
android:layoutDirection="ltr">
|
||||||
|
|
||||||
<LinearLayout android:id="@+id/exo_time"
|
<LinearLayout android:id="@+id/exo_time"
|
||||||
android:layout_width="@dimen/exo_time_view_width"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="@dimen/exo_small_icon_height"
|
android:layout_height="wrap_content"
|
||||||
android:paddingStart="@dimen/exo_time_view_padding"
|
android:paddingStart="@dimen/exo_styled_time_padding"
|
||||||
android:paddingEnd="@dimen/exo_time_view_padding"
|
android:paddingEnd="@dimen/exo_styled_time_padding"
|
||||||
android:paddingLeft="@dimen/exo_time_view_padding"
|
android:paddingLeft="@dimen/exo_styled_time_padding"
|
||||||
android:paddingRight="@dimen/exo_time_view_padding"
|
android:paddingRight="@dimen/exo_styled_time_padding"
|
||||||
android:layout_gravity="bottom|start"
|
android:layout_gravity="center_vertical|start"
|
||||||
android:layoutDirection="ltr">
|
android:layoutDirection="ltr">
|
||||||
|
|
||||||
<TextView android:id="@+id/exo_position"
|
<TextView android:id="@+id/exo_position"
|
||||||
|
|
@ -67,23 +83,21 @@
|
||||||
<LinearLayout android:id="@+id/exo_basic_controls"
|
<LinearLayout android:id="@+id/exo_basic_controls"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom|end"
|
android:layout_gravity="center_vertical|end"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layoutDirection="ltr">
|
android:layoutDirection="ltr">
|
||||||
|
|
||||||
<ImageButton android:id="@id/exo_shuffle"
|
<ImageButton android:id="@+id/exo_shuffle"
|
||||||
style="@style/ExoStyledControls.Button.Bottom.Shuffle"/>
|
style="@style/ExoStyledControls.Button.Bottom.Shuffle"/>
|
||||||
|
|
||||||
<ImageButton android:id="@id/exo_repeat_toggle"
|
<ImageButton android:id="@+id/exo_repeat_toggle"
|
||||||
style="@style/ExoStyledControls.Button.Bottom.RepeatToggle"/>
|
style="@style/ExoStyledControls.Button.Bottom.RepeatToggle"/>
|
||||||
|
|
||||||
<ImageButton android:id="@id/exo_vr"
|
<ImageButton android:id="@+id/exo_vr"
|
||||||
style="@style/ExoStyledControls.Button.Bottom.VR"/>
|
style="@style/ExoStyledControls.Button.Bottom.VR"/>
|
||||||
|
|
||||||
<ImageButton android:id="@+id/exo_subtitle"
|
<ImageButton android:id="@+id/exo_subtitle"
|
||||||
style="@style/ExoStyledControls.Button.Bottom.CC"
|
style="@style/ExoStyledControls.Button.Bottom.CC"/>
|
||||||
android:alpha="0.5"
|
|
||||||
android:scaleType="fitCenter"/>
|
|
||||||
|
|
||||||
<ImageButton android:id="@+id/exo_fullscreen"
|
<ImageButton android:id="@+id/exo_fullscreen"
|
||||||
style="@style/ExoStyledControls.Button.Bottom.FullScreen"/>
|
style="@style/ExoStyledControls.Button.Bottom.FullScreen"/>
|
||||||
|
|
@ -92,7 +106,6 @@
|
||||||
style="@style/ExoStyledControls.Button.Bottom.Settings"/>
|
style="@style/ExoStyledControls.Button.Bottom.Settings"/>
|
||||||
|
|
||||||
<ImageButton android:id="@+id/exo_overflow_show"
|
<ImageButton android:id="@+id/exo_overflow_show"
|
||||||
android:visibility="gone"
|
|
||||||
style="@style/ExoStyledControls.Button.Bottom.OverflowShow"/>
|
style="@style/ExoStyledControls.Button.Bottom.OverflowShow"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
@ -100,14 +113,12 @@
|
||||||
<HorizontalScrollView android:id="@+id/exo_extra_controls_scroll_view"
|
<HorizontalScrollView android:id="@+id/exo_extra_controls_scroll_view"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom|end"
|
android:layout_gravity="center_vertical|end"
|
||||||
android:visibility="invisible">
|
android:visibility="invisible">
|
||||||
|
|
||||||
<LinearLayout android:id="@+id/exo_extra_controls"
|
<LinearLayout android:id="@+id/exo_extra_controls"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom|end"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:layoutDirection="ltr">
|
android:layoutDirection="ltr">
|
||||||
|
|
||||||
<ImageButton android:id="@+id/exo_overflow_hide"
|
<ImageButton android:id="@+id/exo_overflow_hide"
|
||||||
|
|
@ -125,13 +136,12 @@
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_gravity="bottom|end"
|
android:layout_gravity="bottom|end"
|
||||||
android:layout_marginBottom="@dimen/exo_styled_progress_layout_height"
|
android:layout_marginBottom="@dimen/exo_styled_progress_layout_height"
|
||||||
android:visibility="invisible">
|
android:visibility="invisible"/>
|
||||||
|
|
||||||
</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_styled_progress_layout_height"
|
android:layout_height="@dimen/exo_styled_progress_layout_height"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
android:layout_marginBottom="@dimen/exo_styled_progress_margin_bottom"/>
|
android:layout_marginBottom="@dimen/exo_styled_progress_margin_bottom"/>
|
||||||
|
|
||||||
</merge>
|
</merge>
|
||||||
|
|
|
||||||
|
|
@ -41,13 +41,8 @@
|
||||||
<dimen name="exo_styled_progress_layout_height">48dp</dimen>
|
<dimen name="exo_styled_progress_layout_height">48dp</dimen>
|
||||||
<dimen name="exo_styled_progress_touch_target_height">48dp</dimen>
|
<dimen name="exo_styled_progress_touch_target_height">48dp</dimen>
|
||||||
<dimen name="exo_styled_progress_margin_bottom">52dp</dimen>
|
<dimen name="exo_styled_progress_margin_bottom">52dp</dimen>
|
||||||
|
<dimen name="exo_styled_bottom_bar_height">60dp</dimen>
|
||||||
<dimen name="exo_bottom_bar_height">60dp</dimen>
|
<dimen name="exo_styled_time_padding">10dp</dimen>
|
||||||
<dimen name="exo_bottom_bar_padding_bottom">4dp</dimen>
|
|
||||||
|
|
||||||
<dimen name="exo_time_view_padding">10dp</dimen>
|
|
||||||
<dimen name="exo_time_view_width">170sp</dimen>
|
|
||||||
<dimen name="exo_time_view_height">48dp</dimen>
|
|
||||||
|
|
||||||
<dimen name="exo_error_message_height">32dp</dimen>
|
<dimen name="exo_error_message_height">32dp</dimen>
|
||||||
<dimen name="exo_error_message_margin_bottom">64dp</dimen>
|
<dimen name="exo_error_message_margin_bottom">64dp</dimen>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue