From 8c77caa3964175762d23a9790578724f336716d6 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Fri, 14 Feb 2014 22:07:22 +0100 Subject: Make Config Converter layout work again on small devices --- doc/README.txt | 4 +- .../blinkt/openvpn/activities/ConfigConverter.java | 30 ++++++----- main/src/main/res/layout/config_converter.xml | 62 +++++++++++++--------- main/src/main/res/values/strings.xml | 1 + 4 files changed, 57 insertions(+), 40 deletions(-) diff --git a/doc/README.txt b/doc/README.txt index ba0ad06d..4e39f72b 100644 --- a/doc/README.txt +++ b/doc/README.txt @@ -21,9 +21,9 @@ svn co http://google-breakpad.googlecode.com/svn/trunk/ google-breakpad - Install ndk (Version r9 is tested and used by me) - Make sure that ndk-build is in your build path. -Do ./misc/build-native.(sh|bat) in the root directory of the project. +Do cd main;./misc/build-native.(sh|bat) in the root directory of the project. After that build the project using "gradle build" (Or use Android Studio). -Building with Eclipse *might* still work but has not beeen teseted for a long time. +The project is converted to gradle and building with Eclipse is no longer supported. FAQ 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 8e11802c..1ad9d9e3 100644 --- a/main/src/main/java/de/blinkt/openvpn/activities/ConfigConverter.java +++ b/main/src/main/java/de/blinkt/openvpn/activities/ConfigConverter.java @@ -39,7 +39,7 @@ import java.util.*; import static de.blinkt.openvpn.views.FileSelectLayout.FileSelectCallback; -public class ConfigConverter extends ListActivity implements FileSelectCallback { +public class ConfigConverter extends Activity implements FileSelectCallback { public static final String IMPORT_PROFILE = "de.blinkt.openvpn.IMPORT_PROFILE"; private static final int RESULT_INSTALLPKCS12 = 7; @@ -47,8 +47,7 @@ public class ConfigConverter extends ListActivity implements FileSelectCallback public static final String VPNPROFILE = "vpnProfile"; private VpnProfile mResult; - private transient ArrayAdapter mArrayAdapter; - + private transient List mPathsegments; private String mAliasName = null; @@ -56,6 +55,7 @@ public class ConfigConverter extends ListActivity implements FileSelectCallback private Map fileSelectMap = new HashMap(); private String mEmbeddedPwFile; + private Vector mLogEntries = new Vector(); @Override public boolean onOptionsItemSelected(MenuItem item) { @@ -89,10 +89,10 @@ public class ConfigConverter extends ListActivity implements FileSelectCallback outState.putSerializable(VPNPROFILE, mResult); outState.putString("mAliasName", mAliasName); - String[] logentries = new String[mArrayAdapter.getCount()]; - for (int i = 0; i < mArrayAdapter.getCount(); i++) { - logentries[i] = mArrayAdapter.getItem(i); - } + + + String[] logentries = mLogEntries.toArray(new String[mLogEntries.size()]); + outState.putStringArray("logentries", logentries); int[] fileselects = new int[fileSelectMap.size()]; @@ -473,18 +473,16 @@ public class ConfigConverter extends ListActivity implements FileSelectCallback protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.config_converter); - - mArrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1); - getListView().setAdapter(mArrayAdapter); - super.onCreate(savedInstanceState); - if (savedInstanceState != null && savedInstanceState.containsKey(VPNPROFILE)) { mResult = (VpnProfile) savedInstanceState.getSerializable(VPNPROFILE); mAliasName = savedInstanceState.getString("mAliasName"); mEmbeddedPwFile = savedInstanceState.getString("pwfile"); - mArrayAdapter.addAll(savedInstanceState.getStringArray("logentries")); + + for(String logItem : savedInstanceState.getStringArray("logentries")) + log (logItem); + for (int k : savedInstanceState.getIntArray("fileselects")) { addFileSelectDialog(Utils.FileType.getFileTypeByValue(k)); } @@ -563,7 +561,11 @@ public class ConfigConverter extends ListActivity implements FileSelectCallback } private void log(String logmessage) { - mArrayAdapter.add(logmessage); + mLogEntries.add(logmessage); + TextView tv = new TextView(this); + tv.setText(logmessage); + LinearLayout logLayout = (LinearLayout) findViewById(R.id.config_convert_root); + logLayout.addView(tv); } private void doImport(InputStream is, String newName) { diff --git a/main/src/main/res/layout/config_converter.xml b/main/src/main/res/layout/config_converter.xml index f43d463e..ff0dcaa2 100644 --- a/main/src/main/res/layout/config_converter.xml +++ b/main/src/main/res/layout/config_converter.xml @@ -1,29 +1,43 @@ - - + android:layout_height="match_parent" + android:layout_margin="@dimen/stdpadding" + android:orientation="vertical"> - + + + + + + + + + - - \ No newline at end of file + \ No newline at end of file diff --git a/main/src/main/res/values/strings.xml b/main/src/main/res/values/strings.xml index 32839feb..157f8864 100755 --- a/main/src/main/res/values/strings.xml +++ b/main/src/main/res/values/strings.xml @@ -317,4 +317,5 @@ [Imported from: %s] Some files could not be found. Please select the files to import the profile: To use this app you need a VPN provider/VPN gateway supporting OpenVPN (often provided by your employer .Check out http://community.openvpn.net/ for more information on OpenVPN and how to setup your own OpenVPN server. + Import log: -- cgit v1.2.3