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/java/de/danoeh/antennapod | |
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/java/de/danoeh/antennapod')
4 files changed, 67 insertions, 10 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(); + } + } + } +} |