From ac3c6ff479d9bf517625309ee6908e0e2252f4e7 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Wed, 7 Nov 2012 16:09:59 +0100 Subject: [PATCH] android: Add the ability to create shortcuts to specific VPN profiles --- src/frontends/android/AndroidManifest.xml | 8 +++ .../android/res/layout/vpn_profile_select.xml | 30 +++++++++++ .../android/res/values-de/strings.xml | 1 + .../android/res/values-pl/strings.xml | 1 + src/frontends/android/res/values/strings.xml | 1 + .../android/ui/VpnProfileSelectActivity.java | 52 +++++++++++++++++++ 6 files changed, 93 insertions(+) create mode 100644 src/frontends/android/res/layout/vpn_profile_select.xml create mode 100644 src/frontends/android/src/org/strongswan/android/ui/VpnProfileSelectActivity.java diff --git a/src/frontends/android/AndroidManifest.xml b/src/frontends/android/AndroidManifest.xml index c191a9e52..24528cc0b 100644 --- a/src/frontends/android/AndroidManifest.xml +++ b/src/frontends/android/AndroidManifest.xml @@ -53,6 +53,14 @@ android:name=".ui.LogActivity" android:label="@string/log_title" > + + + + + + + + + + + + \ No newline at end of file diff --git a/src/frontends/android/res/values-de/strings.xml b/src/frontends/android/res/values-de/strings.xml index 5c922ad51..a89425c0e 100644 --- a/src/frontends/android/res/values-de/strings.xml +++ b/src/frontends/android/res/values-de/strings.xml @@ -28,6 +28,7 @@ VPN Verbindungen sind nicht möglich im abgeriegelten Modus. Laden… Profil nicht gefunden + strongSwan-Verknüpfung Log diff --git a/src/frontends/android/res/values-pl/strings.xml b/src/frontends/android/res/values-pl/strings.xml index 80fab6350..4df32c57e 100644 --- a/src/frontends/android/res/values-pl/strings.xml +++ b/src/frontends/android/res/values-pl/strings.xml @@ -30,6 +30,7 @@ Polączenia nie sa możliwe w trybie zamkniętym Wczytywanie… Nie znaleziono profilu + Skrót strongSwan Log diff --git a/src/frontends/android/res/values/strings.xml b/src/frontends/android/res/values/strings.xml index 84fdf382e..eba7a667a 100644 --- a/src/frontends/android/res/values/strings.xml +++ b/src/frontends/android/res/values/strings.xml @@ -28,6 +28,7 @@ VPN connections are not supported in lockdown mode. Loading… Profile not found + strongSwan shortcut Log diff --git a/src/frontends/android/src/org/strongswan/android/ui/VpnProfileSelectActivity.java b/src/frontends/android/src/org/strongswan/android/ui/VpnProfileSelectActivity.java new file mode 100644 index 000000000..b4d34f5a5 --- /dev/null +++ b/src/frontends/android/src/org/strongswan/android/ui/VpnProfileSelectActivity.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2012 Tobias Brunner + * Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See . + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +package org.strongswan.android.ui; + +import org.strongswan.android.R; +import org.strongswan.android.data.VpnProfile; +import org.strongswan.android.ui.VpnProfileListFragment.OnVpnProfileSelectedListener; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; + +public class VpnProfileSelectActivity extends Activity implements OnVpnProfileSelectedListener +{ + @Override + protected void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + setContentView(R.layout.vpn_profile_select); + + /* we should probably return a result also if the user clicks the back + * button before selecting a profile */ + setResult(RESULT_CANCELED); + } + + @Override + public void onVpnProfileSelected(VpnProfile profile) + { + Intent shortcut = new Intent(MainActivity.START_PROFILE); + shortcut.putExtra(MainActivity.EXTRA_VPN_PROFILE_ID, profile.getId()); + + Intent intent = new Intent(); + intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcut); + intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, profile.getName()); + intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this, R.drawable.ic_launcher)); + setResult(RESULT_OK, intent); + finish(); + } +}