diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2014-10-17 20:46:31 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-10-17 20:46:32 +0000 |
commit | 27c0b548ab701aefef7655e78401a52c33c6270c (patch) | |
tree | d9785a85fe2c20c553c07f8fe16b0c0d7f5340d5 /src/com/android/settings/accounts | |
parent | 0303bb203059e75c729804405d481bd3333c4098 (diff) | |
parent | 1bc996532ca5c53efaaa5718d7ba4d0ad9710571 (diff) | |
download | packages_apps_Settings-27c0b548ab701aefef7655e78401a52c33c6270c.zip packages_apps_Settings-27c0b548ab701aefef7655e78401a52c33c6270c.tar.gz packages_apps_Settings-27c0b548ab701aefef7655e78401a52c33c6270c.tar.bz2 |
Merge "Fix bug #15730311 Checkboxes on R side should update to Quantum/Material on/off switch" into lmp-mr1-dev
Diffstat (limited to 'src/com/android/settings/accounts')
-rw-r--r-- | src/com/android/settings/accounts/AccountSyncSettings.java | 48 | ||||
-rw-r--r-- | src/com/android/settings/accounts/SyncStateSwitchPreference.java (renamed from src/com/android/settings/accounts/SyncStateCheckBoxPreference.java) | 16 |
2 files changed, 32 insertions, 32 deletions
diff --git a/src/com/android/settings/accounts/AccountSyncSettings.java b/src/com/android/settings/accounts/AccountSyncSettings.java index f0896c9..d51610d 100644 --- a/src/com/android/settings/accounts/AccountSyncSettings.java +++ b/src/com/android/settings/accounts/AccountSyncSettings.java @@ -74,8 +74,8 @@ public class AccountSyncSettings extends AccountPreferenceBase { private ImageView mProviderIcon; private TextView mErrorInfoView; private Account mAccount; - private ArrayList<SyncStateCheckBoxPreference> mCheckBoxes = - new ArrayList<SyncStateCheckBoxPreference>(); + private ArrayList<SyncStateSwitchPreference> mSwitches = + new ArrayList<SyncStateSwitchPreference>(); private ArrayList<SyncAdapterType> mInvisibleAdapters = Lists.newArrayList(); @Override @@ -209,9 +209,9 @@ public class AccountSyncSettings extends AccountPreferenceBase { mAuthenticatorHelper.stopListeningToAccountUpdates(); } - private void addSyncStateCheckBox(Account account, String authority) { - SyncStateCheckBoxPreference item = - new SyncStateCheckBoxPreference(getActivity(), account, authority); + private void addSyncStateSwitch(Account account, String authority) { + SyncStateSwitchPreference item = + new SyncStateSwitchPreference(getActivity(), account, authority); item.setPersistent(false); final ProviderInfo providerInfo = getPackageManager().resolveContentProviderAsUser( authority, 0, mUserHandle.getIdentifier()); @@ -226,7 +226,7 @@ public class AccountSyncSettings extends AccountPreferenceBase { String title = getString(R.string.sync_item_title, providerLabel); item.setTitle(title); item.setKey(authority); - mCheckBoxes.add(item); + mSwitches.add(item); } @Override @@ -282,8 +282,8 @@ public class AccountSyncSettings extends AccountPreferenceBase { @Override public boolean onPreferenceTreeClick(PreferenceScreen preferences, Preference preference) { - if (preference instanceof SyncStateCheckBoxPreference) { - SyncStateCheckBoxPreference syncPref = (SyncStateCheckBoxPreference) preference; + if (preference instanceof SyncStateSwitchPreference) { + SyncStateSwitchPreference syncPref = (SyncStateSwitchPreference) preference; String authority = syncPref.getAuthority(); Account account = syncPref.getAccount(); final int userId = mUserHandle.getIdentifier(); @@ -326,10 +326,10 @@ public class AccountSyncSettings extends AccountPreferenceBase { int count = getPreferenceScreen().getPreferenceCount(); for (int i = 0; i < count; i++) { Preference pref = getPreferenceScreen().getPreference(i); - if (! (pref instanceof SyncStateCheckBoxPreference)) { + if (! (pref instanceof SyncStateSwitchPreference)) { continue; } - SyncStateCheckBoxPreference syncPref = (SyncStateCheckBoxPreference) pref; + SyncStateSwitchPreference syncPref = (SyncStateSwitchPreference) pref; if (!syncPref.isChecked()) { continue; } @@ -376,15 +376,15 @@ public class AccountSyncSettings extends AccountPreferenceBase { List<SyncInfo> currentSyncs = ContentResolver.getCurrentSyncsAsUser(userId); boolean syncIsFailing = false; - // Refresh the sync status checkboxes - some syncs may have become active. - updateAccountCheckboxes(); + // Refresh the sync status switches - some syncs may have become active. + updateAccountSwitches(); for (int i = 0, count = getPreferenceScreen().getPreferenceCount(); i < count; i++) { Preference pref = getPreferenceScreen().getPreference(i); - if (! (pref instanceof SyncStateCheckBoxPreference)) { + if (! (pref instanceof SyncStateSwitchPreference)) { continue; } - SyncStateCheckBoxPreference syncPref = (SyncStateCheckBoxPreference) pref; + SyncStateSwitchPreference syncPref = (SyncStateSwitchPreference) pref; String authority = syncPref.getAuthority(); Account account = syncPref.getAccount(); @@ -450,7 +450,7 @@ public class AccountSyncSettings extends AccountPreferenceBase { finish(); return; } - updateAccountCheckboxes(); + updateAccountSwitches(); onSyncStateUpdated(); } @@ -468,7 +468,7 @@ public class AccountSyncSettings extends AccountPreferenceBase { return false; } - private void updateAccountCheckboxes() { + private void updateAccountSwitches() { mInvisibleAdapters.clear(); SyncAdapterType[] syncAdapters = ContentResolver.getSyncAdapterTypesAsUser( @@ -480,7 +480,7 @@ public class AccountSyncSettings extends AccountPreferenceBase { if (!sa.accountType.equals(mAccount.type)) continue; if (sa.isUserVisible()) { if (Log.isLoggable(TAG, Log.VERBOSE)) { - Log.d(TAG, "updateAccountCheckboxes: added authority " + sa.authority + Log.d(TAG, "updateAccountSwitches: added authority " + sa.authority + " to accountType " + sa.accountType); } authorities.add(sa.authority); @@ -491,10 +491,10 @@ public class AccountSyncSettings extends AccountPreferenceBase { } } - for (int i = 0, n = mCheckBoxes.size(); i < n; i++) { - getPreferenceScreen().removePreference(mCheckBoxes.get(i)); + for (int i = 0, n = mSwitches.size(); i < n; i++) { + getPreferenceScreen().removePreference(mSwitches.get(i)); } - mCheckBoxes.clear(); + mSwitches.clear(); if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.d(TAG, "looking for sync adapters that match account " + mAccount); @@ -508,13 +508,13 @@ public class AccountSyncSettings extends AccountPreferenceBase { Log.d(TAG, " found authority " + authority + " " + syncState); } if (syncState > 0) { - addSyncStateCheckBox(mAccount, authority); + addSyncStateSwitch(mAccount, authority); } } - Collections.sort(mCheckBoxes); - for (int i = 0, n = mCheckBoxes.size(); i < n; i++) { - getPreferenceScreen().addPreference(mCheckBoxes.get(i)); + Collections.sort(mSwitches); + for (int i = 0, n = mSwitches.size(); i < n; i++) { + getPreferenceScreen().addPreference(mSwitches.get(i)); } } diff --git a/src/com/android/settings/accounts/SyncStateCheckBoxPreference.java b/src/com/android/settings/accounts/SyncStateSwitchPreference.java index db746ee..4d63870 100644 --- a/src/com/android/settings/accounts/SyncStateCheckBoxPreference.java +++ b/src/com/android/settings/accounts/SyncStateSwitchPreference.java @@ -19,7 +19,7 @@ package com.android.settings.accounts; import android.accounts.Account; import android.app.ActivityManager; import android.content.Context; -import android.preference.CheckBoxPreference; +import android.preference.SwitchPreference; import android.util.AttributeSet; import android.util.Log; import android.view.View; @@ -28,7 +28,7 @@ import android.widget.TextView; import com.android.settings.R; import com.android.settings.widget.AnimatedImageView; -public class SyncStateCheckBoxPreference extends CheckBoxPreference { +public class SyncStateSwitchPreference extends SwitchPreference { private boolean mIsActive = false; private boolean mIsPending = false; @@ -42,14 +42,14 @@ public class SyncStateCheckBoxPreference extends CheckBoxPreference { */ private boolean mOneTimeSyncMode = false; - public SyncStateCheckBoxPreference(Context context, AttributeSet attrs) { + public SyncStateSwitchPreference(Context context, AttributeSet attrs) { super(context, attrs); setWidgetLayoutResource(R.layout.preference_widget_sync_toggle); mAccount = null; mAuthority = null; } - public SyncStateCheckBoxPreference(Context context, Account account, String authority) { + public SyncStateSwitchPreference(Context context, Account account, String authority) { super(context, null); mAccount = account; mAuthority = authority; @@ -70,9 +70,9 @@ public class SyncStateCheckBoxPreference extends CheckBoxPreference { final boolean failedVisible = mFailed && !activeVisible; syncFailedView.setVisibility(failedVisible ? View.VISIBLE : View.GONE); - View checkBox = view.findViewById(android.R.id.checkbox); + View switchView = view.findViewById(com.android.internal.R.id.switchWidget); if (mOneTimeSyncMode) { - checkBox.setVisibility(View.GONE); + switchView.setVisibility(View.GONE); /* * Override the summary. Fill in the %1$s with the existing summary @@ -82,7 +82,7 @@ public class SyncStateCheckBoxPreference extends CheckBoxPreference { TextView summary = (TextView) view.findViewById(android.R.id.summary); summary.setText(getContext().getString(R.string.sync_one_time_sync, getSummary())); } else { - checkBox.setVisibility(View.VISIBLE); + switchView.setVisibility(View.VISIBLE); } } @@ -131,7 +131,7 @@ public class SyncStateCheckBoxPreference extends CheckBoxPreference { @Override protected void onClick() { // When we're in one-time sync mode, we don't want a click to change the - // checkbox state + // Switch state if (!mOneTimeSyncMode) { if (ActivityManager.isUserAMonkey()) { Log.d("SyncState", "ignoring monkey's attempt to flip sync state"); |