diff options
5 files changed, 97 insertions, 100 deletions
diff --git a/app/src/main/java/com/google/android/material/bottomsheet/ViewPagerBottomSheetBehavior.java b/app/src/main/java/com/google/android/material/bottomsheet/ViewPagerBottomSheetBehavior.java index 1e76b3bc1..1667006a5 100644 --- a/app/src/main/java/com/google/android/material/bottomsheet/ViewPagerBottomSheetBehavior.java +++ b/app/src/main/java/com/google/android/material/bottomsheet/ViewPagerBottomSheetBehavior.java @@ -34,7 +34,9 @@ public class ViewPagerBottomSheetBehavior<V extends View> extends BottomSheetBeh if (view instanceof ViewPager) { ViewPager viewPager = (ViewPager) view; View currentViewPagerChild = viewPager.getChildAt(viewPager.getCurrentItem()); - return findScrollingChild(currentViewPagerChild); + if (currentViewPagerChild != null) { + return findScrollingChild(currentViewPagerChild); + } } else if (view instanceof ViewGroup) { ViewGroup group = (ViewGroup) view; for (int i = 0, count = group.getChildCount(); i < count; i++) { 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 57193e08b..03b1d6f8f 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java @@ -40,7 +40,6 @@ import org.greenrobot.eventbus.ThreadMode; public class ExternalPlayerFragment extends Fragment { public static final String TAG = "ExternalPlayerFragment"; - private ViewGroup fragmentLayout; private ImageView imgvCover; private TextView txtvTitle; private ImageButton butPlay; @@ -56,16 +55,14 @@ public class ExternalPlayerFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View root = inflater.inflate(R.layout.external_player_fragment, - container, false); - fragmentLayout = root.findViewById(R.id.fragmentLayout); + View root = inflater.inflate(R.layout.external_player_fragment, container, false); imgvCover = root.findViewById(R.id.imgvCover); txtvTitle = root.findViewById(R.id.txtvTitle); butPlay = root.findViewById(R.id.butPlay); mFeedName = root.findViewById(R.id.txtvAuthor); mProgressBar = root.findViewById(R.id.episodeProgress); - fragmentLayout.setOnClickListener(v -> { + root.findViewById(R.id.fragmentLayout).setOnClickListener(v -> { Log.d(TAG, "layoutInfo was clicked"); if (controller != null && controller.getMedia() != null) { @@ -175,9 +172,7 @@ public class ExternalPlayerFragment extends Fragment { } private void playbackDone() { - if (fragmentLayout != null) { - fragmentLayout.setVisibility(View.GONE); - } + clearUi(); if (controller != null) { controller.release(); } @@ -214,10 +209,22 @@ public class ExternalPlayerFragment extends Fragment { .observeOn(AndroidSchedulers.mainThread()) .subscribe(media -> updateUi((Playable) media), error -> Log.e(TAG, Log.getStackTraceString(error)), - () -> fragmentLayout.setVisibility(View.GONE)); + this::clearUi); return true; } + private void clearUi() { + if (txtvTitle == null || mFeedName == null || mProgressBar == null || butPlay == null) { + return; + } + txtvTitle.setText(R.string.no_media_playing_label); + mFeedName.setText(""); + butPlay.setVisibility(View.GONE); + mProgressBar.setProgress(0); + Glide.with(getActivity()).clear(imgvCover); + ((MainActivity) getActivity()).getBottomSheet().setLocked(true); + } + private void updateUi(Playable media) { if (media != null) { txtvTitle.setText(media.getEpisodeTitle()); @@ -233,8 +240,6 @@ public class ExternalPlayerFragment extends Fragment { .fitCenter() .dontAnimate()) .into(imgvCover); - - fragmentLayout.setVisibility(View.VISIBLE); if (controller != null && controller.isPlayingVideoLocally()) { butPlay.setVisibility(View.GONE); ((MainActivity) getActivity()).getBottomSheet().setLocked(true); diff --git a/app/src/main/res/drawable/shadow.xml b/app/src/main/res/drawable/shadow.xml deleted file mode 100644 index fc5110e0b..000000000 --- a/app/src/main/res/drawable/shadow.xml +++ /dev/null @@ -1,7 +0,0 @@ -<shape xmlns:android="http://schemas.android.com/apk/res/android" - android:shape="rectangle"> - <gradient - android:startColor="@android:color/transparent" - android:endColor="#40000000" - android:angle="90" /> -</shape> diff --git a/app/src/main/res/layout/external_player_fragment.xml b/app/src/main/res/layout/external_player_fragment.xml index 3e2efe47e..651953b0e 100644 --- a/app/src/main/res/layout/external_player_fragment.xml +++ b/app/src/main/res/layout/external_player_fragment.xml @@ -1,87 +1,84 @@ <?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - xmlns:app="http://schemas.android.com/apk/res-auto" - android:id="@+id/fragmentLayout" - android:layout_width="match_parent" - android:layout_height="@dimen/external_player_height" - android:visibility="gone" - android:background="?attr/selectableItemBackground"> - - <ImageView - android:id="@+id/imgvCover" - android:contentDescription="@string/cover_label" - android:layout_width="@dimen/external_player_height" +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:id="@+id/fragmentLayout" + android:layout_width="match_parent" android:layout_height="@dimen/external_player_height" - android:adjustViewBounds="true" - android:cropToPadding="true" - android:scaleType="centerCrop" - tools:src="@drawable/ic_drag_vertical_white_48dp" - tools:background="@android:color/holo_green_dark" - android:transitionName="coverTransition" - android:layout_alignParentTop="true" - android:layout_alignParentLeft="true" - android:layout_alignParentStart="true"/> + android:background="?attr/selectableItemBackground" + android:orientation="vertical"> - <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"/> + <View + android:layout_width="match_parent" + android:layout_height="1dp" + android:background="?android:attr/dividerHorizontal" /> - <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" - app:srcCompat="?attr/av_play" - android:scaleType="fitCenter" - android:padding="8dp" - tools:src="@drawable/ic_play_arrow_white_36dp"/> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="0dp" + android:gravity="center_vertical" + android:layout_weight="1"> + + <ImageView + android:id="@+id/imgvCover" + android:contentDescription="@string/cover_label" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:adjustViewBounds="true" + android:cropToPadding="true" + android:scaleType="centerCrop" + tools:src="@tools:sample/avatars"/> - <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"/> - <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"/> + <LinearLayout + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:orientation="vertical" + android:layout_marginLeft="16dp" + android:layout_marginStart="16dp"> + + <TextView + android:id="@+id/txtvTitle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + 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"/> + + <TextView + android:id="@+id/txtvAuthor" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + 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"/> + </LinearLayout> + + + <ImageButton + android:id="@+id/butPlay" + android:layout_width="52dp" + android:layout_height="match_parent" + android:contentDescription="@string/pause_label" + android:background="?attr/selectableItemBackground" + app:srcCompat="?attr/av_play" + android:scaleType="fitCenter" + android:padding="8dp" + tools:src="@drawable/ic_play_arrow_white_36dp"/> + + </LinearLayout> + + <ProgressBar + android:id="@+id/episodeProgress" + android:layout_width="match_parent" + android:layout_height="4dp" + style="?attr/progressBarTheme" + android:indeterminate="false" + tools:progress="100"/> -</RelativeLayout> +</LinearLayout> diff --git a/core/src/main/res/values/dimens.xml b/core/src/main/res/values/dimens.xml index 5083eb749..cfb272ad9 100644 --- a/core/src/main/res/values/dimens.xml +++ b/core/src/main/res/values/dimens.xml @@ -3,7 +3,7 @@ <dimen name="widget_margin">0dp</dimen> <dimen name="thumbnail_length">70dp</dimen> - <dimen name="external_player_height">56dp</dimen> + <dimen name="external_player_height">64dp</dimen> <dimen name="enc_icons_size">20dp</dimen> <dimen name="text_size_micro">12sp</dimen> <dimen name="text_size_small">14sp</dimen> |