android: Add the ability to create shortcuts to specific VPN profiles
This commit is contained in:
parent
127d83bb21
commit
ac3c6ff479
|
@ -53,6 +53,14 @@
|
|||
android:name=".ui.LogActivity"
|
||||
android:label="@string/log_title" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.VpnProfileSelectActivity"
|
||||
android:label="@string/strongswan_shortcut" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.CREATE_SHORTCUT" />
|
||||
<action android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<service
|
||||
android:name=".logic.VpnStateService"
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
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 <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
|
||||
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.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:strongswan="http://schemas.android.com/apk/res/org.strongswan.android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<fragment
|
||||
class="org.strongswan.android.ui.VpnProfileListFragment"
|
||||
android:id="@+id/profile_list_frag"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
strongswan:read_only="true" />
|
||||
|
||||
</LinearLayout>
|
|
@ -28,6 +28,7 @@
|
|||
<string name="vpn_not_supported_during_lockdown">VPN Verbindungen sind nicht möglich im abgeriegelten Modus.</string>
|
||||
<string name="loading">Laden…</string>
|
||||
<string name="profile_not_found">Profil nicht gefunden</string>
|
||||
<string name="strongswan_shortcut">strongSwan-Verknüpfung</string>
|
||||
|
||||
<!-- Log view -->
|
||||
<string name="log_title">Log</string>
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
<string name="vpn_not_supported_during_lockdown">Polączenia nie sa możliwe w trybie zamkniętym</string>
|
||||
<string name="loading">Wczytywanie…</string>
|
||||
<string name="profile_not_found">Nie znaleziono profilu</string>
|
||||
<string name="strongswan_shortcut">Skrót strongSwan</string>
|
||||
|
||||
<!-- Log view -->
|
||||
<string name="log_title">Log</string>
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
<string name="vpn_not_supported_during_lockdown">VPN connections are not supported in lockdown mode.</string>
|
||||
<string name="loading">Loading…</string>
|
||||
<string name="profile_not_found">Profile not found</string>
|
||||
<string name="strongswan_shortcut">strongSwan shortcut</string>
|
||||
|
||||
<!-- Log view -->
|
||||
<string name="log_title">Log</string>
|
||||
|
|
|
@ -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 <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* 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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue