Make certificate selector work
Change-Id: Id1ae8c9bb9467effc8feca9d915dc4927c4bbe25
This commit is contained in:
parent
8a41d9fd10
commit
d23fa61a01
@ -17,9 +17,9 @@
|
||||
package com.android.email.activity.setup;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.FragmentManager;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
@ -45,6 +45,7 @@ import com.android.email2.ui.MailActivityEmail;
|
||||
import com.android.emailcommon.Logging;
|
||||
import com.android.emailcommon.provider.Account;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.utility.CertificateRequestor;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
import com.android.mail.utils.LogUtils;
|
||||
|
||||
@ -59,6 +60,8 @@ import java.util.ArrayList;
|
||||
public class AccountSetupIncomingFragment extends AccountServerBaseFragment
|
||||
implements AuthenticationCallback {
|
||||
|
||||
private static final int CERTIFICATE_REQUEST = 0;
|
||||
|
||||
private final static String STATE_KEY_CREDENTIAL = "AccountSetupIncomingFragment.credential";
|
||||
private final static String STATE_KEY_LOADED = "AccountSetupIncomingFragment.loaded";
|
||||
|
||||
@ -564,4 +567,20 @@ public class AccountSetupIncomingFragment extends AccountServerBaseFragment
|
||||
public void onValidateStateChanged() {
|
||||
validateFields();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCertificateRequested() {
|
||||
final Intent intent = new Intent(CertificateRequestor.ACTION_REQUEST_CERT);
|
||||
intent.setData(Uri.parse("eas://com.android.emailcommon/certrequest"));
|
||||
startActivityForResult(intent, CERTIFICATE_REQUEST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == CERTIFICATE_REQUEST && resultCode == Activity.RESULT_OK) {
|
||||
final String certAlias = data.getStringExtra(CertificateRequestor.RESULT_ALIAS);
|
||||
mAuthenticationView.setCertificate(certAlias);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,8 +43,6 @@ import java.io.IOException;
|
||||
|
||||
public class AuthenticationView extends LinearLayout implements HostCallback, OnClickListener {
|
||||
|
||||
private static final int CERTIFICATE_REQUEST = 0;
|
||||
|
||||
private final static String SUPER_STATE = "super_state";
|
||||
private final static String SAVE_PASSWORD = "save_password";
|
||||
private final static String SAVE_OFFER_OAUTH = "save_offer_oauth";
|
||||
@ -83,6 +81,8 @@ public class AuthenticationView extends LinearLayout implements HostCallback, On
|
||||
|
||||
public interface AuthenticationCallback {
|
||||
public void onValidateStateChanged();
|
||||
|
||||
public void onCertificateRequested();
|
||||
}
|
||||
|
||||
public AuthenticationView(Context context) {
|
||||
@ -120,6 +120,8 @@ public class AuthenticationView extends LinearLayout implements HostCallback, On
|
||||
mClearOAuthView.setOnClickListener(this);
|
||||
mAddAuthenticationView.setOnClickListener(this);
|
||||
|
||||
mClientCertificateSelector.setHostCallback(this);
|
||||
|
||||
mValidationTextWatcher = new TextWatcher() {
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
@ -295,20 +297,11 @@ public class AuthenticationView extends LinearLayout implements HostCallback, On
|
||||
|
||||
@Override
|
||||
public void onCertificateRequested() {
|
||||
final Intent intent = new Intent(CertificateRequestor.ACTION_REQUEST_CERT);
|
||||
intent.setData(Uri.parse("eas://com.android.emailcommon/certrequest"));
|
||||
// FLAG this is wrong, since this is not an activity or fragment, it cannot receive
|
||||
// results directly. The owning activity or fragment needs to forward them.
|
||||
// startActivityForResult(intent, CERTIFICATE_REQUEST);
|
||||
mAuthenticationCallback.onCertificateRequested();
|
||||
}
|
||||
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == CERTIFICATE_REQUEST && resultCode == Activity.RESULT_OK) {
|
||||
final String certAlias = data.getStringExtra(CertificateRequestor.RESULT_ALIAS);
|
||||
if (certAlias != null) {
|
||||
mClientCertificateSelector.setCertificate(certAlias);
|
||||
}
|
||||
}
|
||||
public void setCertificate(final String certAlias) {
|
||||
mClientCertificateSelector.setCertificate(certAlias);
|
||||
}
|
||||
|
||||
public void onUseSslChanged(boolean useSsl) {
|
||||
|
@ -63,7 +63,7 @@ public class CertificateSelector extends RelativeLayout implements OnClickListen
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
public void setHostActivity(HostCallback host) {
|
||||
public void setHostCallback(HostCallback host) {
|
||||
mHost = host;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user