From 0d54bd18a74839a6b6c6ba47524903629bb4ffb4 Mon Sep 17 00:00:00 2001 From: recalculated Date: Thu, 7 Jan 2016 19:05:41 -0600 Subject: [PATCH 1/3] Redesign ExternalPlayerFragment --- .../fragment/ExternalPlayerFragment.java | 20 ++- .../res/layout/external_player_fragment.xml | 138 ++++++++++-------- .../drawable-v21/progress_bar_horizontal.xml | 10 ++ .../res/drawable/progress_bar_horizontal.xml | 10 ++ core/src/main/res/values/dimens.xml | 2 +- core/src/main/res/values/styles.xml | 5 + 6 files changed, 119 insertions(+), 66 deletions(-) create mode 100644 core/src/main/res/drawable-v21/progress_bar_horizontal.xml create mode 100644 core/src/main/res/drawable/progress_bar_horizontal.xml diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java index 7b02b4f18..888684313 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java @@ -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)); + } } diff --git a/app/src/main/res/layout/external_player_fragment.xml b/app/src/main/res/layout/external_player_fragment.xml index ef83baa17..c1dccc658 100644 --- a/app/src/main/res/layout/external_player_fragment.xml +++ b/app/src/main/res/layout/external_player_fragment.xml @@ -1,69 +1,83 @@ - + - + + + 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"/> - + - + - + - - - - - - - \ No newline at end of file + diff --git a/core/src/main/res/drawable-v21/progress_bar_horizontal.xml b/core/src/main/res/drawable-v21/progress_bar_horizontal.xml new file mode 100644 index 000000000..2c0c18182 --- /dev/null +++ b/core/src/main/res/drawable-v21/progress_bar_horizontal.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/core/src/main/res/drawable/progress_bar_horizontal.xml b/core/src/main/res/drawable/progress_bar_horizontal.xml new file mode 100644 index 000000000..f96a1c3e0 --- /dev/null +++ b/core/src/main/res/drawable/progress_bar_horizontal.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/core/src/main/res/values/dimens.xml b/core/src/main/res/values/dimens.xml index c46537b3e..aa57e3051 100644 --- a/core/src/main/res/values/dimens.xml +++ b/core/src/main/res/values/dimens.xml @@ -3,7 +3,7 @@ 8dp 70dp - 70dp + 56dp 20dp 12sp 14sp diff --git a/core/src/main/res/values/styles.xml b/core/src/main/res/values/styles.xml index b9ee70dbf..b006f31b9 100644 --- a/core/src/main/res/values/styles.xml +++ b/core/src/main/res/values/styles.xml @@ -253,4 +253,9 @@ + + From 30e963fc3e4f1f49369e79ae131143c835d1a3fd Mon Sep 17 00:00:00 2001 From: recalculated Date: Fri, 8 Jan 2016 17:42:05 -0600 Subject: [PATCH 2/3] Make progress bar theme-specific --- .../main/res/layout/external_player_fragment.xml | 2 +- ...izontal.xml => progress_bar_horizontal_dark.xml} | 5 +++++ .../progress_bar_horizontal_light.xml} | 7 ++++++- core/src/main/res/values/attrs.xml | 1 + core/src/main/res/values/styles.xml | 13 +++++++++++-- 5 files changed, 24 insertions(+), 4 deletions(-) rename core/src/main/res/drawable/{progress_bar_horizontal.xml => progress_bar_horizontal_dark.xml} (69%) rename core/src/main/res/{drawable-v21/progress_bar_horizontal.xml => drawable/progress_bar_horizontal_light.xml} (55%) diff --git a/app/src/main/res/layout/external_player_fragment.xml b/app/src/main/res/layout/external_player_fragment.xml index c1dccc658..78c197e1d 100644 --- a/app/src/main/res/layout/external_player_fragment.xml +++ b/app/src/main/res/layout/external_player_fragment.xml @@ -29,7 +29,7 @@ android:layout_toRightOf="@id/imgvCover" android:layout_toEndOf="@id/imgvCover" android:layout_alignParentTop="true" - style="@style/ProgressBarStyle" + style="?attr/progressBarTheme" android:indeterminate="false" tools:progress="100"/> diff --git a/core/src/main/res/drawable/progress_bar_horizontal.xml b/core/src/main/res/drawable/progress_bar_horizontal_dark.xml similarity index 69% rename from core/src/main/res/drawable/progress_bar_horizontal.xml rename to core/src/main/res/drawable/progress_bar_horizontal_dark.xml index f96a1c3e0..73ad5b37c 100644 --- a/core/src/main/res/drawable/progress_bar_horizontal.xml +++ b/core/src/main/res/drawable/progress_bar_horizontal_dark.xml @@ -1,5 +1,10 @@ + + + + + diff --git a/core/src/main/res/drawable-v21/progress_bar_horizontal.xml b/core/src/main/res/drawable/progress_bar_horizontal_light.xml similarity index 55% rename from core/src/main/res/drawable-v21/progress_bar_horizontal.xml rename to core/src/main/res/drawable/progress_bar_horizontal_light.xml index 2c0c18182..a1a7129e9 100644 --- a/core/src/main/res/drawable-v21/progress_bar_horizontal.xml +++ b/core/src/main/res/drawable/progress_bar_horizontal_light.xml @@ -1,9 +1,14 @@ + + + + + - + diff --git a/core/src/main/res/values/attrs.xml b/core/src/main/res/values/attrs.xml index de641f518..4e444c990 100644 --- a/core/src/main/res/values/attrs.xml +++ b/core/src/main/res/values/attrs.xml @@ -41,6 +41,7 @@ + diff --git a/core/src/main/res/values/styles.xml b/core/src/main/res/values/styles.xml index b006f31b9..1f73fbba2 100644 --- a/core/src/main/res/values/styles.xml +++ b/core/src/main/res/values/styles.xml @@ -4,6 +4,7 @@ - + + From 09286cfbe883d563b49144e4c59a0162ad1705ef Mon Sep 17 00:00:00 2001 From: recalculated Date: Fri, 8 Jan 2016 20:53:49 -0600 Subject: [PATCH 3/3] Fix external player not hiding on 2.3 --- .../res/layout/external_player_fragment.xml | 142 +++++++++--------- 1 file changed, 74 insertions(+), 68 deletions(-) diff --git a/app/src/main/res/layout/external_player_fragment.xml b/app/src/main/res/layout/external_player_fragment.xml index 78c197e1d..b928b6233 100644 --- a/app/src/main/res/layout/external_player_fragment.xml +++ b/app/src/main/res/layout/external_player_fragment.xml @@ -1,83 +1,89 @@ - + android:layout_height="wrap_content" + android:orientation="vertical" + android:visibility="gone"> - - - + android:layout_height="@dimen/external_player_height"> - + - + - + + + + - + + +