Merge "UI improvements to cert selection"

This commit is contained in:
Ben Komalo 2011-09-19 16:52:08 -07:00 committed by Android (Google) Code Review
commit 02774840d0
3 changed files with 47 additions and 19 deletions

View File

@ -21,22 +21,37 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dip"
android:gravity="center_vertical"
android:orientation="horizontal" >
android:gravity="center_vertical" >
<TextView
android:id="@+id/certificate_alias"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="end"
android:visibility="gone" />
<Button
android:id="@+id/select_button"
style="@style/accountSetupButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="@string/account_setup_exchange_use_certificate" />
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/select_button"
android:textStyle="bold"
android:text="@string/account_setup_exchange_certificate_title" />
<TextView
android:id="@+id/certificate_alias"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dip"
android:layout_below="@+id/title"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/select_button"
android:textColor="@color/text_secondary_color"
android:singleLine="true"
android:ellipsize="end"
android:text="@string/account_setup_exchange_no_certificate" />
</com.android.email.view.CertificateSelector>

View File

@ -700,10 +700,15 @@ save attachment.</string>
<string name="account_setup_exchange_ssl_label">Use secure connection (SSL)</string>
<!-- On "Exchange" setup screen, the trust ssl certificates checkbox label -->
<string name="account_setup_exchange_trust_certificates_label">Accept all SSL certificates</string>
<!-- On "Exchange" setup screen, a heading title for the current client certificate [CHAR LIMIT=50] -->
<string name="account_setup_exchange_certificate_title">Client certificate</string>
<!-- On "Exchange" setup screen, a button label to include a client certificate [CHAR LIMIT=35] -->
<string name="account_setup_exchange_use_certificate">Use client certificate</string>
<string name="account_setup_exchange_select_certificate">Select</string>
<!-- On "Exchange" setup screen, a button label to remove the currently used client certificate [CHAR LIMIT=35] -->
<string name="account_setup_exchange_remove_certificate">Remove</string>
<!-- On "Exchange" setup screen, placeholder text to indicate no client
certificate is used [CHAR LIMIT=50] -->
<string name="account_setup_exchange_no_certificate">None</string>
<!-- On "Exchange" setup screen, the exchange device-id label [CHAR LIMIT=30] -->
<string name="account_setup_exchange_device_id_label">Mobile Device ID</string>

View File

@ -18,6 +18,7 @@
package com.android.email.view;
import android.content.Context;
import android.content.res.Resources;
import android.os.Parcel;
import android.os.Parcelable;
import android.security.KeyChain;
@ -25,7 +26,7 @@ import android.util.AttributeSet;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.android.email.R;
@ -36,12 +37,15 @@ import com.android.email.activity.UiUtilities;
*
* Host activities must register themselves view {@link #setHostActivity} for this selector to work.
*/
public class CertificateSelector extends LinearLayout implements OnClickListener {
public class CertificateSelector extends RelativeLayout implements OnClickListener {
/** Button to select or remove the certificate. */
private Button mSelectButton;
private TextView mAliasText;
/** The value of the cert selected, if any. Null, otherwise. */
private String mValue;
/** The host activity. */
private HostCallback mHost;
@ -77,23 +81,27 @@ public class CertificateSelector extends LinearLayout implements OnClickListener
}
public void setCertificate(String alias) {
mAliasText.setText(alias);
mAliasText.setVisibility((alias == null) ? View.GONE : View.VISIBLE);
mSelectButton.setText(getResources().getString(
Resources res = getResources();
mValue = alias;
mAliasText.setText(
(alias == null)
? R.string.account_setup_exchange_use_certificate
? res.getString(R.string.account_setup_exchange_no_certificate)
: alias);
mSelectButton.setText(res.getString(
(alias == null)
? R.string.account_setup_exchange_select_certificate
: R.string.account_setup_exchange_remove_certificate));
}
public boolean hasCertificate() {
return mAliasText.getVisibility() == View.VISIBLE;
return mValue != null;
}
/**
* Gets the alias for the currently selected certificate, or null if one is not selected.
*/
public String getCertificate() {
return hasCertificate() ? mAliasText.getText().toString() : null;
return mValue;
}