From ffac53f9edbd59a0157284a2c1892c73d5dce79d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Liese=CC=81n?= Date: Fri, 21 Mar 2014 16:55:06 +0100 Subject: Restore subscriptions when the app is first started Perform a subscription list restore when the app is started for the first time. Use a preference setting to figure out if the app is freshly installed or not. --- .../danoeh/antennapod/activity/MainActivity.java | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/de/danoeh/antennapod/activity') diff --git a/src/de/danoeh/antennapod/activity/MainActivity.java b/src/de/danoeh/antennapod/activity/MainActivity.java index 9edb312de..8e84f08f8 100644 --- a/src/de/danoeh/antennapod/activity/MainActivity.java +++ b/src/de/danoeh/antennapod/activity/MainActivity.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import android.app.SearchManager; import android.app.SearchableInfo; +import android.app.backup.BackupManager; +import android.app.backup.RestoreObserver; import android.content.Context; import android.content.Intent; import android.media.AudioManager; @@ -22,6 +24,8 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.Window; +import android.widget.Toast; + import de.danoeh.antennapod.AppConfig; import de.danoeh.antennapod.R; import de.danoeh.antennapod.feed.EventDistributor; @@ -114,6 +118,26 @@ public class MainActivity extends ActionBarActivity { updateProgressBarVisibility(); EventDistributor.getInstance().register(contentUpdate); + // Possibly restore feed subscriptions from backup + if (UserPreferences.isFreshInstall()) { + new BackupManager(this).requestRestore(new BackupRestoreObserver(this)); + UserPreferences.setIsFreshInstall(false); + } + } + + private static class BackupRestoreObserver extends RestoreObserver { + private final Context mContext; + + public BackupRestoreObserver(final Context context) { + mContext = context; + } + + @Override + public void restoreFinished(int error) { + if (error == 0) { + Toast.makeText(mContext, R.string.backup_restored, Toast.LENGTH_SHORT).show(); + } + } } private EventDistributor.EventListener contentUpdate = new EventDistributor.EventListener() { -- cgit v1.2.3 From eb756cc65715c2f5b8b382ee9025eb3f2cfc8db4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Liese=CC=81n?= Date: Mon, 24 Mar 2014 20:57:24 +0100 Subject: Restore happens by itself upon app install --- src/de/danoeh/antennapod/activity/MainActivity.java | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'src/de/danoeh/antennapod/activity') diff --git a/src/de/danoeh/antennapod/activity/MainActivity.java b/src/de/danoeh/antennapod/activity/MainActivity.java index 8e84f08f8..1637bd53a 100644 --- a/src/de/danoeh/antennapod/activity/MainActivity.java +++ b/src/de/danoeh/antennapod/activity/MainActivity.java @@ -117,27 +117,6 @@ public class MainActivity extends ActionBarActivity { StorageUtils.checkStorageAvailability(this); updateProgressBarVisibility(); EventDistributor.getInstance().register(contentUpdate); - - // Possibly restore feed subscriptions from backup - if (UserPreferences.isFreshInstall()) { - new BackupManager(this).requestRestore(new BackupRestoreObserver(this)); - UserPreferences.setIsFreshInstall(false); - } - } - - private static class BackupRestoreObserver extends RestoreObserver { - private final Context mContext; - - public BackupRestoreObserver(final Context context) { - mContext = context; - } - - @Override - public void restoreFinished(int error) { - if (error == 0) { - Toast.makeText(mContext, R.string.backup_restored, Toast.LENGTH_SHORT).show(); - } - } } private EventDistributor.EventListener contentUpdate = new EventDistributor.EventListener() { -- cgit v1.2.3