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:
Robin Lee
2016-09-01 18:35:00 +01:00
parent 141c20c5e3
commit bed8559a20
3 changed files with 41 additions and 29 deletions

View File

@@ -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);