Merge pull request #3962 from ByteHamster/cleanup-lint
Cleaned up some Lint warnings
This commit is contained in:
commit
b4b2b45247
|
@ -18,9 +18,7 @@ public class NthMatcher {
|
|||
@Override
|
||||
public boolean matches(final Object item) {
|
||||
if (matcher.matches(item)) {
|
||||
if (count.incrementAndGet() == index) {
|
||||
return true;
|
||||
}
|
||||
return count.incrementAndGet() == index;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -139,19 +139,19 @@ public class FeedHandlerTest {
|
|||
|
||||
@Test
|
||||
public void testRSS2Basic() throws IOException, UnsupportedFeedtypeException, SAXException, ParserConfigurationException {
|
||||
Feed f1 = createTestFeed(10, false, true, true);
|
||||
Feed f1 = createTestFeed(10, true);
|
||||
Feed f2 = runFeedTest(f1, new RSS2Generator(), "UTF-8", RSS2Generator.FEATURE_WRITE_GUID);
|
||||
feedValid(f1, f2, Feed.TYPE_RSS2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAtomBasic() throws IOException, UnsupportedFeedtypeException, SAXException, ParserConfigurationException {
|
||||
Feed f1 = createTestFeed(10, false, true, true);
|
||||
Feed f1 = createTestFeed(10, true);
|
||||
Feed f2 = runFeedTest(f1, new AtomGenerator(), "UTF-8", 0);
|
||||
feedValid(f1, f2, Feed.TYPE_ATOM1);
|
||||
}
|
||||
|
||||
private Feed createTestFeed(int numItems, boolean withImage, boolean withFeedMedia, boolean withChapters) {
|
||||
private Feed createTestFeed(int numItems, boolean withFeedMedia) {
|
||||
Feed feed = new Feed(0, null, "title", "http://example.com", "This is the description",
|
||||
"http://example.com/payment", "Daniel", "en", null, "http://example.com/feed", "http://example.com/picture", file.getAbsolutePath(),
|
||||
"http://example.com/feed", true);
|
||||
|
|
|
@ -45,13 +45,10 @@ import static org.junit.Assert.assertTrue;
|
|||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* @see HttpDownloaderTest for the test of actual download (and saving the file)
|
||||
* @see HttpDownloaderTest for the test of actual download (and saving the file).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class DownloadServiceTest {
|
||||
|
||||
private CountDownLatch latch = null;
|
||||
private Feed testFeed = null;
|
||||
private FeedMedia testMedia11 = null;
|
||||
|
||||
private DownloaderFactory origFactory = null;
|
||||
|
@ -61,7 +58,7 @@ public class DownloadServiceTest {
|
|||
EspressoTestUtils.clearDatabase();
|
||||
EspressoTestUtils.clearPreferences();
|
||||
origFactory = DownloadService.getDownloaderFactory();
|
||||
testFeed = setUpTestFeeds();
|
||||
Feed testFeed = setUpTestFeeds();
|
||||
testMedia11 = testFeed.getItemAtIndex(0).getMedia();
|
||||
}
|
||||
|
||||
|
|
|
@ -124,7 +124,6 @@ public class PlaybackServiceMediaPlayerTest {
|
|||
}
|
||||
|
||||
private Playable writeTestPlayable(String downloadUrl, String fileUrl) {
|
||||
final Context c = getInstrumentation().getTargetContext();
|
||||
Feed f = new Feed(0, null, "f", "l", "d", null, null, null, null, "i", null, null, "l", false);
|
||||
FeedPreferences prefs = new FeedPreferences(f.getId(), false, FeedPreferences.AutoDeleteAction.NO, VolumeAdaptionSetting.OFF, null, null);
|
||||
f.setPreferences(prefs);
|
||||
|
|
|
@ -1,20 +1,16 @@
|
|||
package de.test.antennapod.storage;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.filters.LargeTest;
|
||||
import androidx.test.filters.SmallTest;
|
||||
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.DBReader;
|
||||
import de.danoeh.antennapod.core.storage.FeedItemStatistics;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
import de.danoeh.antennapod.core.util.LongList;
|
||||
import org.junit.After;
|
||||
|
@ -103,7 +99,6 @@ public class DBReaderTest {
|
|||
|
||||
@Test
|
||||
public void testLoadFeedDataOfFeedItemlist() {
|
||||
final Context context = InstrumentationRegistry.getTargetContext();
|
||||
final int numFeeds = 10;
|
||||
final int numItems = 1;
|
||||
List<Feed> feeds = saveFeedlist(numFeeds, numItems, false);
|
||||
|
@ -313,24 +308,11 @@ public class DBReaderTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetFeedStatisticsCheckOrder() {
|
||||
final int NUM_FEEDS = 10;
|
||||
final int NUM_ITEMS = 10;
|
||||
List<Feed> feeds = DBTestUtils.saveFeedlist(NUM_FEEDS, NUM_ITEMS, false);
|
||||
List<FeedItemStatistics> statistics = DBReader.getFeedStatisticsList();
|
||||
assertNotNull(statistics);
|
||||
assertEquals(feeds.size(), statistics.size());
|
||||
for (int i = 0; i < NUM_FEEDS; i++) {
|
||||
assertEquals("Wrong entry at index " + i, feeds.get(i).getId(), statistics.get(i).getFeedID());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNavDrawerDataQueueEmptyNoUnreadItems() {
|
||||
final int NUM_FEEDS = 10;
|
||||
final int NUM_ITEMS = 10;
|
||||
List<Feed> feeds = DBTestUtils.saveFeedlist(NUM_FEEDS, NUM_ITEMS, true);
|
||||
DBTestUtils.saveFeedlist(NUM_FEEDS, NUM_ITEMS, true);
|
||||
DBReader.NavDrawerData navDrawerData = DBReader.getNavDrawerData();
|
||||
assertEquals(NUM_FEEDS, navDrawerData.feeds.size());
|
||||
assertEquals(0, navDrawerData.numNewItems);
|
||||
|
|
|
@ -177,7 +177,7 @@ public class DBWriterTest {
|
|||
assertTrue(queue.size() != 0);
|
||||
|
||||
DBWriter.deleteFeedMediaOfItem(getInstrumentation().getTargetContext(), media.getId());
|
||||
Awaitility.await().until(() -> dest.exists() == false);
|
||||
Awaitility.await().until(() -> !dest.exists());
|
||||
media = DBReader.getFeedMedia(media.getId());
|
||||
assertNotNull(media);
|
||||
assertFalse(dest.exists());
|
||||
|
@ -422,7 +422,6 @@ public class DBWriterTest {
|
|||
}
|
||||
|
||||
private FeedMedia playbackHistorySetup(Date playbackCompletionDate) {
|
||||
final Context context = 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);
|
||||
|
@ -558,7 +557,6 @@ public class DBWriterTest {
|
|||
|
||||
@Test
|
||||
public void testAddQueueItemMultipleItems() throws InterruptedException, ExecutionException, TimeoutException {
|
||||
final Context context = getInstrumentation().getTargetContext();
|
||||
final int NUM_ITEMS = 10;
|
||||
|
||||
Feed feed = queueTestSetupMultipleItems(NUM_ITEMS);
|
||||
|
@ -583,7 +581,7 @@ public class DBWriterTest {
|
|||
public void testClearQueue() throws InterruptedException, ExecutionException, TimeoutException {
|
||||
final int NUM_ITEMS = 10;
|
||||
|
||||
Feed feed = queueTestSetupMultipleItems(NUM_ITEMS);
|
||||
queueTestSetupMultipleItems(NUM_ITEMS);
|
||||
DBWriter.clearQueue().get(TIMEOUT, TimeUnit.SECONDS);
|
||||
PodDBAdapter adapter = PodDBAdapter.getInstance();
|
||||
adapter.open();
|
||||
|
@ -797,7 +795,7 @@ public class DBWriterTest {
|
|||
) {
|
||||
List<FeedItem> queue = DBReader.getQueue();
|
||||
List<Long> itemIdsActualList = toItemIds(queue);
|
||||
List<Long> itemIdsExpectedList = new ArrayList<Long>(itemIdsExpected.length);
|
||||
List<Long> itemIdsExpectedList = new ArrayList<>(itemIdsExpected.length);
|
||||
for (long id : itemIdsExpected) {
|
||||
itemIdsExpectedList.add(id);
|
||||
}
|
||||
|
@ -806,7 +804,7 @@ public class DBWriterTest {
|
|||
}
|
||||
|
||||
private static List<Long> toItemIds(List<FeedItem> items) {
|
||||
List<Long> itemIds = new ArrayList<Long>(items.size());
|
||||
List<Long> itemIds = new ArrayList<>(items.size());
|
||||
for(FeedItem item : items) {
|
||||
itemIds.add(item.getId());
|
||||
}
|
||||
|
|
|
@ -618,7 +618,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
|||
private final String feedUrl;
|
||||
|
||||
FeedViewAuthenticationDialog(Context context, int titleRes, String feedUrl) {
|
||||
super(context, titleRes, true, false, null, null);
|
||||
super(context, titleRes, true, null, null);
|
||||
this.feedUrl = feedUrl;
|
||||
}
|
||||
|
||||
|
@ -629,7 +629,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onConfirmed(String username, String password, boolean saveUsernamePassword) {
|
||||
protected void onConfirmed(String username, String password) {
|
||||
startFeedDownload(feedUrl, username, password);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ public class OpmlImportActivity extends AppCompatActivity {
|
|||
*/
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
Log.d(TAG, "Received result");
|
||||
if (resultCode == RESULT_CANCELED) {
|
||||
Log.d(TAG, "Activity was cancelled");
|
||||
|
|
|
@ -121,8 +121,9 @@ public class StorageErrorActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (resultCode == Activity.RESULT_OK &&
|
||||
requestCode == DirectoryChooserActivity.RESULT_CODE_DIR_SELECTED) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (resultCode == Activity.RESULT_OK
|
||||
&& requestCode == DirectoryChooserActivity.RESULT_CODE_DIR_SELECTED) {
|
||||
String dir = data.getStringExtra(DirectoryChooserActivity.RESULT_SELECTED_DIR);
|
||||
|
||||
File path;
|
||||
|
@ -131,19 +132,19 @@ public class StorageErrorActivity extends AppCompatActivity {
|
|||
} else {
|
||||
path = getExternalFilesDir(null);
|
||||
}
|
||||
if(path == null) {
|
||||
if (path == null) {
|
||||
return;
|
||||
}
|
||||
String message = null;
|
||||
if(!path.exists()) {
|
||||
if (!path.exists()) {
|
||||
message = String.format(getString(R.string.folder_does_not_exist_error), dir);
|
||||
} else if(!path.canRead()) {
|
||||
} else if (!path.canRead()) {
|
||||
message = String.format(getString(R.string.folder_not_readable_error), dir);
|
||||
} else if(!path.canWrite()) {
|
||||
} else if (!path.canWrite()) {
|
||||
message = String.format(getString(R.string.folder_not_writable_error), dir);
|
||||
}
|
||||
|
||||
if(message == null) {
|
||||
if (message == null) {
|
||||
Log.d(TAG, "Setting data folder: " + dir);
|
||||
UserPreferences.setDataFolder(dir);
|
||||
leaveErrorState();
|
||||
|
|
|
@ -190,8 +190,6 @@ public class GpodnetAuthenticationActivity extends AppCompatActivity {
|
|||
final AtomicReference<List<GpodnetDevice>> devices = new AtomicReference<>();
|
||||
new AsyncTask<GpodnetService, Void, List<GpodnetDevice>>() {
|
||||
|
||||
private volatile Exception exception;
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
|
@ -226,7 +224,6 @@ public class GpodnetAuthenticationActivity extends AppCompatActivity {
|
|||
return params[0].getDevices(username);
|
||||
} catch (GpodnetServiceException e) {
|
||||
e.printStackTrace();
|
||||
exception = e;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,13 +38,6 @@ public abstract class StatisticsListAdapter extends RecyclerView.Adapter<Recycle
|
|||
return statisticsData.size() + 1;
|
||||
}
|
||||
|
||||
public StatisticsItem getItem(int position) {
|
||||
if (position == 0) {
|
||||
return null;
|
||||
}
|
||||
return statisticsData.get(position - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position == 0 ? TYPE_HEADER : TYPE_FEED;
|
||||
|
|
|
@ -44,11 +44,6 @@ public class DownloadServiceCallbacksImpl implements DownloadServiceCallbacks {
|
|||
return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFeedParsed(Context context, Feed feed) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCreateReport() {
|
||||
return true;
|
||||
|
|
|
@ -28,8 +28,4 @@ public class PlaybackServiceCallbacksImpl implements PlaybackServiceCallbacks {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNotificationIconResource(Context context) {
|
||||
return R.drawable.ic_antenna;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package de.danoeh.antennapod.dialog;
|
|||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import de.danoeh.antennapod.R;
|
||||
|
||||
|
@ -13,8 +12,7 @@ import de.danoeh.antennapod.R;
|
|||
public abstract class AuthenticationDialog extends AlertDialog.Builder {
|
||||
|
||||
public AuthenticationDialog(Context context, int titleRes, boolean enableUsernameField,
|
||||
boolean showSaveCredentialsCheckbox, String usernameInitialValue,
|
||||
String passwordInitialValue) {
|
||||
String usernameInitialValue, String passwordInitialValue) {
|
||||
super(context);
|
||||
setTitle(titleRes);
|
||||
View rootView = View.inflate(context, R.layout.authentication_dialog, null);
|
||||
|
@ -22,14 +20,8 @@ public abstract class AuthenticationDialog extends AlertDialog.Builder {
|
|||
|
||||
final EditText etxtUsername = rootView.findViewById(R.id.etxtUsername);
|
||||
final EditText etxtPassword = rootView.findViewById(R.id.etxtPassword);
|
||||
final CheckBox saveUsernamePassword = rootView.findViewById(R.id.chkSaveUsernamePassword);
|
||||
|
||||
etxtUsername.setEnabled(enableUsernameField);
|
||||
if (showSaveCredentialsCheckbox) {
|
||||
saveUsernamePassword.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
saveUsernamePassword.setVisibility(View.GONE);
|
||||
}
|
||||
if (usernameInitialValue != null) {
|
||||
etxtUsername.setText(usernameInitialValue);
|
||||
}
|
||||
|
@ -39,13 +31,12 @@ public abstract class AuthenticationDialog extends AlertDialog.Builder {
|
|||
setOnCancelListener(dialog -> onCancelled());
|
||||
setNegativeButton(R.string.cancel_label, null);
|
||||
setPositiveButton(R.string.confirm_label, (dialog, which)
|
||||
-> onConfirmed(etxtUsername.getText().toString(), etxtPassword.getText().toString(),
|
||||
showSaveCredentialsCheckbox && saveUsernamePassword.isChecked()));
|
||||
-> onConfirmed(etxtUsername.getText().toString(), etxtPassword.getText().toString()));
|
||||
}
|
||||
|
||||
protected void onCancelled() {
|
||||
|
||||
}
|
||||
|
||||
protected abstract void onConfirmed(String username, String password, boolean saveUsernamePassword);
|
||||
protected abstract void onConfirmed(String username, String password);
|
||||
}
|
||||
|
|
|
@ -84,16 +84,16 @@ public class ProxyDialog {
|
|||
String host = etHost.getText().toString();
|
||||
String port = etPort.getText().toString();
|
||||
String username = etUsername.getText().toString();
|
||||
if(TextUtils.isEmpty(username)) {
|
||||
if (TextUtils.isEmpty(username)) {
|
||||
username = null;
|
||||
}
|
||||
String password = etPassword.getText().toString();
|
||||
if(TextUtils.isEmpty(password)) {
|
||||
if (TextUtils.isEmpty(password)) {
|
||||
password = null;
|
||||
}
|
||||
int portValue = 0;
|
||||
if(!TextUtils.isEmpty(port)) {
|
||||
portValue = Integer.valueOf(port);
|
||||
if (!TextUtils.isEmpty(port)) {
|
||||
portValue = Integer.parseInt(port);
|
||||
}
|
||||
if (Proxy.Type.valueOf(type) == Proxy.Type.SOCKS) {
|
||||
proxy = ProxyConfig.socks(host, portValue, username, password);
|
||||
|
@ -257,8 +257,8 @@ public class ProxyDialog {
|
|||
String username = etUsername.getText().toString();
|
||||
String password = etPassword.getText().toString();
|
||||
int portValue = 8080;
|
||||
if(!TextUtils.isEmpty(port)) {
|
||||
portValue = Integer.valueOf(port);
|
||||
if (!TextUtils.isEmpty(port)) {
|
||||
portValue = Integer.parseInt(port);
|
||||
}
|
||||
SocketAddress address = InetSocketAddress.createUnresolved(host, portValue);
|
||||
Proxy.Type proxyType = Proxy.Type.valueOf(type.toUpperCase());
|
||||
|
@ -268,7 +268,7 @@ public class ProxyDialog {
|
|||
.proxy(proxy);
|
||||
builder.interceptors().clear();
|
||||
OkHttpClient client = builder.build();
|
||||
if(!TextUtils.isEmpty(username)) {
|
||||
if (!TextUtils.isEmpty(username)) {
|
||||
String credentials = Credentials.basic(username, password);
|
||||
client.interceptors().add(chain -> {
|
||||
Request request = chain.request().newBuilder()
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.util.Set;
|
|||
* supports swiping to mark as read.
|
||||
*/
|
||||
public class AllEpisodesFragment extends EpisodesListFragment {
|
||||
public static final String TAG = "AllEpisodesFragment";
|
||||
private static final String PREF_NAME = "PrefAllEpisodesFragment";
|
||||
private static final String PREF_FILTER = "filter";
|
||||
|
||||
|
|
|
@ -200,10 +200,10 @@ public class FeedSettingsFragment extends Fragment {
|
|||
private void setupAuthentificationPreference() {
|
||||
findPreference("authentication").setOnPreferenceClickListener(preference -> {
|
||||
new AuthenticationDialog(getContext(),
|
||||
R.string.authentication_label, true, false,
|
||||
R.string.authentication_label, true,
|
||||
feedPreferences.getUsername(), feedPreferences.getPassword()) {
|
||||
@Override
|
||||
protected void onConfirmed(String username, String password, boolean saveUsernamePassword) {
|
||||
protected void onConfirmed(String username, String password) {
|
||||
feedPreferences.setUsername(username);
|
||||
feedPreferences.setPassword(password);
|
||||
feed.savePreferences();
|
||||
|
|
|
@ -38,16 +38,6 @@ public class ItemPagerFragment extends Fragment {
|
|||
private static final String ARG_FEEDITEMS = "feeditems";
|
||||
private static final String ARG_FEEDITEM_POS = "feeditem_pos";
|
||||
|
||||
/**
|
||||
* Creates a new instance of an ItemPagerFragment.
|
||||
*
|
||||
* @param feeditem The ID of the FeedItem that should be displayed.
|
||||
* @return The ItemFragment instance
|
||||
*/
|
||||
public static ItemPagerFragment newInstance(long feeditem) {
|
||||
return newInstance(new long[] { feeditem }, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of an ItemPagerFragment.
|
||||
*
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package de.danoeh.antennapod.fragment.gpodnet;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -28,7 +27,7 @@ public class GpodnetMainFragment extends Fragment {
|
|||
((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
|
||||
|
||||
ViewPager viewPager = root.findViewById(R.id.viewpager);
|
||||
GpodnetPagerAdapter pagerAdapter = new GpodnetPagerAdapter(getChildFragmentManager(), getResources());
|
||||
GpodnetPagerAdapter pagerAdapter = new GpodnetPagerAdapter(getChildFragmentManager());
|
||||
viewPager.setAdapter(pagerAdapter);
|
||||
|
||||
// Give the TabLayout the ViewPager
|
||||
|
@ -39,18 +38,13 @@ public class GpodnetMainFragment extends Fragment {
|
|||
}
|
||||
|
||||
public class GpodnetPagerAdapter extends FragmentPagerAdapter {
|
||||
|
||||
|
||||
private static final int NUM_PAGES = 2;
|
||||
private static final int POS_TOPLIST = 0;
|
||||
private static final int POS_TAGS = 1;
|
||||
private static final int POS_SUGGESTIONS = 2;
|
||||
|
||||
final Resources resources;
|
||||
|
||||
public GpodnetPagerAdapter(FragmentManager fm, Resources resources) {
|
||||
public GpodnetPagerAdapter(FragmentManager fm) {
|
||||
super(fm);
|
||||
this.resources = resources;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -63,11 +63,11 @@ public class GpodderPreferencesFragment extends PreferenceFragmentCompat {
|
|||
findPreference(PREF_GPODNET_SETLOGIN_INFORMATION)
|
||||
.setOnPreferenceClickListener(preference -> {
|
||||
AuthenticationDialog dialog = new AuthenticationDialog(activity,
|
||||
R.string.pref_gpodnet_setlogin_information_title, false, false, GpodnetPreferences.getUsername(),
|
||||
R.string.pref_gpodnet_setlogin_information_title, false, GpodnetPreferences.getUsername(),
|
||||
null) {
|
||||
|
||||
@Override
|
||||
protected void onConfirmed(String username, String password, boolean saveUsernamePassword) {
|
||||
protected void onConfirmed(String username, String password) {
|
||||
GpodnetPreferences.setPassword(password);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -96,8 +96,7 @@ public class NetworkPreferencesFragment extends PreferenceFragmentCompat {
|
|||
private void setParallelDownloadsText(int downloads) {
|
||||
final Resources res = getActivity().getResources();
|
||||
|
||||
String s = Integer.toString(downloads)
|
||||
+ res.getString(R.string.parallel_downloads_suffix);
|
||||
String s = downloads + res.getString(R.string.parallel_downloads_suffix);
|
||||
findPreference(UserPreferences.PREF_PARALLEL_DOWNLOADS).setSummary(s);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ import com.google.android.material.snackbar.Snackbar;
|
|||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.activity.PreferenceActivity;
|
||||
|
@ -19,7 +18,6 @@ import org.apache.commons.lang3.ArrayUtils;
|
|||
import java.util.List;
|
||||
|
||||
public class UserInterfacePreferencesFragment extends PreferenceFragmentCompat {
|
||||
private static final String PREF_EXPANDED_NOTIFICATION = "prefExpandNotify";
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
|
@ -59,26 +57,26 @@ public class UserInterfacePreferencesFragment extends PreferenceFragmentCompat {
|
|||
|
||||
findPreference(UserPreferences.PREF_BACK_BUTTON_BEHAVIOR)
|
||||
.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
if (newValue.equals("page")) {
|
||||
final Context context = getActivity();
|
||||
final String[] navTitles = context.getResources().getStringArray(R.array.back_button_go_to_pages);
|
||||
final String[] navTags = context.getResources().getStringArray(R.array.back_button_go_to_pages_tags);
|
||||
final String[] choice = { UserPreferences.getBackButtonGoToPage() };
|
||||
if (!newValue.equals("page")) {
|
||||
return true;
|
||||
}
|
||||
final Context context = getActivity();
|
||||
final String[] navTitles = context.getResources().getStringArray(R.array.back_button_go_to_pages);
|
||||
final String[] navTags = context.getResources().getStringArray(R.array.back_button_go_to_pages_tags);
|
||||
final String[] choice = { UserPreferences.getBackButtonGoToPage() };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle(R.string.back_button_go_to_page_title);
|
||||
builder.setSingleChoiceItems(navTitles, ArrayUtils.indexOf(navTags, UserPreferences.getBackButtonGoToPage()), (dialogInterface, i) -> {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle(R.string.back_button_go_to_page_title);
|
||||
builder.setSingleChoiceItems(navTitles, ArrayUtils.indexOf(navTags,
|
||||
UserPreferences.getBackButtonGoToPage()), (dialogInterface, i) -> {
|
||||
if (i >= 0) {
|
||||
choice[0] = navTags[i];
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(R.string.confirm_label, (dialogInterface, i) -> UserPreferences.setBackButtonGoToPage(choice[0]));
|
||||
builder.setNegativeButton(R.string.cancel_label, null);
|
||||
builder.create().show();
|
||||
return true;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
builder.setPositiveButton(R.string.confirm_label, (dialogInterface, i) -> UserPreferences.setBackButtonGoToPage(choice[0]));
|
||||
builder.setNegativeButton(R.string.cancel_label, null);
|
||||
builder.create().show();
|
||||
return true;
|
||||
});
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 26) {
|
||||
|
|
|
@ -41,8 +41,7 @@ public class FeedItemMenuHandler {
|
|||
* @param selectedItem The FeedItem for which the menu is supposed to be prepared
|
||||
* @return Returns true if selectedItem is not null.
|
||||
*/
|
||||
public static boolean onPrepareMenu(Menu menu,
|
||||
FeedItem selectedItem) {
|
||||
public static boolean onPrepareMenu(Menu menu, FeedItem selectedItem) {
|
||||
if (menu == null || selectedItem == null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -146,15 +145,13 @@ public class FeedItemMenuHandler {
|
|||
}
|
||||
|
||||
/**
|
||||
* The same method as onPrepareMenu(MenuInterface, FeedItem, boolean, QueueAccess), but lets the
|
||||
* The same method as {@link #onPrepareMenu(Menu, FeedItem)}, but lets the
|
||||
* caller also specify a list of menu items that should not be shown.
|
||||
*
|
||||
* @param excludeIds Menu item that should be excluded
|
||||
* @return true if selectedItem is not null.
|
||||
*/
|
||||
public static boolean onPrepareMenu(Menu menu,
|
||||
FeedItem selectedItem,
|
||||
int... excludeIds) {
|
||||
public static boolean onPrepareMenu(Menu menu, FeedItem selectedItem, int... excludeIds) {
|
||||
if (menu == null || selectedItem == null ) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -6,8 +6,6 @@ import android.content.SharedPreferences;
|
|||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.receiver.SPAReceiver;
|
||||
|
||||
|
@ -22,7 +20,6 @@ public class SPAUtil {
|
|||
private SPAUtil() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sends an ACTION_SP_APPS_QUERY_FEEDS intent to all AntennaPod Single Purpose apps.
|
||||
* The receiving single purpose apps will then send their feeds back to AntennaPod via an
|
||||
|
@ -53,17 +50,4 @@ public class SPAUtil {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets all preferences created by this class. Should only be used for debug purposes.
|
||||
*/
|
||||
public static void resetSPAPreferences(Context c) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
Validate.notNull(c);
|
||||
SharedPreferences.Editor editor = PreferenceManager
|
||||
.getDefaultSharedPreferences(c.getApplicationContext()).edit();
|
||||
editor.putBoolean(PREF_HAS_QUERIED_SP_APPS, false);
|
||||
editor.apply();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ public class CircularProgressBar extends View {
|
|||
private float percentage = 0;
|
||||
private float targetPercentage = 0;
|
||||
private Object tag = null;
|
||||
private final RectF bounds = new RectF();
|
||||
|
||||
public CircularProgressBar(Context context) {
|
||||
super(context);
|
||||
|
@ -70,7 +71,7 @@ public class CircularProgressBar extends View {
|
|||
float padding = getHeight() * 0.07f;
|
||||
paintBackground.setStrokeWidth(getHeight() * 0.02f);
|
||||
paintProgress.setStrokeWidth(padding);
|
||||
RectF bounds = new RectF(padding, padding, getWidth() - padding, getHeight() - padding);
|
||||
bounds.set(padding, padding, getWidth() - padding, getHeight() - padding);
|
||||
canvas.drawArc(bounds, 0, 360, false, paintBackground);
|
||||
|
||||
if (percentage > EPSILON && 1 - percentage > EPSILON) {
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
package de.danoeh.antennapod.view;
|
||||
|
||||
public interface OnSwipeGesture {
|
||||
|
||||
boolean onSwipeLeftToRight();
|
||||
|
||||
boolean onSwipeRightToLeft();
|
||||
|
||||
}
|
|
@ -24,6 +24,7 @@ public class PlaybackSpeedIndicatorView extends View {
|
|||
private float degreePerFrame = 2;
|
||||
private float paddingArc = 20;
|
||||
private float paddingIndicator = 10;
|
||||
private RectF arcBounds = new RectF();
|
||||
|
||||
public PlaybackSpeedIndicatorView(Context context) {
|
||||
super(context);
|
||||
|
@ -100,7 +101,7 @@ public class PlaybackSpeedIndicatorView extends View {
|
|||
canvas.drawPath(trianglePath, indicatorPaint);
|
||||
|
||||
arcPaint.setStrokeWidth(getHeight() / 15f);
|
||||
RectF arcBounds = new RectF(paddingArc, paddingArc, getWidth() - paddingArc, getHeight() - paddingArc);
|
||||
arcBounds.set(paddingArc, paddingArc, getWidth() - paddingArc, getHeight() - paddingArc);
|
||||
canvas.drawArc(arcBounds, -180 - 45, 90 + 45 + angle - PADDING_ANGLE, false, arcPaint);
|
||||
canvas.drawArc(arcBounds, -90 + PADDING_ANGLE + angle, 90 + 45 - PADDING_ANGLE - angle, false, arcPaint);
|
||||
|
||||
|
|
|
@ -11,12 +11,10 @@ import android.widget.TextView;
|
|||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.joanzapata.iconify.widget.IconTextView;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.view.CircularProgressBar;
|
||||
|
||||
public class DownloadItemViewHolder extends RecyclerView.ViewHolder {
|
||||
public final View secondaryActionButton;
|
||||
public final ImageView secondaryActionIcon;
|
||||
public final CircularProgressBar secondaryActionProgress;
|
||||
public final IconTextView icon;
|
||||
public final TextView title;
|
||||
public final TextView type;
|
||||
|
@ -29,7 +27,6 @@ public class DownloadItemViewHolder extends RecyclerView.ViewHolder {
|
|||
type = itemView.findViewById(R.id.txtvType);
|
||||
icon = itemView.findViewById(R.id.txtvIcon);
|
||||
reason = itemView.findViewById(R.id.txtvReason);
|
||||
secondaryActionProgress = itemView.findViewById(R.id.secondaryActionProgress);
|
||||
secondaryActionButton = itemView.findViewById(R.id.secondaryActionButton);
|
||||
secondaryActionIcon = itemView.findViewById(R.id.secondaryActionIcon);
|
||||
title = itemView.findViewById(R.id.txtvTitle);
|
||||
|
|
|
@ -64,7 +64,6 @@
|
|||
android:layout_height="16dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:indeterminateOnly="true"
|
||||
android:layout_centerInParent="true"
|
||||
tools:background="@android:color/holo_red_light" />
|
||||
|
||||
<TextView
|
||||
|
|
|
@ -27,10 +27,4 @@
|
|||
android:focusableInTouchMode="true"
|
||||
android:cursorVisible="true"/>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/chkSaveUsernamePassword"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:text="@string/save_username_password_label"/>
|
||||
</LinearLayout>
|
|
@ -21,7 +21,8 @@
|
|||
android:layout_marginStart="@dimen/listitem_threeline_textleftpadding"
|
||||
android:textSize="40dp"
|
||||
android:gravity="center"
|
||||
tools:text="X"/>
|
||||
tools:text="X"
|
||||
tools:ignore="SpUsage"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
android:orientation="vertical"
|
||||
android:padding="16dp">
|
||||
|
||||
<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RadioGroup
|
||||
android:id="@+id/radio_filter_group"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -104,7 +104,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
tools:background="@android:color/holo_blue_bright">
|
||||
tools:background="@android:color/holo_blue_bright"
|
||||
android:baselineAligned="false">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
|
@ -123,7 +124,7 @@
|
|||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
tools:src="@drawable/ic_settings_grey600_24dp" />
|
||||
tools:src="@drawable/ic_settings_black" />
|
||||
|
||||
<TextView
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Button"
|
||||
|
@ -151,7 +152,7 @@
|
|||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
tools:src="@drawable/ic_settings_grey600_24dp" />
|
||||
tools:src="@drawable/ic_settings_black" />
|
||||
|
||||
<TextView
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Button"
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/listitem_iconwithtext_height"
|
||||
android:foreground="?attr/selectableItemBackground"
|
||||
tools:background="@android:color/darker_gray">
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/listitem_iconwithtext_height"
|
||||
android:foreground="?attr/selectableItemBackground" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imgvCover"
|
||||
|
@ -24,8 +23,7 @@
|
|||
android:layout_marginStart="@dimen/listitem_icon_leftpadding"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
tools:src="@drawable/ic_file_download_grey600_24dp"
|
||||
tools:background="@android:color/holo_green_dark"/>
|
||||
tools:src="@drawable/ic_download_black"/>
|
||||
|
||||
|
||||
<TextView
|
||||
|
@ -44,9 +42,7 @@
|
|||
android:layout_marginEnd="48dp"
|
||||
android:layout_toRightOf="@id/imgvCover"
|
||||
android:layout_toEndOf="@id/imgvCover"
|
||||
tools:text="Navigation item title"
|
||||
tools:background="@android:color/holo_green_dark"
|
||||
/>
|
||||
tools:text="Navigation item title" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvCount"
|
||||
|
@ -62,6 +58,5 @@
|
|||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
tools:text="23"
|
||||
tools:background="@android:color/holo_green_dark"/>
|
||||
tools:text="23" />
|
||||
</RelativeLayout>
|
||||
|
|
|
@ -3,11 +3,10 @@ package de.danoeh.antennapod.core;
|
|||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
|
||||
import de.danoeh.antennapod.core.feed.Feed;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadRequest;
|
||||
|
||||
/**
|
||||
* Callbacks for the DownloadService of the core module
|
||||
* Callbacks for the DownloadService of the core module.
|
||||
*/
|
||||
public interface DownloadServiceCallbacks {
|
||||
|
||||
|
@ -42,13 +41,6 @@ public interface DownloadServiceCallbacks {
|
|||
*/
|
||||
PendingIntent getReportNotificationContentIntent(Context context);
|
||||
|
||||
/**
|
||||
* Called by the FeedSyncThread after a feed has been downloaded and parsed.
|
||||
*
|
||||
* @param feed The non-null feed that has been parsed.
|
||||
*/
|
||||
void onFeedParsed(Context context, Feed feed);
|
||||
|
||||
/**
|
||||
* Returns true if the DownloadService should create a report that shows the number of failed
|
||||
* downloads when the service shuts down.
|
||||
|
|
|
@ -26,9 +26,4 @@ public interface PlaybackServiceCallbacks {
|
|||
* finishes.
|
||||
*/
|
||||
boolean useQueue();
|
||||
|
||||
/**
|
||||
* Returns a drawable resource that is used for the notification of the playback service.
|
||||
*/
|
||||
int getNotificationIconResource(Context context);
|
||||
}
|
||||
|
|
|
@ -59,18 +59,6 @@ public class QueueEvent {
|
|||
return new QueueEvent(Action.MOVED, item, null, newPosition);
|
||||
}
|
||||
|
||||
public boolean contains(long id) {
|
||||
if(item != null) {
|
||||
return item.getId() == id;
|
||||
}
|
||||
for(FeedItem item : items) {
|
||||
if(item.getId() == id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
|
||||
|
|
|
@ -224,14 +224,6 @@ public class Feed extends FeedFile implements ImageResource {
|
|||
return feed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of FeedItems.
|
||||
*
|
||||
*/
|
||||
public int getNumOfItems() {
|
||||
return items.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the item at the specified index.
|
||||
*
|
||||
|
|
|
@ -221,16 +221,6 @@ public class FeedMedia extends FeedFile implements Playable {
|
|||
((PlaybackPreferences.getCurrentPlayerStatus() == PlaybackPreferences.PLAYER_STATUS_PLAYING));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads playback preferences to determine whether this FeedMedia object is
|
||||
* currently being played and the current player status is paused.
|
||||
*/
|
||||
public boolean isCurrentlyPaused() {
|
||||
return isPlaying() &&
|
||||
((PlaybackPreferences.getCurrentPlayerStatus() == PlaybackPreferences.PLAYER_STATUS_PAUSED));
|
||||
}
|
||||
|
||||
|
||||
public boolean hasAlmostEnded() {
|
||||
int smartMarkAsPlayedSecs = UserPreferences.getSmartMarkAsPlayedSecs();
|
||||
return this.position >= this.duration - smartMarkAsPlayedSecs * 1000;
|
||||
|
|
|
@ -199,14 +199,14 @@ public class GpodnetEpisodeAction {
|
|||
}
|
||||
|
||||
public String writeToString() {
|
||||
return this.podcast + "\t" +
|
||||
this.episode + "\t" +
|
||||
this.deviceId + "\t" +
|
||||
this.action + "\t" +
|
||||
this.timestamp.getTime() + "\t" +
|
||||
String.valueOf(this.started) + "\t" +
|
||||
String.valueOf(this.position) + "\t" +
|
||||
String.valueOf(this.total);
|
||||
return this.podcast + "\t"
|
||||
+ this.episode + "\t"
|
||||
+ this.deviceId + "\t"
|
||||
+ this.action + "\t"
|
||||
+ this.timestamp.getTime() + "\t"
|
||||
+ this.started + "\t"
|
||||
+ this.position + "\t"
|
||||
+ this.total;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,16 +2,13 @@ package de.danoeh.antennapod.core.service.download.handler;
|
|||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import de.danoeh.antennapod.core.ClientConfig;
|
||||
import de.danoeh.antennapod.core.feed.Feed;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadRequest;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.storage.DBTasks;
|
||||
import de.danoeh.antennapod.core.storage.DownloadRequestException;
|
||||
import de.danoeh.antennapod.core.storage.DownloadRequester;
|
||||
import de.danoeh.antennapod.core.syndication.handler.FeedHandlerResult;
|
||||
import java.util.List;
|
||||
|
||||
public class FeedSyncTask {
|
||||
private static final String TAG = "FeedParserTask";
|
||||
|
@ -46,8 +43,6 @@ public class FeedSyncTask {
|
|||
Log.e(TAG, "Error trying to load next page", e);
|
||||
}
|
||||
}
|
||||
|
||||
ClientConfig.downloadServiceCallbacks.onFeedParsed(context, savedFeed);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -372,7 +372,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
|
||||
private MediaBrowserCompat.MediaItem createBrowsableMediaItemForFeed(Feed feed) {
|
||||
MediaDescriptionCompat.Builder builder = new MediaDescriptionCompat.Builder()
|
||||
.setMediaId("FeedId:" + Long.toString(feed.getId()))
|
||||
.setMediaId("FeedId:" + feed.getId())
|
||||
.setTitle(feed.getTitle())
|
||||
.setDescription(feed.getDescription())
|
||||
.setSubtitle(feed.getCustomTitle());
|
||||
|
|
|
@ -216,11 +216,11 @@ public class PlaybackServiceTaskManager {
|
|||
* @throws java.lang.IllegalArgumentException if waitingTime <= 0
|
||||
*/
|
||||
public synchronized void setSleepTimer(long waitingTime, boolean shakeToReset, boolean vibrate) {
|
||||
if(waitingTime <= 0) {
|
||||
if (waitingTime <= 0) {
|
||||
throw new IllegalArgumentException("Waiting time <= 0");
|
||||
}
|
||||
|
||||
Log.d(TAG, "Setting sleep timer to " + Long.toString(waitingTime) + " milliseconds");
|
||||
Log.d(TAG, "Setting sleep timer to " + waitingTime + " milliseconds");
|
||||
if (isSleepTimerActive()) {
|
||||
sleepTimerFuture.cancel(true);
|
||||
}
|
||||
|
|
|
@ -160,12 +160,12 @@ public final class DBReader {
|
|||
}
|
||||
|
||||
/**
|
||||
* Loads the list of FeedItems for a certain Feed-object. This method should NOT be used if the FeedItems are not
|
||||
* used. In order to get information ABOUT the list of FeedItems, consider using {@link #getFeedStatisticsList()} instead.
|
||||
* Loads the list of FeedItems for a certain Feed-object.
|
||||
* This method should NOT be used if the FeedItems are not used.
|
||||
*
|
||||
* @param feed The Feed whose items should be loaded
|
||||
* @return A list with the FeedItems of the Feed. The Feed-attribute of the FeedItems will already be set correctly.
|
||||
* The method does NOT change the items-attribute of the feed.
|
||||
* The method does NOT change the items-attribute of the feed.
|
||||
*/
|
||||
public static List<FeedItem> getFeedItemList(final Feed feed) {
|
||||
Log.d(TAG, "getFeedItemList() called with: " + "feed = [" + feed + "]");
|
||||
|
@ -273,8 +273,7 @@ public final class DBReader {
|
|||
* Loads the IDs of the FeedItems in the queue. This method should be preferred over
|
||||
* {@link #getQueue()} if the FeedItems of the queue are not needed.
|
||||
*
|
||||
* @return A list of IDs sorted by the same order as the queue. The caller can wrap the returned
|
||||
* list in a {@link de.danoeh.antennapod.core.util.QueueAccess} object for easier access to the queue's properties.
|
||||
* @return A list of IDs sorted by the same order as the queue.
|
||||
*/
|
||||
public static LongList getQueueIDList() {
|
||||
Log.d(TAG, "getQueueIDList() called");
|
||||
|
@ -307,8 +306,7 @@ public final class DBReader {
|
|||
* Loads a list of the FeedItems in the queue. If the FeedItems of the queue are not used directly, consider using
|
||||
* {@link #getQueueIDList()} instead.
|
||||
*
|
||||
* @return A list of FeedItems sorted by the same order as the queue. The caller can wrap the returned
|
||||
* list in a {@link de.danoeh.antennapod.core.util.QueueAccess} object for easier access to the queue's properties.
|
||||
* @return A list of FeedItems sorted by the same order as the queue.
|
||||
*/
|
||||
@NonNull
|
||||
public static List<FeedItem> getQueue() {
|
||||
|
@ -545,34 +543,6 @@ public final class DBReader {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the FeedItemStatistics objects of all Feeds in the database. This method should be preferred over
|
||||
* {@link #getFeedItemList(Feed)} if only metadata about
|
||||
* the FeedItems is needed.
|
||||
*
|
||||
* @return A list of FeedItemStatistics objects sorted alphabetically by their Feed's title.
|
||||
*/
|
||||
public static List<FeedItemStatistics> getFeedStatisticsList() {
|
||||
Log.d(TAG, "getFeedStatisticsList() called");
|
||||
PodDBAdapter adapter = PodDBAdapter.getInstance();
|
||||
adapter.open();
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = adapter.getFeedStatisticsCursor();
|
||||
List<FeedItemStatistics> result = new ArrayList<>(cursor.getCount());
|
||||
while (cursor.moveToNext()) {
|
||||
FeedItemStatistics fis = FeedItemStatistics.fromCursor(cursor);
|
||||
result.add(fis);
|
||||
}
|
||||
return result;
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
adapter.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a specific Feed from the database.
|
||||
*
|
||||
|
|
|
@ -93,7 +93,7 @@ public class DBWriter {
|
|||
private static boolean deleteFeedMediaSynchronous(
|
||||
@NonNull Context context, @NonNull FeedMedia media) {
|
||||
Log.i(TAG, String.format("Requested to delete FeedMedia [id=%d, title=%s, downloaded=%s",
|
||||
media.getId(), media.getEpisodeTitle(), String.valueOf(media.isDownloaded())));
|
||||
media.getId(), media.getEpisodeTitle(), media.isDownloaded()));
|
||||
if (media.isDownloaded()) {
|
||||
// delete downloaded media file
|
||||
File mediaFile = new File(media.getFile_url());
|
||||
|
|
|
@ -1,81 +0,0 @@
|
|||
package de.danoeh.antennapod.core.storage;
|
||||
|
||||
import android.database.Cursor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Contains information about a feed's items.
|
||||
*/
|
||||
public class FeedItemStatistics {
|
||||
private final long feedID;
|
||||
private final int numberOfItems;
|
||||
private final int numberOfNewItems;
|
||||
private final int numberOfInProgressItems;
|
||||
private final Date lastUpdate;
|
||||
private static final Date UNKNOWN_DATE = new Date(0);
|
||||
|
||||
|
||||
/**
|
||||
* Creates new FeedItemStatistics object.
|
||||
*
|
||||
* @param feedID ID of the feed.
|
||||
* @param numberOfItems Number of items that this feed has.
|
||||
* @param numberOfNewItems Number of unread items this feed has.
|
||||
* @param numberOfInProgressItems Number of items that the user has started listening to.
|
||||
* @param lastUpdate pubDate of the latest episode. A lastUpdate value of 0 will be interpreted as DATE_UNKOWN if
|
||||
* numberOfItems is 0.
|
||||
*/
|
||||
private FeedItemStatistics(long feedID, int numberOfItems, int numberOfNewItems, int numberOfInProgressItems, Date lastUpdate) {
|
||||
this.feedID = feedID;
|
||||
this.numberOfItems = numberOfItems;
|
||||
this.numberOfNewItems = numberOfNewItems;
|
||||
this.numberOfInProgressItems = numberOfInProgressItems;
|
||||
if (numberOfItems > 0) {
|
||||
this.lastUpdate = (lastUpdate != null) ? (Date) lastUpdate.clone() : null;
|
||||
} else {
|
||||
this.lastUpdate = UNKNOWN_DATE;
|
||||
}
|
||||
}
|
||||
|
||||
public static FeedItemStatistics fromCursor(Cursor cursor) {
|
||||
return new FeedItemStatistics(
|
||||
cursor.getLong(0),
|
||||
cursor.getInt(1),
|
||||
cursor.getInt(2),
|
||||
cursor.getInt(4),
|
||||
new Date(cursor.getLong(3)));
|
||||
}
|
||||
|
||||
public long getFeedID() {
|
||||
return feedID;
|
||||
}
|
||||
|
||||
public int getNumberOfItems() {
|
||||
return numberOfItems;
|
||||
}
|
||||
|
||||
public int getNumberOfNewItems() {
|
||||
return numberOfNewItems;
|
||||
}
|
||||
|
||||
public int getNumberOfInProgressItems() {
|
||||
return numberOfInProgressItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the pubDate of the latest item in the feed. Users of this method
|
||||
* should check if this value is unkown or not by calling lastUpdateKnown() first.
|
||||
*/
|
||||
public Date getLastUpdate() {
|
||||
return (lastUpdate != null) ? (Date) lastUpdate.clone() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the lastUpdate value is known. The lastUpdate value is unkown if the
|
||||
* feed has no items.
|
||||
*/
|
||||
public boolean lastUpdateKnown() {
|
||||
return lastUpdate != UNKNOWN_DATE;
|
||||
}
|
||||
}
|
|
@ -36,16 +36,7 @@ public class AtomText extends SyndElement {
|
|||
}
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,21 +37,6 @@ public class SyndTypeUtils {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Should be used if mime-type of enclosure tag is not supported. This
|
||||
* method will check if the mime-type of the file extension is supported. If
|
||||
* the type is not supported, this method will return null.
|
||||
*/
|
||||
public static String getValidMimeTypeFromUrl(String url) {
|
||||
String type = getMimeTypeFromUrl(url);
|
||||
if (enclosureTypeValid(type)) {
|
||||
return type;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be used if mime-type of enclosure tag is not supported. This
|
||||
* method will return the mime-type of the file extension.
|
||||
|
|
|
@ -8,16 +8,4 @@ public class InvalidFeedException extends Exception {
|
|||
|
||||
public InvalidFeedException() {
|
||||
}
|
||||
|
||||
public InvalidFeedException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public InvalidFeedException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public InvalidFeedException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
package de.danoeh.antennapod.core.util;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
|
||||
/**
|
||||
* Provides methods for accessing the queue. It is possible to load only a part of the information about the queue that
|
||||
* is stored in the database (e.g. sometimes the user just has to test if a specific item is contained in the List.
|
||||
* QueueAccess provides an interface for accessing the queue without having to care about the type of the queue
|
||||
* representation.
|
||||
*/
|
||||
public abstract class QueueAccess {
|
||||
/**
|
||||
* Returns true if the item is in the queue, false otherwise.
|
||||
*/
|
||||
public abstract boolean contains(long id);
|
||||
|
||||
/**
|
||||
* Removes the item from the queue.
|
||||
*
|
||||
* @return true if the queue was modified by this operation.
|
||||
*/
|
||||
public abstract boolean remove(long id);
|
||||
|
||||
private QueueAccess() {
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package de.danoeh.antennapod.core.util.exception;
|
||||
|
||||
import de.danoeh.antennapod.core.feed.FeedMedia;
|
||||
|
||||
public class MediaFileNotFoundException extends Exception {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final FeedMedia media;
|
||||
|
||||
public MediaFileNotFoundException(String msg, FeedMedia media) {
|
||||
super(msg);
|
||||
this.media = media;
|
||||
}
|
||||
|
||||
public FeedMedia getMedia() {
|
||||
return media;
|
||||
}
|
||||
}
|
|
@ -43,9 +43,7 @@ public class ID3Reader {
|
|||
onNoTagHeaderFound();
|
||||
} else {
|
||||
rc = onStartTagHeader(tagHeader);
|
||||
if (rc == ACTION_SKIP) {
|
||||
onEndTag();
|
||||
} else {
|
||||
if (rc != ACTION_SKIP) {
|
||||
while (readerPosition < tagHeader.getSize()) {
|
||||
FrameHeader frameHeader = createFrameHeader(readChars(input, HEADER_LENGTH));
|
||||
if (checkForNullString(frameHeader.getId())) {
|
||||
|
@ -59,8 +57,8 @@ public class ID3Reader {
|
|||
skipBytes(input, frameHeader.getSize());
|
||||
}
|
||||
}
|
||||
onEndTag();
|
||||
}
|
||||
onEndTag();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,18 +3,7 @@ package de.danoeh.antennapod.core.util.id3reader;
|
|||
public class ID3ReaderException extends Exception {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ID3ReaderException() {
|
||||
}
|
||||
|
||||
public ID3ReaderException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ID3ReaderException(Throwable message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ID3ReaderException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -381,12 +381,6 @@ public class PlaybackController {
|
|||
|
||||
public void onPlaybackEnd() {}
|
||||
|
||||
public void repeatHandleStatus() {
|
||||
if (status != null && playbackService != null) {
|
||||
handleStatus();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is called whenever the PlaybackService changes its status. This method
|
||||
* should be used to update the GUI or start/cancel background threads.
|
||||
|
|
|
@ -37,7 +37,7 @@ import de.danoeh.antennapod.core.util.ShownotesProvider;
|
|||
public class Timeline {
|
||||
private static final String TAG = "Timeline";
|
||||
|
||||
private static final Pattern TIMECODE_LINK_REGEX = Pattern.compile("antennapod://timecode/((\\d+))");
|
||||
private static final Pattern TIMECODE_LINK_REGEX = Pattern.compile("antennapod://timecode/(\\d+)");
|
||||
private static final String TIMECODE_LINK = "<a class=\"timecode\" href=\"antennapod://timecode/%d\">%s</a>";
|
||||
private static final Pattern TIMECODE_REGEX = Pattern.compile("\\b((\\d+):)?(\\d+):(\\d{2})\\b");
|
||||
private static final Pattern LINE_BREAK_REGEX = Pattern.compile("<br */?>");
|
||||
|
|
|
@ -120,10 +120,6 @@ public class ItemEnqueuePositionCalculatorTest {
|
|||
return ItemEnqueuePositionCalculatorTest.getCurrentlyPlaying(idCurrentlyPlaying);
|
||||
}
|
||||
|
||||
private static Playable externalMedia() {
|
||||
return new ExternalMedia("http://example.com/episode.mp3", MediaType.AUDIO);
|
||||
}
|
||||
|
||||
private static final long ID_CURRENTLY_PLAYING_NULL = -1L;
|
||||
private static final long ID_CURRENTLY_PLAYING_NOT_FEEDMEDIA = -9999L;
|
||||
|
||||
|
|
|
@ -13,61 +13,49 @@ import de.danoeh.antennapod.core.feed.FeedItem;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class FeedItemUtilTest {
|
||||
private static final String FEED_LINK = "http://example.com";
|
||||
private static final String ITEM_LINK = "http://example.com/feedItem1";
|
||||
|
||||
private final String msg;
|
||||
private final String feedLink;
|
||||
private final String itemLink;
|
||||
private final String expected;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public static class LinkWithFallbackTest {
|
||||
private static final String FEED_LINK = "http://example.com";
|
||||
private static final String ITEM_LINK = "http://example.com/feedItem1";
|
||||
@Parameters
|
||||
public static Collection<Object[]> data() {
|
||||
return Arrays.asList(new Object[][] {
|
||||
{ "average", FEED_LINK, ITEM_LINK, ITEM_LINK },
|
||||
{ "null item link - fallback to feed", FEED_LINK, null, FEED_LINK},
|
||||
{ "empty item link - same as null", FEED_LINK, "", FEED_LINK},
|
||||
{ "blank item link - same as null", FEED_LINK, " ", FEED_LINK},
|
||||
{ "fallback, but feed link is null too", null, null, null },
|
||||
{ "fallback - but empty feed link - same as null", "", null, null},
|
||||
{ "fallback - but blank feed link - same as null", " ", null, null}
|
||||
});
|
||||
}
|
||||
|
||||
@Parameters
|
||||
public static Collection<Object[]> data() {
|
||||
return Arrays.asList(new Object[][] {
|
||||
{ "average",
|
||||
FEED_LINK, ITEM_LINK, ITEM_LINK },
|
||||
{ "null item link - fallback to feed",
|
||||
FEED_LINK, null, FEED_LINK},
|
||||
{ "empty item link - same as null",
|
||||
FEED_LINK, "", FEED_LINK},
|
||||
{ "blank item link - same as null",
|
||||
FEED_LINK, " ", FEED_LINK},
|
||||
{ "fallback, but feed link is null too",
|
||||
null, null, null },
|
||||
{ "fallback - but empty feed link - same as null",
|
||||
"", null, null},
|
||||
{ "fallback - but blank feed link - same as null",
|
||||
" ", null, null}
|
||||
});
|
||||
}
|
||||
public FeedItemUtilTest(String msg, String feedLink, String itemLink, String expected) {
|
||||
this.msg = msg;
|
||||
this.feedLink = feedLink;
|
||||
this.itemLink = itemLink;
|
||||
this.expected = expected;
|
||||
}
|
||||
|
||||
private final String msg;
|
||||
private final String feedLink;
|
||||
private final String itemLink;
|
||||
private final String expected;
|
||||
@Test
|
||||
public void testLinkWithFallback() {
|
||||
String actual = FeedItemUtil.getLinkWithFallback(createFeedItem(feedLink, itemLink));
|
||||
assertEquals(msg, expected, actual);
|
||||
}
|
||||
|
||||
public LinkWithFallbackTest(String msg, String feedLink, String itemLink, String expected) {
|
||||
this.msg = msg;
|
||||
this.feedLink = feedLink;
|
||||
this.itemLink = itemLink;
|
||||
this.expected = expected;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testLinkWithFallback() {
|
||||
String actual = FeedItemUtil.getLinkWithFallback(createFeedItem(feedLink, itemLink));
|
||||
assertEquals(msg, expected, actual);
|
||||
}
|
||||
|
||||
private static FeedItem createFeedItem(String feedLink, String itemLink) {
|
||||
Feed feed = new Feed();
|
||||
feed.setLink(feedLink);
|
||||
FeedItem feedItem = new FeedItem();
|
||||
feedItem.setLink(itemLink);
|
||||
feedItem.setFeed(feed);
|
||||
feed.setItems(Arrays.asList(feedItem));
|
||||
return feedItem;
|
||||
}
|
||||
private static FeedItem createFeedItem(String feedLink, String itemLink) {
|
||||
Feed feed = new Feed();
|
||||
feed.setLink(feedLink);
|
||||
FeedItem feedItem = new FeedItem();
|
||||
feedItem.setLink(itemLink);
|
||||
feedItem.setFeed(feed);
|
||||
feed.setItems(Arrays.asList(feedItem));
|
||||
return feedItem;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue