summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Robin Lee <rgl@google.com> 2016-09-01 18:35:00 +0100
committer Robin Lee <rgl@google.com> 2016-09-02 11:03:32 +0100
commitbed8559a203dc0227b8609c2d45fd3f461c41ccc (patch)
tree45b888421c1778648d5b3d2c8fd4906ae816e987
parent141c20c5e316481ce2f012f16a65ee77e5097829 (diff)
Enable the switch in TrustedCredentialsSettings
And match the behaviour of the dialog button that does the same thing, so it only asks for confirmation when something is being irrevocably deleted. The dialog button should not be removed as it's used by system services that deeplink to a specific cert to give the option of reviewing, removing, or trusting it. Bug: 31159682 Change-Id: I4fb3f38f8ab0e80e5c2dca0fc3d6d3bd4db26bb6
-rw-r--r--res/layout/trusted_credential.xml8
-rw-r--r--src/com/android/settings/TrustedCredentialsDialogBuilder.java42
-rw-r--r--src/com/android/settings/TrustedCredentialsSettings.java20
3 files changed, 41 insertions, 29 deletions
diff --git a/res/layout/trusted_credential.xml b/res/layout/trusted_credential.xml
index cc146f8195c..acef60bb5ec 100644
--- a/res/layout/trusted_credential.xml
+++ b/res/layout/trusted_credential.xml
@@ -21,14 +21,15 @@
android:background="?android:attr/selectableItemBackground"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
- android:paddingTop="15dip"
- android:paddingBottom="15dip"
+ android:descendantFocusability="blocksDescendants"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
+ android:paddingTop="15dip"
+ android:paddingBottom="15dip"
android:orientation="vertical">
<TextView
@@ -53,8 +54,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible"
- android:clickable="false"
- android:focusable="false"
+ android:padding="8dp"
android:layout_weight="0" />
</LinearLayout>
diff --git a/src/com/android/settings/TrustedCredentialsDialogBuilder.java b/src/com/android/settings/TrustedCredentialsDialogBuilder.java
index 31042cbcde1..03414bdc2e1 100644
--- a/src/com/android/settings/TrustedCredentialsDialogBuilder.java
+++ b/src/com/android/settings/TrustedCredentialsDialogBuilder.java
@@ -138,7 +138,7 @@ class TrustedCredentialsDialogBuilder extends AlertDialog.Builder {
onClickOk();
}
} else if (view == mNegativeButton) {
- onClickRemove();
+ onClickEnableOrDisable();
}
}
@@ -155,21 +155,26 @@ class TrustedCredentialsDialogBuilder extends AlertDialog.Builder {
}
}
- private void onClickRemove() {
+ private void onClickEnableOrDisable() {
final CertHolder certHolder = getCurrentCertInfo();
- new AlertDialog.Builder(mActivity)
- .setMessage(getButtonConfirmation(certHolder))
- .setPositiveButton(android.R.string.yes,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int id) {
- mDelegate.removeOrInstallCert(certHolder);
- dialog.dismiss();
- nextOrDismiss();
- }
- })
- .setNegativeButton(android.R.string.no, null)
- .show();
+ DialogInterface.OnClickListener onConfirm = new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int id) {
+ mDelegate.removeOrInstallCert(certHolder);
+ nextOrDismiss();
+ }
+ };
+ if (certHolder.isSystemCert()) {
+ // Removing system certs is reversible, so skip confirmation.
+ onConfirm.onClick(null, -1);
+ } else {
+ new AlertDialog.Builder(mActivity)
+ .setMessage(R.string.trusted_credentials_remove_confirmation)
+ .setPositiveButton(android.R.string.yes, onConfirm)
+ .setNegativeButton(android.R.string.no, null)
+ .show();
+
+ }
}
private void onCredentialConfirmed(int userId) {
@@ -314,13 +319,6 @@ class TrustedCredentialsDialogBuilder extends AlertDialog.Builder {
return certLayout;
}
- private static int getButtonConfirmation(CertHolder certHolder) {
- return certHolder.isSystemCert() ? ( certHolder.isDeleted()
- ? R.string.trusted_credentials_enable_confirmation
- : R.string.trusted_credentials_disable_confirmation )
- : R.string.trusted_credentials_remove_confirmation;
- }
-
private static int getButtonLabel(CertHolder certHolder) {
return certHolder.isSystemCert() ? ( certHolder.isDeleted()
? R.string.trusted_credentials_enable_label
diff --git a/src/com/android/settings/TrustedCredentialsSettings.java b/src/com/android/settings/TrustedCredentialsSettings.java
index 4cefc74674f..bae0a929ccf 100644
--- a/src/com/android/settings/TrustedCredentialsSettings.java
+++ b/src/com/android/settings/TrustedCredentialsSettings.java
@@ -318,7 +318,8 @@ public class TrustedCredentialsSettings extends OptionsMenuFragment
* whereas children correspond to certificates.
*/
private class GroupAdapter extends BaseExpandableListAdapter implements
- ExpandableListView.OnGroupClickListener, ExpandableListView.OnChildClickListener {
+ ExpandableListView.OnGroupClickListener, ExpandableListView.OnChildClickListener,
+ View.OnClickListener {
private final AdapterData mData;
private GroupAdapter(Tab tab) {
@@ -402,6 +403,16 @@ public class TrustedCredentialsSettings extends OptionsMenuFragment
return true;
}
+ /**
+ * Called when the switch on a system certificate is clicked. This will toggle whether it
+ * is trusted as a credential.
+ */
+ @Override
+ public void onClick(View view) {
+ CertHolder holder = (CertHolder) view.getTag();
+ removeOrInstallCert(holder);
+ }
+
@Override
public boolean onGroupClick(ExpandableListView expandableListView, View view,
int groupPosition, long id) {
@@ -459,16 +470,17 @@ public class TrustedCredentialsSettings extends OptionsMenuFragment
ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
+ holder = new ViewHolder();
LayoutInflater inflater = LayoutInflater.from(getActivity());
convertView = inflater.inflate(R.layout.trusted_credential, parent, false);
- holder = new ViewHolder();
+ convertView.setTag(holder);
holder.mSubjectPrimaryView = (TextView)
convertView.findViewById(R.id.trusted_credential_subject_primary);
holder.mSubjectSecondaryView = (TextView)
convertView.findViewById(R.id.trusted_credential_subject_secondary);
holder.mSwitch = (Switch) convertView.findViewById(
R.id.trusted_credential_status);
- convertView.setTag(holder);
+ holder.mSwitch.setOnClickListener(this);
} else {
holder = (ViewHolder) convertView.getTag();
}
@@ -480,6 +492,7 @@ public class TrustedCredentialsSettings extends OptionsMenuFragment
UserManager.DISALLOW_CONFIG_CREDENTIALS,
new UserHandle(certHolder.mProfileId)));
holder.mSwitch.setVisibility(View.VISIBLE);
+ holder.mSwitch.setTag(certHolder);
}
return convertView;
}
@@ -576,6 +589,7 @@ public class TrustedCredentialsSettings extends OptionsMenuFragment
mListView = (ListView) mContainerView.findViewById(R.id.cert_list);
mListView.setAdapter(this);
mListView.setOnItemClickListener(this);
+ mListView.setItemsCanFocus(true);
mHeaderView = (ViewGroup) mContainerView.findViewById(R.id.header_view);
mHeaderView.setOnClickListener(this);