Merge pull request #4035 from ByteHamster/proguard
Allow Proguard to optimize androidx packages
This commit is contained in:
commit
55fe840fc7
|
@ -87,6 +87,7 @@ android {
|
|||
release {
|
||||
resValue "string", "provider_authority", "de.danoeh.antennapod.provider"
|
||||
minifyEnabled true
|
||||
shrinkResources true
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), "proguard.cfg"
|
||||
signingConfig signingConfigs.releaseConfig
|
||||
}
|
||||
|
|
|
@ -5,21 +5,24 @@
|
|||
-optimizationpasses 5
|
||||
|
||||
-dontpreverify
|
||||
-repackageclasses ''
|
||||
-allowaccessmodification
|
||||
-keepattributes *Annotation*
|
||||
-dontskipnonpubliclibraryclassmembers
|
||||
|
||||
-keep public class * extends android.app.Activity
|
||||
-keep public class * extends android.app.Application
|
||||
-keep public class * extends android.app.Service
|
||||
-keep public class * extends android.content.BroadcastReceiver
|
||||
-keep public class * extends android.content.ContentProvider
|
||||
# Keep our own classes and members. They are all used.
|
||||
# Without this, methods only used in tests are removed and break tests.
|
||||
-keep class de.danoeh.antennapod**
|
||||
-keepclassmembers class de.danoeh.antennapod** {*;}
|
||||
-keep class de.test.antennapod**
|
||||
-keepclassmembers class de.test.antennapod** {*;}
|
||||
|
||||
-keep public class * extends android.view.View {
|
||||
public <init>(android.content.Context);
|
||||
public <init>(android.content.Context, android.util.AttributeSet);
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
public void set*(...);
|
||||
# Keep methods used in tests.
|
||||
# This is only needed when running tests with proguard enabled.
|
||||
-keepclassmembers class org.apache.commons.lang3.StringUtils {*;}
|
||||
-keepclassmembers class androidx.appcompat.app.ActionBar {
|
||||
public ** getTitle();
|
||||
}
|
||||
-keepclassmembers class org.apache.commons.io.IOUtils {
|
||||
public static void write(...);
|
||||
}
|
||||
|
||||
-keepclassmembers enum * {
|
||||
|
@ -27,27 +30,10 @@
|
|||
public static ** valueOf(java.lang.String);
|
||||
}
|
||||
|
||||
-keepclasseswithmembers class * {
|
||||
public <init>(android.content.Context, android.util.AttributeSet);
|
||||
}
|
||||
|
||||
-keepclasseswithmembers class * {
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
}
|
||||
|
||||
-keepclassmembers class * extends android.content.Context {
|
||||
public void *(android.view.View);
|
||||
public void *(android.view.MenuItem);
|
||||
}
|
||||
|
||||
-keepclassmembers class * implements android.os.Parcelable {
|
||||
static android.os.Parcelable$Creator CREATOR;
|
||||
}
|
||||
|
||||
-keepclassmembers class **.R$* {
|
||||
public static <fields>;
|
||||
}
|
||||
|
||||
-keep public class org.jsoup.** {
|
||||
public *;
|
||||
}
|
||||
|
@ -65,19 +51,6 @@
|
|||
# for retrolambda
|
||||
-dontwarn java.lang.invoke.*
|
||||
|
||||
-dontwarn com.google.android.material.**
|
||||
-keep class com.google.android.material.** { *; }
|
||||
|
||||
-dontwarn androidx.**
|
||||
-keep class androidx.** { *; }
|
||||
-keep interface androidx.** { *; }
|
||||
|
||||
-dontwarn com.google.android.wearable.**
|
||||
|
||||
-keep class org.apache.commons.** { *; }
|
||||
|
||||
-dontskipnonpubliclibraryclassmembers
|
||||
|
||||
# greenrobot EventBus
|
||||
-keepattributes *Annotation*
|
||||
-keepclassmembers class * {
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import androidx.test.filters.LargeTest;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
@ -13,6 +12,7 @@ import de.danoeh.antennapod.R;
|
|||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
import de.danoeh.antennapod.core.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||
import de.danoeh.antennapod.core.service.playback.PlayerStatus;
|
||||
|
@ -20,6 +20,7 @@ import de.danoeh.antennapod.core.storage.DBReader;
|
|||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||
import de.danoeh.antennapod.core.util.LongList;
|
||||
import de.danoeh.antennapod.core.util.playback.PlaybackController;
|
||||
import de.test.antennapod.EspressoTestUtils;
|
||||
import de.test.antennapod.IgnoreOnCi;
|
||||
import de.test.antennapod.ui.UITestUtils;
|
||||
|
@ -71,6 +72,7 @@ public class PlaybackTest {
|
|||
public String playerToUse;
|
||||
private UITestUtils uiTestUtils;
|
||||
protected Context context;
|
||||
private PlaybackController controller;
|
||||
|
||||
@Parameterized.Parameters(name = "{0}")
|
||||
public static Collection<Object[]> initParameters() {
|
||||
|
@ -96,6 +98,14 @@ public class PlaybackTest {
|
|||
activityTestRule.finishActivity();
|
||||
EspressoTestUtils.tryKillPlaybackService();
|
||||
uiTestUtils.tearDown();
|
||||
if (controller != null) {
|
||||
controller.release();
|
||||
}
|
||||
}
|
||||
|
||||
private void setupPlaybackController() {
|
||||
controller = new PlaybackController(activityTestRule.getActivity());
|
||||
controller.init();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -103,9 +113,10 @@ public class PlaybackTest {
|
|||
setContinuousPlaybackPreference(false);
|
||||
uiTestUtils.addLocalFeedData(true);
|
||||
activityTestRule.launchActivity(new Intent());
|
||||
setupPlaybackController();
|
||||
playFromQueue(0);
|
||||
Awaitility.await().atMost(5, TimeUnit.SECONDS).until(
|
||||
() -> uiTestUtils.getPlaybackController(getActivity()).getStatus() == PlayerStatus.INITIALIZED);
|
||||
Awaitility.await().atMost(5, TimeUnit.SECONDS)
|
||||
.until(() -> controller.getStatus() == PlayerStatus.INITIALIZED);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -120,9 +131,9 @@ public class PlaybackTest {
|
|||
|
||||
playFromQueue(0);
|
||||
Awaitility.await().atMost(2, TimeUnit.SECONDS).until(
|
||||
() -> first.getMedia().equals(uiTestUtils.getCurrentMedia()));
|
||||
() -> first.getMedia().getId() == PlaybackPreferences.getCurrentlyPlayingFeedMediaId());
|
||||
Awaitility.await().atMost(6, TimeUnit.SECONDS).until(
|
||||
() -> second.getMedia().equals(uiTestUtils.getCurrentMedia()));
|
||||
() -> second.getMedia().getId() == PlaybackPreferences.getCurrentlyPlayingFeedMediaId());
|
||||
}
|
||||
|
||||
|
||||
|
@ -152,6 +163,7 @@ public class PlaybackTest {
|
|||
|
||||
uiTestUtils.addLocalFeedData(true);
|
||||
activityTestRule.launchActivity(new Intent());
|
||||
setupPlaybackController();
|
||||
|
||||
final int fiIdx = 0;
|
||||
final FeedItem feedItem = DBReader.getQueue().get(fiIdx);
|
||||
|
@ -161,11 +173,11 @@ public class PlaybackTest {
|
|||
// let playback run a bit then pause
|
||||
Awaitility.await()
|
||||
.atMost(1000, MILLISECONDS)
|
||||
.until(() -> PlayerStatus.PLAYING == uiTestUtils.getPlaybackController(getActivity()).getStatus());
|
||||
.until(() -> PlayerStatus.PLAYING == controller.getStatus());
|
||||
pauseEpisode();
|
||||
Awaitility.await()
|
||||
.atMost(1000, MILLISECONDS)
|
||||
.until(() -> PlayerStatus.PAUSED == uiTestUtils.getPlaybackController(getActivity()).getStatus());
|
||||
.until(() -> PlayerStatus.PAUSED == controller.getStatus());
|
||||
|
||||
assertThat("Ensure even with smart mark as play, after pause, the item remains in the queue.",
|
||||
DBReader.getQueue(), hasItems(feedItem));
|
||||
|
@ -232,7 +244,7 @@ public class PlaybackTest {
|
|||
|
||||
FeedMedia media = episodes.get(0).getMedia();
|
||||
Awaitility.await().atMost(1, TimeUnit.SECONDS).until(
|
||||
() -> media.equals(uiTestUtils.getCurrentMedia()));
|
||||
() -> media.getId() == PlaybackPreferences.getCurrentlyPlayingFeedMediaId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -248,7 +260,7 @@ public class PlaybackTest {
|
|||
|
||||
FeedMedia media = queue.get(itemIdx).getMedia();
|
||||
Awaitility.await().atMost(1, TimeUnit.SECONDS).until(
|
||||
() -> media.equals(uiTestUtils.getCurrentMedia()));
|
||||
() -> media.getId() == PlaybackPreferences.getCurrentlyPlayingFeedMediaId());
|
||||
|
||||
}
|
||||
|
||||
|
@ -265,15 +277,15 @@ public class PlaybackTest {
|
|||
startLocalPlayback();
|
||||
FeedMedia media = episodes.get(0).getMedia();
|
||||
Awaitility.await().atMost(1, TimeUnit.SECONDS).until(
|
||||
() -> media.equals(uiTestUtils.getCurrentMedia()));
|
||||
() -> media.getId() == PlaybackPreferences.getCurrentlyPlayingFeedMediaId());
|
||||
|
||||
Awaitility.await().atMost(5, TimeUnit.SECONDS).until(
|
||||
() -> !media.equals(uiTestUtils.getCurrentMedia()));
|
||||
() -> media.getId() != PlaybackPreferences.getCurrentlyPlayingFeedMediaId());
|
||||
|
||||
startLocalPlayback();
|
||||
|
||||
Awaitility.await().atMost(1, TimeUnit.SECONDS).until(
|
||||
() -> media.equals(uiTestUtils.getCurrentMedia()));
|
||||
() -> media.getId() == PlaybackPreferences.getCurrentlyPlayingFeedMediaId());
|
||||
}
|
||||
|
||||
protected void doTestSmartMarkAsPlayed_Skip_ForEpisode(int itemIdxNegAllowed) throws Exception {
|
||||
|
|
|
@ -1,15 +1,20 @@
|
|||
package de.test.antennapod.storage;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import de.danoeh.antennapod.core.ClientConfig;
|
||||
import de.danoeh.antennapod.core.DBTasksCallbacks;
|
||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
import de.danoeh.antennapod.core.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.storage.AutomaticDownloadAlgorithm;
|
||||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.storage.EpisodeCleanupAlgorithm;
|
||||
import de.danoeh.antennapod.core.util.playback.PlaybackServiceStarter;
|
||||
import de.test.antennapod.EspressoTestUtils;
|
||||
import de.test.antennapod.ui.UITestUtils;
|
||||
import org.awaitility.Awaitility;
|
||||
import org.awaitility.core.ConditionTimeoutException;
|
||||
import org.junit.After;
|
||||
|
@ -17,21 +22,6 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import de.danoeh.antennapod.core.ClientConfig;
|
||||
import de.danoeh.antennapod.core.DBTasksCallbacks;
|
||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
import de.danoeh.antennapod.core.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||
import de.danoeh.antennapod.core.storage.AutomaticDownloadAlgorithm;
|
||||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.storage.DBTasks;
|
||||
import de.danoeh.antennapod.core.storage.EpisodeCleanupAlgorithm;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
import de.danoeh.antennapod.core.util.playback.Playable;
|
||||
import de.test.antennapod.ui.UITestUtils;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
@ -100,13 +90,12 @@ public class AutoDownloadTest {
|
|||
// ensure that currently playing has been advanced to the next one by this point.
|
||||
Awaitility.await("advanced to the next episode")
|
||||
.atMost(6000, MILLISECONDS) // the test mp3 media is 3-second long. twice should be enough
|
||||
.until(() -> item1.equals(stubDownloadAlgorithm.getCurrentlyPlayingAtDownload()));
|
||||
.until(() -> item1.getMedia().getId() == stubDownloadAlgorithm.getCurrentlyPlayingAtDownload());
|
||||
} catch (ConditionTimeoutException cte) {
|
||||
FeedItem actual = stubDownloadAlgorithm.getCurrentlyPlayingAtDownload();
|
||||
long actual = stubDownloadAlgorithm.getCurrentlyPlayingAtDownload();
|
||||
fail("when auto download is triggered, the next episode should be playing: ("
|
||||
+ item1.getId() + ", " + item1.getTitle() + ") . "
|
||||
+ "Actual playing: ("
|
||||
+ (actual == null ? "" : actual.getId() + ", " + actual.getTitle()) + ")"
|
||||
+ "Actual playing: (" + actual + ")"
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -121,15 +110,7 @@ public class AutoDownloadTest {
|
|||
.start();
|
||||
Awaitility.await("episode is playing")
|
||||
.atMost(2000, MILLISECONDS)
|
||||
.until(() -> item.equals(getCurrentlyPlaying()));
|
||||
}
|
||||
|
||||
private FeedItem getCurrentlyPlaying() {
|
||||
Playable playable = Playable.PlayableUtils.createInstanceFromPreferences(context);
|
||||
if (playable == null) {
|
||||
return null;
|
||||
}
|
||||
return ((FeedMedia) playable).getItem();
|
||||
.until(() -> item.getMedia().getId() == PlaybackPreferences.getCurrentlyPlayingFeedMediaId());
|
||||
}
|
||||
|
||||
private void useDownloadAlgorithm(final AutomaticDownloadAlgorithm downloadAlgorithm) {
|
||||
|
@ -146,23 +127,21 @@ public class AutoDownloadTest {
|
|||
};
|
||||
}
|
||||
|
||||
private class StubDownloadAlgorithm implements AutomaticDownloadAlgorithm {
|
||||
@Nullable
|
||||
private FeedItem currentlyPlaying;
|
||||
private static class StubDownloadAlgorithm implements AutomaticDownloadAlgorithm {
|
||||
private long currentlyPlaying = -1;
|
||||
|
||||
@Override
|
||||
public Runnable autoDownloadUndownloadedItems(Context context) {
|
||||
return () -> {
|
||||
if (currentlyPlaying == null) {
|
||||
currentlyPlaying = getCurrentlyPlaying();
|
||||
if (currentlyPlaying == -1) {
|
||||
currentlyPlaying = PlaybackPreferences.getCurrentlyPlayingFeedMediaId();
|
||||
} else {
|
||||
throw new AssertionError("Stub automatic download should be invoked once and only once");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Nullable
|
||||
FeedItem getCurrentlyPlayingAtDownload() {
|
||||
long getCurrentlyPlayingAtDownload() {
|
||||
return currentlyPlaying;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -404,6 +404,7 @@ public class DBReaderTest {
|
|||
List<Feed> feeds = saveFeedlist(1, 1, false, true, NUM_CHAPTERS);
|
||||
FeedItem item1 = feeds.get(0).getItems().get(0);
|
||||
FeedItem item2 = DBReader.getFeedItem(item1.getId());
|
||||
DBReader.loadChaptersOfFeedItem(item2);
|
||||
assertTrue(item2.hasChapters());
|
||||
assertEquals(item1.getChapters(), item2.getChapters());
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ public class NavigationDrawerTest {
|
|||
onView(first(withText(R.string.queue_label))).perform(longClick());
|
||||
for (int i = 0; i < titles.length; i++) {
|
||||
String title = titles[i];
|
||||
onView(first(withText(title))).perform(click());
|
||||
onView(allOf(withText(title), isDisplayed())).perform(click());
|
||||
|
||||
if (i == 3) {
|
||||
onView(withId(R.id.select_dialog_listview)).perform(swipeUp());
|
||||
|
|
|
@ -83,6 +83,7 @@ public class SpeedChangeTest {
|
|||
@After
|
||||
public void tearDown() throws Exception {
|
||||
uiTestUtils.tearDown();
|
||||
controller.release();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,14 +1,20 @@
|
|||
package de.test.antennapod.ui;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.util.Log;
|
||||
|
||||
import de.danoeh.antennapod.core.event.FeedListUpdateEvent;
|
||||
import de.danoeh.antennapod.core.util.playback.Playable;
|
||||
import de.danoeh.antennapod.core.event.QueueEvent;
|
||||
import de.danoeh.antennapod.core.feed.Feed;
|
||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
import de.danoeh.antennapod.core.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
import de.test.antennapod.util.service.download.HTTPBin;
|
||||
import de.test.antennapod.util.syndication.feedgenerator.RSS2Generator;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.junit.Assert;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
|
@ -19,19 +25,6 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.core.event.QueueEvent;
|
||||
import de.danoeh.antennapod.core.feed.Feed;
|
||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
import de.danoeh.antennapod.core.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
import de.danoeh.antennapod.core.util.playback.PlaybackController;
|
||||
import de.danoeh.antennapod.fragment.ExternalPlayerFragment;
|
||||
import de.test.antennapod.util.service.download.HTTPBin;
|
||||
import de.test.antennapod.util.syndication.feedgenerator.RSS2Generator;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.junit.Assert;
|
||||
|
||||
/**
|
||||
* Utility methods for UI tests.
|
||||
* Starts a web server that hosts feeds, episodes and images.
|
||||
|
@ -200,17 +193,6 @@ public class UITestUtils {
|
|||
EventBus.getDefault().post(QueueEvent.setQueue(queue));
|
||||
}
|
||||
|
||||
public PlaybackController getPlaybackController(MainActivity mainActivity) {
|
||||
ExternalPlayerFragment fragment = (ExternalPlayerFragment) mainActivity.getSupportFragmentManager()
|
||||
.findFragmentByTag(ExternalPlayerFragment.TAG);
|
||||
return fragment.getPlaybackControllerTestingOnly();
|
||||
}
|
||||
|
||||
public FeedMedia getCurrentMedia() {
|
||||
Playable playable = Playable.PlayableUtils.createInstanceFromPreferences(context);
|
||||
return (FeedMedia) playable;
|
||||
}
|
||||
|
||||
public void setMediaFileName(String filename) {
|
||||
testFileName = filename;
|
||||
}
|
||||
|
|
|
@ -210,10 +210,6 @@ public class ExternalPlayerFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
public PlaybackController getPlaybackControllerTestingOnly() {
|
||||
return controller;
|
||||
}
|
||||
|
||||
private void onPositionObserverUpdate() {
|
||||
if (controller == null) {
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue