Add L2TP secret, L2TP/IPSec PSK support. Fix screen orientation.

* Changes
  + Add L2tpActor, L2tpEditor, L2tpIpsecPskActor.
  + Make L2tpIpsecEditor extend L2tpEditor.
  + Revise the code for saving username. Make
    VpnSettings.saveProfileToStorage() static.
  + Fix support for screen orientation change in both VpnSettings and
    VpnEditor.

  Patch Set 2:
  + Remove Util.isNullOrEmpty(). Use TextUtils.isEmpty() instead.
  + Remove unused imports. Wrap lines longer than 80 chars.

  Patch Set 3:
  + Fix all the strings according to UI feedback.
  + Remove all the added actor subclasses and move password to editor.
  + Remove VPN entry in Security & location.

  Patch Set 4:
  + Misc string fixes.

  Patch Set 5:
  + Add strings for credential storage settings.
  + Changed the error dialog icon.
  + Fix "Remember me" indentation in connect dialog.

  Patch Set 6:
  + resolve res/values/strings.xml
This commit is contained in:
Hung-ying Tyan
2009-06-26 14:24:50 +08:00
parent 386278a338
commit e7565f3c48
15 changed files with 660 additions and 369 deletions

View File

@@ -28,11 +28,14 @@ import android.net.vpn.VpnProfile;
import android.net.vpn.VpnState;
import android.os.IBinder;
import android.os.RemoteException;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.CheckBox;
import android.widget.TextView;
import java.io.IOException;
/**
* A {@link VpnProfileActor} that provides an authentication view for users to
* input username and password before connecting to the VPN server.
@@ -66,9 +69,9 @@ public class AuthenticationActor implements VpnProfileActor {
TextView usernameView = (TextView) d.findViewById(R.id.username_value);
TextView passwordView = (TextView) d.findViewById(R.id.password_value);
Context c = mContext;
if (Util.isNullOrEmpty(usernameView.getText().toString())) {
if (TextUtils.isEmpty(usernameView.getText().toString())) {
return c.getString(R.string.vpn_username);
} else if (Util.isNullOrEmpty(passwordView.getText().toString())) {
} else if (TextUtils.isEmpty(passwordView.getText().toString())) {
return c.getString(R.string.vpn_password);
} else {
return null;
@@ -81,12 +84,14 @@ public class AuthenticationActor implements VpnProfileActor {
TextView passwordView = (TextView) d.findViewById(R.id.password_value);
CheckBox saveUsername = (CheckBox) d.findViewById(R.id.save_username);
// save username
if (saveUsername.isChecked()) {
mProfile.setSavedUsername(usernameView.getText().toString());
} else {
mProfile.setSavedUsername("");
try {
setSavedUsername(saveUsername.isChecked()
? usernameView.getText().toString()
: "");
} catch (IOException e) {
Log.e(TAG, "setSavedUsername()", e);
}
connect(usernameView.getText().toString(),
passwordView.getText().toString());
passwordView.setText("");
@@ -101,7 +106,11 @@ public class AuthenticationActor implements VpnProfileActor {
public void updateConnectView(Dialog d) {
String username = mProfile.getSavedUsername();
if (username == null) username = "";
updateConnectView(d, username, "", !Util.isNullOrEmpty(username));
updateConnectView(d, username, "", !TextUtils.isEmpty(username));
}
protected Context getContext() {
return mContext;
}
private void connect(final String username, final String password) {
@@ -121,7 +130,6 @@ public class AuthenticationActor implements VpnProfileActor {
if (!success) {
Log.d(TAG, "~~~~~~ connect() failed!");
// TODO: pop up a dialog
broadcastConnectivity(VpnState.IDLE);
} else {
Log.d(TAG, "~~~~~~ connect() succeeded!");
@@ -209,4 +217,11 @@ public class AuthenticationActor implements VpnProfileActor {
} catch (Exception e) {}
}
}
private void setSavedUsername(String name) throws IOException {
if (!name.equals(mProfile.getSavedUsername())) {
mProfile.setSavedUsername(name);
VpnSettings.saveProfileToStorage(mProfile);
}
}
}