diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2021-04-15 21:25:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-15 21:25:14 +0200 |
commit | 58cdba45c52a4d71f583b91a6a8e6b43293130a6 (patch) | |
tree | b414c08eaeb0825cdc688f624848f07cd54916ec /app/src/main | |
parent | 456470e68992b7482902e9138d7d4ee437d2c30c (diff) | |
parent | f1cba8042f18c2a138ca3af6df1005b9983e491e (diff) | |
download | AntennaPod-58cdba45c52a4d71f583b91a6a8e6b43293130a6.zip |
Merge pull request #5113 from ByteHamster/play-button
Play button animation
Diffstat (limited to 'app/src/main')
11 files changed, 143 insertions, 13 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java index 1fcc3512d..1eec762e9 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java @@ -17,6 +17,7 @@ import android.widget.TextView; import com.bumptech.glide.Glide; +import de.danoeh.antennapod.view.PlayButton; import org.apache.commons.lang3.StringUtils; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -72,7 +73,7 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements SeekBar sbPosition; private ImageButton butRev; private TextView txtvRev; - private ImageButton butPlay; + private PlayButton butPlay; private ImageButton butFF; private TextView txtvFF; private ImageButton butSkip; @@ -123,8 +124,8 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements } @Override - public ImageButton getPlayButton() { - return butPlay; + protected void updatePlayButtonShowsPlay(boolean showPlay) { + butPlay.setIsShowPlay(showPlay); } @Override @@ -513,6 +514,7 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements txtvRev.setText(NumberFormat.getInstance().format(UserPreferences.getRewindSecs())); } butPlay = findViewById(R.id.butPlay); + butPlay.setIsVideoScreen(true); butFF = findViewById(R.id.butFF); txtvFF = findViewById(R.id.txtvFF); if (txtvFF != null) { diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java index 184febdc9..cd7a6b913 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java @@ -50,6 +50,7 @@ import de.danoeh.antennapod.dialog.VariableSpeedDialog; import de.danoeh.antennapod.menuhandler.FeedItemMenuHandler; import de.danoeh.antennapod.view.ChapterSeekBar; import de.danoeh.antennapod.ui.common.PlaybackSpeedIndicatorView; +import de.danoeh.antennapod.view.PlayButton; import io.reactivex.Maybe; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; @@ -82,7 +83,7 @@ public class AudioPlayerFragment extends Fragment implements private ChapterSeekBar sbPosition; private ImageButton butRev; private TextView txtvRev; - private ImageButton butPlay; + private PlayButton butPlay; private ImageButton butFF; private TextView txtvFF; private ImageButton butSkip; @@ -381,8 +382,8 @@ public class AudioPlayerFragment extends Fragment implements } @Override - public ImageButton getPlayButton() { - return butPlay; + protected void updatePlayButtonShowsPlay(boolean showPlay) { + butPlay.setIsShowPlay(showPlay); } @Override 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 d77935910..37f372383 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java @@ -6,7 +6,6 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.ImageButton; import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.TextView; @@ -24,6 +23,7 @@ import de.danoeh.antennapod.core.service.playback.PlaybackService; import de.danoeh.antennapod.core.service.playback.PlayerStatus; import de.danoeh.antennapod.core.util.playback.Playable; import de.danoeh.antennapod.core.util.playback.PlaybackController; +import de.danoeh.antennapod.view.PlayButton; import io.reactivex.Maybe; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; @@ -40,7 +40,7 @@ public class ExternalPlayerFragment extends Fragment { private ImageView imgvCover; private TextView txtvTitle; - private ImageButton butPlay; + private PlayButton butPlay; private TextView feedName; private ProgressBar progressBar; private PlaybackController controller; @@ -103,8 +103,8 @@ public class ExternalPlayerFragment extends Fragment { } @Override - public ImageButton getPlayButton() { - return butPlay; + protected void updatePlayButtonShowsPlay(boolean showPlay) { + butPlay.setIsShowPlay(showPlay); } @Override diff --git a/app/src/main/java/de/danoeh/antennapod/view/PlayButton.java b/app/src/main/java/de/danoeh/antennapod/view/PlayButton.java new file mode 100644 index 000000000..691a15ca2 --- /dev/null +++ b/app/src/main/java/de/danoeh/antennapod/view/PlayButton.java @@ -0,0 +1,54 @@ +package de.danoeh.antennapod.view; + +import android.content.Context; +import android.util.AttributeSet; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.AppCompatImageButton; +import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat; +import de.danoeh.antennapod.R; +import de.danoeh.antennapod.ui.common.ThemeUtils; + +public class PlayButton extends AppCompatImageButton { + private boolean isShowPlay = true; + private boolean isVideoScreen = false; + + public PlayButton(@NonNull Context context) { + super(context); + } + + public PlayButton(@NonNull Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + } + + public PlayButton(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + public void setIsVideoScreen(boolean isVideoScreen) { + this.isVideoScreen = isVideoScreen; + } + + public void setIsShowPlay(boolean showPlay) { + if (this.isShowPlay != showPlay) { + this.isShowPlay = showPlay; + setContentDescription(getContext().getString(showPlay ? R.string.play_label : R.string.pause_label)); + if (isVideoScreen) { + setImageResource(showPlay ? R.drawable.ic_av_play_white_80dp : R.drawable.ic_av_pause_white_80dp); + } else if (!isShown()) { + setImageResource(ThemeUtils.getDrawableFromAttr(getContext(), + showPlay ? R.attr.av_play : R.attr.av_pause)); + } else if (showPlay) { + AnimatedVectorDrawableCompat drawable = AnimatedVectorDrawableCompat.create( + getContext(), R.drawable.ic_animate_pause_play); + setImageDrawable(drawable); + drawable.start(); + } else { + AnimatedVectorDrawableCompat drawable = AnimatedVectorDrawableCompat.create( + getContext(), R.drawable.ic_animate_play_pause); + setImageDrawable(drawable); + drawable.start(); + } + } + } +} diff --git a/app/src/main/res/drawable/ic_animate_pause_play.xml b/app/src/main/res/drawable/ic_animate_pause_play.xml new file mode 100644 index 000000000..cc68279cd --- /dev/null +++ b/app/src/main/res/drawable/ic_animate_pause_play.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<animated-vector + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + xmlns:aapt="http://schemas.android.com/aapt" + android:drawable="@drawable/ic_animate_play" + tools:ignore="NewApi"> + <target android:name="path"> + <aapt:attr name="android:animation"> + <objectAnimator + android:duration="@integer/fragment_transition_duration" + android:propertyName="pathData" + android:valueFrom="@string/svg_animatable_pause" + android:valueTo="@string/svg_animatable_play" + android:valueType="pathType"/> + </aapt:attr> + </target> + <target android:name="group"> + <aapt:attr name="android:animation"> + <objectAnimator + android:duration="@integer/fragment_transition_duration" + android:propertyName="rotation" + android:valueFrom="-90" + android:valueTo="0"/> + </aapt:attr> + </target> +</animated-vector> diff --git a/app/src/main/res/drawable/ic_animate_play.xml b/app/src/main/res/drawable/ic_animate_play.xml new file mode 100644 index 000000000..3c0a5ef1d --- /dev/null +++ b/app/src/main/res/drawable/ic_animate_play.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportHeight="24.0" + android:viewportWidth="24.0"> + <group android:name="group" + android:pivotX="12" + android:pivotY="12"> + <path android:name="path" + android:fillColor="?attr/action_icon_color" + android:pathData="@string/svg_animatable_play"/> + </group> +</vector> diff --git a/app/src/main/res/drawable/ic_animate_play_pause.xml b/app/src/main/res/drawable/ic_animate_play_pause.xml new file mode 100644 index 000000000..8e4f65b5e --- /dev/null +++ b/app/src/main/res/drawable/ic_animate_play_pause.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<animated-vector + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + xmlns:aapt="http://schemas.android.com/aapt" + android:drawable="@drawable/ic_animate_play" + tools:ignore="NewApi"> + <target android:name="path"> + <aapt:attr name="android:animation"> + <objectAnimator + android:duration="@integer/fragment_transition_duration" + android:propertyName="pathData" + android:valueFrom="@string/svg_animatable_play" + android:valueTo="@string/svg_animatable_pause" + android:valueType="pathType"/> + </aapt:attr> + </target> + <target android:name="group"> + <aapt:attr name="android:animation"> + <objectAnimator + android:duration="@integer/fragment_transition_duration" + android:propertyName="rotation" + android:valueFrom="0" + android:valueTo="90"/> + </aapt:attr> + </target> +</animated-vector> diff --git a/app/src/main/res/layout/audioplayer_fragment.xml b/app/src/main/res/layout/audioplayer_fragment.xml index d87fe85f0..3685032e6 100644 --- a/app/src/main/res/layout/audioplayer_fragment.xml +++ b/app/src/main/res/layout/audioplayer_fragment.xml @@ -140,7 +140,7 @@ android:layout_height="wrap_content" android:layout_marginBottom="24dp"> - <ImageButton + <de.danoeh.antennapod.view.PlayButton android:id="@+id/butPlay" android:layout_width="@dimen/audioplayer_playercontrols_length_big" android:layout_height="@dimen/audioplayer_playercontrols_length_big" diff --git a/app/src/main/res/layout/external_player_fragment.xml b/app/src/main/res/layout/external_player_fragment.xml index f36baec26..4f200162a 100644 --- a/app/src/main/res/layout/external_player_fragment.xml +++ b/app/src/main/res/layout/external_player_fragment.xml @@ -57,7 +57,7 @@ </LinearLayout> - <ImageButton + <de.danoeh.antennapod.view.PlayButton android:id="@+id/butPlay" android:layout_width="52dp" android:layout_height="match_parent" diff --git a/app/src/main/res/layout/videoplayer_activity.xml b/app/src/main/res/layout/videoplayer_activity.xml index e0632ef41..fc902602c 100644 --- a/app/src/main/res/layout/videoplayer_activity.xml +++ b/app/src/main/res/layout/videoplayer_activity.xml @@ -41,7 +41,7 @@ android:contentDescription="@string/rewind_label" app:srcCompat="@drawable/ic_av_fast_rewind_white_80dp" /> - <ImageButton + <de.danoeh.antennapod.view.PlayButton android:id="@+id/butPlay" android:layout_width="wrap_content" android:layout_height="wrap_content" diff --git a/app/src/main/res/values/svg.xml b/app/src/main/res/values/svg.xml new file mode 100644 index 000000000..6fd4ff0c4 --- /dev/null +++ b/app/src/main/res/values/svg.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string name="svg_animatable_play" translatable="false">M 8 5 L 8 12 L 19 12 L 19 12 M 8 19 L 8 12 L 19 12 L 19 12</string> + <string name="svg_animatable_pause" translatable="false">M 5 6 L 5 10 L 19 10 L 19 6 M 5 18 L 5 14 L 19 14 L 19 18</string> +</resources> |