commit
2a1dabf602
@ -182,6 +182,7 @@ dependencies {
|
||||
androidTestImplementation "androidx.test.espresso:espresso-intents:$espressoVersion"
|
||||
androidTestImplementation "androidx.test:runner:$runnerVersion"
|
||||
androidTestImplementation "androidx.test:rules:$rulesVersion"
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||
}
|
||||
|
||||
if (project.hasProperty("antennaPodPlayPublisherCredentials")) {
|
||||
|
@ -5,7 +5,7 @@ import android.content.Intent;
|
||||
import androidx.annotation.IdRes;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.espresso.PerformException;
|
||||
import androidx.test.espresso.UiController;
|
||||
import androidx.test.espresso.ViewAction;
|
||||
@ -116,38 +116,39 @@ public class EspressoTestUtils {
|
||||
* Clear all app databases
|
||||
*/
|
||||
public static void clearPreferences() {
|
||||
File root = InstrumentationRegistry.getTargetContext().getFilesDir().getParentFile();
|
||||
File root = InstrumentationRegistry.getInstrumentation().getTargetContext().getFilesDir().getParentFile();
|
||||
String[] sharedPreferencesFileNames = new File(root, "shared_prefs").list();
|
||||
for (String fileName : sharedPreferencesFileNames) {
|
||||
System.out.println("Cleared database: " + fileName);
|
||||
InstrumentationRegistry.getTargetContext().getSharedPreferences(
|
||||
InstrumentationRegistry.getInstrumentation().getTargetContext().getSharedPreferences(
|
||||
fileName.replace(".xml", ""), Context.MODE_PRIVATE).edit().clear().commit();
|
||||
}
|
||||
|
||||
InstrumentationRegistry.getTargetContext().getSharedPreferences(MainActivity.PREF_NAME, Context.MODE_PRIVATE)
|
||||
InstrumentationRegistry.getInstrumentation().getTargetContext()
|
||||
.getSharedPreferences(MainActivity.PREF_NAME, Context.MODE_PRIVATE)
|
||||
.edit()
|
||||
.putBoolean(MainActivity.PREF_IS_FIRST_LAUNCH, false)
|
||||
.commit();
|
||||
|
||||
PreferenceManager.getDefaultSharedPreferences(InstrumentationRegistry.getTargetContext())
|
||||
PreferenceManager.getDefaultSharedPreferences(InstrumentationRegistry.getInstrumentation().getTargetContext())
|
||||
.edit()
|
||||
.putString(UserPreferences.PREF_UPDATE_INTERVAL, "0")
|
||||
.commit();
|
||||
|
||||
RatingDialog.init(InstrumentationRegistry.getTargetContext());
|
||||
RatingDialog.init(InstrumentationRegistry.getInstrumentation().getTargetContext());
|
||||
RatingDialog.saveRated();
|
||||
}
|
||||
|
||||
public static void setLastNavFragment(String tag) {
|
||||
InstrumentationRegistry.getTargetContext().getSharedPreferences(
|
||||
NavDrawerFragment.PREF_NAME, Context.MODE_PRIVATE)
|
||||
InstrumentationRegistry.getInstrumentation().getTargetContext()
|
||||
.getSharedPreferences(NavDrawerFragment.PREF_NAME, Context.MODE_PRIVATE)
|
||||
.edit()
|
||||
.putString(NavDrawerFragment.PREF_LAST_FRAGMENT_TAG, tag)
|
||||
.commit();
|
||||
}
|
||||
|
||||
public static void clearDatabase() {
|
||||
PodDBAdapter.init(InstrumentationRegistry.getTargetContext());
|
||||
PodDBAdapter.init(InstrumentationRegistry.getInstrumentation().getTargetContext());
|
||||
PodDBAdapter.deleteDatabase();
|
||||
PodDBAdapter adapter = PodDBAdapter.getInstance();
|
||||
adapter.open();
|
||||
@ -172,7 +173,7 @@ public class EspressoTestUtils {
|
||||
}
|
||||
|
||||
public static void tryKillPlaybackService() {
|
||||
Context context = InstrumentationRegistry.getTargetContext();
|
||||
Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
context.stopService(new Intent(context, PlaybackService.class));
|
||||
try {
|
||||
// Android has no reliable way to stop a service instantly.
|
||||
@ -183,11 +184,11 @@ public class EspressoTestUtils {
|
||||
} catch (ConditionTimeoutException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
androidx.test.platform.app.InstrumentationRegistry.getInstrumentation().waitForIdleSync();
|
||||
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
|
||||
}
|
||||
|
||||
public static void tryKillDownloadService() {
|
||||
Context context = InstrumentationRegistry.getTargetContext();
|
||||
Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
context.stopService(new Intent(context, DownloadService.class));
|
||||
try {
|
||||
// Android has no reliable way to stop a service instantly.
|
||||
@ -198,7 +199,7 @@ public class EspressoTestUtils {
|
||||
} catch (ConditionTimeoutException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
androidx.test.platform.app.InstrumentationRegistry.getInstrumentation().waitForIdleSync();
|
||||
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
|
||||
}
|
||||
|
||||
public static Matcher<View> actionBarOverflow() {
|
||||
|
@ -15,7 +15,7 @@ import java.util.List;
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
|
@ -4,7 +4,7 @@ import android.annotation.SuppressLint;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.filters.LargeTest;
|
||||
import androidx.test.filters.SmallTest;
|
||||
import de.danoeh.antennapod.core.feed.MediaType;
|
||||
@ -36,7 +36,7 @@ public class ExternalMediaTest {
|
||||
}
|
||||
|
||||
private SharedPreferences getDefaultSharedPrefs() {
|
||||
return PreferenceManager.getDefaultSharedPreferences(InstrumentationRegistry.getTargetContext());
|
||||
return PreferenceManager.getDefaultSharedPreferences(InstrumentationRegistry.getInstrumentation().getTargetContext());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -6,6 +6,7 @@ import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@SmallTest
|
||||
@ -17,8 +18,8 @@ public class FeedFilterTest {
|
||||
FeedItem item = new FeedItem();
|
||||
item.setTitle("Hello world");
|
||||
|
||||
assertTrue(!filter.excludeOnly());
|
||||
assertTrue(!filter.includeOnly());
|
||||
assertFalse(filter.excludeOnly());
|
||||
assertFalse(filter.includeOnly());
|
||||
assertEquals("", filter.getExcludeFilter());
|
||||
assertEquals("", filter.getIncludeFilter());
|
||||
assertTrue(filter.shouldAutoDownload(item));
|
||||
@ -34,12 +35,12 @@ public class FeedFilterTest {
|
||||
FeedItem item2 = new FeedItem();
|
||||
item2.setTitle("Don't include me");
|
||||
|
||||
assertTrue(!filter.excludeOnly());
|
||||
assertFalse(filter.excludeOnly());
|
||||
assertTrue(filter.includeOnly());
|
||||
assertEquals("", filter.getExcludeFilter());
|
||||
assertEquals(includeFilter, filter.getIncludeFilter());
|
||||
assertTrue(filter.shouldAutoDownload(item));
|
||||
assertTrue(!filter.shouldAutoDownload(item2));
|
||||
assertFalse(filter.shouldAutoDownload(item2));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -53,10 +54,10 @@ public class FeedFilterTest {
|
||||
item2.setTitle("Item2");
|
||||
|
||||
assertTrue(filter.excludeOnly());
|
||||
assertTrue(!filter.includeOnly());
|
||||
assertFalse(filter.includeOnly());
|
||||
assertEquals(excludeFilter, filter.getExcludeFilter());
|
||||
assertEquals("", filter.getIncludeFilter());
|
||||
assertTrue(!filter.shouldAutoDownload(item));
|
||||
assertFalse(filter.shouldAutoDownload(item));
|
||||
assertTrue(filter.shouldAutoDownload(item2));
|
||||
}
|
||||
|
||||
@ -73,12 +74,12 @@ public class FeedFilterTest {
|
||||
FeedItem item3 = new FeedItem();
|
||||
item3.setTitle("One two words");
|
||||
|
||||
assertTrue(!filter.excludeOnly());
|
||||
assertFalse(filter.excludeOnly());
|
||||
assertTrue(filter.includeOnly());
|
||||
assertEquals("", filter.getExcludeFilter());
|
||||
assertEquals(includeFilter, filter.getIncludeFilter());
|
||||
assertTrue(filter.shouldAutoDownload(item));
|
||||
assertTrue(!filter.shouldAutoDownload(item2));
|
||||
assertFalse(filter.shouldAutoDownload(item2));
|
||||
assertTrue(filter.shouldAutoDownload(item3));
|
||||
}
|
||||
|
||||
@ -96,12 +97,12 @@ public class FeedFilterTest {
|
||||
item3.setTitle("One two words");
|
||||
|
||||
assertTrue(filter.excludeOnly());
|
||||
assertTrue(!filter.includeOnly());
|
||||
assertFalse(filter.includeOnly());
|
||||
assertEquals(excludeFilter, filter.getExcludeFilter());
|
||||
assertEquals("", filter.getIncludeFilter());
|
||||
assertTrue(!filter.shouldAutoDownload(item));
|
||||
assertFalse(filter.shouldAutoDownload(item));
|
||||
assertTrue(filter.shouldAutoDownload(item2));
|
||||
assertTrue(!filter.shouldAutoDownload(item3));
|
||||
assertFalse(filter.shouldAutoDownload(item3));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -122,8 +123,8 @@ public class FeedFilterTest {
|
||||
assertTrue(filter.hasExcludeFilter());
|
||||
assertTrue(filter.hasIncludeFilter());
|
||||
assertTrue(filter.shouldAutoDownload(download));
|
||||
assertTrue(!filter.shouldAutoDownload(doNotDownload));
|
||||
assertTrue(!filter.shouldAutoDownload(doNotDownload2));
|
||||
assertFalse(filter.shouldAutoDownload(doNotDownload));
|
||||
assertFalse(filter.shouldAutoDownload(doNotDownload2));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.core.sync.gpoddernet.GpodnetService;
|
||||
import de.danoeh.antennapod.core.sync.gpoddernet.GpodnetServiceException;
|
||||
|
@ -5,8 +5,8 @@ import android.content.Intent;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.util.Consumer;
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import de.test.antennapod.EspressoTestUtils;
|
||||
import org.awaitility.Awaitility;
|
||||
@ -81,7 +81,7 @@ public class DownloadServiceTest {
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
DownloadService.setDownloaderFactory(origFactory);
|
||||
Context context = InstrumentationRegistry.getTargetContext();
|
||||
Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
DownloadRequester.getInstance().cancelAllDownloads(context);
|
||||
context.stopService(new Intent(context, DownloadService.class));
|
||||
EspressoTestUtils.tryKillDownloadService();
|
||||
@ -106,9 +106,7 @@ public class DownloadServiceTest {
|
||||
// OPEN: Ideally, I'd like the download time long enough so that multiple in-progress DownloadEvents
|
||||
// are generated (to simulate typical download), but it'll make download time quite long (1-2 seconds)
|
||||
// to do so
|
||||
DownloadService.setDownloaderFactory(new StubDownloaderFactory(50, downloadStatus -> {
|
||||
downloadStatus.setSuccessful();
|
||||
}));
|
||||
DownloadService.setDownloaderFactory(new StubDownloaderFactory(50, DownloadStatus::setSuccessful));
|
||||
|
||||
UserPreferences.setEnqueueDownloadedEpisodes(enqueueDownloaded);
|
||||
withFeedItemEventListener(feedItemEventListener -> {
|
||||
@ -117,7 +115,8 @@ public class DownloadServiceTest {
|
||||
assertFalse("The media in test should not yet been downloaded",
|
||||
DBReader.getFeedMedia(testMedia11.getId()).isDownloaded());
|
||||
|
||||
DownloadRequester.getInstance().downloadMedia(false, InstrumentationRegistry.getTargetContext(), true, testMedia11.getItem());
|
||||
DownloadRequester.getInstance().downloadMedia(false, InstrumentationRegistry
|
||||
.getInstrumentation().getTargetContext(), true, testMedia11.getItem());
|
||||
Awaitility.await()
|
||||
.atMost(5000, TimeUnit.MILLISECONDS)
|
||||
.until(() -> feedItemEventListener.getEvents().size() >= numEventsExpected);
|
||||
@ -144,11 +143,10 @@ public class DownloadServiceTest {
|
||||
}
|
||||
|
||||
private void doTestCancelDownload_UndoEnqueue(boolean itemAlreadyInQueue) throws Exception {
|
||||
Context context = InstrumentationRegistry.getTargetContext();
|
||||
Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
// let download take longer to ensure the test can cancel the download in time
|
||||
DownloadService.setDownloaderFactory(new StubDownloaderFactory(30000, downloadStatus -> {
|
||||
downloadStatus.setSuccessful();
|
||||
}));
|
||||
DownloadService.setDownloaderFactory(
|
||||
new StubDownloaderFactory(30000, DownloadStatus::setSuccessful));
|
||||
UserPreferences.setEnqueueDownloadedEpisodes(true);
|
||||
UserPreferences.setEnableAutodownload(false);
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package de.test.antennapod.service.download;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.filters.LargeTest;
|
||||
import android.util.Log;
|
||||
|
||||
@ -51,7 +51,7 @@ public class HttpDownloaderTest {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
UserPreferences.init(InstrumentationRegistry.getInstrumentation().getTargetContext());
|
||||
destDir = InstrumentationRegistry.getTargetContext().getExternalFilesDir(DOWNLOAD_DIR);
|
||||
destDir = InstrumentationRegistry.getInstrumentation().getTargetContext().getExternalFilesDir(DOWNLOAD_DIR);
|
||||
assertNotNull(destDir);
|
||||
assertTrue(destDir.exists());
|
||||
httpServer = new HTTPBin();
|
||||
@ -82,7 +82,7 @@ public class HttpDownloaderTest {
|
||||
downloader.call();
|
||||
DownloadStatus status = downloader.getResult();
|
||||
assertNotNull(status);
|
||||
assertTrue(status.isSuccessful() == expectedResult);
|
||||
assertEquals(expectedResult, status.isSuccessful());
|
||||
assertTrue(status.isDone());
|
||||
// the file should not exist if the download has failed and deleteExisting was true
|
||||
assertTrue(!deleteExisting || new File(feedFile.getFile_url()).exists() == expectedResult);
|
||||
|
@ -38,6 +38,7 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
@ -173,7 +174,7 @@ public class PlaybackServiceMediaPlayerTest {
|
||||
throw assertionError;
|
||||
assertTrue(res);
|
||||
|
||||
assertTrue(psmp.getPSMPInfo().playerStatus == PlayerStatus.INITIALIZED);
|
||||
assertSame(PlayerStatus.INITIALIZED, psmp.getPSMPInfo().playerStatus);
|
||||
assertFalse(psmp.isStartWhenPrepared());
|
||||
callback.cancel();
|
||||
psmp.shutdown();
|
||||
@ -214,7 +215,7 @@ public class PlaybackServiceMediaPlayerTest {
|
||||
throw assertionError;
|
||||
assertTrue(res);
|
||||
|
||||
assertTrue(psmp.getPSMPInfo().playerStatus == PlayerStatus.INITIALIZED);
|
||||
assertSame(PlayerStatus.INITIALIZED, psmp.getPSMPInfo().playerStatus);
|
||||
assertTrue(psmp.isStartWhenPrepared());
|
||||
callback.cancel();
|
||||
psmp.shutdown();
|
||||
@ -256,7 +257,7 @@ public class PlaybackServiceMediaPlayerTest {
|
||||
if (assertionError != null)
|
||||
throw assertionError;
|
||||
assertTrue(res);
|
||||
assertTrue(psmp.getPSMPInfo().playerStatus == PlayerStatus.PREPARED);
|
||||
assertSame(PlayerStatus.PREPARED, psmp.getPSMPInfo().playerStatus);
|
||||
callback.cancel();
|
||||
|
||||
psmp.shutdown();
|
||||
@ -301,7 +302,7 @@ public class PlaybackServiceMediaPlayerTest {
|
||||
if (assertionError != null)
|
||||
throw assertionError;
|
||||
assertTrue(res);
|
||||
assertTrue(psmp.getPSMPInfo().playerStatus == PlayerStatus.PLAYING);
|
||||
assertSame(PlayerStatus.PLAYING, psmp.getPSMPInfo().playerStatus);
|
||||
callback.cancel();
|
||||
psmp.shutdown();
|
||||
}
|
||||
@ -339,7 +340,7 @@ public class PlaybackServiceMediaPlayerTest {
|
||||
if (assertionError != null)
|
||||
throw assertionError;
|
||||
assertTrue(res);
|
||||
assertTrue(psmp.getPSMPInfo().playerStatus == PlayerStatus.INITIALIZED);
|
||||
assertSame(PlayerStatus.INITIALIZED, psmp.getPSMPInfo().playerStatus);
|
||||
assertFalse(psmp.isStartWhenPrepared());
|
||||
callback.cancel();
|
||||
psmp.shutdown();
|
||||
@ -378,7 +379,7 @@ public class PlaybackServiceMediaPlayerTest {
|
||||
if (assertionError != null)
|
||||
throw assertionError;
|
||||
assertTrue(res);
|
||||
assertTrue(psmp.getPSMPInfo().playerStatus == PlayerStatus.INITIALIZED);
|
||||
assertSame(PlayerStatus.INITIALIZED, psmp.getPSMPInfo().playerStatus);
|
||||
assertTrue(psmp.isStartWhenPrepared());
|
||||
callback.cancel();
|
||||
psmp.shutdown();
|
||||
@ -420,7 +421,7 @@ public class PlaybackServiceMediaPlayerTest {
|
||||
if (assertionError != null)
|
||||
throw assertionError;
|
||||
assertTrue(res);
|
||||
assertTrue(psmp.getPSMPInfo().playerStatus == PlayerStatus.PREPARED);
|
||||
assertSame(PlayerStatus.PREPARED, psmp.getPSMPInfo().playerStatus);
|
||||
callback.cancel();
|
||||
psmp.shutdown();
|
||||
}
|
||||
@ -465,7 +466,7 @@ public class PlaybackServiceMediaPlayerTest {
|
||||
if (assertionError != null)
|
||||
throw assertionError;
|
||||
assertTrue(res);
|
||||
assertTrue(psmp.getPSMPInfo().playerStatus == PlayerStatus.PLAYING);
|
||||
assertSame(PlayerStatus.PLAYING, psmp.getPSMPInfo().playerStatus);
|
||||
callback.cancel();
|
||||
psmp.shutdown();
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package de.test.antennapod.service.playback;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.annotation.UiThreadTest;
|
||||
import androidx.test.filters.LargeTest;
|
||||
|
||||
@ -29,6 +29,7 @@ import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
import de.danoeh.antennapod.core.util.playback.Playable;
|
||||
|
||||
import static de.test.antennapod.util.event.FeedItemEventListener.withFeedItemEventListener;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@ -92,9 +93,9 @@ public class PlaybackServiceTaskManagerTest {
|
||||
PlaybackServiceTaskManager pstm = new PlaybackServiceTaskManager(c, defaultPSTM);
|
||||
List<FeedItem> testQueue = pstm.getQueue();
|
||||
assertNotNull(testQueue);
|
||||
assertTrue(queue.size() == testQueue.size());
|
||||
assertEquals(testQueue.size(), queue.size());
|
||||
for (int i = 0; i < queue.size(); i++) {
|
||||
assertTrue(queue.get(i).getId() == testQueue.get(i).getId());
|
||||
assertEquals(testQueue.get(i).getId(), queue.get(i).getId());
|
||||
}
|
||||
pstm.shutdown();
|
||||
}
|
||||
@ -114,9 +115,9 @@ public class PlaybackServiceTaskManagerTest {
|
||||
assertNotNull(queue);
|
||||
testQueue = pstm.getQueue();
|
||||
assertNotNull(testQueue);
|
||||
assertTrue(queue.size() == testQueue.size());
|
||||
assertEquals(testQueue.size(), queue.size());
|
||||
for (int i = 0; i < queue.size(); i++) {
|
||||
assertTrue(queue.get(i).getId() == testQueue.get(i).getId());
|
||||
assertEquals(testQueue.get(i).getId(), queue.get(i).getId());
|
||||
}
|
||||
pstm.shutdown();
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.filters.LargeTest;
|
||||
import androidx.test.filters.SmallTest;
|
||||
import de.danoeh.antennapod.core.feed.Feed;
|
||||
@ -64,7 +64,7 @@ public class DBCleanupTests {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
context = InstrumentationRegistry.getTargetContext();
|
||||
context = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
destFolder = new File(context.getCacheDir(), "DDCleanupTests");
|
||||
destFolder.mkdir();
|
||||
cleanupDestFolder(destFolder);
|
||||
|
@ -10,7 +10,7 @@ import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.filters.LargeTest;
|
||||
import androidx.test.filters.SmallTest;
|
||||
import de.danoeh.antennapod.core.feed.Feed;
|
||||
@ -55,7 +55,7 @@ public class DBNullCleanupAlgorithmTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
context = InstrumentationRegistry.getTargetContext();
|
||||
context = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
destFolder = context.getExternalCacheDir();
|
||||
cleanupDestFolder(destFolder);
|
||||
assertNotNull(destFolder);
|
||||
|
@ -5,7 +5,7 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.filters.SmallTest;
|
||||
import de.danoeh.antennapod.core.feed.Feed;
|
||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
@ -38,7 +38,7 @@ public class DBReaderTest {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// create new database
|
||||
PodDBAdapter.init(InstrumentationRegistry.getTargetContext());
|
||||
PodDBAdapter.init(InstrumentationRegistry.getInstrumentation().getTargetContext());
|
||||
PodDBAdapter.deleteDatabase();
|
||||
PodDBAdapter adapter = PodDBAdapter.getInstance();
|
||||
adapter.open();
|
||||
@ -52,7 +52,7 @@ public class DBReaderTest {
|
||||
assertNotNull(savedFeeds);
|
||||
assertEquals(feeds.size(), savedFeeds.size());
|
||||
for (int i = 0; i < feeds.size(); i++) {
|
||||
assertTrue(savedFeeds.get(i).getId() == feeds.get(i).getId());
|
||||
assertEquals(feeds.get(i).getId(), savedFeeds.get(i).getId());
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ public class DBReaderTest {
|
||||
List<Feed> feeds = saveFeedlist(10, 0, false);
|
||||
List<String> urls = DBReader.getFeedListDownloadUrls();
|
||||
assertNotNull(urls);
|
||||
assertTrue(urls.size() == feeds.size());
|
||||
assertEquals(feeds.size(), urls.size());
|
||||
for (int i = 0; i < urls.size(); i++) {
|
||||
assertEquals(urls.get(i), feeds.get(i).getDownload_url());
|
||||
}
|
||||
@ -115,8 +115,8 @@ public class DBReaderTest {
|
||||
for (int j = 0; j < numItems; j++) {
|
||||
FeedItem item = feeds.get(i).getItems().get(j);
|
||||
assertNotNull(item.getFeed());
|
||||
assertTrue(item.getFeed().getId() == feeds.get(i).getId());
|
||||
assertTrue(item.getFeedId() == item.getFeed().getId());
|
||||
assertEquals(feeds.get(i).getId(), item.getFeed().getId());
|
||||
assertEquals(item.getFeed().getId(), item.getFeedId());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -130,9 +130,9 @@ public class DBReaderTest {
|
||||
feed.setItems(null);
|
||||
List<FeedItem> savedItems = DBReader.getFeedItemList(feed);
|
||||
assertNotNull(savedItems);
|
||||
assertTrue(savedItems.size() == items.size());
|
||||
assertEquals(items.size(), savedItems.size());
|
||||
for (int i = 0; i < savedItems.size(); i++) {
|
||||
assertTrue(items.get(i).getId() == savedItems.get(i).getId());
|
||||
assertEquals(savedItems.get(i).getId(), items.get(i).getId());
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,10 +167,10 @@ public class DBReaderTest {
|
||||
List<FeedItem> queue = saveQueue(numItems);
|
||||
LongList ids = DBReader.getQueueIDList();
|
||||
assertNotNull(ids);
|
||||
assertTrue(queue.size() == ids.size());
|
||||
assertEquals(ids.size(), queue.size());
|
||||
for (int i = 0; i < queue.size(); i++) {
|
||||
assertTrue(ids.get(i) != 0);
|
||||
assertTrue(queue.get(i).getId() == ids.get(i));
|
||||
assertEquals(ids.get(i), queue.get(i).getId());
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,10 +180,10 @@ public class DBReaderTest {
|
||||
List<FeedItem> queue = saveQueue(numItems);
|
||||
List<FeedItem> savedQueue = DBReader.getQueue();
|
||||
assertNotNull(savedQueue);
|
||||
assertTrue(queue.size() == savedQueue.size());
|
||||
assertEquals(savedQueue.size(), queue.size());
|
||||
for (int i = 0; i < queue.size(); i++) {
|
||||
assertTrue(savedQueue.get(i).getId() != 0);
|
||||
assertTrue(queue.get(i).getId() == savedQueue.get(i).getId());
|
||||
assertEquals(savedQueue.get(i).getId(), queue.get(i).getId());
|
||||
}
|
||||
}
|
||||
|
||||
@ -221,7 +221,7 @@ public class DBReaderTest {
|
||||
List<FeedItem> downloaded = saveDownloadedItems(numItems);
|
||||
List<FeedItem> downloaded_saved = DBReader.getDownloadedItems();
|
||||
assertNotNull(downloaded_saved);
|
||||
assertTrue(downloaded_saved.size() == downloaded.size());
|
||||
assertEquals(downloaded.size(), downloaded_saved.size());
|
||||
for (FeedItem item : downloaded_saved) {
|
||||
assertNotNull(item.getMedia());
|
||||
assertTrue(item.getMedia().isDownloaded());
|
||||
@ -264,7 +264,7 @@ public class DBReaderTest {
|
||||
}
|
||||
List<FeedItem> newItemsSaved = DBReader.getNewItemsList(0, Integer.MAX_VALUE);
|
||||
assertNotNull(newItemsSaved);
|
||||
assertTrue(newItems.size() == newItemsSaved.size());
|
||||
assertEquals(newItemsSaved.size(), newItems.size());
|
||||
for (FeedItem feedItem : newItemsSaved) {
|
||||
long savedId = feedItem.getId();
|
||||
boolean found = false;
|
||||
|
@ -2,7 +2,7 @@ package de.test.antennapod.storage;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import org.junit.After;
|
||||
@ -29,6 +29,8 @@ import static java.util.Collections.singletonList;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
@ -45,7 +47,7 @@ public class DBTasksTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
context = InstrumentationRegistry.getTargetContext();
|
||||
context = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
|
||||
// create new database
|
||||
PodDBAdapter.init(context);
|
||||
@ -68,7 +70,7 @@ public class DBTasksTest {
|
||||
}
|
||||
Feed newFeed = DBTasks.updateFeed(context, feed)[0];
|
||||
|
||||
assertTrue(newFeed == feed);
|
||||
assertSame(feed, newFeed);
|
||||
assertTrue(feed.getId() != 0);
|
||||
for (FeedItem item : feed.getItems()) {
|
||||
assertFalse(item.isPlayed());
|
||||
@ -123,13 +125,13 @@ public class DBTasksTest {
|
||||
}
|
||||
|
||||
final Feed newFeed = DBTasks.updateFeed(context, feed)[0];
|
||||
assertTrue(feed != newFeed);
|
||||
assertNotSame(newFeed, feed);
|
||||
|
||||
updatedFeedTest(newFeed, feedID, itemIDs, NUM_ITEMS_OLD, NUM_ITEMS_NEW);
|
||||
|
||||
final Feed feedFromDB = DBReader.getFeed(newFeed.getId());
|
||||
assertNotNull(feedFromDB);
|
||||
assertTrue(feedFromDB.getId() == newFeed.getId());
|
||||
assertEquals(newFeed.getId(), feedFromDB.getId());
|
||||
updatedFeedTest(feedFromDB, feedID, itemIDs, NUM_ITEMS_OLD, NUM_ITEMS_NEW);
|
||||
}
|
||||
|
||||
@ -155,7 +157,7 @@ public class DBTasksTest {
|
||||
feed.setItems(list);
|
||||
|
||||
final Feed newFeed = DBTasks.updateFeed(context, feed)[0];
|
||||
assertTrue(feed != newFeed);
|
||||
assertNotSame(newFeed, feed);
|
||||
|
||||
final Feed feedFromDB = DBReader.getFeed(newFeed.getId());
|
||||
final FeedItem feedItemFromDB = feedFromDB.getItems().get(0);
|
||||
@ -163,21 +165,21 @@ public class DBTasksTest {
|
||||
}
|
||||
|
||||
private void updatedFeedTest(final Feed newFeed, long feedID, List<Long> itemIDs, final int NUM_ITEMS_OLD, final int NUM_ITEMS_NEW) {
|
||||
assertTrue(newFeed.getId() == feedID);
|
||||
assertTrue(newFeed.getItems().size() == NUM_ITEMS_NEW + NUM_ITEMS_OLD);
|
||||
assertEquals(feedID, newFeed.getId());
|
||||
assertEquals(NUM_ITEMS_NEW + NUM_ITEMS_OLD, newFeed.getItems().size());
|
||||
Collections.reverse(newFeed.getItems());
|
||||
Date lastDate = new Date(0);
|
||||
for (int i = 0; i < NUM_ITEMS_OLD; i++) {
|
||||
FeedItem item = newFeed.getItems().get(i);
|
||||
assertTrue(item.getFeed() == newFeed);
|
||||
assertTrue(item.getId() == itemIDs.get(i));
|
||||
assertSame(newFeed, item.getFeed());
|
||||
assertEquals((long) itemIDs.get(i), item.getId());
|
||||
assertTrue(item.isPlayed());
|
||||
assertTrue(item.getPubDate().getTime() >= lastDate.getTime());
|
||||
lastDate = item.getPubDate();
|
||||
}
|
||||
for (int i = NUM_ITEMS_OLD; i < NUM_ITEMS_NEW + NUM_ITEMS_OLD; i++) {
|
||||
FeedItem item = newFeed.getItems().get(i);
|
||||
assertTrue(item.getFeed() == newFeed);
|
||||
assertSame(newFeed, item.getFeed());
|
||||
assertTrue(item.getId() != 0);
|
||||
assertFalse(item.isPlayed());
|
||||
assertTrue(item.getPubDate().getTime() >= lastDate.getTime());
|
||||
|
@ -7,7 +7,7 @@ import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.core.util.Consumer;
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.filters.MediumTest;
|
||||
|
||||
import org.awaitility.Awaitility;
|
||||
@ -35,9 +35,9 @@ import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
import de.danoeh.antennapod.core.util.FeedItemUtil;
|
||||
|
||||
import static androidx.test.InstrumentationRegistry.getInstrumentation;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@ -56,7 +56,7 @@ public class DBWriterTest {
|
||||
public void tearDown() throws Exception {
|
||||
assertTrue(PodDBAdapter.deleteDatabase());
|
||||
|
||||
final Context context = InstrumentationRegistry.getTargetContext();
|
||||
final Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
File testDir = context.getExternalFilesDir(TEST_FOLDER);
|
||||
assertNotNull(testDir);
|
||||
for (File f : testDir.listFiles()) {
|
||||
@ -67,13 +67,13 @@ public class DBWriterTest {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// create new database
|
||||
PodDBAdapter.init(InstrumentationRegistry.getTargetContext());
|
||||
PodDBAdapter.init(InstrumentationRegistry.getInstrumentation().getTargetContext());
|
||||
PodDBAdapter.deleteDatabase();
|
||||
PodDBAdapter adapter = PodDBAdapter.getInstance();
|
||||
adapter.open();
|
||||
adapter.close();
|
||||
|
||||
Context context = InstrumentationRegistry.getTargetContext();
|
||||
Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
SharedPreferences.Editor prefEdit = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()).edit();
|
||||
prefEdit.putBoolean(UserPreferences.PREF_DELETE_REMOVES_FROM_QUEUE, true).commit();
|
||||
|
||||
@ -116,7 +116,8 @@ public class DBWriterTest {
|
||||
@Test
|
||||
public void testDeleteFeedMediaOfItemFileExists()
|
||||
throws IOException, ExecutionException, InterruptedException, TimeoutException {
|
||||
File dest = new File(getInstrumentation().getTargetContext().getExternalFilesDir(TEST_FOLDER), "testFile");
|
||||
File dest = new File(InstrumentationRegistry
|
||||
.getInstrumentation().getTargetContext().getExternalFilesDir(TEST_FOLDER), "testFile");
|
||||
|
||||
assertTrue(dest.createNewFile());
|
||||
|
||||
@ -137,7 +138,7 @@ public class DBWriterTest {
|
||||
assertTrue(media.getId() != 0);
|
||||
assertTrue(item.getId() != 0);
|
||||
|
||||
DBWriter.deleteFeedMediaOfItem(getInstrumentation().getTargetContext(), media.getId())
|
||||
DBWriter.deleteFeedMediaOfItem(InstrumentationRegistry.getInstrumentation().getTargetContext(), media.getId())
|
||||
.get(TIMEOUT, TimeUnit.SECONDS);
|
||||
media = DBReader.getFeedMedia(media.getId());
|
||||
assertNotNull(media);
|
||||
@ -151,7 +152,8 @@ public class DBWriterTest {
|
||||
throws IOException, ExecutionException, InterruptedException, TimeoutException {
|
||||
assertTrue(UserPreferences.shouldDeleteRemoveFromQueue());
|
||||
|
||||
File dest = new File(getInstrumentation().getTargetContext().getExternalFilesDir(TEST_FOLDER), "testFile");
|
||||
File dest = new File(InstrumentationRegistry
|
||||
.getInstrumentation().getTargetContext().getExternalFilesDir(TEST_FOLDER), "testFile");
|
||||
|
||||
assertTrue(dest.createNewFile());
|
||||
|
||||
@ -177,7 +179,7 @@ public class DBWriterTest {
|
||||
queue = DBReader.getQueue();
|
||||
assertTrue(queue.size() != 0);
|
||||
|
||||
DBWriter.deleteFeedMediaOfItem(getInstrumentation().getTargetContext(), media.getId());
|
||||
DBWriter.deleteFeedMediaOfItem(InstrumentationRegistry.getInstrumentation().getTargetContext(), media.getId());
|
||||
Awaitility.await().until(() -> !dest.exists());
|
||||
media = DBReader.getFeedMedia(media.getId());
|
||||
assertNotNull(media);
|
||||
@ -185,12 +187,12 @@ public class DBWriterTest {
|
||||
assertFalse(media.isDownloaded());
|
||||
assertNull(media.getFile_url());
|
||||
queue = DBReader.getQueue();
|
||||
assertTrue(queue.size() == 0);
|
||||
assertEquals(0, queue.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteFeed() throws ExecutionException, InterruptedException, IOException, TimeoutException {
|
||||
File destFolder = getInstrumentation().getTargetContext().getExternalFilesDir(TEST_FOLDER);
|
||||
File destFolder = InstrumentationRegistry.getInstrumentation().getTargetContext().getExternalFilesDir(TEST_FOLDER);
|
||||
assertNotNull(destFolder);
|
||||
|
||||
Feed feed = new Feed("url", null, "title");
|
||||
@ -221,7 +223,8 @@ public class DBWriterTest {
|
||||
assertTrue(item.getMedia().getId() != 0);
|
||||
}
|
||||
|
||||
DBWriter.deleteFeed(getInstrumentation().getTargetContext(), feed.getId()).get(TIMEOUT, TimeUnit.SECONDS);
|
||||
DBWriter.deleteFeed(InstrumentationRegistry
|
||||
.getInstrumentation().getTargetContext(), feed.getId()).get(TIMEOUT, TimeUnit.SECONDS);
|
||||
|
||||
// check if files still exist
|
||||
for (File f : itemFiles) {
|
||||
@ -231,14 +234,14 @@ public class DBWriterTest {
|
||||
adapter = PodDBAdapter.getInstance();
|
||||
adapter.open();
|
||||
Cursor c = adapter.getFeedCursor(feed.getId());
|
||||
assertTrue(c.getCount() == 0);
|
||||
assertEquals(0, c.getCount());
|
||||
c.close();
|
||||
for (FeedItem item : feed.getItems()) {
|
||||
c = adapter.getFeedItemCursor(String.valueOf(item.getId()));
|
||||
assertTrue(c.getCount() == 0);
|
||||
assertEquals(0, c.getCount());
|
||||
c.close();
|
||||
c = adapter.getSingleFeedMediaCursor(item.getMedia().getId());
|
||||
assertTrue(c.getCount() == 0);
|
||||
assertEquals(0, c.getCount());
|
||||
c.close();
|
||||
}
|
||||
adapter.close();
|
||||
@ -246,7 +249,7 @@ public class DBWriterTest {
|
||||
|
||||
@Test
|
||||
public void testDeleteFeedNoItems() throws IOException, ExecutionException, InterruptedException, TimeoutException {
|
||||
File destFolder = getInstrumentation().getTargetContext().getExternalFilesDir(TEST_FOLDER);
|
||||
File destFolder = InstrumentationRegistry.getInstrumentation().getTargetContext().getExternalFilesDir(TEST_FOLDER);
|
||||
assertNotNull(destFolder);
|
||||
|
||||
Feed feed = new Feed("url", null, "title");
|
||||
@ -260,19 +263,20 @@ public class DBWriterTest {
|
||||
|
||||
assertTrue(feed.getId() != 0);
|
||||
|
||||
DBWriter.deleteFeed(getInstrumentation().getTargetContext(), feed.getId()).get(TIMEOUT, TimeUnit.SECONDS);
|
||||
DBWriter.deleteFeed(InstrumentationRegistry
|
||||
.getInstrumentation().getTargetContext(), feed.getId()).get(TIMEOUT, TimeUnit.SECONDS);
|
||||
|
||||
adapter = PodDBAdapter.getInstance();
|
||||
adapter.open();
|
||||
Cursor c = adapter.getFeedCursor(feed.getId());
|
||||
assertTrue(c.getCount() == 0);
|
||||
assertEquals(0, c.getCount());
|
||||
c.close();
|
||||
adapter.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteFeedNoFeedMedia() throws IOException, ExecutionException, InterruptedException, TimeoutException {
|
||||
File destFolder = getInstrumentation().getTargetContext().getExternalFilesDir(TEST_FOLDER);
|
||||
File destFolder = InstrumentationRegistry.getInstrumentation().getTargetContext().getExternalFilesDir(TEST_FOLDER);
|
||||
assertNotNull(destFolder);
|
||||
|
||||
Feed feed = new Feed("url", null, "title");
|
||||
@ -297,17 +301,18 @@ public class DBWriterTest {
|
||||
assertTrue(item.getId() != 0);
|
||||
}
|
||||
|
||||
DBWriter.deleteFeed(getInstrumentation().getTargetContext(), feed.getId()).get(TIMEOUT, TimeUnit.SECONDS);
|
||||
DBWriter.deleteFeed(InstrumentationRegistry
|
||||
.getInstrumentation().getTargetContext(), feed.getId()).get(TIMEOUT, TimeUnit.SECONDS);
|
||||
|
||||
|
||||
adapter = PodDBAdapter.getInstance();
|
||||
adapter.open();
|
||||
Cursor c = adapter.getFeedCursor(feed.getId());
|
||||
assertTrue(c.getCount() == 0);
|
||||
assertEquals(0, c.getCount());
|
||||
c.close();
|
||||
for (FeedItem item : feed.getItems()) {
|
||||
c = adapter.getFeedItemCursor(String.valueOf(item.getId()));
|
||||
assertTrue(c.getCount() == 0);
|
||||
assertEquals(0, c.getCount());
|
||||
c.close();
|
||||
}
|
||||
adapter.close();
|
||||
@ -315,7 +320,7 @@ public class DBWriterTest {
|
||||
|
||||
@Test
|
||||
public void testDeleteFeedWithQueueItems() throws ExecutionException, InterruptedException, TimeoutException {
|
||||
File destFolder = getInstrumentation().getTargetContext().getExternalFilesDir(TEST_FOLDER);
|
||||
File destFolder = InstrumentationRegistry.getInstrumentation().getTargetContext().getExternalFilesDir(TEST_FOLDER);
|
||||
assertNotNull(destFolder);
|
||||
|
||||
Feed feed = new Feed("url", null, "title");
|
||||
@ -344,39 +349,39 @@ public class DBWriterTest {
|
||||
}
|
||||
|
||||
|
||||
List<FeedItem> queue = new ArrayList<>();
|
||||
queue.addAll(feed.getItems());
|
||||
List<FeedItem> queue = new ArrayList<>(feed.getItems());
|
||||
adapter.open();
|
||||
adapter.setQueue(queue);
|
||||
|
||||
Cursor queueCursor = adapter.getQueueIDCursor();
|
||||
assertTrue(queueCursor.getCount() == queue.size());
|
||||
assertEquals(queue.size(), queueCursor.getCount());
|
||||
queueCursor.close();
|
||||
|
||||
adapter.close();
|
||||
DBWriter.deleteFeed(getInstrumentation().getTargetContext(), feed.getId()).get(TIMEOUT, TimeUnit.SECONDS);
|
||||
DBWriter.deleteFeed(InstrumentationRegistry
|
||||
.getInstrumentation().getTargetContext(), feed.getId()).get(TIMEOUT, TimeUnit.SECONDS);
|
||||
adapter.open();
|
||||
|
||||
Cursor c = adapter.getFeedCursor(feed.getId());
|
||||
assertTrue(c.getCount() == 0);
|
||||
assertEquals(0, c.getCount());
|
||||
c.close();
|
||||
for (FeedItem item : feed.getItems()) {
|
||||
c = adapter.getFeedItemCursor(String.valueOf(item.getId()));
|
||||
assertTrue(c.getCount() == 0);
|
||||
assertEquals(0, c.getCount());
|
||||
c.close();
|
||||
c = adapter.getSingleFeedMediaCursor(item.getMedia().getId());
|
||||
assertTrue(c.getCount() == 0);
|
||||
assertEquals(0, c.getCount());
|
||||
c.close();
|
||||
}
|
||||
c = adapter.getQueueCursor();
|
||||
assertTrue(c.getCount() == 0);
|
||||
assertEquals(0, c.getCount());
|
||||
c.close();
|
||||
adapter.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteFeedNoDownloadedFiles() throws ExecutionException, InterruptedException, TimeoutException {
|
||||
File destFolder = getInstrumentation().getTargetContext().getExternalFilesDir(TEST_FOLDER);
|
||||
File destFolder = InstrumentationRegistry.getInstrumentation().getTargetContext().getExternalFilesDir(TEST_FOLDER);
|
||||
assertNotNull(destFolder);
|
||||
|
||||
Feed feed = new Feed("url", null, "title");
|
||||
@ -404,19 +409,20 @@ public class DBWriterTest {
|
||||
assertTrue(item.getMedia().getId() != 0);
|
||||
}
|
||||
|
||||
DBWriter.deleteFeed(getInstrumentation().getTargetContext(), feed.getId()).get(TIMEOUT, TimeUnit.SECONDS);
|
||||
DBWriter.deleteFeed(InstrumentationRegistry
|
||||
.getInstrumentation().getTargetContext(), feed.getId()).get(TIMEOUT, TimeUnit.SECONDS);
|
||||
|
||||
adapter = PodDBAdapter.getInstance();
|
||||
adapter.open();
|
||||
Cursor c = adapter.getFeedCursor(feed.getId());
|
||||
assertTrue(c.getCount() == 0);
|
||||
assertEquals(0, c.getCount());
|
||||
c.close();
|
||||
for (FeedItem item : feed.getItems()) {
|
||||
c = adapter.getFeedItemCursor(String.valueOf(item.getId()));
|
||||
assertTrue(c.getCount() == 0);
|
||||
assertEquals(0, c.getCount());
|
||||
c.close();
|
||||
c = adapter.getSingleFeedMediaCursor(item.getMedia().getId());
|
||||
assertTrue(c.getCount() == 0);
|
||||
assertEquals(0, c.getCount());
|
||||
c.close();
|
||||
}
|
||||
adapter.close();
|
||||
@ -465,11 +471,11 @@ public class DBWriterTest {
|
||||
|
||||
assertNotNull(media);
|
||||
assertNotNull(media.getPlaybackCompletionDate());
|
||||
assertFalse(OLD_DATE == media.getPlaybackCompletionDate().getTime());
|
||||
assertNotEquals(media.getPlaybackCompletionDate().getTime(), OLD_DATE);
|
||||
}
|
||||
|
||||
private Feed queueTestSetupMultipleItems(final int numItems) throws InterruptedException, ExecutionException, TimeoutException {
|
||||
final Context context = getInstrumentation().getTargetContext();
|
||||
final Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
UserPreferences.setEnqueueLocation(UserPreferences.EnqueueLocation.BACK);
|
||||
Feed feed = new Feed("url", null, "title");
|
||||
feed.setItems(new ArrayList<>());
|
||||
@ -498,7 +504,7 @@ public class DBWriterTest {
|
||||
|
||||
@Test
|
||||
public void testAddQueueItemSingleItem() throws InterruptedException, ExecutionException, TimeoutException {
|
||||
final Context context = getInstrumentation().getTargetContext();
|
||||
final Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
Feed feed = new Feed("url", null, "title");
|
||||
feed.setItems(new ArrayList<>());
|
||||
FeedItem item = new FeedItem(0, "title", "id", "link", new Date(), FeedItem.PLAYED, feed);
|
||||
@ -516,14 +522,14 @@ public class DBWriterTest {
|
||||
adapter.open();
|
||||
Cursor cursor = adapter.getQueueIDCursor();
|
||||
assertTrue(cursor.moveToFirst());
|
||||
assertTrue(cursor.getLong(0) == item.getId());
|
||||
assertEquals(item.getId(), cursor.getLong(0));
|
||||
cursor.close();
|
||||
adapter.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddQueueItemSingleItemAlreadyInQueue() throws InterruptedException, ExecutionException, TimeoutException {
|
||||
final Context context = getInstrumentation().getTargetContext();
|
||||
final Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
Feed feed = new Feed("url", null, "title");
|
||||
feed.setItems(new ArrayList<>());
|
||||
FeedItem item = new FeedItem(0, "title", "id", "link", new Date(), FeedItem.PLAYED, feed);
|
||||
@ -541,7 +547,7 @@ public class DBWriterTest {
|
||||
adapter.open();
|
||||
Cursor cursor = adapter.getQueueIDCursor();
|
||||
assertTrue(cursor.moveToFirst());
|
||||
assertTrue(cursor.getLong(0) == item.getId());
|
||||
assertEquals(item.getId(), cursor.getLong(0));
|
||||
cursor.close();
|
||||
adapter.close();
|
||||
|
||||
@ -550,8 +556,8 @@ public class DBWriterTest {
|
||||
adapter.open();
|
||||
cursor = adapter.getQueueIDCursor();
|
||||
assertTrue(cursor.moveToFirst());
|
||||
assertTrue(cursor.getLong(0) == item.getId());
|
||||
assertTrue(cursor.getCount() == 1);
|
||||
assertEquals(item.getId(), cursor.getLong(0));
|
||||
assertEquals(1, cursor.getCount());
|
||||
cursor.close();
|
||||
adapter.close();
|
||||
}
|
||||
@ -565,7 +571,7 @@ public class DBWriterTest {
|
||||
adapter.open();
|
||||
Cursor cursor = adapter.getQueueIDCursor();
|
||||
assertTrue(cursor.moveToFirst());
|
||||
assertTrue(cursor.getCount() == NUM_ITEMS);
|
||||
assertEquals(NUM_ITEMS, cursor.getCount());
|
||||
List<Long> expectedIds = FeedItemUtil.getIdList(feed.getItems());
|
||||
List<Long> actualIds = new ArrayList<>();
|
||||
for (int i = 0; i < NUM_ITEMS; i++) {
|
||||
@ -595,7 +601,7 @@ public class DBWriterTest {
|
||||
@Test
|
||||
public void testRemoveQueueItem() throws InterruptedException, ExecutionException, TimeoutException {
|
||||
final int NUM_ITEMS = 10;
|
||||
final Context context = getInstrumentation().getTargetContext();
|
||||
final Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
Feed feed = createTestFeed(NUM_ITEMS);
|
||||
|
||||
for (int removeIndex = 0; removeIndex < NUM_ITEMS; removeIndex++) {
|
||||
@ -609,7 +615,7 @@ public class DBWriterTest {
|
||||
adapter = PodDBAdapter.getInstance();
|
||||
adapter.open();
|
||||
Cursor queue = adapter.getQueueIDCursor();
|
||||
assertTrue(queue.getCount() == NUM_ITEMS - 1);
|
||||
assertEquals(NUM_ITEMS - 1, queue.getCount());
|
||||
for (int i = 0; i < queue.getCount(); i++) {
|
||||
assertTrue(queue.moveToPosition(i));
|
||||
final long queueID = queue.getLong(0);
|
||||
@ -631,7 +637,7 @@ public class DBWriterTest {
|
||||
//
|
||||
final int NUM_ITEMS = 5;
|
||||
final int NUM_IN_QUEUE = NUM_ITEMS - 1; // the last one not in queue for boundary condition
|
||||
final Context context = getInstrumentation().getTargetContext();
|
||||
final Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
Feed feed = createTestFeed(NUM_ITEMS);
|
||||
|
||||
List<FeedItem> itemsToAdd = feed.getItems().subList(0, NUM_IN_QUEUE);
|
||||
@ -698,11 +704,11 @@ public class DBWriterTest {
|
||||
adapter = PodDBAdapter.getInstance();
|
||||
adapter.open();
|
||||
Cursor queue = adapter.getQueueIDCursor();
|
||||
assertTrue(queue.getCount() == NUM_ITEMS);
|
||||
assertEquals(NUM_ITEMS, queue.getCount());
|
||||
assertTrue(queue.moveToPosition(from));
|
||||
assertFalse(queue.getLong(0) == fromID);
|
||||
assertNotEquals(fromID, queue.getLong(0));
|
||||
assertTrue(queue.moveToPosition(to));
|
||||
assertTrue(queue.getLong(0) == fromID);
|
||||
assertEquals(fromID, queue.getLong(0));
|
||||
|
||||
queue.close();
|
||||
adapter.close();
|
||||
|
@ -3,7 +3,7 @@ package de.test.antennapod.ui;
|
||||
import android.content.Intent;
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.core.feed.Feed;
|
||||
|
@ -2,10 +2,10 @@ package de.test.antennapod.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.espresso.Espresso;
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import com.robotium.solo.Solo;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
@ -20,7 +20,6 @@ import org.junit.runner.RunWith;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static androidx.test.InstrumentationRegistry.getInstrumentation;
|
||||
import static androidx.test.espresso.Espresso.onView;
|
||||
import static androidx.test.espresso.action.ViewActions.click;
|
||||
import static androidx.test.espresso.action.ViewActions.replaceText;
|
||||
@ -55,10 +54,10 @@ public class MainActivityTest {
|
||||
|
||||
mActivityRule.launchActivity(new Intent());
|
||||
|
||||
uiTestUtils = new UITestUtils(InstrumentationRegistry.getTargetContext());
|
||||
uiTestUtils = new UITestUtils(InstrumentationRegistry.getInstrumentation().getTargetContext());
|
||||
uiTestUtils.setup();
|
||||
|
||||
solo = new Solo(getInstrumentation(), mActivityRule.getActivity());
|
||||
solo = new Solo(InstrumentationRegistry.getInstrumentation(), mActivityRule.getActivity());
|
||||
}
|
||||
|
||||
@After
|
||||
|
@ -1,10 +1,10 @@
|
||||
package de.test.antennapod.ui;
|
||||
|
||||
import android.content.Intent;
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.espresso.contrib.DrawerActions;
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.activity.PreferenceActivity;
|
||||
@ -59,7 +59,7 @@ public class NavigationDrawerTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws IOException {
|
||||
uiTestUtils = new UITestUtils(InstrumentationRegistry.getTargetContext());
|
||||
uiTestUtils = new UITestUtils(InstrumentationRegistry.getInstrumentation().getTargetContext());
|
||||
uiTestUtils.setup();
|
||||
|
||||
EspressoTestUtils.clearPreferences();
|
||||
|
@ -4,7 +4,7 @@ import android.content.Intent;
|
||||
import android.view.View;
|
||||
import androidx.test.espresso.Espresso;
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.fragment.QueueFragment;
|
||||
|
@ -5,7 +5,7 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import androidx.test.rule.ActivityTestRule;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
|
@ -3,7 +3,7 @@ package de.test.antennapod.ui;
|
||||
import android.content.Intent;
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.core.feed.Feed;
|
||||
|
@ -5,7 +5,7 @@ import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.filters.LargeTest;
|
||||
import androidx.test.filters.MediumTest;
|
||||
import de.danoeh.antennapod.core.feed.Feed;
|
||||
@ -29,7 +29,7 @@ public class UITestUtilsTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
uiTestUtils = new UITestUtils(InstrumentationRegistry.getTargetContext());
|
||||
uiTestUtils = new UITestUtils(InstrumentationRegistry.getInstrumentation().getTargetContext());
|
||||
uiTestUtils.setup();
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ package de.test.antennapod.util.playback;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.filters.SmallTest;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
@ -35,7 +35,7 @@ public class TimelineTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
context = InstrumentationRegistry.getTargetContext();
|
||||
context = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
}
|
||||
|
||||
private Playable newTestPlayable(List<Chapter> chapters, String shownotes, int duration) {
|
||||
|
@ -1,11 +1,12 @@
|
||||
package de.test.antennapod.util.syndication;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Map;
|
||||
|
||||
import de.danoeh.antennapod.core.util.syndication.FeedDiscoverer;
|
||||
@ -29,7 +30,8 @@ public class FeedDiscovererTest {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
fd = new FeedDiscoverer();
|
||||
testDir = new File(InstrumentationRegistry.getTargetContext().getFilesDir(), "FeedDiscovererTest");
|
||||
testDir = new File(InstrumentationRegistry
|
||||
.getInstrumentation().getTargetContext().getFilesDir(), "FeedDiscovererTest");
|
||||
testDir.mkdir();
|
||||
assertTrue(testDir.exists());
|
||||
}
|
||||
@ -67,7 +69,7 @@ public class FeedDiscovererTest {
|
||||
} else {
|
||||
File testFile = new File(testDir, "feed");
|
||||
FileOutputStream out = new FileOutputStream(testFile);
|
||||
IOUtils.write(html, out);
|
||||
IOUtils.write(html, out, Charset.forName("UTF-8"));
|
||||
out.close();
|
||||
res = fd.findLinks(testFile, base);
|
||||
}
|
||||
|
@ -42,9 +42,8 @@ public class BugReportActivity extends AppCompatActivity {
|
||||
}
|
||||
crashDetailsTextView.setText(crashDetailsText);
|
||||
|
||||
findViewById(R.id.btn_open_bug_tracker).setOnClickListener(v -> {
|
||||
IntentUtils.openInBrowser(BugReportActivity.this, "https://github.com/AntennaPod/AntennaPod/issues");
|
||||
});
|
||||
findViewById(R.id.btn_open_bug_tracker).setOnClickListener(v -> IntentUtils.openInBrowser(
|
||||
BugReportActivity.this, "https://github.com/AntennaPod/AntennaPod/issues"));
|
||||
|
||||
findViewById(R.id.btn_copy_log).setOnClickListener(v -> {
|
||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
|
@ -113,7 +113,7 @@ public class DirectoryChooserActivity extends AppCompatActivity {
|
||||
});
|
||||
|
||||
butNavUp.setOnClickListener(v -> {
|
||||
File parent = null;
|
||||
File parent;
|
||||
if (selectedDir != null
|
||||
&& (parent = selectedDir.getParentFile()) != null) {
|
||||
changeDirectory(parent);
|
||||
|
@ -305,7 +305,7 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
|
||||
return false;
|
||||
}
|
||||
Playable media = controller.getMedia();
|
||||
boolean isFeedMedia = media != null && (media instanceof FeedMedia);
|
||||
boolean isFeedMedia = (media instanceof FeedMedia);
|
||||
|
||||
menu.findItem(R.id.open_feed_item).setVisible(isFeedMedia); // FeedMedia implies it belongs to a Feed
|
||||
|
||||
|
@ -227,15 +227,14 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
Intent destIntent = new Intent(this, MainActivity.class);
|
||||
if (NavUtils.shouldUpRecreateTask(this, destIntent)) {
|
||||
startActivity(destIntent);
|
||||
} else {
|
||||
NavUtils.navigateUpFromSameTask(this);
|
||||
}
|
||||
return true;
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
Intent destIntent = new Intent(this, MainActivity.class);
|
||||
if (NavUtils.shouldUpRecreateTask(this, destIntent)) {
|
||||
startActivity(destIntent);
|
||||
} else {
|
||||
NavUtils.navigateUpFromSameTask(this);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
@ -609,9 +608,8 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
final List<String> titles = new ArrayList<>();
|
||||
final List<String> urls = new ArrayList<>();
|
||||
|
||||
urls.addAll(urlsMap.keySet());
|
||||
final List<String> urls = new ArrayList<>(urlsMap.keySet());
|
||||
for (String url : urls) {
|
||||
titles.add(urlsMap.get(url));
|
||||
}
|
||||
|
@ -88,10 +88,9 @@ public class GpodnetAuthenticationActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
return true;
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ public class NavListAdapter extends BaseAdapter
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
int viewType = getItemViewType(position);
|
||||
View v = null;
|
||||
View v;
|
||||
if (viewType == VIEW_TYPE_NAV) {
|
||||
v = getNavView((String) getItem(position), position, convertView, parent);
|
||||
} else if (viewType == VIEW_TYPE_SECTION_DIVIDER) {
|
||||
|
@ -37,7 +37,7 @@ public class QueueRecyclerAdapter extends EpisodeItemListAdapter {
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
protected void afterBindViewHolder(EpisodeItemViewHolder holder, int pos) {
|
||||
View.OnTouchListener startDragTouchListener = (v1, event) -> {
|
||||
if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) {
|
||||
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
|
||||
Log.d(TAG, "startDrag()");
|
||||
itemTouchHelper.startDrag(holder);
|
||||
}
|
||||
|
@ -413,7 +413,7 @@ public class EpisodesApplyActionFragment extends Fragment {
|
||||
boolean checked = checkedIds.contains(episode.getId());
|
||||
mListView.setItemChecked(i, checked);
|
||||
}
|
||||
ActivityCompat.invalidateOptionsMenu(EpisodesApplyActionFragment.this.getActivity());
|
||||
getActivity().invalidateOptionsMenu();
|
||||
toolbar.setTitle(getResources().getQuantityString(R.plurals.num_selected_label,
|
||||
checkedIds.size(), checkedIds.size()));
|
||||
}
|
||||
|
@ -70,7 +70,6 @@ public abstract class FilterDialog {
|
||||
}
|
||||
updateFilter(filterValues);
|
||||
});
|
||||
|
||||
builder.setNegativeButton(R.string.cancel_label, null);
|
||||
builder.create().show();
|
||||
}
|
||||
|
@ -227,12 +227,11 @@ public class ProxyDialog {
|
||||
if(required) {
|
||||
testSuccessful = false;
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setText(R.string.proxy_test_label);
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);
|
||||
} else {
|
||||
testSuccessful = true;
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setText(android.R.string.ok);
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);
|
||||
}
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);
|
||||
}
|
||||
|
||||
private void test() {
|
||||
|
@ -2,7 +2,6 @@ package de.danoeh.antennapod.dialog;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
@ -68,24 +67,17 @@ public class ShareDialog extends DialogFragment {
|
||||
|
||||
setupOptions();
|
||||
|
||||
builder.setPositiveButton(R.string.share_label, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
boolean includePlaybackPosition = checkBoxStartAt.isChecked();
|
||||
if (radioEpisodeWebsite.isChecked()) {
|
||||
ShareUtils.shareFeedItemLink(ctx, item, includePlaybackPosition);
|
||||
prefs.edit().putString(PREF_SHARE_DIALOG_OPTION, "website").apply();
|
||||
} else {
|
||||
ShareUtils.shareFeedItemDownloadLink(ctx, item, includePlaybackPosition);
|
||||
prefs.edit().putString(PREF_SHARE_DIALOG_OPTION, "media").apply();
|
||||
}
|
||||
prefs.edit().putBoolean(PREF_SHARE_EPISODE_START_AT, includePlaybackPosition).apply();
|
||||
builder.setPositiveButton(R.string.share_label, (dialog, id) -> {
|
||||
boolean includePlaybackPosition = checkBoxStartAt.isChecked();
|
||||
if (radioEpisodeWebsite.isChecked()) {
|
||||
ShareUtils.shareFeedItemLink(ctx, item, includePlaybackPosition);
|
||||
prefs.edit().putString(PREF_SHARE_DIALOG_OPTION, "website").apply();
|
||||
} else {
|
||||
ShareUtils.shareFeedItemDownloadLink(ctx, item, includePlaybackPosition);
|
||||
prefs.edit().putString(PREF_SHARE_DIALOG_OPTION, "media").apply();
|
||||
}
|
||||
}).setNegativeButton(R.string.cancel_label, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
prefs.edit().putBoolean(PREF_SHARE_EPISODE_START_AT, includePlaybackPosition).apply();
|
||||
}).setNegativeButton(R.string.cancel_label, (dialog, id) -> dialog.dismiss());
|
||||
|
||||
return builder.create();
|
||||
}
|
||||
|
@ -45,13 +45,11 @@ public class AllEpisodesFragment extends EpisodesListFragment {
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (!super.onOptionsItemSelected(item)) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.filter_items:
|
||||
showFilterDialog();
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
if (item.getItemId() == R.id.filter_items) {
|
||||
showFilterDialog();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
@ -491,11 +491,11 @@ public class AudioPlayerFragment extends Fragment implements
|
||||
switch (item.getItemId()) {
|
||||
case R.id.disable_sleeptimer_item: // Fall-through
|
||||
case R.id.set_sleeptimer_item:
|
||||
new SleepTimerDialog().show(getFragmentManager(), "SleepTimerDialog");
|
||||
new SleepTimerDialog().show(getChildFragmentManager(), "SleepTimerDialog");
|
||||
return true;
|
||||
case R.id.audio_controls:
|
||||
PlaybackControlsDialog dialog = PlaybackControlsDialog.newInstance(false);
|
||||
dialog.show(getFragmentManager(), "playback_controls");
|
||||
dialog.show(getChildFragmentManager(), "playback_controls");
|
||||
return true;
|
||||
case R.id.open_feed_item:
|
||||
if (feedItem != null) {
|
||||
|
@ -93,7 +93,7 @@ public class DownloadLogFragment extends ListFragment {
|
||||
private void onFragmentLoaded() {
|
||||
setListShown(true);
|
||||
adapter.notifyDataSetChanged();
|
||||
getActivity().supportInvalidateOptionsMenu();
|
||||
getActivity().invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -156,7 +156,7 @@ public class DownloadLogFragment extends ListFragment {
|
||||
}
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
MenuItem clearHistory = menu.add(Menu.NONE, R.id.clear_history_item, Menu.CATEGORY_CONTAINER, R.string.clear_history_label);
|
||||
MenuItemCompat.setShowAsAction(clearHistory, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
||||
clearHistory.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||
TypedArray drawables = getActivity().obtainStyledAttributes(new int[]{R.attr.ic_delete});
|
||||
clearHistory.setIcon(drawables.getDrawable(0));
|
||||
drawables.recycle();
|
||||
|
@ -405,7 +405,7 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
|
||||
|
||||
private void updateSyncProgressBarVisibility() {
|
||||
if (isUpdatingFeed != updateRefreshMenuItemChecker.isRefreshing()) {
|
||||
getActivity().supportInvalidateOptionsMenu();
|
||||
getActivity().invalidateOptionsMenu();
|
||||
}
|
||||
if (!DownloadRequester.getInstance().isDownloadingFeeds()) {
|
||||
nextPageLoader.getRoot().setVisibility(View.GONE);
|
||||
@ -427,7 +427,7 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
|
||||
progressBar.setVisibility(View.GONE);
|
||||
adapter.updateItems(feed.getItems());
|
||||
|
||||
getActivity().supportInvalidateOptionsMenu();
|
||||
getActivity().invalidateOptionsMenu();
|
||||
updateSyncProgressBarVisibility();
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ public class FeedSettingsFragment extends Fragment {
|
||||
Toolbar toolbar = root.findViewById(R.id.toolbar);
|
||||
((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
|
||||
|
||||
getFragmentManager().beginTransaction()
|
||||
getParentFragmentManager().beginTransaction()
|
||||
.replace(R.id.settings_fragment_container,
|
||||
FeedSettingsPreferenceFragment.newInstance(feedId), "settings_fragment")
|
||||
.commitAllowingStateLoss();
|
||||
|
@ -145,9 +145,7 @@ public class ItemFragment extends Fragment {
|
||||
}
|
||||
txtvDuration = layout.findViewById(R.id.txtvDuration);
|
||||
txtvPublished = layout.findViewById(R.id.txtvPublished);
|
||||
if (Build.VERSION.SDK_INT >= 14) { // ellipsize is causing problems on old versions, see #448
|
||||
txtvTitle.setEllipsize(TextUtils.TruncateAt.END);
|
||||
}
|
||||
txtvTitle.setEllipsize(TextUtils.TruncateAt.END);
|
||||
webvDescription = layout.findViewById(R.id.webvDescription);
|
||||
webvDescription.setTimecodeSelectedListener(time -> {
|
||||
if (controller != null && item.getMedia() != null && controller.getMedia() != null
|
||||
|
@ -140,13 +140,11 @@ public class ItemPagerFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem menuItem) {
|
||||
switch (menuItem.getItemId()) {
|
||||
case R.id.open_podcast:
|
||||
openPodcast();
|
||||
return true;
|
||||
default:
|
||||
return FeedItemMenuHandler.onMenuItemClicked(this, menuItem.getItemId(), item);
|
||||
if (menuItem.getItemId() == R.id.open_podcast) {
|
||||
openPodcast();
|
||||
return true;
|
||||
}
|
||||
return FeedItemMenuHandler.onMenuItemClicked(this, menuItem.getItemId(), item);
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
|
@ -85,9 +85,8 @@ public class NavDrawerFragment extends Fragment implements AdapterView.OnItemCli
|
||||
registerForContextMenu(navList);
|
||||
updateSelection();
|
||||
|
||||
root.findViewById(R.id.nav_settings).setOnClickListener(v -> {
|
||||
startActivity(new Intent(getActivity(), PreferenceActivity.class));
|
||||
});
|
||||
root.findViewById(R.id.nav_settings).setOnClickListener(v ->
|
||||
startActivity(new Intent(getActivity(), PreferenceActivity.class)));
|
||||
getContext().getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE)
|
||||
.registerOnSharedPreferenceChangeListener(this);
|
||||
return root;
|
||||
|
@ -126,7 +126,7 @@ public class OnlineSearchFragment extends Fragment {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
inflater.inflate(R.menu.online_search, menu);
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
final SearchView sv = (SearchView) MenuItemCompat.getActionView(searchItem);
|
||||
final SearchView sv = (SearchView) searchItem.getActionView();
|
||||
sv.setQueryHint(getString(R.string.search_podcast_hint));
|
||||
sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
|
@ -153,7 +153,7 @@ public class PlaybackHistoryFragment extends Fragment {
|
||||
}
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
MenuItem clearHistory = menu.add(Menu.NONE, R.id.clear_history_item, Menu.CATEGORY_CONTAINER, R.string.clear_history_label);
|
||||
MenuItemCompat.setShowAsAction(clearHistory, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
||||
clearHistory.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||
TypedArray drawables = getActivity().obtainStyledAttributes(new int[]{R.attr.ic_delete});
|
||||
clearHistory.setIcon(drawables.getDrawable(0));
|
||||
drawables.recycle();
|
||||
@ -171,13 +171,11 @@ public class PlaybackHistoryFragment extends Fragment {
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (!super.onOptionsItemSelected(item)) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.clear_history_item:
|
||||
DBWriter.clearPlaybackHistory();
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
if (item.getItemId() == R.id.clear_history_item) {
|
||||
DBWriter.clearPlaybackHistory();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
@ -196,18 +194,18 @@ public class PlaybackHistoryFragment extends Fragment {
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onHistoryUpdated(PlaybackHistoryEvent event) {
|
||||
loadItems();
|
||||
getActivity().supportInvalidateOptionsMenu();
|
||||
getActivity().invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onPlayerStatusChanged(PlayerStatusEvent event) {
|
||||
loadItems();
|
||||
getActivity().supportInvalidateOptionsMenu();
|
||||
getActivity().invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
private void onFragmentLoaded() {
|
||||
adapter.notifyDataSetChanged();
|
||||
getActivity().supportInvalidateOptionsMenu();
|
||||
getActivity().invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
private void loadItems() {
|
||||
|
@ -136,6 +136,7 @@ public class QueueFragment extends Fragment {
|
||||
recyclerAdapter.notifyItemInserted(event.position);
|
||||
break;
|
||||
case SET_QUEUE:
|
||||
case SORTED: //Deliberate fall-through
|
||||
queue = event.items;
|
||||
recyclerAdapter.notifyDataSetChanged();
|
||||
break;
|
||||
@ -149,10 +150,6 @@ public class QueueFragment extends Fragment {
|
||||
queue.clear();
|
||||
recyclerAdapter.notifyDataSetChanged();
|
||||
break;
|
||||
case SORTED:
|
||||
queue = event.items;
|
||||
recyclerAdapter.notifyDataSetChanged();
|
||||
break;
|
||||
case MOVED:
|
||||
return;
|
||||
}
|
||||
@ -216,7 +213,7 @@ public class QueueFragment extends Fragment {
|
||||
public void onPlayerStatusChanged(PlayerStatusEvent event) {
|
||||
loadItems(false);
|
||||
if (isUpdatingFeeds != updateRefreshMenuItemChecker.isRefreshing()) {
|
||||
getActivity().supportInvalidateOptionsMenu();
|
||||
getActivity().invalidateOptionsMenu();
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,7 +222,7 @@ public class QueueFragment extends Fragment {
|
||||
// Sent when playback position is reset
|
||||
loadItems(false);
|
||||
if (isUpdatingFeeds != updateRefreshMenuItemChecker.isRefreshing()) {
|
||||
getActivity().supportInvalidateOptionsMenu();
|
||||
getActivity().invalidateOptionsMenu();
|
||||
}
|
||||
}
|
||||
|
||||
@ -384,7 +381,7 @@ public class QueueFragment extends Fragment {
|
||||
|
||||
private void setQueueLocked(boolean locked) {
|
||||
UserPreferences.setQueueLocked(locked);
|
||||
getActivity().supportInvalidateOptionsMenu();
|
||||
getActivity().invalidateOptionsMenu();
|
||||
if (recyclerAdapter != null) {
|
||||
recyclerAdapter.setLocked(locked);
|
||||
}
|
||||
@ -572,7 +569,7 @@ public class QueueFragment extends Fragment {
|
||||
|
||||
// we need to refresh the options menu because it sometimes
|
||||
// needs data that may have just been loaded.
|
||||
getActivity().supportInvalidateOptionsMenu();
|
||||
getActivity().invalidateOptionsMenu();
|
||||
|
||||
refreshInfoBar();
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ public class SearchFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemActionCollapse(MenuItem item) {
|
||||
getFragmentManager().popBackStack();
|
||||
getParentFragmentManager().popBackStack();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
@ -56,9 +56,9 @@ public abstract class PodcastListFragment extends Fragment {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
inflater.inflate(R.menu.gpodder_podcasts, menu);
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
final SearchView sv = (SearchView) MenuItemCompat.getActionView(searchItem);
|
||||
final SearchView sv = (SearchView) searchItem.getActionView();
|
||||
sv.setQueryHint(getString(R.string.gpodnet_search_hint));
|
||||
sv.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String s) {
|
||||
sv.clearFocus();
|
||||
|
@ -48,7 +48,7 @@ public class SearchListFragment extends PodcastListFragment {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
// parent already inflated menu
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
final SearchView sv = (SearchView) MenuItemCompat.getActionView(searchItem);
|
||||
final SearchView sv = (SearchView) searchItem.getActionView();
|
||||
sv.setQueryHint(getString(R.string.gpodnet_search_hint));
|
||||
sv.setQuery(query, false);
|
||||
sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
|
@ -38,7 +38,7 @@ public class TagListFragment extends ListFragment {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
inflater.inflate(R.menu.gpodder_podcasts, menu);
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
final SearchView sv = (SearchView) MenuItemCompat.getActionView(searchItem);
|
||||
final SearchView sv = (SearchView) searchItem.getActionView();
|
||||
sv.setQueryHint(getString(R.string.gpodnet_search_hint));
|
||||
sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
|
@ -28,12 +28,12 @@ public class AboutFragment extends PreferenceFragmentCompat {
|
||||
return true;
|
||||
});
|
||||
findPreference("about_developers").setOnPreferenceClickListener((preference) -> {
|
||||
getFragmentManager().beginTransaction().replace(R.id.content, new AboutDevelopersFragment())
|
||||
getParentFragmentManager().beginTransaction().replace(R.id.content, new AboutDevelopersFragment())
|
||||
.addToBackStack(getString(R.string.developers)).commit();
|
||||
return true;
|
||||
});
|
||||
findPreference("about_translators").setOnPreferenceClickListener((preference) -> {
|
||||
getFragmentManager().beginTransaction().replace(R.id.content, new AboutTranslatorsFragment())
|
||||
getParentFragmentManager().beginTransaction().replace(R.id.content, new AboutTranslatorsFragment())
|
||||
.addToBackStack(getString(R.string.translators)).commit();
|
||||
return true;
|
||||
});
|
||||
@ -42,7 +42,7 @@ public class AboutFragment extends PreferenceFragmentCompat {
|
||||
return true;
|
||||
});
|
||||
findPreference("about_licenses").setOnPreferenceClickListener((preference) -> {
|
||||
getFragmentManager().beginTransaction().replace(R.id.content, new AboutLicensesFragment())
|
||||
getParentFragmentManager().beginTransaction().replace(R.id.content, new AboutLicensesFragment())
|
||||
.addToBackStack(getString(R.string.translators)).commit();
|
||||
return true;
|
||||
});
|
||||
|
@ -62,14 +62,14 @@ public class MainPreferencesFragment extends PreferenceFragmentCompat {
|
||||
|
||||
findPreference(PREF_ABOUT).setOnPreferenceClickListener(
|
||||
preference -> {
|
||||
getFragmentManager().beginTransaction().replace(R.id.content, new AboutFragment())
|
||||
getParentFragmentManager().beginTransaction().replace(R.id.content, new AboutFragment())
|
||||
.addToBackStack(getString(R.string.about_pref)).commit();
|
||||
return true;
|
||||
}
|
||||
);
|
||||
findPreference(STATISTICS).setOnPreferenceClickListener(
|
||||
preference -> {
|
||||
getFragmentManager().beginTransaction().replace(R.id.content, new StatisticsFragment())
|
||||
getParentFragmentManager().beginTransaction().replace(R.id.content, new StatisticsFragment())
|
||||
.addToBackStack(getString(R.string.statistics_label)).commit();
|
||||
return true;
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ public class PlaybackPreferencesFragment extends PreferenceFragmentCompat {
|
||||
if(x == 0) {
|
||||
entries[x] = res.getString(R.string.pref_smart_mark_as_played_disabled);
|
||||
} else {
|
||||
Integer v = Integer.parseInt(values[x]);
|
||||
int v = Integer.parseInt(values[x]);
|
||||
if(v < 60) {
|
||||
entries[x] = res.getQuantityString(R.plurals.time_seconds_quantified, v, v);
|
||||
} else {
|
||||
|
@ -54,7 +54,7 @@ class NestedScrollableHost extends FrameLayout {
|
||||
touchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
|
||||
}
|
||||
|
||||
private int touchSlop = 0;
|
||||
private int touchSlop;
|
||||
private float initialX = 0f;
|
||||
private float initialY = 0f;
|
||||
|
||||
|
@ -71,7 +71,7 @@
|
||||
android:focusableInTouchMode="true"
|
||||
android:padding="16dp">
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/quickFeedDiscovery"
|
||||
android:name="de.danoeh.antennapod.fragment.QuickFeedDiscoveryFragment"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/root"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/container"
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<automotiveApp xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<automotiveApp>
|
||||
<uses name="media"/>
|
||||
</automotiveApp>
|
@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:search="http://schemas.android.com/apk/com.bytehamster.lib.preferencesearch">
|
||||
|
||||
<de.danoeh.antennapod.preferences.MasterSwitchPreference
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<PreferenceCategory android:title="@string/appearance">
|
||||
<ListPreference
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<paths>
|
||||
<external-path name="external_storage" path="."/>
|
||||
<root-path name="external_files" path="/storage/" />
|
||||
</paths>
|
||||
|
@ -50,7 +50,7 @@ public abstract class FeedComponent {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || !(o instanceof FeedComponent)) return false;
|
||||
if (!(o instanceof FeedComponent)) return false;
|
||||
|
||||
FeedComponent that = (FeedComponent) o;
|
||||
|
||||
|
@ -481,7 +481,7 @@ public class FeedMedia extends FeedFile implements Playable {
|
||||
|
||||
@Override
|
||||
public void onPlaybackStart() {
|
||||
startPosition = (position > 0) ? position : 0;
|
||||
startPosition = Math.max(position, 0);
|
||||
playedDurationWhenStarted = played_duration;
|
||||
}
|
||||
|
||||
|
@ -826,8 +826,8 @@ public class UserPreferences {
|
||||
public static VideoBackgroundBehavior getVideoBackgroundBehavior() {
|
||||
switch (prefs.getString(PREF_VIDEO_BEHAVIOR, "pip")) {
|
||||
case "stop": return VideoBackgroundBehavior.STOP;
|
||||
case "pip": return VideoBackgroundBehavior.PICTURE_IN_PICTURE;
|
||||
case "continue": return VideoBackgroundBehavior.CONTINUE_PLAYING;
|
||||
case "pip": //Deliberate fall-through
|
||||
default: return VideoBackgroundBehavior.PICTURE_IN_PICTURE;
|
||||
}
|
||||
}
|
||||
@ -977,11 +977,11 @@ public class UserPreferences {
|
||||
|
||||
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;
|
||||
case "default": // Deliberate fall-through
|
||||
default: return BackButtonBehavior.DEFAULT;
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ public class PlayerWidgetJobService extends SafeJobIntentService {
|
||||
views.setOnClickPendingIntent(R.id.layout_left, startMediaPlayer);
|
||||
|
||||
try {
|
||||
Bitmap icon = null;
|
||||
Bitmap icon;
|
||||
int iconSize = getResources().getDimensionPixelSize(android.R.dimen.app_icon_size);
|
||||
icon = Glide.with(PlayerWidgetJobService.this)
|
||||
.asBitmap()
|
||||
|
@ -154,8 +154,8 @@ public class AntennapodHttpClient {
|
||||
|
||||
// workaround for Android 4.x for certain web sites.
|
||||
// see: https://github.com/square/okhttp/issues/4053#issuecomment-402579554
|
||||
List<CipherSuite> cipherSuites = new ArrayList<>();
|
||||
cipherSuites.addAll(ConnectionSpec.MODERN_TLS.cipherSuites());
|
||||
List<CipherSuite> cipherSuites = new ArrayList<>(
|
||||
ConnectionSpec.MODERN_TLS.cipherSuites());
|
||||
cipherSuites.add(CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA);
|
||||
cipherSuites.add(CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA);
|
||||
|
||||
|
@ -115,7 +115,7 @@ public class DownloadRequest implements Parcelable {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || !(o instanceof DownloadRequest)) return false;
|
||||
if (!(o instanceof DownloadRequest)) return false;
|
||||
|
||||
DownloadRequest that = (DownloadRequest) o;
|
||||
|
||||
|
@ -189,7 +189,7 @@ public class HttpDownloader extends Downloader {
|
||||
}
|
||||
|
||||
byte[] buffer = new byte[BUFFER_SIZE];
|
||||
int count = 0;
|
||||
int count;
|
||||
request.setStatusMsg(R.string.download_running);
|
||||
Log.d(TAG, "Getting size of download");
|
||||
request.setSize(responseBody.contentLength() + request.getSoFar());
|
||||
|
@ -419,7 +419,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (parentId.startsWith("FeedId:")) {
|
||||
Long feedId = Long.parseLong(parentId.split(":")[1]);
|
||||
long feedId = Long.parseLong(parentId.split(":")[1]);
|
||||
List<FeedItem> feedItems = DBReader.getFeedItemList(DBReader.getFeed(feedId));
|
||||
for (FeedItem feedItem : feedItems) {
|
||||
if (feedItem.getMedia() != null && feedItem.getMedia().getMediaItem() != null) {
|
||||
@ -1140,13 +1140,11 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||
case INITIALIZING:
|
||||
state = PlaybackStateCompat.STATE_CONNECTING;
|
||||
break;
|
||||
case INITIALIZED:
|
||||
case INDETERMINATE:
|
||||
state = PlaybackStateCompat.STATE_NONE;
|
||||
break;
|
||||
case ERROR:
|
||||
state = PlaybackStateCompat.STATE_ERROR;
|
||||
break;
|
||||
case INITIALIZED: // Deliberate fall-through
|
||||
case INDETERMINATE:
|
||||
default:
|
||||
state = PlaybackStateCompat.STATE_NONE;
|
||||
break;
|
||||
|
@ -183,15 +183,14 @@ public class PlaybackServiceNotificationBuilder {
|
||||
notification.addAction(R.drawable.ic_notification_pause, //pause action
|
||||
context.getString(R.string.pause_label),
|
||||
pauseButtonPendingIntent);
|
||||
compactActionList.add(numActions++);
|
||||
} else {
|
||||
PendingIntent playButtonPendingIntent = getPendingIntentForMediaAction(
|
||||
KeyEvent.KEYCODE_MEDIA_PLAY, numActions);
|
||||
notification.addAction(R.drawable.ic_notification_play, //play action
|
||||
context.getString(R.string.play_label),
|
||||
playButtonPendingIntent);
|
||||
compactActionList.add(numActions++);
|
||||
}
|
||||
compactActionList.add(numActions++);
|
||||
|
||||
// ff follows play, then we have skip (if it's present)
|
||||
PendingIntent ffButtonPendingIntent = getPendingIntentForMediaAction(
|
||||
|
@ -58,7 +58,6 @@ class ShakeListener implements SensorEventListener
|
||||
|
||||
@Override
|
||||
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
@ -72,19 +72,13 @@ public final class DBReader {
|
||||
|
||||
@NonNull
|
||||
private static List<Feed> getFeedList(PodDBAdapter adapter) {
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = adapter.getAllFeedsCursor();
|
||||
try (Cursor cursor = adapter.getAllFeedsCursor()) {
|
||||
List<Feed> feeds = new ArrayList<>(cursor.getCount());
|
||||
while (cursor.moveToNext()) {
|
||||
Feed feed = extractFeedFromCursorRow(cursor);
|
||||
feeds.add(feed);
|
||||
}
|
||||
return feeds;
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,18 +90,13 @@ public final class DBReader {
|
||||
public static List<String> getFeedListDownloadUrls() {
|
||||
PodDBAdapter adapter = PodDBAdapter.getInstance();
|
||||
adapter.open();
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = adapter.getFeedCursorDownloadUrls();
|
||||
try (Cursor cursor = adapter.getFeedCursorDownloadUrls()) {
|
||||
List<String> result = new ArrayList<>(cursor.getCount());
|
||||
while (cursor.moveToNext()) {
|
||||
result.add(cursor.getString(1));
|
||||
}
|
||||
return result;
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
adapter.close();
|
||||
}
|
||||
}
|
||||
@ -172,9 +161,7 @@ public final class DBReader {
|
||||
|
||||
PodDBAdapter adapter = PodDBAdapter.getInstance();
|
||||
adapter.open();
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = adapter.getAllItemsOfFeedCursor(feed);
|
||||
try (Cursor cursor = adapter.getAllItemsOfFeedCursor(feed)) {
|
||||
List<FeedItem> items = extractItemlistFromCursor(adapter, cursor);
|
||||
Collections.sort(items, new FeedItemPubdateComparator());
|
||||
for (FeedItem item : items) {
|
||||
@ -182,9 +169,6 @@ public final class DBReader {
|
||||
}
|
||||
return items;
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
adapter.close();
|
||||
}
|
||||
}
|
||||
@ -226,16 +210,10 @@ public final class DBReader {
|
||||
@NonNull
|
||||
static List<FeedItem> getQueue(PodDBAdapter adapter) {
|
||||
Log.d(TAG, "getQueue()");
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = adapter.getQueueCursor();
|
||||
try (Cursor cursor = adapter.getQueueCursor()) {
|
||||
List<FeedItem> items = extractItemlistFromCursor(adapter, cursor);
|
||||
loadAdditionalFeedItemListData(items);
|
||||
return items;
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -257,18 +235,12 @@ public final class DBReader {
|
||||
}
|
||||
|
||||
private static LongList getQueueIDList(PodDBAdapter adapter) {
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = adapter.getQueueIDCursor();
|
||||
try (Cursor cursor = adapter.getQueueIDCursor()) {
|
||||
LongList queueIds = new LongList(cursor.getCount());
|
||||
while (cursor.moveToNext()) {
|
||||
queueIds.add(cursor.getLong(0));
|
||||
}
|
||||
return queueIds;
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -302,17 +274,12 @@ public final class DBReader {
|
||||
|
||||
PodDBAdapter adapter = PodDBAdapter.getInstance();
|
||||
adapter.open();
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = adapter.getDownloadedItemsCursor();
|
||||
try (Cursor cursor = adapter.getDownloadedItemsCursor()) {
|
||||
List<FeedItem> items = extractItemlistFromCursor(adapter, cursor);
|
||||
loadAdditionalFeedItemListData(items);
|
||||
Collections.sort(items, new FeedItemPubdateComparator());
|
||||
return items;
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
adapter.close();
|
||||
}
|
||||
}
|
||||
@ -328,16 +295,11 @@ public final class DBReader {
|
||||
|
||||
PodDBAdapter adapter = PodDBAdapter.getInstance();
|
||||
adapter.open();
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = adapter.getPlayedItemsCursor();
|
||||
try (Cursor cursor = adapter.getPlayedItemsCursor()) {
|
||||
List<FeedItem> items = extractItemlistFromCursor(adapter, cursor);
|
||||
loadAdditionalFeedItemListData(items);
|
||||
return items;
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
adapter.close();
|
||||
}
|
||||
}
|
||||
@ -355,16 +317,11 @@ public final class DBReader {
|
||||
|
||||
PodDBAdapter adapter = PodDBAdapter.getInstance();
|
||||
adapter.open();
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = adapter.getNewItemsCursor(offset, limit);
|
||||
try (Cursor cursor = adapter.getNewItemsCursor(offset, limit)) {
|
||||
List<FeedItem> items = extractItemlistFromCursor(adapter, cursor);
|
||||
loadAdditionalFeedItemListData(items);
|
||||
return items;
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
adapter.close();
|
||||
}
|
||||
}
|
||||
@ -381,16 +338,11 @@ public final class DBReader {
|
||||
|
||||
PodDBAdapter adapter = PodDBAdapter.getInstance();
|
||||
adapter.open();
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = adapter.getFavoritesCursor(offset, limit);
|
||||
try (Cursor cursor = adapter.getFavoritesCursor(offset, limit)) {
|
||||
List<FeedItem> items = extractItemlistFromCursor(adapter, cursor);
|
||||
loadAdditionalFeedItemListData(items);
|
||||
return items;
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
adapter.close();
|
||||
}
|
||||
}
|
||||
@ -400,18 +352,13 @@ public final class DBReader {
|
||||
|
||||
PodDBAdapter adapter = PodDBAdapter.getInstance();
|
||||
adapter.open();
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = adapter.getFavoritesCursor(0, Integer.MAX_VALUE);
|
||||
try (Cursor cursor = adapter.getFavoritesCursor(0, Integer.MAX_VALUE)) {
|
||||
LongList favoriteIDs = new LongList(cursor.getCount());
|
||||
while (cursor.moveToNext()) {
|
||||
favoriteIDs.add(cursor.getLong(0));
|
||||
}
|
||||
return favoriteIDs;
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
adapter.close();
|
||||
}
|
||||
}
|
||||
@ -428,16 +375,11 @@ public final class DBReader {
|
||||
|
||||
PodDBAdapter adapter = PodDBAdapter.getInstance();
|
||||
adapter.open();
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = adapter.getRecentlyPublishedItemsCursor(offset, limit);
|
||||
try (Cursor cursor = adapter.getRecentlyPublishedItemsCursor(offset, limit)) {
|
||||
List<FeedItem> items = extractItemlistFromCursor(adapter, cursor);
|
||||
loadAdditionalFeedItemListData(items);
|
||||
return items;
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
adapter.close();
|
||||
}
|
||||
}
|
||||
@ -492,9 +434,7 @@ public final class DBReader {
|
||||
|
||||
PodDBAdapter adapter = PodDBAdapter.getInstance();
|
||||
adapter.open();
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = adapter.getDownloadLogCursor(DOWNLOAD_LOG_SIZE);
|
||||
try (Cursor cursor = adapter.getDownloadLogCursor(DOWNLOAD_LOG_SIZE)) {
|
||||
List<DownloadStatus> downloadLog = new ArrayList<>(cursor.getCount());
|
||||
while (cursor.moveToNext()) {
|
||||
downloadLog.add(DownloadStatus.fromCursor(cursor));
|
||||
@ -502,9 +442,6 @@ public final class DBReader {
|
||||
Collections.sort(downloadLog, new DownloadStatusComparator());
|
||||
return downloadLog;
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
adapter.close();
|
||||
}
|
||||
}
|
||||
@ -521,9 +458,7 @@ public final class DBReader {
|
||||
|
||||
PodDBAdapter adapter = PodDBAdapter.getInstance();
|
||||
adapter.open();
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = adapter.getDownloadLog(Feed.FEEDFILETYPE_FEED, feedId);
|
||||
try (Cursor cursor = adapter.getDownloadLog(Feed.FEEDFILETYPE_FEED, feedId)) {
|
||||
List<DownloadStatus> downloadLog = new ArrayList<>(cursor.getCount());
|
||||
while (cursor.moveToNext()) {
|
||||
downloadLog.add(DownloadStatus.fromCursor(cursor));
|
||||
@ -531,9 +466,6 @@ public final class DBReader {
|
||||
Collections.sort(downloadLog, new DownloadStatusComparator());
|
||||
return downloadLog;
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
adapter.close();
|
||||
}
|
||||
}
|
||||
@ -560,9 +492,7 @@ public final class DBReader {
|
||||
@Nullable
|
||||
static Feed getFeed(final long feedId, PodDBAdapter adapter) {
|
||||
Feed feed = null;
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = adapter.getFeedCursor(feedId);
|
||||
try (Cursor cursor = adapter.getFeedCursor(feedId)) {
|
||||
if (cursor.moveToNext()) {
|
||||
feed = extractFeedFromCursorRow(cursor);
|
||||
feed.setItems(getFeedItemList(feed));
|
||||
@ -570,10 +500,6 @@ public final class DBReader {
|
||||
Log.e(TAG, "getFeed could not find feed with id " + feedId);
|
||||
}
|
||||
return feed;
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -582,9 +508,7 @@ public final class DBReader {
|
||||
Log.d(TAG, "Loading feeditem with id " + itemId);
|
||||
|
||||
FeedItem item = null;
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = adapter.getFeedItemCursor(Long.toString(itemId));
|
||||
try (Cursor cursor = adapter.getFeedItemCursor(Long.toString(itemId))) {
|
||||
if (cursor.moveToNext()) {
|
||||
List<FeedItem> list = extractItemlistFromCursor(adapter, cursor);
|
||||
if (!list.isEmpty()) {
|
||||
@ -593,10 +517,6 @@ public final class DBReader {
|
||||
}
|
||||
}
|
||||
return item;
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -631,9 +551,7 @@ public final class DBReader {
|
||||
@Nullable
|
||||
private static FeedItem getFeedItemByUrl(final String podcastUrl, final String episodeUrl, PodDBAdapter adapter) {
|
||||
Log.d(TAG, "Loading feeditem with podcast url " + podcastUrl + " and episode url " + episodeUrl);
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = adapter.getFeedItemCursor(podcastUrl, episodeUrl);
|
||||
try (Cursor cursor = adapter.getFeedItemCursor(podcastUrl, episodeUrl)) {
|
||||
if (!cursor.moveToNext()) {
|
||||
return null;
|
||||
}
|
||||
@ -642,10 +560,6 @@ public final class DBReader {
|
||||
return list.get(0);
|
||||
}
|
||||
return null;
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -668,10 +582,8 @@ public final class DBReader {
|
||||
}
|
||||
|
||||
private static String getImageAuthentication(final String imageUrl, PodDBAdapter adapter) {
|
||||
String credentials = null;
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = adapter.getImageAuthenticationCursor(imageUrl);
|
||||
String credentials;
|
||||
try (Cursor cursor = adapter.getImageAuthenticationCursor(imageUrl)) {
|
||||
if (cursor.moveToFirst()) {
|
||||
String username = cursor.getString(0);
|
||||
String password = cursor.getString(1);
|
||||
@ -683,10 +595,6 @@ public final class DBReader {
|
||||
} else {
|
||||
credentials = "";
|
||||
}
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
return credentials;
|
||||
}
|
||||
@ -720,9 +628,7 @@ public final class DBReader {
|
||||
Log.d(TAG, "loadDescriptionOfFeedItem() called with: " + "item = [" + item + "]");
|
||||
PodDBAdapter adapter = PodDBAdapter.getInstance();
|
||||
adapter.open();
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = adapter.getDescriptionOfItem(item);
|
||||
try (Cursor cursor = adapter.getDescriptionOfItem(item)) {
|
||||
if (cursor.moveToFirst()) {
|
||||
int indexDescription = cursor.getColumnIndex(PodDBAdapter.KEY_DESCRIPTION);
|
||||
String description = cursor.getString(indexDescription);
|
||||
@ -732,9 +638,6 @@ public final class DBReader {
|
||||
item.setContentEncoded(contentEncoded);
|
||||
}
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
adapter.close();
|
||||
}
|
||||
}
|
||||
|
@ -1218,7 +1218,7 @@ public class PodDBAdapter {
|
||||
public Cursor searchItems(long feedID, String searchQuery) {
|
||||
String preparedQuery = prepareSearchQuery(searchQuery);
|
||||
|
||||
String queryFeedId = "";
|
||||
String queryFeedId;
|
||||
if (feedID != 0) {
|
||||
// search items in specific feed
|
||||
queryFeedId = KEY_FEED + " = " + feedID;
|
||||
|
@ -21,7 +21,6 @@ import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
@ -34,6 +33,7 @@ import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
@ -505,7 +505,7 @@ public class GpodnetService implements ISyncService {
|
||||
RequestBody requestBody = RequestBody.create(TEXT, "");
|
||||
Request request = new Request.Builder().url(url).post(requestBody).build();
|
||||
try {
|
||||
String credential = Credentials.basic(username, password, Charsets.UTF_8);
|
||||
String credential = Credentials.basic(username, password, Charset.forName("UTF-8"));
|
||||
Request authRequest = request.newBuilder().header("Authorization", credential).build();
|
||||
Response response = httpClient.newCall(authRequest).execute();
|
||||
checkStatusCode(response);
|
||||
@ -519,8 +519,8 @@ public class GpodnetService implements ISyncService {
|
||||
|
||||
private String executeRequest(@NonNull Request.Builder requestB) throws GpodnetServiceException {
|
||||
Request request = requestB.build();
|
||||
String responseString = null;
|
||||
Response response = null;
|
||||
String responseString;
|
||||
Response response;
|
||||
ResponseBody body = null;
|
||||
try {
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class RewindAfterPauseUtils {
|
||||
|
||||
int newPosition = currentPosition - (int) rewindTime;
|
||||
|
||||
return newPosition > 0 ? newPosition : 0;
|
||||
return Math.max(newPosition, 0);
|
||||
} else {
|
||||
return currentPosition;
|
||||
}
|
||||
|
@ -8,13 +8,7 @@ public class ChapterStartTimeComparator implements Comparator<Chapter> {
|
||||
|
||||
@Override
|
||||
public int compare(Chapter lhs, Chapter rhs) {
|
||||
if (lhs.getStart() == rhs.getStart()) {
|
||||
return 0;
|
||||
} else if (lhs.getStart() < rhs.getStart()) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
return Long.compare(lhs.getStart(), rhs.getStart());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -118,9 +118,8 @@ public class AutoUpdateManager {
|
||||
*/
|
||||
public static void runImmediate(@NonNull Context context) {
|
||||
Log.d(TAG, "Run auto update immediately in background.");
|
||||
new Thread(() -> {
|
||||
DBTasks.refreshAllFeeds(context.getApplicationContext(), true);
|
||||
}, "ManualRefreshAllFeeds").start();
|
||||
new Thread(() -> DBTasks.refreshAllFeeds(
|
||||
context.getApplicationContext(), true), "ManualRefreshAllFeeds").start();
|
||||
}
|
||||
|
||||
public static void disableAutoUpdate(Context context) {
|
||||
|
@ -39,7 +39,7 @@ class OggInputStream extends InputStream {
|
||||
private void readOggPage() throws IOException {
|
||||
// find OggS
|
||||
int[] buffer = new int[4];
|
||||
int c = 0;
|
||||
int c;
|
||||
boolean isInOggS = false;
|
||||
while ((c = input.read()) != -1) {
|
||||
switch (c) {
|
||||
|
@ -5,7 +5,7 @@ import org.junit.Test;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class VolumeAdaptionSettingTest {
|
||||
|
@ -13,6 +13,7 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import de.danoeh.antennapod.core.feed.FeedComponent;
|
||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
import de.danoeh.antennapod.core.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.core.feed.FeedMother;
|
||||
@ -27,6 +28,7 @@ import static de.danoeh.antennapod.core.preferences.UserPreferences.EnqueueLocat
|
||||
import static de.danoeh.antennapod.core.util.CollectionTestUtil.concat;
|
||||
import static de.danoeh.antennapod.core.util.CollectionTestUtil.list;
|
||||
import static de.danoeh.antennapod.core.util.FeedItemUtil.getIdList;
|
||||
import static java.util.Collections.emptyList;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@ -248,13 +250,13 @@ public class ItemEnqueuePositionCalculatorTest {
|
||||
assertEquals(message, idsExpected, getIdList(queue));
|
||||
}
|
||||
|
||||
static final List<FeedItem> QUEUE_EMPTY = Collections.unmodifiableList(Arrays.asList());
|
||||
static final List<FeedItem> QUEUE_EMPTY = Collections.unmodifiableList(emptyList());
|
||||
|
||||
static final List<FeedItem> QUEUE_DEFAULT =
|
||||
Collections.unmodifiableList(Arrays.asList(
|
||||
createFeedItem(11), createFeedItem(12), createFeedItem(13), createFeedItem(14)));
|
||||
static final List<Long> QUEUE_DEFAULT_IDS =
|
||||
QUEUE_DEFAULT.stream().map(fi -> fi.getId()).collect(Collectors.toList());
|
||||
QUEUE_DEFAULT.stream().map(FeedComponent::getId).collect(Collectors.toList());
|
||||
|
||||
|
||||
static Playable getCurrentlyPlaying(long idCurrentlyPlaying) {
|
||||
|
@ -7,6 +7,7 @@ import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import de.danoeh.antennapod.core.feed.Feed;
|
||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
@ -55,7 +56,7 @@ public class FeedItemUtilTest {
|
||||
FeedItem feedItem = new FeedItem();
|
||||
feedItem.setLink(itemLink);
|
||||
feedItem.setFeed(feed);
|
||||
feed.setItems(Arrays.asList(feedItem));
|
||||
feed.setItems(Collections.singletonList(feedItem));
|
||||
return feedItem;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ package de.danoeh.antennapod.core.util;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class LongLongMapTest {
|
||||
|
||||
@ -13,7 +15,7 @@ public class LongLongMapTest {
|
||||
assertEquals("LongLongMap{}", map.toString());
|
||||
assertEquals(0, map.get(42));
|
||||
assertEquals(-1, map.get(42, -1));
|
||||
assertEquals(false, map.delete(42));
|
||||
assertFalse(map.delete(42));
|
||||
assertEquals(-1, map.indexOfKey(42));
|
||||
assertEquals(-1, map.indexOfValue(42));
|
||||
assertEquals(1, map.hashCode());
|
||||
@ -29,7 +31,7 @@ public class LongLongMapTest {
|
||||
assertEquals(42, map.get(17, -1));
|
||||
assertEquals(0, map.indexOfKey(17));
|
||||
assertEquals(0, map.indexOfValue(42));
|
||||
assertEquals(true, map.delete(17));
|
||||
assertTrue(map.delete(17));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -45,7 +47,7 @@ public class LongLongMapTest {
|
||||
assertEquals(1, map.indexOfKey(17));
|
||||
assertEquals(1, map.indexOfValue(42));
|
||||
for(int i=0; i < 100; i++) {
|
||||
assertEquals(true, map.delete(i * 17));
|
||||
assertTrue(map.delete(i * 17));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user