leanback: new transport controls
PlaybackTransportRowPresenter is the new UX.
PlaybackTransportControlGlue extends from PlaybackGlue.
PlaybackTransportControlGlue is backed by PlayerWrapper.
PlaybackWrapper wraps underlying media player,
concrete example: MediaPlayerWrapper.
PlaybackSeekDataProvider defines the data interface that app
provides to leanback.
PlaybackUI defines seeking interaction between
PlaybackTransportControlGlue, PlaybackGlueHost and the presenter.
more:
- added progress bar support for media loading.
- fixed vertical video proportion and support video size change.
Test: PlaybackTransportControlGlueTest
PlaybackTransportRowPresenterTest.
Updated SampleVideoFragment.
Bug: 33751556
Change-Id: I1d39c6f65d04121f8cb9c25fb7ce103e32355190
diff --git a/v17/leanback/res/layout/lb_playback_fragment.xml b/v17/leanback/res/layout/lb_playback_fragment.xml
index 1b0ffa1..ab2909b 100644
--- a/v17/leanback/res/layout/lb_playback_fragment.xml
+++ b/v17/leanback/res/layout/lb_playback_fragment.xml
@@ -21,7 +21,13 @@
android:transitionGroup="false"
android:layout_height="match_parent">
- <FrameLayout
+ <android.support.v17.leanback.widget.NonOverlappingFrameLayout
+ android:id="@+id/playback_fragment_background"
+ android:transitionGroup="false"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+ <android.support.v17.leanback.widget.NonOverlappingFrameLayout
android:id="@+id/playback_controls_dock"
android:transitionGroup="true"
android:layout_height="match_parent"
diff --git a/v17/leanback/res/layout/lb_playback_transport_controls.xml b/v17/leanback/res/layout/lb_playback_transport_controls.xml
new file mode 100644
index 0000000..d4380f3
--- /dev/null
+++ b/v17/leanback/res/layout/lb_playback_transport_controls.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 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="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical" >
+
+ <FrameLayout
+ android:id="@+id/controls_container"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" >
+
+ <android.support.v17.leanback.widget.ControlBar
+ android:id="@+id/control_bar"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layoutDirection="ltr"
+ android:orientation="horizontal" />
+
+
+ </FrameLayout>
+
+
+</LinearLayout>
\ No newline at end of file
diff --git a/v17/leanback/res/layout/lb_playback_transport_controls_row.xml b/v17/leanback/res/layout/lb_playback_transport_controls_row.xml
new file mode 100644
index 0000000..1b32be6
--- /dev/null
+++ b/v17/leanback/res/layout/lb_playback_transport_controls_row.xml
@@ -0,0 +1,127 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2017 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.
+ -->
+
+<!-- Note: clipChildren/clipToPadding false are needed to apply shadows to child
+ views with no padding of their own. Also to allow for negative margin on description. -->
+
+<android.support.v17.leanback.widget.PlaybackTransportRowView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:clipChildren="false"
+ android:clipToPadding="false"
+ android:paddingBottom="@dimen/lb_playback_transport_control_row_padding_bottom"
+ android:paddingStart="?attr/browsePaddingStart"
+ android:paddingEnd="?attr/browsePaddingEnd" >
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <LinearLayout
+ android:id="@+id/controls_card"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:clipChildren="false"
+ android:clipToPadding="false"
+ android:layout_marginBottom="@dimen/lb_playback_transport_control_info_margin_bottom"
+ android:orientation="horizontal" >
+
+ <ImageView
+ android:id="@+id/image"
+ android:layout_width="wrap_content"
+ android:layout_height="@dimen/lb_playback_transport_image_height"
+ android:layout_gravity="top"
+ android:adjustViewBounds="true"
+ android:layout_marginEnd="@dimen/lb_playback_transport_image_margin_end"
+ android:scaleType="fitStart" />
+
+ <FrameLayout
+ android:id="@+id/description_dock"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="top"
+ android:clipToPadding="false"
+ android:gravity="bottom" />
+ </LinearLayout>
+ <android.support.v17.leanback.widget.ThumbsBar
+ android:id="@+id/thumbs_row"
+ android:orientation="horizontal"
+ android:visibility="invisible"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom" />
+ </FrameLayout>
+
+ <FrameLayout
+ android:id="@+id/controls_dock"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layoutDirection="ltr"
+ android:layout_marginLeft="@dimen/lb_playback_transport_controlbar_margin_start"
+ />
+
+ <android.support.v17.leanback.widget.SeekBar
+ android:id="@+id/playback_progress"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/lb_playback_transport_progressbar_height"
+ android:focusable="true" />
+
+ <RelativeLayout android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layoutDirection="ltr"
+ android:layout_marginLeft="@dimen/lb_playback_transport_controlbar_margin_start">
+ <FrameLayout
+ android:id="@+id/secondary_controls_dock"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentStart="true" >
+ </FrameLayout>
+
+ <TextView
+ android:id="@+id/current_time"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="top"
+ android:layout_toStartOf="@+id/separate_time"
+ android:layout_marginStart="@dimen/lb_playback_transport_time_margin"
+ android:layout_marginTop="@dimen/lb_playback_transport_time_margin_top"
+ style="?attr/playbackControlsTimeStyle" />
+
+ <TextView
+ android:id="@+id/separate_time"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/lb_playback_time_separator"
+ android:layout_gravity="top"
+ android:layout_toStartOf="@+id/total_time"
+ android:layout_marginStart="@dimen/lb_playback_transport_time_margin"
+ android:layout_marginTop="@dimen/lb_playback_transport_time_margin_top"
+ style="?attr/playbackControlsTimeStyle" />
+
+ <TextView
+ android:id="@+id/total_time"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="top"
+ android:layout_alignParentEnd="true"
+ android:layout_marginStart="@dimen/lb_playback_transport_time_margin"
+ android:layout_marginTop="@dimen/lb_playback_transport_time_margin_top"
+ style="?attr/playbackControlsTimeStyle" />
+ </RelativeLayout>
+
+</android.support.v17.leanback.widget.PlaybackTransportRowView>
diff --git a/v17/leanback/res/layout/lb_video_surface.xml b/v17/leanback/res/layout/lb_video_surface.xml
index 9c6c8fd..61ac944 100644
--- a/v17/leanback/res/layout/lb_video_surface.xml
+++ b/v17/leanback/res/layout/lb_video_surface.xml
@@ -17,5 +17,6 @@
<android.support.v17.leanback.widget.VideoSurfaceView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/video_surface"
+ android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent" />
diff --git a/v17/leanback/res/values/dimens.xml b/v17/leanback/res/values/dimens.xml
index 4bf237d..1f4299f 100644
--- a/v17/leanback/res/values/dimens.xml
+++ b/v17/leanback/res/values/dimens.xml
@@ -160,6 +160,25 @@
<dimen name="lb_playback_now_playing_view_size">28dp</dimen>
<dimen name="lb_playback_play_icon_size">14dp</dimen>
+ <!-- margin to move controlBar button a bit left to align icon with description left -->
+ <dimen name="lb_playback_transport_controlbar_margin_start">-12dp</dimen>
+ <dimen name="lb_playback_transport_control_info_margin_bottom">20dp</dimen>
+ <dimen name="lb_playback_transport_control_row_padding_bottom">20dp</dimen>
+ <dimen name="lb_playback_transport_image_height">176dp</dimen>
+ <dimen name="lb_playback_transport_image_margin_end">24dp</dimen>
+
+ <!-- height should including enough space for thumbs when activated -->
+ <dimen name="lb_playback_transport_progressbar_height">28dp</dimen>
+ <!-- height for the bar when not focused -->
+ <dimen name="lb_playback_transport_progressbar_bar_height">4dp</dimen>
+ <!-- height for the bar when focused -->
+ <dimen name="lb_playback_transport_progressbar_active_bar_height">6dp</dimen>
+ <!-- radius of thumb when focused -->
+ <dimen name="lb_playback_transport_progressbar_active_radius">6dp</dimen>
+
+ <dimen name="lb_playback_transport_time_margin">8dp</dimen>
+ <dimen name="lb_playback_transport_time_margin_top">8dp</dimen>
+
<dimen name="lb_control_button_diameter">90dp</dimen>
<dimen name="lb_control_button_height">64dp</dimen>
<dimen name="lb_control_button_secondary_diameter">48dp</dimen>
diff --git a/v17/leanback/res/values/strings.xml b/v17/leanback/res/values/strings.xml
index cbf4904..aef086a 100644
--- a/v17/leanback/res/values/strings.xml
+++ b/v17/leanback/res/values/strings.xml
@@ -80,7 +80,8 @@
<string name="lb_playback_controls_closed_captioning_disable">Disable Closed Captioning</string>
<!-- Talkback label for the control button to enter picture in picture mode -->
<string name="lb_playback_controls_picture_in_picture">Enter Picture In Picture Mode</string>
-
+ <!-- separator between current time and duration -->
+ <string name="lb_playback_time_separator">/</string>
<string name="lb_playback_controls_shown">Media controls shown</string>
<string name="lb_playback_controls_hidden">Media controls hidden, press d-pad to show</string>
@@ -95,6 +96,9 @@
<!-- Separator for time picker [CHAR LIMIT=2] -->
<string name="lb_time_separator">:</string>
+ <!-- Error string for MediaPlayer -->
+ <string name="lb_media_player_error">MediaPlayer error code %1$d extra %2$d</string>
+
<!-- Onboarding screen -->
<eat-comment />
<!-- Text for "GET STARTED" button. This text should be in ALL CAPS. -->