summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2012-07-10 22:39:06 +0200
committerArne Schwabe <arne@rfc2549.org>2012-07-10 22:39:06 +0200
commitda3d649cfa356873b72e6c25b9c0496268efcf89 (patch)
tree1287b35a3ebe9c57ec9d58b5a218e170cfef416c
parentd1e7bca7723f912c2f8af7f9c006171906ab14b7 (diff)
Add ability to export openvpn configuration. (closes issue #52)
-rw-r--r--res/menu/configmenu.xml11
-rw-r--r--res/values/strings.xml1
-rw-r--r--src/de/blinkt/openvpn/ShowConfigFragment.java37
-rw-r--r--src/de/blinkt/openvpn/VPNProfileList.java3
4 files changed, 51 insertions, 1 deletions
diff --git a/res/menu/configmenu.xml b/res/menu/configmenu.xml
new file mode 100644
index 00000000..1d47e26b
--- /dev/null
+++ b/res/menu/configmenu.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+ <item
+ android:id="@+id/sendConfig"
+ android:icon="@android:drawable/ic_menu_share"
+ android:showAsAction="ifRoom|withText"
+ android:title="Send config file"
+ android:titleCondensed="@string/send"/>
+
+</menu> \ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 6cdfcc7e..6fa78150 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -232,6 +232,7 @@
<string name="routing">Routing</string>
<string name="obscure">Obscure OpenVPN Settings. Normally not needed.</string>
<string name="advanced">Advanced</string>
+ <string name="export_config_title">ICS Openvpn Config</string>
</resources> \ No newline at end of file
diff --git a/src/de/blinkt/openvpn/ShowConfigFragment.java b/src/de/blinkt/openvpn/ShowConfigFragment.java
index 13c65df8..8c8ab315 100644
--- a/src/de/blinkt/openvpn/ShowConfigFragment.java
+++ b/src/de/blinkt/openvpn/ShowConfigFragment.java
@@ -1,14 +1,19 @@
package de.blinkt.openvpn;
import android.app.Fragment;
+import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
public class ShowConfigFragment extends Fragment {
+ private String configtext;
public android.view.View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
String profileUUID = getArguments().getString(getActivity().getPackageName() + ".profileUUID");
@@ -19,11 +24,43 @@ public class ShowConfigFragment extends Fragment {
int check=vp.checkProfile();
if(check!=R.string.no_error_found) {
cv.setText(check);
+ configtext = getString(check);
}
else {
String cfg=vp.getConfigFile(getActivity().getCacheDir());
+ configtext= cfg;
cv.setText(cfg);
}
return v;
};
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setHasOptionsMenu(true);
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ inflater.inflate(R.menu.configmenu, menu);
+ }
+
+ private void shareConfig() {
+ Intent shareIntent = new Intent(Intent.ACTION_SEND);
+ shareIntent.putExtra(Intent.EXTRA_TEXT, configtext);
+ shareIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.export_config_title));
+ shareIntent.setType("text/plain");
+ startActivity(Intent.createChooser(shareIntent, "Export Configfile"));
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ final int itemId = item.getItemId();
+ if (itemId == R.id.sendConfig) {
+ shareConfig();
+ return true;
+ } else {
+ return super.onOptionsItemSelected(item);
+ }
+ }
}
diff --git a/src/de/blinkt/openvpn/VPNProfileList.java b/src/de/blinkt/openvpn/VPNProfileList.java
index beadf53d..aee3ce4b 100644
--- a/src/de/blinkt/openvpn/VPNProfileList.java
+++ b/src/de/blinkt/openvpn/VPNProfileList.java
@@ -291,7 +291,8 @@ public class VPNProfileList extends ListFragment {
return true;
default:
return false;
- } }
+ }
+ }
@Override
public void onDestroyActionMode(ActionMode mode) {