diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2014-11-10 21:01:41 +0100 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2014-11-10 21:01:41 +0100 |
commit | ad04a80ae7b2091c94b0d007c2a78d97e7af871d (patch) | |
tree | 0d43b619ddcc6ea6d1222595d7a56db5a8c6e823 /app/src | |
parent | 6035e8fee91d895dd3a0fcedbedab2bc9de5b6a1 (diff) | |
download | AntennaPod-ad04a80ae7b2091c94b0d007c2a78d97e7af871d.zip |
Squashed commit of the following:
commit 7d0e6d5c2dc75f8f1e54f4a1279c6b0cffa7b8cc
Author: daniel oeh <daniel.oeh@gmail.com>
Date: Mon Nov 10 21:00:58 2014 +0100
Made tests compile
commit 05c57df87dd469d8f64835700eefe2e3c87e04e4
Author: daniel oeh <daniel.oeh@gmail.com>
Date: Mon Nov 10 20:56:58 2014 +0100
Removed unused code
commit 0a1fbc9e6d9648646140e30dec0ec8389fb8d37f
Author: daniel oeh <daniel.oeh@gmail.com>
Date: Thu Nov 6 15:48:24 2014 +0100
Added UI controls to download more feed pages
closes #245
commit 6486fb40f1d03887e264df95946f91f0a9cdac9b
Author: daniel oeh <daniel.oeh@gmail.com>
Date: Thu Nov 6 14:49:43 2014 +0100
Added support for downloading feed pages
commit e1faa06908bfd50f2aa0c28ee5118772c4281557
Author: daniel oeh <daniel.oeh@gmail.com>
Date: Wed Nov 5 21:27:03 2014 +0100
Added "paged" and "loadAllPages" attributes
Diffstat (limited to 'app/src')
9 files changed, 75 insertions, 17 deletions
diff --git a/app/src/androidTest/java/de/test/antennapod/service/download/HttpDownloaderTest.java b/app/src/androidTest/java/de/test/antennapod/service/download/HttpDownloaderTest.java index 1a561f282..65b1145a2 100644 --- a/app/src/androidTest/java/de/test/antennapod/service/download/HttpDownloaderTest.java +++ b/app/src/androidTest/java/de/test/antennapod/service/download/HttpDownloaderTest.java @@ -65,7 +65,7 @@ public class HttpDownloaderTest extends InstrumentationTestCase { private Downloader download(String url, String title, boolean expectedResult, boolean deleteExisting, String username, String password, boolean deleteOnFail) { FeedFile feedFile = setupFeedFile(url, title, deleteExisting); - DownloadRequest request = new DownloadRequest(feedFile.getFile_url(), url, title, 0, feedFile.getTypeAsInt(), username, password, deleteOnFail); + DownloadRequest request = new DownloadRequest(feedFile.getFile_url(), url, title, 0, feedFile.getTypeAsInt(), username, password, deleteOnFail, null); Downloader downloader = new HttpDownloader(request); downloader.call(); DownloadStatus status = downloader.getResult(); diff --git a/app/src/androidTest/java/de/test/antennapod/storage/DBReaderTest.java b/app/src/androidTest/java/de/test/antennapod/storage/DBReaderTest.java index 33f7fb350..a96c9a6d3 100644 --- a/app/src/androidTest/java/de/test/antennapod/storage/DBReaderTest.java +++ b/app/src/androidTest/java/de/test/antennapod/storage/DBReaderTest.java @@ -43,7 +43,7 @@ public class DBReaderTest extends InstrumentationTestCase { private void expiredFeedListTestHelper(long lastUpdate, long expirationTime, boolean shouldReturn) { final Context context = getInstrumentation().getTargetContext(); Feed feed = new Feed(0, new Date(lastUpdate), "feed", "link", "descr", null, - null, null, null, "feed", null, null, "url", false, new FlattrStatus()); + null, null, null, "feed", null, null, "url", false, new FlattrStatus(), false, null); feed.setItems(new ArrayList<FeedItem>()); PodDBAdapter adapter = new PodDBAdapter(context); adapter.open(); diff --git a/app/src/androidTest/java/de/test/antennapod/storage/DBTasksTest.java b/app/src/androidTest/java/de/test/antennapod/storage/DBTasksTest.java index fd5b1c393..e28a7918f 100644 --- a/app/src/androidTest/java/de/test/antennapod/storage/DBTasksTest.java +++ b/app/src/androidTest/java/de/test/antennapod/storage/DBTasksTest.java @@ -296,7 +296,7 @@ public class DBTasksTest extends InstrumentationTestCase { final Context context = getInstrumentation().getTargetContext(); UserPreferences.setUpdateInterval(context, expirationTime); Feed feed = new Feed(0, new Date(lastUpdate), "feed", "link", "descr", null, - null, null, null, "feed", null, null, "url", false, new FlattrStatus()); + null, null, null, "feed", null, null, "url", false, new FlattrStatus(), false, null); feed.setItems(new ArrayList<FeedItem>()); PodDBAdapter adapter = new PodDBAdapter(context); adapter.open(); diff --git a/app/src/androidTest/java/de/test/antennapod/storage/DBTestUtils.java b/app/src/androidTest/java/de/test/antennapod/storage/DBTestUtils.java index e7d6396f5..9e5f6546d 100644 --- a/app/src/androidTest/java/de/test/antennapod/storage/DBTestUtils.java +++ b/app/src/androidTest/java/de/test/antennapod/storage/DBTestUtils.java @@ -32,7 +32,7 @@ public class DBTestUtils { adapter.open(); for (int i = 0; i < numFeeds; i++) { Feed f = new Feed(0, new Date(), "feed " + i, "link" + i, "descr", null, null, - null, null, "id" + i, null, null, "url" + i, false, new FlattrStatus()); + null, null, "id" + i, null, null, "url" + i, false, new FlattrStatus(), false, null); f.setItems(new ArrayList<FeedItem>()); for (int j = 0; j < numItems; j++) { FeedItem item = new FeedItem(0, "item " + j, "id" + j, "link" + j, new Date(), diff --git a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java index d84e6cc03..9f028000e 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java @@ -183,14 +183,14 @@ public abstract class OnlineFeedViewActivity extends ActionBarActivity { url = URLChecker.prepareURL(url); feed = new Feed(url, new Date()); if (username != null && password != null) { - feed.setPreferences(new FeedPreferences(0, true, username, password)); + feed.setPreferences(new FeedPreferences(0, false, username, password)); } String fileUrl = new File(getExternalCacheDir(), FileNameGenerator.generateFileName(feed.getDownload_url())) .toString(); feed.setFile_url(fileUrl); final DownloadRequest request = new DownloadRequest(feed.getFile_url(), - feed.getDownload_url(), "OnlineFeed", 0, Feed.FEEDFILETYPE_FEED, username, password, true); + feed.getDownload_url(), "OnlineFeed", 0, Feed.FEEDFILETYPE_FEED, username, password, true, null); downloader = new HttpDownloader( request); new Thread() { diff --git a/app/src/main/java/de/danoeh/antennapod/config/StorageCallbacksImpl.java b/app/src/main/java/de/danoeh/antennapod/config/StorageCallbacksImpl.java index ec133aed1..ebb3780b7 100644 --- a/app/src/main/java/de/danoeh/antennapod/config/StorageCallbacksImpl.java +++ b/app/src/main/java/de/danoeh/antennapod/config/StorageCallbacksImpl.java @@ -13,7 +13,7 @@ public class StorageCallbacksImpl implements StorageCallbacks { @Override public int getDatabaseVersion() { - return 12; + return 13; } @Override @@ -103,5 +103,11 @@ public class StorageCallbacksImpl implements StorageCallbacks { + " ADD COLUMN " + PodDBAdapter.KEY_IMAGE + " INTEGER"); } + if (oldVersion <= 12) { + db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS + + " ADD COLUMN " + PodDBAdapter.KEY_IS_PAGED + " INTEGER DEFAULT 0"); + db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS + + " ADD COLUMN " + PodDBAdapter.KEY_NEXT_PAGE_LINK + " TEXT"); + } } } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java index 15f6e85e4..abf894c2a 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java @@ -4,7 +4,6 @@ import android.annotation.SuppressLint; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; -import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; @@ -44,9 +43,11 @@ import de.danoeh.antennapod.core.feed.FeedMedia; import de.danoeh.antennapod.core.service.download.DownloadService; import de.danoeh.antennapod.core.service.download.Downloader; 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.util.QueueAccess; +import de.danoeh.antennapod.core.util.gui.MoreContentListFooterUtil; import de.danoeh.antennapod.dialog.FeedItemDialog; import de.danoeh.antennapod.menuhandler.FeedMenuHandler; import de.danoeh.antennapod.menuhandler.MenuItemUtils; @@ -82,6 +83,8 @@ public class ItemlistFragment extends ListFragment { private FeedItemDialog feedItemDialog; private FeedItemDialog.FeedItemDialogSavedInstance feedItemDialogSavedInstance; + private MoreContentListFooterUtil listFooter; + private boolean isUpdatingFeed; /** @@ -293,12 +296,17 @@ public class ItemlistFragment extends ListFragment { if (isUpdatingFeed != updateRefreshMenuItemChecker.isRefreshing()) { getActivity().supportInvalidateOptionsMenu(); } + if (listFooter != null) { + listFooter.setLoadingState(DownloadRequester.getInstance().isDownloadingFeeds()); + } + } private void onFragmentLoaded() { if (adapter == null) { getListView().setAdapter(null); setupHeaderView(); + setupFooterView(); adapter = new FeedItemlistAdapter(getActivity(), itemAccess, new DefaultActionButtonCallback(getActivity()), false); setListAdapter(adapter); downloadObserver = new DownloadObserver(getActivity(), new Handler(), downloadObserverCallback); @@ -313,6 +321,11 @@ public class ItemlistFragment extends ListFragment { feedItemDialog = FeedItemDialog.newInstance(getActivity(), feedItemDialogSavedInstance); } getActivity().supportInvalidateOptionsMenu(); + + if (feed != null && feed.getNextPageLink() == null && listFooter != null) { + getListView().removeFooterView(listFooter.getRoot()); + } + } private DownloadObserver.Callback downloadObserverCallback = new DownloadObserver.Callback() { @@ -372,6 +385,34 @@ public class ItemlistFragment extends ListFragment { }); } + private void setupFooterView() { + if (getListView() == null || feed == null) { + Log.e(TAG, "Unable to setup listview: listView = null or feed = null"); + return; + } + if (feed.isPaged() && feed.getNextPageLink() != null) { + ListView lv = getListView(); + LayoutInflater inflater = (LayoutInflater) + getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); + View header = inflater.inflate(R.layout.more_content_list_footer, lv, false); + lv.addFooterView(header); + listFooter = new MoreContentListFooterUtil(header); + listFooter.setClickListener(new MoreContentListFooterUtil.Listener() { + @Override + public void onClick() { + if (feed != null) { + try { + DBTasks.loadNextPageOfFeed(getActivity(), feed, false); + } catch (DownloadRequestException e) { + e.printStackTrace(); + DownloadRequestErrorDialogCreator.newRequestErrorDialog(getActivity(), e.getMessage()); + } + } + } + }); + } + } + private FeedItemlistAdapter.ItemAccess itemAccess = new FeedItemlistAdapter.ItemAccess() { @Override diff --git a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java index e382a5888..b62fd22b2 100644 --- a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java +++ b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java @@ -41,6 +41,8 @@ public class FeedMenuHandler { else menu.findItem(R.id.support_item).setVisible(false); + menu.findItem(R.id.refresh_complete_item).setVisible(selectedFeed.isPaged()); + return true; } @@ -55,6 +57,9 @@ public class FeedMenuHandler { case R.id.refresh_item: DBTasks.refreshFeed(context, selectedFeed); break; + case R.id.refresh_complete_item: + DBTasks.refreshCompleteFeed(context, selectedFeed); + break; case R.id.mark_all_read_item: DBWriter.markFeedRead(context, selectedFeed.getId()); break; diff --git a/app/src/main/res/menu/feedlist.xml b/app/src/main/res/menu/feedlist.xml index dfee70522..8d2d9e367 100644 --- a/app/src/main/res/menu/feedlist.xml +++ b/app/src/main/res/menu/feedlist.xml @@ -6,29 +6,35 @@ android:id="@+id/refresh_item" android:icon="?attr/navigation_refresh" android:menuCategory="container" - custom:showAsAction="ifRoom" - android:title="@string/refresh_label"> + android:title="@string/refresh_label" + custom:showAsAction="ifRoom"> + </item> + <item + android:id="@+id/refresh_complete_item" + android:menuCategory="container" + android:title="@string/load_complete_feed" + custom:showAsAction="collapseActionView"> </item> <item android:id="@+id/mark_all_read_item" android:menuCategory="container" - custom:showAsAction="collapseActionView" - android:title="@string/mark_all_read_label"> + android:title="@string/mark_all_read_label" + custom:showAsAction="collapseActionView"> </item> <item android:id="@+id/support_item" android:menuCategory="container" - custom:showAsAction="collapseActionView" android:title="@string/support_label" - android:visible="false"> + android:visible="false" + custom:showAsAction="collapseActionView"> </item> <item android:id="@+id/remove_item" - android:menuCategory="container" android:icon="?attr/content_discard" - custom:showAsAction="collapseActionView" + android:menuCategory="container" android:title="@string/remove_feed_label" - android:visible="true"> + android:visible="true" + custom:showAsAction="collapseActionView"> </item> </menu>
\ No newline at end of file |