diff options
author | ByteHamster <info@bytehamster.com> | 2020-03-25 17:09:03 +0100 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2020-03-25 17:09:03 +0100 |
commit | 0a7d054aad0a0f48505c1ea10f2b0aeea9e10675 (patch) | |
tree | d9b064edbd52782ca5b380c995accf1f5b6f90d1 /app/src/main/java/de/danoeh/antennapod | |
parent | 9e84a0626049430fbd758aea2bf2fd00e12811b2 (diff) | |
download | AntennaPod-0a7d054aad0a0f48505c1ea10f2b0aeea9e10675.zip |
Removed AudioPlayerActivity
Diffstat (limited to 'app/src/main/java/de/danoeh/antennapod')
5 files changed, 10 insertions, 162 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java deleted file mode 100644 index ae8634516..000000000 --- a/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java +++ /dev/null @@ -1,136 +0,0 @@ -package de.danoeh.antennapod.activity; - -import android.content.Intent; -import android.text.TextUtils; -import android.util.Log; -import android.view.View; -import de.danoeh.antennapod.core.feed.MediaType; -import de.danoeh.antennapod.core.feed.util.PlaybackSpeedUtils; -import de.danoeh.antennapod.core.preferences.PlaybackPreferences; -import de.danoeh.antennapod.core.preferences.UserPreferences; -import de.danoeh.antennapod.core.service.playback.PlaybackService; -import de.danoeh.antennapod.dialog.VariableSpeedDialog; - -import java.text.DecimalFormat; -import java.util.concurrent.atomic.AtomicBoolean; - -/** - * Activity for playing audio files. - */ -public class AudioplayerActivity extends MediaplayerInfoActivity { - private static final String TAG = "AudioPlayerActivity"; - private static final float EPSILON = 0.001f; - - private final AtomicBoolean isSetup = new AtomicBoolean(false); - - @Override - protected void onResume() { - super.onResume(); - if (TextUtils.equals(getIntent().getAction(), Intent.ACTION_VIEW)) { - playExternalMedia(getIntent(), MediaType.AUDIO); - } else if (PlaybackService.isCasting()) { - Intent intent = PlaybackService.getPlayerActivityIntent(this); - if (intent.getComponent() != null - && !intent.getComponent().getClassName().equals(AudioplayerActivity.class.getName())) { - saveCurrentFragment(); - finish(); - startActivity(intent); - } - } - } - - @Override - protected void onReloadNotification(int notificationCode) { - if (notificationCode == PlaybackService.EXTRA_CODE_CAST) { - Log.d(TAG, "ReloadNotification received, switching to Castplayer now"); - saveCurrentFragment(); - finish(); - startActivity(new Intent(this, CastplayerActivity.class)); - - } else { - super.onReloadNotification(notificationCode); - } - } - - @Override - protected void updatePlaybackSpeedButton() { - if (butPlaybackSpeed == null) { - return; - } - if (controller == null) { - butPlaybackSpeed.setVisibility(View.GONE); - txtvPlaybackSpeed.setVisibility(View.GONE); - return; - } - updatePlaybackSpeedButtonText(); - butPlaybackSpeed.setAlpha(controller.canSetPlaybackSpeed() ? 1.0f : 0.5f); - butPlaybackSpeed.setVisibility(View.VISIBLE); - txtvPlaybackSpeed.setVisibility(View.VISIBLE); - } - - @Override - protected void updatePlaybackSpeedButtonText() { - if (butPlaybackSpeed == null) { - return; - } - if (controller == null) { - butPlaybackSpeed.setVisibility(View.GONE); - txtvPlaybackSpeed.setVisibility(View.GONE); - return; - } - float speed = 1.0f; - if (controller.canSetPlaybackSpeed()) { - speed = PlaybackSpeedUtils.getCurrentPlaybackSpeed(controller.getMedia()); - } - String speedStr = new DecimalFormat("0.00").format(speed); - txtvPlaybackSpeed.setText(speedStr); - butPlaybackSpeed.setSpeed(speed); - } - - @Override - protected void setupGUI() { - if (isSetup.getAndSet(true)) { - return; - } - super.setupGUI(); - if (butPlaybackSpeed != null) { - butPlaybackSpeed.setOnClickListener(v -> { - if (controller == null) { - return; - } - if (controller.canSetPlaybackSpeed()) { - float[] availableSpeeds = UserPreferences.getPlaybackSpeedArray(); - float currentSpeed = controller.getCurrentPlaybackSpeedMultiplier(); - - int newSpeedIndex = 0; - while (newSpeedIndex < availableSpeeds.length - && availableSpeeds[newSpeedIndex] < currentSpeed + EPSILON) { - newSpeedIndex++; - } - - float newSpeed; - if (availableSpeeds.length == 0) { - newSpeed = 1.0f; - } else if (newSpeedIndex == availableSpeeds.length) { - newSpeed = availableSpeeds[0]; - } else { - newSpeed = availableSpeeds[newSpeedIndex]; - } - - PlaybackPreferences.setCurrentlyPlayingTemporaryPlaybackSpeed(newSpeed); - UserPreferences.setPlaybackSpeed(newSpeed); - controller.setPlaybackSpeed(newSpeed); - onPositionObserverUpdate(); - } else { - VariableSpeedDialog.showGetPluginDialog(this); - } - }); - butPlaybackSpeed.setOnLongClickListener(v -> { - VariableSpeedDialog.showDialog(this); - return true; - }); - butPlaybackSpeed.setVisibility(View.VISIBLE); - txtvPlaybackSpeed.setVisibility(View.VISIBLE); - } - } -} diff --git a/app/src/main/java/de/danoeh/antennapod/activity/CastplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/CastplayerActivity.java index bbab235c8..bf4e64881 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/CastplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/CastplayerActivity.java @@ -2,13 +2,11 @@ package de.danoeh.antennapod.activity; import android.content.Intent; import android.os.Bundle; -import android.util.Log; import android.view.View; +import de.danoeh.antennapod.core.service.playback.PlaybackService; import java.util.concurrent.atomic.AtomicBoolean; -import de.danoeh.antennapod.core.service.playback.PlaybackService; - /** * Activity for controlling the remote playback on a Cast device. */ @@ -30,20 +28,8 @@ public class CastplayerActivity extends MediaplayerInfoActivity { } @Override - protected void onReloadNotification(int notificationCode) { - if (notificationCode == PlaybackService.EXTRA_CODE_AUDIO) { - Log.d(TAG, "ReloadNotification received, switching to Audioplayer now"); - saveCurrentFragment(); - finish(); - startActivity(new Intent(this, AudioplayerActivity.class)); - } else { - super.onReloadNotification(notificationCode); - } - } - - @Override protected void setupGUI() { - if(isSetup.getAndSet(true)) { + if (isSetup.getAndSet(true)) { return; } super.setupGUI(); diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java index 115114504..ed3ae7637 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java @@ -63,6 +63,7 @@ public class MainActivity extends CastEnabledActivity { public static final String EXTRA_FRAGMENT_TAG = "fragment_tag"; public static final String EXTRA_FRAGMENT_ARGS = "fragment_args"; public static final String EXTRA_FEED_ID = "fragment_feed_id"; + public static final String EXTRA_OPEN_PLAYER = "open_player"; private static final String SAVE_BACKSTACK_COUNT = "backstackCount"; @@ -403,9 +404,11 @@ public class MainActivity extends CastEnabledActivity { } else if (feedId > 0) { loadFeedFragmentById(feedId, args); } - // to avoid handling the intent twice when the configuration changes - setIntent(new Intent(MainActivity.this, MainActivity.class)); + } else if (intent.hasExtra(EXTRA_OPEN_PLAYER)) { + sheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); } + // to avoid handling the intent twice when the configuration changes + setIntent(new Intent(MainActivity.this, MainActivity.class)); } @Override diff --git a/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java index b8a30f994..a9b07b629 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java @@ -278,12 +278,7 @@ public class VideoplayerActivity extends MediaplayerActivity { } return; } - if (notificationCode == PlaybackService.EXTRA_CODE_AUDIO) { - Log.d(TAG, "ReloadNotification received, switching to Audioplayer now"); - destroyingDueToReload = true; - finish(); - startActivity(new Intent(this, AudioplayerActivity.class)); - } else if (notificationCode == PlaybackService.EXTRA_CODE_CAST) { + if (notificationCode == PlaybackService.EXTRA_CODE_CAST) { Log.d(TAG, "ReloadNotification received, switching to Castplayer now"); destroyingDueToReload = true; finish(); diff --git a/app/src/main/java/de/danoeh/antennapod/config/PlaybackServiceCallbacksImpl.java b/app/src/main/java/de/danoeh/antennapod/config/PlaybackServiceCallbacksImpl.java index c3f5d898c..98b5f4b2b 100644 --- a/app/src/main/java/de/danoeh/antennapod/config/PlaybackServiceCallbacksImpl.java +++ b/app/src/main/java/de/danoeh/antennapod/config/PlaybackServiceCallbacksImpl.java @@ -4,8 +4,8 @@ import android.content.Context; import android.content.Intent; import android.os.Build; import de.danoeh.antennapod.R; -import de.danoeh.antennapod.activity.AudioplayerActivity; import de.danoeh.antennapod.activity.CastplayerActivity; +import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.activity.VideoplayerActivity; import de.danoeh.antennapod.core.PlaybackServiceCallbacks; import de.danoeh.antennapod.core.feed.MediaType; @@ -24,7 +24,7 @@ public class PlaybackServiceCallbacksImpl implements PlaybackServiceCallbacks { } return i; } else { - return new Intent(context, AudioplayerActivity.class); + return new Intent(context, MainActivity.class).putExtra(MainActivity.EXTRA_OPEN_PLAYER, true); } } |