// Load the accounts category for adding the list of accounts
mAccountsPrefCategory = (PreferenceCategory) findPreference("accounts_category");
- // Populate the accounts category with the list of accounts
- createAccountsCheckboxPreferences();
-
- // Add Create Account preference if Multiaccount is enabled
- if (getResources().getBoolean(R.bool.multiaccount_support)) {
- createAddAccountPreference();
- }
-
pCode = (CheckBoxPreference) findPreference("set_pincode");
if (pCode != null){
pCode.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
SharedPreferences appPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
boolean state = appPrefs.getBoolean("set_pincode", false);
pCode.setChecked(state);
+
+ // Populate the accounts category with the list of accounts
+ createAccountsCheckboxPreferences();
}
@Override
}
/**
- * Create the list of accounts that have been added into the app
+ * Create the list of accounts that has been added into the app
*/
private void createAccountsCheckboxPreferences() {
+
+ // Remove accounts in case list is refreshing for avoiding to have
+ // duplicate items
+ if (mAccountsPrefCategory.getPreferenceCount() > 0) {
+ mAccountsPrefCategory.removeAll();
+ }
+
AccountManager am = (AccountManager) getSystemService(ACCOUNT_SERVICE);
Account accounts[] = am.getAccountsByType(MainApp.getAccountType());
Account currentAccount = AccountUtils.getCurrentOwnCloudAccount(getApplicationContext());
mAccountsPrefCategory.addPreference(checkBoxPreference);
}
+
+ // Add Create Account preference at the end of account list if Multiaccount is enabled
+ if (getResources().getBoolean(R.bool.multiaccount_support)) {
+ createAddAccountPreference();
+ }
+
}
/**