diff options
author | Martin Fietz <marf@hadiko-99-4.hadiko.uni-karlsruhe.de> | 2015-05-04 23:47:34 +0200 |
---|---|---|
committer | Martin Fietz <marf@hadiko-99-4.hadiko.uni-karlsruhe.de> | 2015-05-09 00:03:41 +0200 |
commit | c8259daaeee9870bc806c5d8b4bed669e68d061c (patch) | |
tree | 427479a7d9a0280d234dec47e29d4c715fc02b26 /app/src/main/java | |
parent | 11a66f451ab76b1ef5c45f12c6ed7100040b9084 (diff) | |
download | AntennaPod-c8259daaeee9870bc806c5d8b4bed669e68d061c.zip |
Cancel auto download
Diffstat (limited to 'app/src/main/java')
3 files changed, 39 insertions, 6 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java b/app/src/main/java/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java index 6df18e759..e39b9e684 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java @@ -12,9 +12,11 @@ import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.dialog.DownloadRequestErrorDialogCreator; 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.gpoddernet.model.GpodnetEpisodeAction; import de.danoeh.antennapod.core.preferences.GpodnetPreferences; -import de.danoeh.antennapod.core.service.playback.PlaybackService; import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBTasks; import de.danoeh.antennapod.core.storage.DBWriter; @@ -75,7 +77,12 @@ public class DefaultActionButtonCallback implements ActionButtonCallback { } } else if (isDownloading) { DownloadRequester.getInstance().cancelDownload(context, media); - Toast.makeText(context, R.string.download_cancelled_msg, Toast.LENGTH_SHORT).show(); + if(UserPreferences.isEnableAutodownload()) { + DBWriter.setFeedItemAutoDownload(context, media.getItem(), false); + Toast.makeText(context, R.string.download_cancelled_autodownload_enabled_msg, Toast.LENGTH_LONG).show(); + } else { + Toast.makeText(context, R.string.download_cancelled_msg, Toast.LENGTH_LONG).show(); + } } else { // media is downloaded if (item.hasMedia() && item.getMedia().isCurrentlyPlaying()) { context.sendBroadcast(new Intent(PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE)); 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 10a3c1b32..de9be4d58 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 14; + return 15; } @Override @@ -124,5 +124,15 @@ public class StorageCallbacksImpl implements StorageCallbacks { PodDBAdapter.KEY_LINK, PodDBAdapter.KEY_CHAPTER_TYPE)); } + if(oldVersion <= 14) { + db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEED_ITEMS + + " ADD COLUMN " + PodDBAdapter.KEY_AUTO_DOWNLOAD + " INTEGER"); + db.execSQL("UPDATE " + PodDBAdapter.TABLE_NAME_FEED_ITEMS + + " SET " + PodDBAdapter.KEY_AUTO_DOWNLOAD + " = " + + "(SELECT " + PodDBAdapter.KEY_AUTO_DOWNLOAD + + " FROM " + PodDBAdapter.TABLE_NAME_FEEDS + + " WHERE " + PodDBAdapter.TABLE_NAME_FEEDS + "." + PodDBAdapter.KEY_ID + + " = " + PodDBAdapter.TABLE_NAME_FEED_ITEMS + "." + PodDBAdapter.KEY_FEED + ")"); + } } } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/RunningDownloadsFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/RunningDownloadsFragment.java index f578d4338..06a8bc92b 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/RunningDownloadsFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/RunningDownloadsFragment.java @@ -5,15 +5,21 @@ import android.os.Handler; import android.support.v4.app.ListFragment; import android.view.View; import android.widget.ListView; +import android.widget.Toast; + +import java.util.List; import de.danoeh.antennapod.R; import de.danoeh.antennapod.adapter.DownloadlistAdapter; import de.danoeh.antennapod.core.asynctask.DownloadObserver; +import de.danoeh.antennapod.core.feed.FeedMedia; +import de.danoeh.antennapod.core.preferences.UserPreferences; +import de.danoeh.antennapod.core.service.download.DownloadRequest; import de.danoeh.antennapod.core.service.download.Downloader; +import de.danoeh.antennapod.core.storage.DBReader; +import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.core.storage.DownloadRequester; -import java.util.List; - /** * Displays all running downloads and provides actions to cancel them */ @@ -73,7 +79,17 @@ public class RunningDownloadsFragment extends ListFragment { @Override public void onSecondaryActionClick(Downloader downloader) { - DownloadRequester.getInstance().cancelDownload(getActivity(), downloader.getDownloadRequest().getSource()); + DownloadRequest downloadRequest = downloader.getDownloadRequest(); + DownloadRequester.getInstance().cancelDownload(getActivity(), downloadRequest.getSource()); + + if(downloadRequest.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA && + UserPreferences.isEnableAutodownload()) { + FeedMedia media = DBReader.getFeedMedia(getActivity(), downloadRequest.getFeedfileId()); + DBWriter.setFeedItemAutoDownload(getActivity(), media.getItem(), false); + Toast.makeText(getActivity(), R.string.download_cancelled_autodownload_enabled_msg, Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(getActivity(), R.string.download_cancelled_msg, Toast.LENGTH_SHORT).show(); + } } }; } |