diff options
author | Arne Schwabe <arne@rfc2549.org> | 2012-07-10 22:39:06 +0200 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2012-07-10 22:39:06 +0200 |
commit | 7a2b9b1880612c78699f03f62697cdab4a7c6747 (patch) | |
tree | b1a4c4724fa284d6f0193fac53c265e98995ba4d /src/de/blinkt/openvpn/ShowConfigFragment.java | |
parent | 300c200ca2aa84e7778f4ef07112a8c6effff24e (diff) |
Add ability to export openvpn configuration. (closes issue #52)
Diffstat (limited to 'src/de/blinkt/openvpn/ShowConfigFragment.java')
-rw-r--r-- | src/de/blinkt/openvpn/ShowConfigFragment.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/de/blinkt/openvpn/ShowConfigFragment.java b/src/de/blinkt/openvpn/ShowConfigFragment.java index 13c65df..8c8ab31 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); + } + } } |