Merge pull request #1539 from recalculated/external-player

Redesign ExternalPlayerFragment
This commit is contained in:
Martin Fietz 2016-01-09 10:15:24 +01:00
commit ce29d9f669
7 changed files with 141 additions and 62 deletions

View File

@ -9,6 +9,7 @@ import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.bumptech.glide.Glide;
@ -30,9 +31,10 @@ public class ExternalPlayerFragment extends Fragment {
private ViewGroup fragmentLayout;
private ImageView imgvCover;
private ViewGroup layoutInfo;
private TextView txtvTitle;
private ImageButton butPlay;
private TextView mFeedName;
private ProgressBar mProgressBar;
private PlaybackController controller;
@ -47,11 +49,12 @@ public class ExternalPlayerFragment extends Fragment {
container, false);
fragmentLayout = (ViewGroup) root.findViewById(R.id.fragmentLayout);
imgvCover = (ImageView) root.findViewById(R.id.imgvCover);
layoutInfo = (ViewGroup) root.findViewById(R.id.layoutInfo);
txtvTitle = (TextView) root.findViewById(R.id.txtvTitle);
butPlay = (ImageButton) root.findViewById(R.id.butPlay);
mFeedName = (TextView) root.findViewById(R.id.txtvAuthor);
mProgressBar = (ProgressBar) root.findViewById(R.id.episodeProgress);
layoutInfo.setOnClickListener(new OnClickListener() {
fragmentLayout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
@ -82,6 +85,7 @@ public class ExternalPlayerFragment extends Fragment {
@Override
public void onPositionObserverUpdate() {
ExternalPlayerFragment.this.onPositionObserverUpdate();
}
@Override
@ -159,6 +163,8 @@ public class ExternalPlayerFragment extends Fragment {
public void onResume() {
super.onResume();
controller.init();
mProgressBar.setProgress((int)
((double) controller.getPosition() / controller.getDuration() * 100));
}
@Override
@ -199,6 +205,9 @@ public class ExternalPlayerFragment extends Fragment {
Playable media = controller.getMedia();
if (media != null) {
txtvTitle.setText(media.getEpisodeTitle());
mFeedName.setText(media.getFeedTitle());
mProgressBar.setProgress((int)
((double) controller.getPosition() / controller.getDuration() * 100));
Glide.with(getActivity())
.load(media.getImageUri())
@ -234,4 +243,9 @@ public class ExternalPlayerFragment extends Fragment {
public PlaybackController getPlaybackControllerTestingOnly() {
return controller;
}
public void onPositionObserverUpdate() {
mProgressBar.setProgress((int)
((double) controller.getPosition() / controller.getDuration() * 100));
}
}

View File

@ -1,69 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/fragmentLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone"
android:background="?attr/colorPrimary"
tools:visibility="visible"
tools:background="@android:color/darker_gray">
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@color/holo_blue_light"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:visibility="gone">
<RelativeLayout
android:id="@+id/layoutInfo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="?attr/selectableItemBackground">
android:layout_width="match_parent"
android:layout_height="@dimen/external_player_height">
<ImageView
android:id="@+id/imgvCover"
android:contentDescription="@string/cover_label"
android:layout_width="@dimen/external_player_height"
android:layout_height="@dimen/external_player_height"
android:layout_alignParentLeft="true"
android:padding="4dp"
android:adjustViewBounds="true"
android:cropToPadding="true"
android:scaleType="fitXY"
tools:src="@drawable/ic_stat_antenna_default"
tools:background="@android:color/holo_green_dark" />
tools:src="@drawable/ic_drag_vertical_white_48dp"
tools:background="@android:color/holo_green_dark"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<ProgressBar
android:id="@+id/episodeProgress"
android:layout_width="match_parent"
android:layout_height="4dp"
android:layout_toRightOf="@id/imgvCover"
android:layout_toEndOf="@id/imgvCover"
android:layout_alignParentTop="true"
style="?attr/progressBarTheme"
android:indeterminate="false"
tools:progress="100"/>
<TextView
android:id="@+id/txtvTitle"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="26dp"
android:layout_toRightOf="@id/imgvCover"
android:layout_toEndOf="@id/imgvCover"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_toLeftOf="@id/butPlay"
android:layout_toStartOf="@id/butPlay"
style="@style/Base.TextAppearance.AppCompat.Body1"
android:ellipsize="end"
android:maxLines="2"
android:textSize="18sp"
android:fontFamily="sans-serif-light"
tools:text="Playback item title"
tools:background="@android:color/holo_green_dark"/>
</RelativeLayout>
android:maxLines="1"
tools:text="Episode title that is too long and will cause the text to wrap"/>
<TextView
android:id="@+id/txtvAuthor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/episodeProgress"
android:layout_marginTop="26dp"
android:layout_toRightOf="@id/imgvCover"
android:layout_toEndOf="@id/imgvCover"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_toLeftOf="@id/butPlay"
android:layout_toStartOf="@id/butPlay"
style="@style/TextAppearance.AppCompat.Body1"
android:textColor="?android:attr/textColorSecondary"
android:ellipsize="end"
android:maxLines="1"
tools:text="Episode author that is too long and will cause the text to wrap"/>
<ImageButton
android:id="@+id/butPlay"
android:layout_width="52dp"
android:layout_height="52dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_below="@id/episodeProgress"
android:layout_centerVertical="true"
android:contentDescription="@string/pause_label"
android:layout_width="@dimen/external_player_height"
android:layout_height="@dimen/external_player_height"
android:background="?attr/selectableItemBackground"
tools:src="@drawable/ic_play_arrow_white_36dp"
tools:background="@android:color/holo_green_dark"/>
</LinearLayout>
tools:src="@drawable/ic_play_arrow_white_36dp"/>
</RelativeLayout>
</LinearLayout>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<solid android:color="#33FFFFFF"/>
</shape>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<solid android:color="@color/holo_blue_dark"/>
</shape>
</clip>
</item>
</layer-list>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<solid android:color="#33212121"/>
</shape>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<solid android:color="@color/holo_blue_light"/>
</shape>
</clip>
</item>
</layer-list>

View File

@ -41,6 +41,7 @@
<attr name="ic_lock_open" format="reference"/>
<attr name="ic_lock_closed" format="reference"/>
<attr name="ic_filter" format="reference"/>
<attr name="progressBarTheme" format="reference"/>
<!-- Used in itemdescription -->
<attr name="non_transparent_background" format="reference"/>

View File

@ -3,7 +3,7 @@
<dimen name="widget_margin">8dp</dimen>
<dimen name="thumbnail_length">70dp</dimen>
<dimen name="external_player_height">70dp</dimen>
<dimen name="external_player_height">56dp</dimen>
<dimen name="enc_icons_size">20dp</dimen>
<dimen name="text_size_micro">12sp</dimen>
<dimen name="text_size_small">14sp</dimen>

View File

@ -4,6 +4,7 @@
<style name="Theme.AntennaPod.Light" parent="Theme.AppCompat.Light">
<item name="colorPrimary">@color/primary_light</item>
<item name="colorAccent">@color/holo_blue_light</item>
<item name="progressBarTheme">@style/ProgressBarLight</item>
<item name="buttonStyle">@style/Widget.AntennaPod.Button</item>
<item name="alertDialogTheme">@style/AntennaPod.Dialog.Light</item>
<item name="attr/action_bar_icon_color">@color/grey600</item>
@ -53,6 +54,7 @@
<style name="Theme.AntennaPod.Dark" parent="Theme.AppCompat">
<item name="colorAccent">@color/holo_blue_dark</item>
<item name="buttonStyle">@style/Widget.AntennaPod.Button</item>
<item name="progressBarTheme">@style/ProgressBarDark</item>
<item name="alertDialogTheme">@style/AntennaPod.Dialog.Dark</item>
<item name="attr/action_bar_icon_color">@color/white</item>
<item name="attr/action_about">@drawable/ic_info_white_24dp</item>g
@ -101,6 +103,7 @@
<style name="Theme.AntennaPod.Light.NoTitle" parent="Theme.AppCompat.Light.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowActionModeOverlay">true</item>
<item name="progressBarTheme">@style/ProgressBarLight</item>
<item name="colorPrimary">@color/primary_light</item>
<item name="colorAccent">@color/holo_blue_light</item>
<item name="buttonStyle">@style/Widget.AntennaPod.Button</item>
@ -151,6 +154,7 @@
<style name="Theme.AntennaPod.Dark.NoTitle" parent="Theme.AppCompat.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowActionModeOverlay">true</item>
<item name="progressBarTheme">@style/ProgressBarDark</item>
<item name="colorAccent">@color/holo_blue_dark</item>
<item name="buttonStyle">@style/Widget.AntennaPod.Button</item>
<item name="alertDialogTheme">@style/AntennaPod.Dialog.Dark</item>
@ -253,4 +257,14 @@
</style>
<style name="ProgressBarLight">
<item name="android:indeterminateOnly">false</item>
<item name="android:progressDrawable">@drawable/progress_bar_horizontal_light</item>
</style>
<style name="ProgressBarDark">
<item name="android:indeterminateOnly">false</item>
<item name="android:progressDrawable">@drawable/progress_bar_horizontal_dark</item>
</style>
</resources>