Removed AudioPlayerActivity
This commit is contained in:
parent
9e84a06260
commit
0a7d054aad
|
@ -73,23 +73,6 @@
|
|||
android:label="@string/app_name">
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".activity.AudioplayerActivity"
|
||||
android:launchMode="singleTop">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="de.danoeh.antennapod.activity.MainActivity"/>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
|
||||
<data android:scheme="file"/>
|
||||
<data android:mimeType="audio/*"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".activity.CastplayerActivity"
|
||||
android:launchMode="singleTop">
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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.
|
||||
*/
|
||||
|
@ -29,18 +27,6 @@ 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)) {
|
||||
|
|
|
@ -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,10 +404,12 @@ public class MainActivity extends CastEnabledActivity {
|
|||
} else if (feedId > 0) {
|
||||
loadFeedFragmentById(feedId, args);
|
||||
}
|
||||
} 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
|
||||
protected void onNewIntent(Intent intent) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue