Improved presentation of CA list
Change-Id: Ibc6dd9d553c3f7f53453fb43e9842afe789d8b50
This commit is contained in:
@@ -22,12 +22,28 @@
|
|||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:padding="15dip"
|
android:padding="15dip"
|
||||||
>
|
>
|
||||||
<TextView
|
<RelativeLayout
|
||||||
android:id="@+id/trusted_credential_subject"
|
|
||||||
android:layout_width="0px"
|
android:layout_width="0px"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
/>
|
>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/trusted_credential_subject_primary"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/trusted_credential_subject_secondary"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/trusted_credential_subject_primary"
|
||||||
|
android:layout_alignLeft="@id/trusted_credential_subject_primary"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
/>
|
||||||
|
</RelativeLayout>
|
||||||
<!-- checkbox is invisible and not gone so that the height is consistent between tabs -->
|
<!-- checkbox is invisible and not gone so that the height is consistent between tabs -->
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:id="@+id/trusted_credential_status"
|
android:id="@+id/trusted_credential_status"
|
||||||
|
@@ -191,14 +191,18 @@ public class TrustedCredentialsSettings extends Fragment {
|
|||||||
LayoutInflater inflater = LayoutInflater.from(getActivity());
|
LayoutInflater inflater = LayoutInflater.from(getActivity());
|
||||||
view = inflater.inflate(R.layout.trusted_credential, parent, false);
|
view = inflater.inflate(R.layout.trusted_credential, parent, false);
|
||||||
holder = new ViewHolder();
|
holder = new ViewHolder();
|
||||||
holder.mSubjectView = (TextView)view.findViewById(R.id.trusted_credential_subject);
|
holder.mSubjectPrimaryView = (TextView)
|
||||||
|
view.findViewById(R.id.trusted_credential_subject_primary);
|
||||||
|
holder.mSubjectSecondaryView = (TextView)
|
||||||
|
view.findViewById(R.id.trusted_credential_subject_secondary);
|
||||||
holder.mCheckBox = (CheckBox) view.findViewById(R.id.trusted_credential_status);
|
holder.mCheckBox = (CheckBox) view.findViewById(R.id.trusted_credential_status);
|
||||||
view.setTag(holder);
|
view.setTag(holder);
|
||||||
} else {
|
} else {
|
||||||
holder = (ViewHolder) view.getTag();
|
holder = (ViewHolder) view.getTag();
|
||||||
}
|
}
|
||||||
CertHolder certHolder = mCertHolders.get(position);
|
CertHolder certHolder = mCertHolders.get(position);
|
||||||
holder.mSubjectView.setText(certHolder.mSubject);
|
holder.mSubjectPrimaryView.setText(certHolder.mSubjectPrimary);
|
||||||
|
holder.mSubjectSecondaryView.setText(certHolder.mSubjectSecondary);
|
||||||
if (mTab.mCheckbox) {
|
if (mTab.mCheckbox) {
|
||||||
holder.mCheckBox.setChecked(!certHolder.mDeleted);
|
holder.mCheckBox.setChecked(!certHolder.mDeleted);
|
||||||
holder.mCheckBox.setVisibility(View.VISIBLE);
|
holder.mCheckBox.setVisibility(View.VISIBLE);
|
||||||
@@ -245,7 +249,8 @@ public class TrustedCredentialsSettings extends Fragment {
|
|||||||
private final X509Certificate mX509Cert;
|
private final X509Certificate mX509Cert;
|
||||||
|
|
||||||
private final SslCertificate mSslCert;
|
private final SslCertificate mSslCert;
|
||||||
private final String mSubject;
|
private final String mSubjectPrimary;
|
||||||
|
private final String mSubjectSecondary;
|
||||||
private boolean mDeleted;
|
private boolean mDeleted;
|
||||||
|
|
||||||
private CertHolder(TrustedCertificateStore store,
|
private CertHolder(TrustedCertificateStore store,
|
||||||
@@ -264,32 +269,34 @@ public class TrustedCredentialsSettings extends Fragment {
|
|||||||
String cn = mSslCert.getIssuedTo().getCName();
|
String cn = mSslCert.getIssuedTo().getCName();
|
||||||
String o = mSslCert.getIssuedTo().getOName();
|
String o = mSslCert.getIssuedTo().getOName();
|
||||||
String ou = mSslCert.getIssuedTo().getUName();
|
String ou = mSslCert.getIssuedTo().getUName();
|
||||||
StringBuilder sb = new StringBuilder();
|
// if we have a O, use O as primary subject, secondary prefer CN over OU
|
||||||
if (!cn.isEmpty()) {
|
// if we don't have an O, use CN as primary, empty secondary
|
||||||
sb.append("CN=" + cn);
|
// if we don't have O or CN, use DName as primary, empty secondary
|
||||||
}
|
|
||||||
if (!o.isEmpty()) {
|
if (!o.isEmpty()) {
|
||||||
if (sb.length() != 0) {
|
if (!cn.isEmpty()) {
|
||||||
sb.append(", ");
|
mSubjectPrimary = o;
|
||||||
|
mSubjectSecondary = cn;
|
||||||
|
} else {
|
||||||
|
mSubjectPrimary = o;
|
||||||
|
mSubjectSecondary = ou;
|
||||||
}
|
}
|
||||||
sb.append("O=" + o);
|
|
||||||
}
|
|
||||||
if (!ou.isEmpty()) {
|
|
||||||
if (sb.length() != 0) {
|
|
||||||
sb.append(", ");
|
|
||||||
}
|
|
||||||
sb.append("OU=" + ou);
|
|
||||||
}
|
|
||||||
if (sb.length() != 0) {
|
|
||||||
mSubject = sb.toString();
|
|
||||||
} else {
|
} else {
|
||||||
mSubject = mSslCert.getIssuedTo().getDName();
|
if (!cn.isEmpty()) {
|
||||||
|
mSubjectPrimary = cn;
|
||||||
|
mSubjectSecondary = "";
|
||||||
|
} else {
|
||||||
|
mSubjectPrimary = mSslCert.getIssuedTo().getDName();
|
||||||
|
mSubjectSecondary = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mDeleted = mTab.deleted(mStore, mAlias);
|
mDeleted = mTab.deleted(mStore, mAlias);
|
||||||
}
|
}
|
||||||
@Override public int compareTo(CertHolder o) {
|
@Override public int compareTo(CertHolder o) {
|
||||||
return this.mSubject.compareTo(o.mSubject);
|
int primary = this.mSubjectPrimary.compareToIgnoreCase(o.mSubjectPrimary);
|
||||||
|
if (primary != 0) {
|
||||||
|
return primary;
|
||||||
|
}
|
||||||
|
return this.mSubjectSecondary.compareToIgnoreCase(o.mSubjectSecondary);
|
||||||
}
|
}
|
||||||
@Override public boolean equals(Object o) {
|
@Override public boolean equals(Object o) {
|
||||||
if (!(o instanceof CertHolder)) {
|
if (!(o instanceof CertHolder)) {
|
||||||
@@ -304,7 +311,8 @@ public class TrustedCredentialsSettings extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class ViewHolder {
|
private static class ViewHolder {
|
||||||
private TextView mSubjectView;
|
private TextView mSubjectPrimaryView;
|
||||||
|
private TextView mSubjectSecondaryView;
|
||||||
private CheckBox mCheckBox;
|
private CheckBox mCheckBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user