Redesign ExternalPlayerFragment

This commit is contained in:
recalculated 2016-01-07 19:05:41 -06:00
parent 8a4624cb92
commit 0d54bd18a7
6 changed files with 119 additions and 66 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,83 @@
<?xml version="1.0" encoding="utf-8"?>
<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">
<RelativeLayout
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="@dimen/external_player_height"
android:visibility="gone"
tools:visibility="visible">
<View
<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:adjustViewBounds="true"
android:cropToPadding="true"
android:scaleType="fitXY"
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="2dp"
android:background="@color/holo_blue_light"/>
android:layout_height="4dp"
android:layout_toRightOf="@id/imgvCover"
android:layout_toEndOf="@id/imgvCover"
android:layout_alignParentTop="true"
style="@style/ProgressBarStyle"
android:indeterminate="false"
tools:progress="100"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/txtvTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
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="1"
tools:text="Episode title that is too long and will cause the text to wrap"/>
<RelativeLayout
android:id="@+id/layoutInfo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="?attr/selectableItemBackground">
<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"/>
<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" />
<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:background="?attr/selectableItemBackground"
tools:src="@drawable/ic_play_arrow_white_36dp"/>
<TextView
android:id="@+id/txtvTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:layout_toRightOf="@id/imgvCover"
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>
<ImageButton
android:id="@+id/butPlay"
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>
</LinearLayout>
</RelativeLayout>

View File

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

View File

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

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

@ -253,4 +253,9 @@
</style>
<style name="ProgressBarStyle">
<item name="android:indeterminateOnly">false</item>
<item name="android:progressDrawable">@drawable/progress_bar_horizontal</item>
</style>
</resources>