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
This commit is contained in:
@@ -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>
|
||||
|
@@ -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() {
|
||||
DialogInterface.OnClickListener onConfirm = new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
mDelegate.removeOrInstallCert(certHolder);
|
||||
dialog.dismiss();
|
||||
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
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user