From 7f986769574b75239a5ac3ae54fd67202d61d89c Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 16 Dec 2011 20:57:21 +0300 Subject: [PATCH 1/2] implement cloud settings backup --- AndroidManifest.xml | 10 ++++++++-- src/org/fox/ttrss/PrefsBackupAgent.java | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 src/org/fox/ttrss/PrefsBackupAgent.java diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 4e621e15..dc479f22 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="44" + android:versionName="0.3.11" > @@ -11,6 +11,8 @@ @@ -43,6 +45,10 @@ + + + \ No newline at end of file diff --git a/src/org/fox/ttrss/PrefsBackupAgent.java b/src/org/fox/ttrss/PrefsBackupAgent.java new file mode 100644 index 00000000..0a7e5dec --- /dev/null +++ b/src/org/fox/ttrss/PrefsBackupAgent.java @@ -0,0 +1,19 @@ +package org.fox.ttrss; + +import android.app.backup.BackupAgentHelper; +import android.app.backup.SharedPreferencesBackupHelper; + +public class PrefsBackupAgent extends BackupAgentHelper { + // The name of the SharedPreferences file + static final String PREFS = "org.fox.ttrss_preferences"; + + // A key to uniquely identify the set of backup data + static final String PREFS_BACKUP_KEY = "prefs"; + + // Allocate a helper and add it to the backup agent + @Override + public void onCreate() { + SharedPreferencesBackupHelper helper = new SharedPreferencesBackupHelper(this, PREFS); + addHelper(PREFS_BACKUP_KEY, helper); + } +} From 288d90c4b0dd873315e464b98f96c42c5960ada2 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 16 Dec 2011 21:06:07 +0300 Subject: [PATCH 2/2] store offline mode status preference in a separate file to prevent backing it up to the cloud --- src/org/fox/ttrss/MainActivity.java | 7 +++++-- src/org/fox/ttrss/OfflineActivity.java | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/org/fox/ttrss/MainActivity.java b/src/org/fox/ttrss/MainActivity.java index d7bdabe5..e89b6adc 100644 --- a/src/org/fox/ttrss/MainActivity.java +++ b/src/org/fox/ttrss/MainActivity.java @@ -479,7 +479,9 @@ public class MainActivity extends FragmentActivity implements OnlineServices { registerReceiver(m_broadcastReceiver, filter); - m_isOffline = m_prefs.getBoolean("offline_mode_active", false); + SharedPreferences localPrefs = getSharedPreferences("localprefs", Context.MODE_PRIVATE); + + m_isOffline = localPrefs.getBoolean("offline_mode_active", false); Log.d(TAG, "m_isOffline=" + m_isOffline); Log.d(TAG, "m_smallScreenMode=" + m_smallScreenMode); @@ -591,7 +593,8 @@ public class MainActivity extends FragmentActivity implements OnlineServices { public void onClick(DialogInterface dialog, int which) { - SharedPreferences.Editor editor = m_prefs.edit(); + SharedPreferences localPrefs = getSharedPreferences("localprefs", Context.MODE_PRIVATE); + SharedPreferences.Editor editor = localPrefs.edit(); editor.putBoolean("offline_mode_active", true); editor.commit(); diff --git a/src/org/fox/ttrss/OfflineActivity.java b/src/org/fox/ttrss/OfflineActivity.java index 1f7793bc..a03dbbf9 100644 --- a/src/org/fox/ttrss/OfflineActivity.java +++ b/src/org/fox/ttrss/OfflineActivity.java @@ -5,6 +5,7 @@ import org.fox.ttrss.OnlineServices.RelativeArticle; import android.app.AlertDialog; import android.app.Dialog; import android.app.NotificationManager; +import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; @@ -215,7 +216,8 @@ public class OfflineActivity extends FragmentActivity implements } private void switchOnline() { - SharedPreferences.Editor editor = m_prefs.edit(); + SharedPreferences localPrefs = getSharedPreferences("localprefs", Context.MODE_PRIVATE); + SharedPreferences.Editor editor = localPrefs.edit(); editor.putBoolean("offline_mode_active", false); editor.commit();