summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2016-03-04 15:44:17 +0100
committerArne Schwabe <arne@rfc2549.org>2016-03-07 09:10:57 +0100
commitacca89bea1dc611ab1d5e8441142360e7957c366 (patch)
tree854212d3ade5c831a4bb4a183b7b87118d481f4b /main
parent3af02771543a45f7b1f1f3ac557f5ad268cca73b (diff)
Allow name to be set on import
Diffstat (limited to 'main')
-rw-r--r--main/src/main/java/de/blinkt/openvpn/activities/ConfigConverter.java13
-rw-r--r--main/src/main/res/layout/config_converter.xml12
2 files changed, 25 insertions, 0 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/activities/ConfigConverter.java b/main/src/main/java/de/blinkt/openvpn/activities/ConfigConverter.java
index d3dd0f20..cb3a43cf 100644
--- a/main/src/main/java/de/blinkt/openvpn/activities/ConfigConverter.java
+++ b/main/src/main/java/de/blinkt/openvpn/activities/ConfigConverter.java
@@ -33,6 +33,7 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
+import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -82,6 +83,7 @@ public class ConfigConverter extends BaseActivity implements FileSelectCallback,
private String mEmbeddedPwFile;
private Vector<String> mLogEntries = new Vector<>();
private Uri mSourceUri;
+ private EditText mProfilename;
@Override
public void onClick(View v) {
@@ -143,6 +145,13 @@ public class ConfigConverter extends BaseActivity implements FileSelectCallback,
return true;
}
+ mResult.mName = mProfilename.getText().toString();
+ ProfileManager vpl = ProfileManager.getInstance(this);
+ if (vpl.getProfileByName(mResult.mName)!=null) {
+ mProfilename.setError(getString(R.string.duplicate_profile_name));
+ return true;
+ }
+
Intent in = installPKCS12();
if (in != null)
@@ -594,11 +603,14 @@ public class ConfigConverter extends BaseActivity implements FileSelectCallback,
findViewById(R.id.fab_footerspace).setVisibility(View.VISIBLE);
}
+ mProfilename = (EditText) findViewById(R.id.profilename);
+
if (savedInstanceState != null && savedInstanceState.containsKey(VPNPROFILE)) {
mResult = (VpnProfile) savedInstanceState.getSerializable(VPNPROFILE);
mAliasName = savedInstanceState.getString("mAliasName");
mEmbeddedPwFile = savedInstanceState.getString("pwfile");
mSourceUri = savedInstanceState.getParcelable("mSourceUri");
+ mProfilename.setText(mResult.mName);
if (savedInstanceState.containsKey("logentries")) {
//noinspection ConstantConditions
@@ -729,6 +741,7 @@ public class ConfigConverter extends BaseActivity implements FileSelectCallback,
embedFiles(cp);
displayWarnings();
mResult.mName = getUniqueProfileName(newName);
+ mProfilename.setText(mResult.getName());
log(R.string.import_done);
return;
diff --git a/main/src/main/res/layout/config_converter.xml b/main/src/main/res/layout/config_converter.xml
index b9bc1ecc..ec248cd4 100644
--- a/main/src/main/res/layout/config_converter.xml
+++ b/main/src/main/res/layout/config_converter.xml
@@ -13,6 +13,7 @@
android:layout_margin="@dimen/stdpadding"
android:orientation="vertical">
+
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
@@ -20,6 +21,17 @@
android:layout_height="wrap_content">
<TextView
+ style="@style/item"
+ android:text="@string/profilename"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ />
+
+ <EditText
+ android:id="@+id/profilename"
+ style="@style/item"
+ android:inputType="text" />
+
+ <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/files_missing_hint"