Loading src/com/android/contacts/preference/ContactsPreferences.java +7 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.contacts.preference; import android.app.backup.BackupAgent; import android.app.backup.BackupManager; import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; Loading Loading @@ -79,6 +81,7 @@ public class ContactsPreferences implements OnSharedPreferenceChangeListener { private ChangeListener mListener = null; private Handler mHandler; private final SharedPreferences mPreferences; private final BackupManager mBackupManager; private final boolean mIsDefaultAccountUserChangeable; private String mDefaultAccountKey; Loading @@ -92,6 +95,8 @@ public class ContactsPreferences implements OnSharedPreferenceChangeListener { mContext = context; mIsDefaultAccountUserChangeable = isDefaultAccountUserChangeable; mBackupManager = new BackupManager(mContext); mHandler = new Handler(Looper.getMainLooper()); mPreferences = mContext.getSharedPreferences(context.getPackageName(), Context.MODE_PRIVATE); Loading Loading @@ -127,6 +132,7 @@ public class ContactsPreferences implements OnSharedPreferenceChangeListener { final Editor editor = mPreferences.edit(); editor.putInt(SORT_ORDER_KEY, sortOrder); editor.commit(); mBackupManager.dataChanged(); } public boolean isDisplayOrderUserChangeable() { Loading Loading @@ -156,6 +162,7 @@ public class ContactsPreferences implements OnSharedPreferenceChangeListener { final Editor editor = mPreferences.edit(); editor.putInt(DISPLAY_ORDER_KEY, displayOrder); editor.commit(); mBackupManager.dataChanged(); } public boolean isDefaultAccountUserChangeable() { Loading src/com/android/contacts/util/SharedPreferenceUtil.java +15 −4 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.contacts.util; import android.app.backup.BackupManager; import android.content.Context; import android.content.SharedPreferences; Loading @@ -36,13 +37,13 @@ public class SharedPreferenceUtil { public static final String PREFERENCE_KEY_GLOBAL_SYNC_OFF_DISMISSES = "num-of-dismisses-auto-sync-off"; private static final String PREFERENCE_KEY_HAMBURGER_PROMO_DISPLAYED = public static final String PREFERENCE_KEY_HAMBURGER_PROMO_DISPLAYED = "hamburgerPromoDisplayed"; private static final String PREFERENCE_KEY_HAMBURGER_MENU_CLICKED = public static final String PREFERENCE_KEY_HAMBURGER_MENU_CLICKED = "hamburgerMenuClicked"; private static final String PREFERENCE_KEY_HAMBURGER_PROMO_TRIGGER_ACTION_HAPPENED = public static final String PREFERENCE_KEY_HAMBURGER_PROMO_TRIGGER_ACTION_HAPPENED = "hamburgerPromoTriggerActionHappened"; private static final String PREFERENCE_KEY_IMPORTED_SIM_CARDS = Loading @@ -69,6 +70,7 @@ public class SharedPreferenceUtil { getSharedPreferences(context).edit() .putBoolean(PREFERENCE_KEY_HAMBURGER_PROMO_DISPLAYED, true) .apply(); new BackupManager(context).dataChanged(); } public static boolean getHamburgerMenuClickedBefore(Context context) { Loading @@ -80,6 +82,7 @@ public class SharedPreferenceUtil { getSharedPreferences(context).edit() .putBoolean(PREFERENCE_KEY_HAMBURGER_MENU_CLICKED, true) .apply(); new BackupManager(context).dataChanged(); } public static boolean getHamburgerPromoTriggerActionHappenedBefore(Context context) { Loading @@ -91,6 +94,7 @@ public class SharedPreferenceUtil { getSharedPreferences(context).edit() .putBoolean(PREFERENCE_KEY_HAMBURGER_PROMO_TRIGGER_ACTION_HAPPENED, true) .apply(); new BackupManager(context).dataChanged(); } /** Loading @@ -109,7 +113,12 @@ public class SharedPreferenceUtil { } protected static SharedPreferences getSharedPreferences(Context context) { return context.getSharedPreferences(context.getPackageName(), Context.MODE_PRIVATE); return context.getSharedPreferences(getSharedPreferencesFilename(context), Context.MODE_PRIVATE); } public static String getSharedPreferencesFilename(Context context) { return context.getPackageName(); } public static int getNumOfDismissesForAutoSyncOff(Context context) { Loading Loading @@ -244,9 +253,11 @@ public class SharedPreferenceUtil { public static void setWelcomeCardDismissed(Context context, boolean isDismissed) { getSharedPreferences(context).edit().putBoolean(PREFERENCE_WELCOME_CARD_DISMISSED, isDismissed).apply(); new BackupManager(context).dataChanged(); } public static void clear(Context context) { getSharedPreferences(context).edit().clear().commit(); new BackupManager(context).dataChanged(); } } Loading
src/com/android/contacts/preference/ContactsPreferences.java +7 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.contacts.preference; import android.app.backup.BackupAgent; import android.app.backup.BackupManager; import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; Loading Loading @@ -79,6 +81,7 @@ public class ContactsPreferences implements OnSharedPreferenceChangeListener { private ChangeListener mListener = null; private Handler mHandler; private final SharedPreferences mPreferences; private final BackupManager mBackupManager; private final boolean mIsDefaultAccountUserChangeable; private String mDefaultAccountKey; Loading @@ -92,6 +95,8 @@ public class ContactsPreferences implements OnSharedPreferenceChangeListener { mContext = context; mIsDefaultAccountUserChangeable = isDefaultAccountUserChangeable; mBackupManager = new BackupManager(mContext); mHandler = new Handler(Looper.getMainLooper()); mPreferences = mContext.getSharedPreferences(context.getPackageName(), Context.MODE_PRIVATE); Loading Loading @@ -127,6 +132,7 @@ public class ContactsPreferences implements OnSharedPreferenceChangeListener { final Editor editor = mPreferences.edit(); editor.putInt(SORT_ORDER_KEY, sortOrder); editor.commit(); mBackupManager.dataChanged(); } public boolean isDisplayOrderUserChangeable() { Loading Loading @@ -156,6 +162,7 @@ public class ContactsPreferences implements OnSharedPreferenceChangeListener { final Editor editor = mPreferences.edit(); editor.putInt(DISPLAY_ORDER_KEY, displayOrder); editor.commit(); mBackupManager.dataChanged(); } public boolean isDefaultAccountUserChangeable() { Loading
src/com/android/contacts/util/SharedPreferenceUtil.java +15 −4 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.contacts.util; import android.app.backup.BackupManager; import android.content.Context; import android.content.SharedPreferences; Loading @@ -36,13 +37,13 @@ public class SharedPreferenceUtil { public static final String PREFERENCE_KEY_GLOBAL_SYNC_OFF_DISMISSES = "num-of-dismisses-auto-sync-off"; private static final String PREFERENCE_KEY_HAMBURGER_PROMO_DISPLAYED = public static final String PREFERENCE_KEY_HAMBURGER_PROMO_DISPLAYED = "hamburgerPromoDisplayed"; private static final String PREFERENCE_KEY_HAMBURGER_MENU_CLICKED = public static final String PREFERENCE_KEY_HAMBURGER_MENU_CLICKED = "hamburgerMenuClicked"; private static final String PREFERENCE_KEY_HAMBURGER_PROMO_TRIGGER_ACTION_HAPPENED = public static final String PREFERENCE_KEY_HAMBURGER_PROMO_TRIGGER_ACTION_HAPPENED = "hamburgerPromoTriggerActionHappened"; private static final String PREFERENCE_KEY_IMPORTED_SIM_CARDS = Loading @@ -69,6 +70,7 @@ public class SharedPreferenceUtil { getSharedPreferences(context).edit() .putBoolean(PREFERENCE_KEY_HAMBURGER_PROMO_DISPLAYED, true) .apply(); new BackupManager(context).dataChanged(); } public static boolean getHamburgerMenuClickedBefore(Context context) { Loading @@ -80,6 +82,7 @@ public class SharedPreferenceUtil { getSharedPreferences(context).edit() .putBoolean(PREFERENCE_KEY_HAMBURGER_MENU_CLICKED, true) .apply(); new BackupManager(context).dataChanged(); } public static boolean getHamburgerPromoTriggerActionHappenedBefore(Context context) { Loading @@ -91,6 +94,7 @@ public class SharedPreferenceUtil { getSharedPreferences(context).edit() .putBoolean(PREFERENCE_KEY_HAMBURGER_PROMO_TRIGGER_ACTION_HAPPENED, true) .apply(); new BackupManager(context).dataChanged(); } /** Loading @@ -109,7 +113,12 @@ public class SharedPreferenceUtil { } protected static SharedPreferences getSharedPreferences(Context context) { return context.getSharedPreferences(context.getPackageName(), Context.MODE_PRIVATE); return context.getSharedPreferences(getSharedPreferencesFilename(context), Context.MODE_PRIVATE); } public static String getSharedPreferencesFilename(Context context) { return context.getPackageName(); } public static int getNumOfDismissesForAutoSyncOff(Context context) { Loading Loading @@ -244,9 +253,11 @@ public class SharedPreferenceUtil { public static void setWelcomeCardDismissed(Context context, boolean isDismissed) { getSharedPreferences(context).edit().putBoolean(PREFERENCE_WELCOME_CARD_DISMISSED, isDismissed).apply(); new BackupManager(context).dataChanged(); } public static void clear(Context context) { getSharedPreferences(context).edit().clear().commit(); new BackupManager(context).dataChanged(); } }