Added more changes to support SP
|
@ -1,55 +1,49 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="de.danoeh.antennapod.core">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
|
||||
<application android:allowBackup="true"
|
||||
android:label="@string/app_name"
|
||||
android:icon="@drawable/ic_launcher">
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name">
|
||||
|
||||
<service
|
||||
android:name=".service.download.DownloadService"
|
||||
android:enabled="true"/>
|
||||
android:enabled="true" />
|
||||
<service
|
||||
android:name=".service.playback.PlaybackService"
|
||||
android:enabled="true"
|
||||
android:exported="true">
|
||||
</service>
|
||||
android:exported="true"/>
|
||||
<service
|
||||
android:name=".service.GpodnetSyncService"
|
||||
android:enabled="true">
|
||||
</service>
|
||||
android:enabled="true"/>
|
||||
|
||||
<receiver
|
||||
android:name=".receiver.MediaButtonReceiver"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MEDIA_BUTTON"/>
|
||||
<action android:name="android.intent.action.MEDIA_BUTTON" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="de.danoeh.antennapod.NOTIFY_BUTTON_RECEIVER"/>
|
||||
<action android:name="de.danoeh.antennapod.NOTIFY_BUTTON_RECEIVER" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver android:name=".receiver.ConnectivityActionReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver android:name=".receiver.AlarmUpdateReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.PACKAGE_REPLACED"/>
|
||||
<action android:name="android.intent.action.PACKAGE_REPLACED" />
|
||||
<data
|
||||
android:path="de.danoeh.antennapod"
|
||||
android:scheme="package"/>
|
||||
android:scheme="package" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
|
|
|
@ -19,4 +19,6 @@ public interface ApplicationCallbacks {
|
|||
* activity.
|
||||
*/
|
||||
public Intent getStorageErrorActivity(Context context);
|
||||
|
||||
public void setUpateInterval(long upateInterval);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,11 @@ public interface PlaybackServiceCallbacks {
|
|||
* Returns true if the PlaybackService should load new episodes from the queue when playback ends
|
||||
* and false if the PlaybackService should ignore the queue and load no more episodes when playback
|
||||
* finishes.
|
||||
* */
|
||||
*/
|
||||
public boolean useQueue();
|
||||
|
||||
/**
|
||||
* Returns a drawable resource that is used for the notification of the playback service.
|
||||
*/
|
||||
public int getNotificationIconResource(Context context);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.List;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import de.danoeh.antennapod.core.BuildConfig;
|
||||
import de.danoeh.antennapod.core.ClientConfig;
|
||||
import de.danoeh.antennapod.core.R;
|
||||
import de.danoeh.antennapod.core.receiver.FeedUpdateReceiver;
|
||||
|
||||
|
@ -329,7 +330,7 @@ public class UserPreferences implements
|
|||
} else if (key.equals(PREF_UPDATE_INTERVAL)) {
|
||||
updateInterval = readUpdateInterval(sp.getString(
|
||||
PREF_UPDATE_INTERVAL, "0"));
|
||||
restartUpdateAlarm(updateInterval);
|
||||
ClientConfig.applicationCallbacks.setUpateInterval(updateInterval);
|
||||
|
||||
} else if (key.equals(PREF_AUTO_DELETE)) {
|
||||
autoDelete = sp.getBoolean(PREF_AUTO_DELETE, false);
|
||||
|
@ -541,23 +542,19 @@ public class UserPreferences implements
|
|||
|
||||
/**
|
||||
* Updates alarm registered with the AlarmManager service or deactivates it.
|
||||
*
|
||||
* @param millis new value to register with AlarmManager. If millis is 0, the
|
||||
* alarm is deactivated.
|
||||
*/
|
||||
public static void restartUpdateAlarm(long millis) {
|
||||
public static void restartUpdateAlarm(long triggerAtMillis, long intervalMillis) {
|
||||
instanceAvailable();
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Restarting update alarm. New value: " + millis);
|
||||
Log.d(TAG, "Restarting update alarm.");
|
||||
AlarmManager alarmManager = (AlarmManager) instance.context
|
||||
.getSystemService(Context.ALARM_SERVICE);
|
||||
PendingIntent updateIntent = PendingIntent.getBroadcast(
|
||||
instance.context, 0, new Intent(
|
||||
FeedUpdateReceiver.ACTION_REFRESH_FEEDS), 0
|
||||
);
|
||||
FeedUpdateReceiver.ACTION_REFRESH_FEEDS), 0);
|
||||
alarmManager.cancel(updateIntent);
|
||||
if (millis != 0) {
|
||||
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, millis, millis,
|
||||
if (intervalMillis != 0) {
|
||||
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, triggerAtMillis, intervalMillis,
|
||||
updateIntent);
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Changed alarm to new interval");
|
||||
|
@ -567,6 +564,7 @@ public class UserPreferences implements
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads episode cache size as it is saved in the episode_cache_size_values array.
|
||||
*/
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.util.Log;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import de.danoeh.antennapod.core.BuildConfig;
|
||||
import de.danoeh.antennapod.core.ClientConfig;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
|
||||
/** Listens for events that make it necessary to reset the update alarm. */
|
||||
|
@ -26,7 +27,7 @@ public class AlarmUpdateReceiver extends BroadcastReceiver {
|
|||
Log.d(TAG, "Resetting update alarm after app upgrade");
|
||||
}
|
||||
|
||||
UserPreferences.restartUpdateAlarm(UserPreferences.getUpdateInterval());
|
||||
ClientConfig.applicationCallbacks.setUpateInterval(UserPreferences.getUpdateInterval());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -79,6 +79,7 @@ public class PlaybackService extends Service {
|
|||
public static final String EXTRA_PREPARE_IMMEDIATELY = "extra.de.danoeh.antennapod.core.service.prepareImmediately";
|
||||
|
||||
public static final String ACTION_PLAYER_STATUS_CHANGED = "action.de.danoeh.antennapod.core.service.playerStatusChanged";
|
||||
public static final String EXTRA_NEW_PLAYER_STATUS = "extra.de.danoeh.antennapod.service.playerStatusChanged.newStatus";
|
||||
private static final String AVRCP_ACTION_PLAYER_STATUS_CHANGED = "com.android.music.playstatechanged";
|
||||
private static final String AVRCP_ACTION_META_CHANGED = "com.android.music.metachanged";
|
||||
|
||||
|
@ -417,6 +418,9 @@ public class PlaybackService extends Service {
|
|||
|
||||
}
|
||||
|
||||
Intent statusUpdate = new Intent(ACTION_PLAYER_STATUS_CHANGED);
|
||||
statusUpdate.putExtra(EXTRA_NEW_PLAYER_STATUS, newInfo.playerStatus.ordinal());
|
||||
sendBroadcast(statusUpdate);
|
||||
sendBroadcast(new Intent(ACTION_PLAYER_STATUS_CHANGED));
|
||||
updateWidget();
|
||||
refreshRemoteControlClientState(newInfo);
|
||||
|
@ -694,8 +698,8 @@ public class PlaybackService extends Service {
|
|||
|
||||
}
|
||||
if (icon == null) {
|
||||
icon = BitmapFactory.decodeResource(getResources(),
|
||||
R.drawable.ic_stat_antenna);
|
||||
icon = BitmapFactory.decodeResource(getApplicationContext().getResources(),
|
||||
ClientConfig.playbackServiceCallbacks.getNotificationIconResource(getApplicationContext()));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -708,6 +712,8 @@ public class PlaybackService extends Service {
|
|||
return;
|
||||
}
|
||||
PlaybackServiceMediaPlayer.PSMPInfo newInfo = mediaPlayer.getPSMPInfo();
|
||||
final int smallIcon = ClientConfig.playbackServiceCallbacks.getNotificationIconResource(getApplicationContext());
|
||||
|
||||
if (!isCancelled() && info.playerStatus == PlayerStatus.PLAYING
|
||||
&& info.playable != null) {
|
||||
String contentText = info.playable.getFeedTitle();
|
||||
|
@ -730,7 +736,7 @@ public class PlaybackService extends Service {
|
|||
.setOngoing(true)
|
||||
.setContentIntent(pIntent)
|
||||
.setLargeIcon(icon)
|
||||
.setSmallIcon(R.drawable.ic_stat_antenna)
|
||||
.setSmallIcon(smallIcon)
|
||||
.addAction(android.R.drawable.ic_media_pause,
|
||||
getString(R.string.pause_label),
|
||||
pauseButtonPendingIntent);
|
||||
|
@ -741,7 +747,7 @@ public class PlaybackService extends Service {
|
|||
.setContentTitle(contentTitle)
|
||||
.setContentText(contentText).setOngoing(true)
|
||||
.setContentIntent(pIntent).setLargeIcon(icon)
|
||||
.setSmallIcon(R.drawable.ic_stat_antenna);
|
||||
.setSmallIcon(smallIcon);
|
||||
notification = notificationBuilder.getNotification();
|
||||
}
|
||||
if (newInfo.playerStatus == PlayerStatus.PLAYING) {
|
||||
|
|
|
@ -10,5 +10,15 @@ public enum PlayerStatus {
|
|||
PREPARED,
|
||||
SEEKING,
|
||||
INITIALIZING, // playback service is loading the Playable's metadata
|
||||
INITIALIZED // playback service was started, data source of media player was set.
|
||||
INITIALIZED; // playback service was started, data source of media player was set.
|
||||
|
||||
private static final PlayerStatus[] fromOrdinalLookup;
|
||||
|
||||
static {
|
||||
fromOrdinalLookup = PlayerStatus.values();
|
||||
}
|
||||
|
||||
public static PlayerStatus fromOrdinal(int o) {
|
||||
return fromOrdinalLookup[o];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -394,6 +394,12 @@ public abstract class PlaybackController {
|
|||
|
||||
public abstract void onPlaybackEnd();
|
||||
|
||||
public void repeatHandleStatus() {
|
||||
if (status != null && playbackService != null) {
|
||||
handleStatus();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is called whenever the PlaybackService changes it's status. This method
|
||||
* should be used to update the GUI or start/cancel background threads.
|
||||
|
|
Before Width: | Height: | Size: 678 B After Width: | Height: | Size: 678 B |
Before Width: | Height: | Size: 649 B After Width: | Height: | Size: 649 B |
Before Width: | Height: | Size: 307 B After Width: | Height: | Size: 307 B |
Before Width: | Height: | Size: 271 B After Width: | Height: | Size: 271 B |
Before Width: | Height: | Size: 414 B After Width: | Height: | Size: 414 B |
Before Width: | Height: | Size: 412 B After Width: | Height: | Size: 412 B |
Before Width: | Height: | Size: 1005 B After Width: | Height: | Size: 1005 B |
Before Width: | Height: | Size: 942 B After Width: | Height: | Size: 942 B |