From acca89bea1dc611ab1d5e8441142360e7957c366 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Fri, 4 Mar 2016 15:44:17 +0100 Subject: Allow name to be set on import --- .../java/de/blinkt/openvpn/activities/ConfigConverter.java | 13 +++++++++++++ main/src/main/res/layout/config_converter.xml | 12 ++++++++++++ 2 files changed, 25 insertions(+) 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 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,12 +13,24 @@ android:layout_margin="@dimen/stdpadding" android:orientation="vertical"> + + + + +