Remove certificate spinner from edit view

This commit is contained in:
Tobias Brunner 2012-08-14 09:12:29 +02:00
parent f075536ebe
commit af46e950b1
4 changed files with 1 additions and 115 deletions

View File

@ -91,19 +91,6 @@
android:layout_height="wrap_content"
android:text="@string/profile_ca_auto_label" />
<CheckBox
android:id="@+id/ca_show_all"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="@string/profile_ca_show_all" />
<Spinner
android:id="@+id/ca_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp" />
</LinearLayout>
</ScrollView>

View File

@ -51,7 +51,6 @@
<string name="profile_password_hint">(anfordern wenn benötigt)</string>
<string name="profile_ca_label">CA-Zertifikat:</string>
<string name="profile_ca_auto_label">Automatisch wählen</string>
<string name="profile_ca_show_all">Alle Zertifikate anzeigen</string>
<!-- Warnings/Notifications in the details view -->
<string name="alert_text_no_input_gateway">Bitte geben Sie hier die Gateway-Adresse ein</string>
<string name="alert_text_no_input_username">Bitte geben Sie hier Ihren Benutzernamen ein</string>

View File

@ -51,7 +51,6 @@
<string name="profile_password_hint">(prompt when needed)</string>
<string name="profile_ca_label">CA certificate:</string>
<string name="profile_ca_auto_label">Select automatically</string>
<string name="profile_ca_show_all">Show all certificates</string>
<!-- Warnings/Notifications in the details view -->
<string name="alert_text_no_input_gateway">Please enter the gateway address here</string>
<string name="alert_text_no_input_username">Please enter your username here</string>

View File

@ -17,14 +17,10 @@
package org.strongswan.android.ui;
import java.security.cert.X509Certificate;
import java.util.Hashtable;
import org.strongswan.android.R;
import org.strongswan.android.data.VpnProfile;
import org.strongswan.android.data.VpnProfileDataSource;
import org.strongswan.android.logic.TrustedCertificateManager;
import org.strongswan.android.ui.adapter.TrustedCertificateAdapter;
import android.app.Activity;
import android.app.AlertDialog;
@ -38,13 +34,10 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.Spinner;
public class VpnProfileDetailActivity extends Activity
{
@ -53,13 +46,10 @@ public class VpnProfileDetailActivity extends Activity
private VpnProfile mProfile;
private boolean mCertsLoaded;
private String mCertAlias;
private Spinner mCertSpinner;
private TrustedCertificateAdapter.CertEntry mSelectedCert;
private EditText mName;
private EditText mGateway;
private EditText mUsername;
private EditText mPassword;
private CheckBox mCheckAll;
private CheckBox mCheckAuto;
@Override
@ -81,42 +71,13 @@ public class VpnProfileDetailActivity extends Activity
mGateway = (EditText)findViewById(R.id.gateway);
mUsername = (EditText)findViewById(R.id.username);
mCheckAll = (CheckBox)findViewById(R.id.ca_show_all);
mCheckAuto = (CheckBox)findViewById(R.id.ca_auto);
mCertSpinner = (Spinner)findViewById(R.id.ca_spinner);
mCheckAuto.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
updateCertSpinner();
}
});
mCheckAll.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
Hashtable<String, X509Certificate> certs;
certs = isChecked ? TrustedCertificateManager.getInstance().getAllCACertificates()
: TrustedCertificateManager.getInstance().getUserCACertificates();
mCertSpinner.setAdapter(new TrustedCertificateAdapter(VpnProfileDetailActivity.this, certs));
mSelectedCert = (TrustedCertificateAdapter.CertEntry)mCertSpinner.getSelectedItem();
}
});
mCertSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int pos, long id)
{
mSelectedCert = (TrustedCertificateAdapter.CertEntry)parent.getSelectedItem();
}
@Override
public void onNothingSelected(AdapterView<?> arg0)
{
mSelectedCert = null;
}
});
@ -215,64 +176,8 @@ public class VpnProfileDetailActivity extends Activity
@Override
protected void onPostExecute(TrustedCertificateManager result)
{
TrustedCertificateAdapter adapter;
if (mCertAlias != null && mCertAlias.startsWith("system:"))
{
mCheckAll.setChecked(true);
adapter = new TrustedCertificateAdapter(VpnProfileDetailActivity.this,
result.getAllCACertificates());
}
else
{
mCheckAll.setChecked(false);
adapter = new TrustedCertificateAdapter(VpnProfileDetailActivity.this,
result.getUserCACertificates());
}
mCertSpinner.setAdapter(adapter);
if (mCertAlias != null)
{
int position = adapter.getItemPosition(mCertAlias);
if (position == -1)
{ /* previously selected certificate is not here anymore */
showCertificateAlert();
}
else
{
mCertSpinner.setSelection(position);
}
}
mSelectedCert = (TrustedCertificateAdapter.CertEntry)mCertSpinner.getSelectedItem();
setProgressBarIndeterminateVisibility(false);
mCertsLoaded = true;
updateCertSpinner();
}
}
/**
* Update the CA certificate selection UI depending on whether the
* certificate should be automatically selected or not.
*/
private void updateCertSpinner()
{
if (!mCheckAuto.isChecked())
{
if (mCertsLoaded)
{
mCertSpinner.setEnabled(true);
mCertSpinner.setVisibility(View.VISIBLE);
mCheckAll.setEnabled(true);
mCheckAll.setVisibility(View.VISIBLE);
}
}
else
{
mCertSpinner.setEnabled(false);
mCertSpinner.setVisibility(View.GONE);
mCheckAll.setEnabled(false);
mCheckAll.setVisibility(View.GONE);
}
}
@ -317,7 +222,7 @@ public class VpnProfileDetailActivity extends Activity
mUsername.setError(getString(R.string.alert_text_no_input_username));
valid = false;
}
if (!mCheckAuto.isChecked() && mSelectedCert == null)
if (!mCheckAuto.isChecked())
{
showCertificateAlert();
valid = false;
@ -339,8 +244,6 @@ public class VpnProfileDetailActivity extends Activity
String password = mPassword.getText().toString().trim();
password = password.isEmpty() ? null : password;
mProfile.setPassword(password);
String certAlias = mCheckAuto.isChecked() ? null : mSelectedCert.mAlias;
mProfile.setCertificateAlias(certAlias);
}
/**
@ -368,8 +271,6 @@ public class VpnProfileDetailActivity extends Activity
finish();
}
}
mCheckAll.setChecked(false);
mCheckAuto.setChecked(mCertAlias == null);
updateCertSpinner();
}
}