diff options
author | H. Lehmann <ByteHamster@users.noreply.github.com> | 2018-12-23 15:25:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-23 15:25:59 +0100 |
commit | 580cc49b1b1f20668a3bc28a9a920e3b437dfe21 (patch) | |
tree | 7b43d0e80ee4f43c8223b35cc9ecf44d4fae96a3 /core/src/main/java/de | |
parent | 94a4b78449043583570d3b97b758985c78e9f4a6 (diff) | |
parent | 9a92e66ffdcb7648ad641fa4f17ffe11d4d72298 (diff) | |
download | AntennaPod-580cc49b1b1f20668a3bc28a9a920e3b437dfe21.zip |
Merge branch 'develop' into glide-48
Diffstat (limited to 'core/src/main/java/de')
4 files changed, 32 insertions, 19 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java index e6b5f9e1b..c44999c88 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java +++ b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java @@ -52,6 +52,8 @@ public class UserPreferences { public static final String PREF_COMPACT_NOTIFICATION_BUTTONS = "prefCompactNotificationButtons"; public static final String PREF_LOCKSCREEN_BACKGROUND = "prefLockscreenBackground"; private static final String PREF_SHOW_DOWNLOAD_REPORT = "prefShowDownloadReport"; + public static final String PREF_BACK_BUTTON_BEHAVIOR = "prefBackButtonBehavior"; + private static final String PREF_BACK_BUTTON_GO_TO_PAGE = "prefBackButtonGoToPage"; // Queue private static final String PREF_QUEUE_ADD_TO_FRONT = "prefQueueAddToFront"; @@ -809,4 +811,29 @@ public class UserPreferences { public enum VideoBackgroundBehavior { STOP, PICTURE_IN_PICTURE, CONTINUE_PLAYING } + + public enum BackButtonBehavior { + DEFAULT, OPEN_DRAWER, DOUBLE_TAP, SHOW_PROMPT, GO_TO_PAGE + } + + public static BackButtonBehavior getBackButtonBehavior() { + switch (prefs.getString(PREF_BACK_BUTTON_BEHAVIOR, "default")) { + case "default": return BackButtonBehavior.DEFAULT; + case "drawer": return BackButtonBehavior.OPEN_DRAWER; + case "doubletap": return BackButtonBehavior.DOUBLE_TAP; + case "prompt": return BackButtonBehavior.SHOW_PROMPT; + case "page": return BackButtonBehavior.GO_TO_PAGE; + default: return BackButtonBehavior.DEFAULT; + } + } + + public static String getBackButtonGoToPage() { + return prefs.getString(PREF_BACK_BUTTON_GO_TO_PAGE, "QueueFragment"); + } + + public static void setBackButtonGoToPage(String tag) { + prefs.edit() + .putString(PREF_BACK_BUTTON_GO_TO_PAGE, tag) + .apply(); + } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java index ffbe7e7d1..ae1e9de86 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java @@ -13,8 +13,6 @@ import android.os.Build; import android.os.Handler; import android.os.IBinder; import android.support.annotation.NonNull; -import android.support.annotation.VisibleForTesting; -import android.support.annotation.Nullable; import android.support.v4.app.NotificationCompat; import android.text.TextUtils; import android.util.Log; @@ -66,7 +64,6 @@ import de.danoeh.antennapod.core.storage.DBTasks; import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.core.storage.DownloadRequestException; import de.danoeh.antennapod.core.storage.DownloadRequester; -import de.danoeh.antennapod.core.storage.PodDBAdapter; import de.danoeh.antennapod.core.syndication.handler.FeedHandler; import de.danoeh.antennapod.core.syndication.handler.FeedHandlerResult; import de.danoeh.antennapod.core.syndication.handler.UnsupportedFeedtypeException; @@ -251,7 +248,6 @@ public class DownloadService extends Service { public void onCreate() { Log.d(TAG, "Service started"); isRunning = true; - PodDBAdapter.getInstance().open(); // Prevent thrashing the database by opening and closing rapidly handler = new Handler(); reportQueue = Collections.synchronizedList(new ArrayList<>()); downloads = Collections.synchronizedList(new ArrayList<>()); @@ -331,7 +327,6 @@ public class DownloadService extends Service { // start auto download in case anything new has shown up DBTasks.autodownloadUndownloadedItems(getApplicationContext()); - PodDBAdapter.getInstance().close(); } private void setupNotificationBuilders() { diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java index f2be7fbb1..aea043a91 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java @@ -1097,7 +1097,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { } else { state = PlaybackStateCompat.STATE_NONE; } - sessionState.setState(state, mediaPlayer.getPosition(), mediaPlayer.getPlaybackSpeed()); + sessionState.setState(state, getCurrentPosition(), getCurrentPlaybackSpeed()); long capabilities = PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_REWIND | PlaybackStateCompat.ACTION_FAST_FORWARD @@ -1637,6 +1637,9 @@ public class PlaybackService extends MediaBrowserServiceCompat { } public float getCurrentPlaybackSpeed() { + if(mediaPlayer == null) { + return 1.0f; + } return mediaPlayer.getPlaybackSpeed(); } diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java index 8ebd8eeb5..4566df2fc 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java @@ -301,7 +301,6 @@ public class PodDBAdapter { private static Context context; private static volatile SQLiteDatabase db; - private static int counter = 0; public static void init(Context context) { PodDBAdapter.context = context.getApplicationContext(); @@ -321,9 +320,6 @@ public class PodDBAdapter { } public synchronized PodDBAdapter open() { - counter++; - Log.v(TAG, "Opening DB #" + counter); - if (db == null || !db.isOpen() || db.isReadOnly()) { db = openDb(); } @@ -334,7 +330,6 @@ public class PodDBAdapter { SQLiteDatabase newDb; try { newDb = SingletonHolder.dbHelper.getWritableDatabase(); - newDb.enableWriteAheadLogging(); } catch (SQLException ex) { Log.e(TAG, Log.getStackTraceString(ex)); newDb = SingletonHolder.dbHelper.getReadableDatabase(); @@ -343,14 +338,7 @@ public class PodDBAdapter { } public synchronized void close() { - counter--; - Log.v(TAG, "Closing DB #" + counter); - - if (counter == 0) { - Log.v(TAG, "Closing DB, really"); - db.close(); - db = null; - } + // do nothing } public static boolean deleteDatabase() { |