diff options
author | 2015-03-09 16:20:01 +0000 | |
---|---|---|
committer | 2015-03-09 16:20:01 +0000 | |
commit | e410a513bed5b5ac00b68d492bf397c07dd342d3 (patch) | |
tree | bc98230e992158539c15b4f29ff6c7c0ddc9e490 /java/src | |
parent | f9477310b3c0cbb3c05266badc52e673e9d1ce8d (diff) | |
parent | e3ac02e796d64c1cdef0c300338124afe27cfbec (diff) | |
download | latinime-e410a513bed5b5ac00b68d492bf397c07dd342d3.tar.gz latinime-e410a513bed5b5ac00b68d492bf397c07dd342d3.tar.xz latinime-e410a513bed5b5ac00b68d492bf397c07dd342d3.zip |
am e3ac02e7: Merge "Sync setting disabled if no account."
* commit 'e3ac02e796d64c1cdef0c300338124afe27cfbec':
Sync setting disabled if no account.
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java index b734d8bcd..9a8a7b9e0 100644 --- a/java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java +++ b/java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java @@ -204,24 +204,19 @@ public final class AccountsSettingsFragment extends SubScreenFragment { * is currently selected. */ private void refreshAccountAndDependentPreferences(@Nullable final String currentAccount) { + // TODO(cvnguyen): Write tests. if (!ProductionFlags.ENABLE_ACCOUNT_SIGN_IN) { return; } - if (currentAccount == null) { - // No account is currently selected; switch enable sync preference off. - mAccountSwitcher.setSummary(getString(R.string.no_accounts_selected)); - mEnableSyncPreference.setChecked(false); - } else { - // Set the currently selected account as the summary text. - mAccountSwitcher.setSummary(getString(R.string.account_selected, currentAccount)); - } + final String[] accountsForLogin = + LoginAccountUtils.getAccountsForLogin(getActivity()); - mAccountSwitcher.setOnPreferenceClickListener(new OnPreferenceClickListener() { + if (accountsForLogin.length > 0) { + enableSyncPreferences(); + mAccountSwitcher.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(final Preference preference) { - final String[] accountsForLogin = - LoginAccountUtils.getAccountsForLogin(getActivity()); if (accountsForLogin.length > 0) { // TODO: Add addition of account. createAccountPicker(accountsForLogin, currentAccount, @@ -229,7 +224,21 @@ public final class AccountsSettingsFragment extends SubScreenFragment { } return true; } - }); + }); + } else { + mAccountSwitcher.setEnabled(false); + disableSyncPreferences(); + mEnableSyncPreference.setSummary(getString(R.string.add_account_to_enable_sync)); + } + + if (currentAccount == null) { + // No account is currently selected; switch enable sync preference off. + mAccountSwitcher.setSummary(getString(R.string.no_accounts_selected)); + mEnableSyncPreference.setChecked(false); + } else { + // Set the currently selected account as the summary text. + mAccountSwitcher.setSummary(getString(R.string.account_selected, currentAccount)); + } } @Nullable |