summaryrefslogtreecommitdiffhomepage
path: root/app/src/main/java/com/wireguard
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2017-11-08 00:50:11 -0600
committerSamuel Holland <samuel@sholland.org>2017-11-08 00:50:24 -0600
commit4a98d07806249017ba044d75de276bcd5e69cee6 (patch)
tree17733ea74c298aa4f21561194c78a2920d3733c2 /app/src/main/java/com/wireguard
parentcd6a124c8464dce75ec83e32592a5559013f15db (diff)
ConfigActivity: Add import menu item
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src/main/java/com/wireguard')
-rw-r--r--app/src/main/java/com/wireguard/android/ConfigActivity.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/src/main/java/com/wireguard/android/ConfigActivity.java b/app/src/main/java/com/wireguard/android/ConfigActivity.java
index 61ccbc14..881f3f9a 100644
--- a/app/src/main/java/com/wireguard/android/ConfigActivity.java
+++ b/app/src/main/java/com/wireguard/android/ConfigActivity.java
@@ -16,6 +16,7 @@ import com.wireguard.config.Config;
public class ConfigActivity extends BaseConfigActivity {
private static final String KEY_EDITOR_STATE = "editorState";
+ private static final int REQUEST_IMPORT = 1;
private static final String TAG_DETAIL = "detail";
private static final String TAG_EDIT = "edit";
private static final String TAG_LIST = "list";
@@ -130,6 +131,16 @@ public class ConfigActivity extends BaseConfigActivity {
}
@Override
+ public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
+ if (requestCode == REQUEST_IMPORT) {
+ if (resultCode == RESULT_OK)
+ VpnService.getInstance().importFrom(data.getData());
+ } else {
+ super.onActivityResult(requestCode, resultCode, data);
+ }
+ }
+
+ @Override
public void onBackPressed() {
super.onBackPressed();
// The visible fragment is now the one that was on top of the back stack, if there was one.
@@ -184,6 +195,12 @@ public class ConfigActivity extends BaseConfigActivity {
// Try to make the editing fragment visible.
setIsEditing(true);
return true;
+ case R.id.menu_action_import:
+ final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
+ intent.addCategory(Intent.CATEGORY_OPENABLE);
+ intent.setType("*/*");
+ startActivityForResult(intent, REQUEST_IMPORT);
+ return true;
case R.id.menu_action_save:
// This menu item is handled by the editing fragment.
return false;