From 7154257b23d1a85f3a7ec4ecbf02c9e18e4440dd Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Wed, 6 Jun 2012 20:23:08 -0700 Subject: [PATCH 1/2] Add back a SYNC_SETTINGS screen Revive the old Accounts&Sync screen as a dialog with the auto-sync checkbox and a list of accounts. This will be launched when Apps request a SYNC_SETTINGS page for controlling account and master sync. Auto-sync data checkbox will also continue to exist in Data Usage. Minor fixes to account list and account update monitoring. Bug: 6614013 Bug: 6622995 Bug: 6610247 Change-Id: I35c0919a29c6bc7e5edf64f2734a3ef4f5ae5e7a --- AndroidManifest.xml | 12 +- res/values/dimens.xml | 2 +- res/xml/sync_settings.xml | 21 +++ .../android/settings/AccountPreference.java | 34 +++- src/com/android/settings/Settings.java | 13 +- .../accounts/ManageAccountsSettings.java | 20 +- .../settings/accounts/SyncSettings.java | 174 ++++++++++++++++++ .../accounts/SyncSettingsActivity.java | 34 ++++ 8 files changed, 287 insertions(+), 23 deletions(-) create mode 100644 res/xml/sync_settings.xml create mode 100644 src/com/android/settings/accounts/SyncSettings.java create mode 100644 src/com/android/settings/accounts/SyncSettingsActivity.java diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 09767bf2881..cf1f888ab4d 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1366,6 +1366,7 @@ @@ -1378,6 +1379,16 @@ android:resource="@id/account_settings" /> + + + + + + + + - diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 3911fd526a5..933578861d2 100755 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -48,7 +48,7 @@ 7dip - 32dp + 28dp 260dip 40dip diff --git a/res/xml/sync_settings.xml b/res/xml/sync_settings.xml new file mode 100644 index 00000000000..530f4ab25cb --- /dev/null +++ b/res/xml/sync_settings.xml @@ -0,0 +1,21 @@ + + + + + + diff --git a/src/com/android/settings/AccountPreference.java b/src/com/android/settings/AccountPreference.java index e7919dd1cf7..2cc013cb8a0 100644 --- a/src/com/android/settings/AccountPreference.java +++ b/src/com/android/settings/AccountPreference.java @@ -39,16 +39,24 @@ public class AccountPreference extends Preference { private int mStatus; private Account mAccount; private ArrayList mAuthorities; + private ImageView mSyncStatusIcon; + private boolean mShowTypeIcon; public AccountPreference(Context context, Account account, Drawable icon, - ArrayList authorities) { + ArrayList authorities, boolean showTypeIcon) { super(context); mAccount = account; mAuthorities = authorities; + mShowTypeIcon = showTypeIcon; + if (showTypeIcon) { + setIcon(icon); + } else { + setIcon(getSyncStatusIcon(SYNC_DISABLED)); + } setTitle(mAccount.name); setSummary(""); setPersistent(false); - setSyncStatus(SYNC_DISABLED); + setSyncStatus(SYNC_DISABLED, false); } public Account getAccount() { @@ -62,16 +70,22 @@ public class AccountPreference extends Preference { @Override protected void onBindView(View view) { super.onBindView(view); - setSummary(getSyncStatusMessage(mStatus)); - ImageView iconView = (ImageView) view.findViewById(android.R.id.icon); - iconView.setImageResource(getSyncStatusIcon(mStatus)); - iconView.setContentDescription(getSyncContentDescription(mStatus)); + if (!mShowTypeIcon) { + mSyncStatusIcon = (ImageView) view.findViewById(android.R.id.icon); + mSyncStatusIcon.setImageResource(getSyncStatusIcon(mStatus)); + mSyncStatusIcon.setContentDescription(getSyncContentDescription(mStatus)); + } } - public void setSyncStatus(int status) { + public void setSyncStatus(int status, boolean updateSummary) { mStatus = status; - setIcon(getSyncStatusIcon(status)); - setSummary(getSyncStatusMessage(status)); + if (!mShowTypeIcon && mSyncStatusIcon != null) { + mSyncStatusIcon.setImageResource(getSyncStatusIcon(status)); + mSyncStatusIcon.setContentDescription(getSyncContentDescription(mStatus)); + } + if (updateSummary) { + setSummary(getSyncStatusMessage(status)); + } } private int getSyncStatusMessage(int status) { @@ -109,7 +123,7 @@ public class AccountPreference extends Preference { res = R.drawable.ic_sync_red_holo; break; case SYNC_IN_PROGRESS: - res = R.drawable.ic_sync_grey_holo; + res = R.drawable.ic_sync_green_holo; break; default: res = R.drawable.ic_sync_red_holo; diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java index 353bc3a699a..50019a33940 100644 --- a/src/com/android/settings/Settings.java +++ b/src/com/android/settings/Settings.java @@ -112,6 +112,7 @@ public class Settings extends PreferenceActivity private AuthenticatorHelper mAuthenticatorHelper; private Header mLastHeader; + private boolean mListeningToAccountUpdates; @Override protected void onCreate(Bundle savedInstanceState) { @@ -187,7 +188,6 @@ public class Settings extends PreferenceActivity ListAdapter listAdapter = getListAdapter(); if (listAdapter instanceof HeaderAdapter) { ((HeaderAdapter) listAdapter).resume(); - AccountManager.get(this).addOnAccountsUpdatedListener(this, null, true); } } @@ -198,6 +198,13 @@ public class Settings extends PreferenceActivity ListAdapter listAdapter = getListAdapter(); if (listAdapter instanceof HeaderAdapter) { ((HeaderAdapter) listAdapter).pause(); + } + } + + @Override + public void onDestroy() { + super.onDestroy(); + if (mListeningToAccountUpdates) { AccountManager.get(this).removeOnAccountsUpdatedListener(this); } } @@ -462,6 +469,10 @@ public class Settings extends PreferenceActivity for (Header header : accountHeaders) { target.add(headerIndex++, header); } + if (!mListeningToAccountUpdates) { + AccountManager.get(this).addOnAccountsUpdatedListener(this, null, true); + mListeningToAccountUpdates = true; + } return headerIndex; } diff --git a/src/com/android/settings/accounts/ManageAccountsSettings.java b/src/com/android/settings/accounts/ManageAccountsSettings.java index 85cf025978e..bb1ebddd528 100644 --- a/src/com/android/settings/accounts/ManageAccountsSettings.java +++ b/src/com/android/settings/accounts/ManageAccountsSettings.java @@ -166,8 +166,8 @@ public class ManageAccountsSettings extends AccountPreferenceBase public void onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); boolean syncActive = ContentResolver.getCurrentSync() != null; - menu.findItem(MENU_SYNC_NOW_ID).setVisible(!syncActive); - menu.findItem(MENU_SYNC_CANCEL_ID).setVisible(syncActive); + menu.findItem(MENU_SYNC_NOW_ID).setVisible(!syncActive && mFirstAccount != null); + menu.findItem(MENU_SYNC_CANCEL_ID).setVisible(syncActive && mFirstAccount != null); } @Override @@ -274,16 +274,16 @@ public class ManageAccountsSettings extends AccountPreferenceBase } } if (syncIsFailing) { - accountPref.setSyncStatus(AccountPreference.SYNC_ERROR); + accountPref.setSyncStatus(AccountPreference.SYNC_ERROR, true); } else if (syncCount == 0) { - accountPref.setSyncStatus(AccountPreference.SYNC_DISABLED); + accountPref.setSyncStatus(AccountPreference.SYNC_DISABLED, true); } else if (syncCount > 0) { if (syncingNow) { - accountPref.setSyncStatus(AccountPreference.SYNC_IN_PROGRESS); + accountPref.setSyncStatus(AccountPreference.SYNC_IN_PROGRESS, true); } else { - accountPref.setSyncStatus(AccountPreference.SYNC_ENABLED); + accountPref.setSyncStatus(AccountPreference.SYNC_ENABLED, true); if (lastSuccessTime > 0) { - accountPref.setSyncStatus(AccountPreference.SYNC_ENABLED); + accountPref.setSyncStatus(AccountPreference.SYNC_ENABLED, false); date.setTime(lastSuccessTime); final String timeString = formatSyncDate(date); accountPref.setSummary(getResources().getString( @@ -291,7 +291,7 @@ public class ManageAccountsSettings extends AccountPreferenceBase } } } else { - accountPref.setSyncStatus(AccountPreference.SYNC_DISABLED); + accountPref.setSyncStatus(AccountPreference.SYNC_DISABLED, true); } } @@ -324,14 +324,14 @@ public class ManageAccountsSettings extends AccountPreferenceBase if (showAccount) { final Drawable icon = getDrawableForType(account.type); final AccountPreference preference = - new AccountPreference(getActivity(), account, icon, auths); + new AccountPreference(getActivity(), account, icon, auths, false); getPreferenceScreen().addPreference(preference); if (mFirstAccount == null) { mFirstAccount = account; } } } - if (mAccountType != null) { + if (mAccountType != null && mFirstAccount != null) { addAuthenticatorSettings(); } onSyncStateUpdated(); diff --git a/src/com/android/settings/accounts/SyncSettings.java b/src/com/android/settings/accounts/SyncSettings.java new file mode 100644 index 00000000000..20c296a1e7d --- /dev/null +++ b/src/com/android/settings/accounts/SyncSettings.java @@ -0,0 +1,174 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.accounts; + +import android.accounts.Account; +import android.accounts.AccountManager; +import android.accounts.OnAccountsUpdateListener; +import android.app.Activity; +import android.content.ContentResolver; +import android.content.Intent; +import android.graphics.drawable.Drawable; +import android.os.Bundle; +import android.preference.CheckBoxPreference; +import android.preference.Preference; +import android.preference.Preference.OnPreferenceChangeListener; +import android.preference.PreferenceScreen; +import android.util.Log; + +import com.android.settings.AccountPreference; +import com.android.settings.DialogCreatable; +import com.android.settings.R; + +import java.util.ArrayList; + +public class SyncSettings extends AccountPreferenceBase + implements OnAccountsUpdateListener, DialogCreatable { + + private static final String KEY_SYNC_SWITCH = "sync_switch"; + + private String[] mAuthorities; + + private SettingsDialogFragment mDialogFragment; + private CheckBoxPreference mAutoSyncPreference; + + @Override + public void onCreate(Bundle icicle) { + super.onCreate(icicle); + + addPreferencesFromResource(R.xml.sync_settings); + mAutoSyncPreference = + (CheckBoxPreference) getPreferenceScreen().findPreference(KEY_SYNC_SWITCH); + mAutoSyncPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + ContentResolver.setMasterSyncAutomatically((Boolean) newValue); + return true; + } + }); + + setHasOptionsMenu(true); + } + + @Override + public void onStart() { + super.onStart(); + Activity activity = getActivity(); + AccountManager.get(activity).addOnAccountsUpdatedListener(this, null, true); + } + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + + final Activity activity = getActivity(); + mAutoSyncPreference.setChecked(ContentResolver.getMasterSyncAutomatically()); + mAuthorities = activity.getIntent().getStringArrayExtra(AUTHORITIES_FILTER_KEY); + + updateAuthDescriptions(); + } + + @Override + public void onStop() { + super.onStop(); + final Activity activity = getActivity(); + AccountManager.get(activity).removeOnAccountsUpdatedListener(this); + } + + @Override + public boolean onPreferenceTreeClick(PreferenceScreen preferences, Preference preference) { + if (preference instanceof AccountPreference) { + startAccountSettings((AccountPreference) preference); + } else { + return false; + } + return true; + } + + private void startAccountSettings(AccountPreference acctPref) { + Intent intent = new Intent("android.settings.ACCOUNT_SYNC_SETTINGS"); + intent.putExtra(AccountSyncSettings.ACCOUNT_KEY, acctPref.getAccount()); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + finish(); + } + + @Override + public void showDialog(int dialogId) { + if (mDialogFragment != null) { + Log.e(TAG, "Old dialog fragment not null!"); + } + mDialogFragment = new SettingsDialogFragment(this, dialogId); + mDialogFragment.show(getActivity().getFragmentManager(), Integer.toString(dialogId)); + } + + private void removeAccountPreferences() { + PreferenceScreen parent = getPreferenceScreen(); + for (int i = 0; i < parent.getPreferenceCount(); ) { + if (parent.getPreference(i) instanceof AccountPreference) { + parent.removePreference(parent.getPreference(i)); + } else { + i++; + } + } + } + + @Override + public void onAccountsUpdated(Account[] accounts) { + if (getActivity() == null) return; + + removeAccountPreferences(); + for (int i = 0, n = accounts.length; i < n; i++) { + final Account account = accounts[i]; + final ArrayList auths = getAuthoritiesForAccountType(account.type); + + boolean showAccount = true; + if (mAuthorities != null && auths != null) { + showAccount = false; + for (String requestedAuthority : mAuthorities) { + if (auths.contains(requestedAuthority)) { + showAccount = true; + break; + } + } + } + + if (showAccount) { + final Drawable icon = getDrawableForType(account.type); + final AccountPreference preference = + new AccountPreference(getActivity(), account, icon, auths, true); + getPreferenceScreen().addPreference(preference); + preference.setSummary(getLabelForType(account.type)); + } + } + onSyncStateUpdated(); + } + + @Override + protected void onAuthDescriptionsUpdated() { + // Update account icons for all account preference items + for (int i = 0; i < getPreferenceScreen().getPreferenceCount(); i++) { + Preference pref = getPreferenceScreen().getPreference(i); + if (pref instanceof AccountPreference) { + AccountPreference accPref = (AccountPreference) + getPreferenceScreen().getPreference(i); + accPref.setIcon(getDrawableForType(accPref.getAccount().type)); + accPref.setSummary(getLabelForType(accPref.getAccount().type)); + } + } + } +} diff --git a/src/com/android/settings/accounts/SyncSettingsActivity.java b/src/com/android/settings/accounts/SyncSettingsActivity.java new file mode 100644 index 00000000000..ed0089e936a --- /dev/null +++ b/src/com/android/settings/accounts/SyncSettingsActivity.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.accounts; + +import android.content.Intent; +import android.preference.PreferenceActivity; + +/** + * Launcher activity for the SyncSettings fragment. + * + */ +public class SyncSettingsActivity extends PreferenceActivity { + @Override + public Intent getIntent() { + Intent modIntent = new Intent(super.getIntent()); + modIntent.putExtra(EXTRA_SHOW_FRAGMENT, SyncSettings.class.getName()); + modIntent.putExtra(EXTRA_NO_HEADERS, true); + return modIntent; + } +} \ No newline at end of file From d7b5290ed1511db4bd18c0d6868bd1031d60a1f1 Mon Sep 17 00:00:00 2001 From: Danielle Millett Date: Wed, 6 Jun 2012 13:54:11 -0400 Subject: [PATCH 2/2] Removing head turn and putting blink back Changing the strings and workflow in settings to be blink again instead of the new head turn. This basically undoes the following two cls: I67c8acd4 and Ifc7b6e18. Change-Id: I8694b1d82efac9d2f97c29128da6698b6ac2a4ce --- res/layout/biometric_weak_liveliness.xml | 46 ------ res/values/strings.xml | 11 +- res/xml/security_settings_biometric_weak.xml | 6 +- .../settings/BiometricWeakLiveliness.java | 136 ------------------ .../android/settings/SecuritySettings.java | 36 ++++- 5 files changed, 37 insertions(+), 198 deletions(-) delete mode 100644 res/layout/biometric_weak_liveliness.xml delete mode 100644 src/com/android/settings/BiometricWeakLiveliness.java diff --git a/res/layout/biometric_weak_liveliness.xml b/res/layout/biometric_weak_liveliness.xml deleted file mode 100644 index 916bd9a3f3c..00000000000 --- a/res/layout/biometric_weak_liveliness.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/res/values/strings.xml b/res/values/strings.xml index ebe764c6915..7aa2b8aa995 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -644,15 +644,10 @@ Improve face matching - + Liveness check - - On - head turn required to unlock - - Off - - - To improve security, you\'ll be asked to turn your head while unlocking. When prompted, turn to the left or right. + + Require eye blink while unlocking Automatically lock diff --git a/res/xml/security_settings_biometric_weak.xml b/res/xml/security_settings_biometric_weak.xml index 66cca28d978..6593f07a9fc 100644 --- a/res/xml/security_settings_biometric_weak.xml +++ b/res/xml/security_settings_biometric_weak.xml @@ -30,10 +30,10 @@ android:key="biometric_weak_improve_matching" android:title="@string/biometric_weak_improve_matching_title"/> - + android:title="@string/biometric_weak_liveliness_title" + android:summary="@string/biometric_weak_liveliness_summary"/>