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 | |
parent | 94a4b78449043583570d3b97b758985c78e9f4a6 (diff) | |
parent | 9a92e66ffdcb7648ad641fa4f17ffe11d4d72298 (diff) | |
download | AntennaPod-580cc49b1b1f20668a3bc28a9a920e3b437dfe21.zip |
Merge branch 'develop' into glide-48
Diffstat (limited to 'core')
11 files changed, 96 insertions, 40 deletions
diff --git a/core/build.gradle b/core/build.gradle index 0a6d4c36b..80adefa60 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -10,7 +10,7 @@ android { versionCode 1 versionName "1.0" testApplicationId "de.danoeh.antennapod.core.tests" - testInstrumentationRunner "de.danoeh.antennapod.core.AntennaPodTestRunner" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { @@ -83,6 +83,9 @@ dependencies { } testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + androidTestImplementation 'com.android.support.test:runner:1.0.2' + androidTestImplementation 'com.android.support.test:rules:1.0.2' } diff --git a/core/src/androidTest/java/de/danoeh/antennapod/core/AntennaPodTestRunner.java b/core/src/androidTest/java/de/danoeh/antennapod/core/AntennaPodTestRunner.java deleted file mode 100644 index 5d086c054..000000000 --- a/core/src/androidTest/java/de/danoeh/antennapod/core/AntennaPodTestRunner.java +++ /dev/null @@ -1,16 +0,0 @@ -package de.danoeh.antennapod.core; - -import android.test.InstrumentationTestRunner; -import android.test.suitebuilder.TestSuiteBuilder; - -import junit.framework.TestSuite; - -public class AntennaPodTestRunner extends InstrumentationTestRunner { - - @Override - public TestSuite getAllTests() { - return new TestSuiteBuilder(AntennaPodTestRunner.class) - .includeAllPackagesUnderHere() - .build(); - } -}
\ No newline at end of file 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() { diff --git a/core/src/main/res/drawable/overlay_drawable_dark_trueblack.xml b/core/src/main/res/drawable/overlay_drawable_dark_trueblack.xml new file mode 100644 index 000000000..5f58e8421 --- /dev/null +++ b/core/src/main/res/drawable/overlay_drawable_dark_trueblack.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > + + <item> + <shape android:shape="rectangle" > + <solid android:color="#45B3E1" /> + </shape> + </item> + <item android:top="1dp"> + <shape android:shape="rectangle" > + <solid android:color="@color/black" /> + </shape> + </item> + +</layer-list>
\ No newline at end of file diff --git a/core/src/main/res/values/arrays.xml b/core/src/main/res/values/arrays.xml index 7e2fed054..12961504c 100644 --- a/core/src/main/res/values/arrays.xml +++ b/core/src/main/res/values/arrays.xml @@ -277,4 +277,32 @@ <item>@string/select_all_above</item> <item>@string/select_all_below</item> </string-array> + + <string-array name="back_button_behavior_options"> + <item>@string/back_button_default</item> + <item>@string/back_button_go_to_page</item> + <item>@string/back_button_open_drawer</item> + <item>@string/back_button_double_tap</item> + <item>@string/back_button_show_prompt</item> + </string-array> + + <string-array name="back_button_behavior_values"> + <item>default</item> + <item>page</item> + <item>drawer</item> + <item>doubletap</item> + <item>prompt</item> + </string-array> + + <string-array name="back_button_go_to_pages"> + <item>@string/queue_label</item> + <item>@string/episodes_label</item> + <item>@string/subscriptions_label</item> + </string-array> + + <string-array name="back_button_go_to_pages_tags"> + <item>QueueFragment</item> + <item>EpisodesFragment</item> + <item>SubscriptionFragment</item> + </string-array> </resources> diff --git a/core/src/main/res/values/colors.xml b/core/src/main/res/values/colors.xml index 37ad81639..f172b0f6d 100644 --- a/core/src/main/res/values/colors.xml +++ b/core/src/main/res/values/colors.xml @@ -31,7 +31,7 @@ <color name="highlight_light">#DDDDDD</color> <color name="highlight_dark">#414141</color> - <color name="highlight_trueblack">#000000</color> + <color name="highlight_trueblack">#414141</color> <color name="antennapod_blue">#147BAF</color> diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index ad91ecc76..9dd928311 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -470,6 +470,17 @@ <string name="pref_videoBehavior_sum">Behavior when leaving video playback</string> <string name="stop_playback">Stop playback</string> <string name="continue_playback">Continue audio playback</string> + <string name="behavior">Behavior</string> + <string name="pref_back_button_behavior_title">Back Button Behavior</string> + <string name="pref_back_button_behavior_sum">Change behavior of the back button.</string> + <string name="back_button_default">Default</string> + <string name="back_button_open_drawer">Open navigation drawer</string> + <string name="back_button_double_tap">Double tap to exit</string> + <string name="back_button_show_prompt">Confirm to exit</string> + <string name="close_prompt">Are you sure you want to close AntennaPod?</string> + <string name="double_tap_toast">Tap back button again to exit</string> + <string name="back_button_go_to_page">Go to pageā¦</string> + <string name="back_button_go_to_page_title">Select page</string> <!-- Auto-Flattr dialog --> <string name="auto_flattr_enable">Enable automatic flattring</string> diff --git a/core/src/main/res/values/styles.xml b/core/src/main/res/values/styles.xml index 353050066..60296c64f 100644 --- a/core/src/main/res/values/styles.xml +++ b/core/src/main/res/values/styles.xml @@ -168,13 +168,14 @@ <style name="Theme.Base.AntennaPod.TrueBlack" parent="Theme.Base.AntennaPod.Dark"> <item name="progressBarTheme">@style/ProgressBarTrueBlack</item> <item type="attr" name="non_transparent_background">@color/black</item> - <item type="attr" name="overlay_background">@color/overlay_dark</item> - <item type="attr" name="overlay_drawable">@drawable/overlay_drawable_dark</item> + <item type="attr" name="overlay_background">@color/black</item> + <item type="attr" name="overlay_drawable">@drawable/overlay_drawable_dark_trueblack</item> <item type="attr" name="dragview_background">@drawable/ic_drag_vertical_white_48dp</item> <item type="attr" name="dragview_float_background">@color/black</item> <item type="attr" name="nav_drawer_background">@color/black</item> <item name="android:textColorPrimary">@color/white</item> <item name="android:color">@color/white</item> + <item name="android:colorBackground">@color/black</item> <item name="android:windowBackground">@color/black</item> <item name="android:actionBarStyle">@color/black</item> <item name="colorPrimary">@color/black</item> @@ -350,13 +351,14 @@ <item name="progressBarTheme">@style/ProgressBarTrueBlack</item> <item type="attr" name="non_transparent_background">@color/black</item> <item type="attr" name="overlay_background">@color/black</item> - <item type="attr" name="overlay_drawable">@drawable/overlay_drawable_dark</item> + <item type="attr" name="overlay_drawable">@drawable/overlay_drawable_dark_trueblack</item> <item type="attr" name="dragview_background">@drawable/ic_drag_vertical_white_48dp</item> <item type="attr" name="dragview_float_background">@color/black</item> <item type="attr" name="nav_drawer_background">@color/black</item> <item type="attr" name="currently_playing_background">@color/highlight_trueblack</item> <item name="android:textColorPrimary">@color/white</item> <item name="android:color">@color/white</item> + <item name="android:colorBackground">@color/black</item> <item name="android:windowBackground">@color/black</item> <item name="android:actionBarStyle">@color/black</item> <item name="colorPrimary">@color/black</item> |