Commit 7d478a9f by olly Committed by Ian Baker

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
parent 7aeeb8dd
......@@ -49,7 +49,7 @@ import java.util.List;
private final StyledPlayerControlView styledPlayerControlView;
@Nullable private final ViewGroup embeddedTransportControls;
@Nullable private final ViewGroup centerControls;
@Nullable private final ViewGroup bottomBar;
@Nullable private final ViewGroup minimalControls;
@Nullable private final ViewGroup basicControls;
......@@ -99,8 +99,7 @@ import java.util.List;
// Relating to Center View
ViewGroup centerView = styledPlayerControlView.findViewById(R.id.exo_center_view);
embeddedTransportControls =
styledPlayerControlView.findViewById(R.id.exo_embedded_transport_controls);
centerControls = styledPlayerControlView.findViewById(R.id.exo_center_controls);
// Relating to Minimal Layout
minimalControls = styledPlayerControlView.findViewById(R.id.exo_minimal_controls);
......@@ -126,7 +125,7 @@ import java.util.List;
Resources resources = styledPlayerControlView.getResources();
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);
float progressBarHeight =
resources.getDimension(R.dimen.exo_styled_progress_margin_bottom)
......@@ -563,10 +562,8 @@ import java.util.List;
- styledPlayerControlView.getPaddingBottom()
- styledPlayerControlView.getPaddingTop();
int defaultModeWidth =
Math.max(
getWidth(embeddedTransportControls), getWidth(timeView) + getWidth(overflowShowButton));
int defaultModeHeight =
getHeight(embeddedTransportControls) + getHeight(timeBar) + getHeight(bottomBar);
Math.max(getWidth(centerControls), getWidth(timeView) + getWidth(overflowShowButton));
int defaultModeHeight = getHeight(centerControls) + getHeight(timeBar) + getHeight(bottomBar);
return (width <= defaultModeWidth || height <= defaultModeHeight);
}
......
<?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: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_height="wrap_content"
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 android:id="@+id/exo_bottom_bar"
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:background="@color/exo_bottom_bar_background"
android:paddingBottom="@dimen/exo_bottom_bar_padding_bottom"
android:layoutDirection="ltr">
<LinearLayout android:id="@+id/exo_time"
android:layout_width="@dimen/exo_time_view_width"
android:layout_height="@dimen/exo_small_icon_height"
android:paddingStart="@dimen/exo_time_view_padding"
android:paddingEnd="@dimen/exo_time_view_padding"
android:paddingLeft="@dimen/exo_time_view_padding"
android:paddingRight="@dimen/exo_time_view_padding"
android:layout_gravity="bottom|start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="@dimen/exo_styled_time_padding"
android:paddingEnd="@dimen/exo_styled_time_padding"
android:paddingLeft="@dimen/exo_styled_time_padding"
android:paddingRight="@dimen/exo_styled_time_padding"
android:layout_gravity="center_vertical|start"
android:layoutDirection="ltr">
<TextView android:id="@+id/exo_position"
......@@ -67,23 +83,21 @@
<LinearLayout android:id="@+id/exo_basic_controls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_gravity="center_vertical|end"
android:orientation="horizontal"
android:layoutDirection="ltr">
<ImageButton android:id="@id/exo_shuffle"
<ImageButton android:id="@+id/exo_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"/>
<ImageButton android:id="@id/exo_vr"
<ImageButton android:id="@+id/exo_vr"
style="@style/ExoStyledControls.Button.Bottom.VR"/>
<ImageButton android:id="@+id/exo_subtitle"
style="@style/ExoStyledControls.Button.Bottom.CC"
android:alpha="0.5"
android:scaleType="fitCenter"/>
style="@style/ExoStyledControls.Button.Bottom.CC"/>
<ImageButton android:id="@+id/exo_fullscreen"
style="@style/ExoStyledControls.Button.Bottom.FullScreen"/>
......@@ -92,7 +106,6 @@
style="@style/ExoStyledControls.Button.Bottom.Settings"/>
<ImageButton android:id="@+id/exo_overflow_show"
android:visibility="gone"
style="@style/ExoStyledControls.Button.Bottom.OverflowShow"/>
</LinearLayout>
......@@ -100,14 +113,12 @@
<HorizontalScrollView android:id="@+id/exo_extra_controls_scroll_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_gravity="center_vertical|end"
android:visibility="invisible">
<LinearLayout android:id="@+id/exo_extra_controls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:orientation="horizontal"
android:layoutDirection="ltr">
<ImageButton android:id="@+id/exo_overflow_hide"
......@@ -125,13 +136,12 @@
android:orientation="vertical"
android:layout_gravity="bottom|end"
android:layout_marginBottom="@dimen/exo_styled_progress_layout_height"
android:visibility="invisible">
</LinearLayout>
android:visibility="invisible"/>
<View android:id="@id/exo_progress_placeholder"
<View android:id="@+id/exo_progress_placeholder"
android:layout_width="match_parent"
android:layout_height="@dimen/exo_styled_progress_layout_height"
android:layout_gravity="bottom"
android:layout_marginBottom="@dimen/exo_styled_progress_margin_bottom"/>
</merge>
......@@ -41,13 +41,8 @@
<dimen name="exo_styled_progress_layout_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_bottom_bar_height">60dp</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_styled_bottom_bar_height">60dp</dimen>
<dimen name="exo_styled_time_padding">10dp</dimen>
<dimen name="exo_error_message_height">32dp</dimen>
<dimen name="exo_error_message_margin_bottom">64dp</dimen>
......
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