aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/frontends/android/AndroidManifest.xml5
-rw-r--r--src/frontends/android/res/layout/profile_detail_view.xml84
-rw-r--r--src/frontends/android/res/values/strings.xml7
-rw-r--r--src/frontends/android/src/org/strongswan/android/ui/VpnProfileDetailActivity.java106
4 files changed, 202 insertions, 0 deletions
diff --git a/src/frontends/android/AndroidManifest.xml b/src/frontends/android/AndroidManifest.xml
index 3a1008218..a88bca533 100644
--- a/src/frontends/android/AndroidManifest.xml
+++ b/src/frontends/android/AndroidManifest.xml
@@ -22,6 +22,11 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
+ <activity
+ android:name=".ui.VpnProfileDetailActivity"
+ android:label="@string/app_name" >
+ </activity>
+
<service
android:name=".logic.CharonVpnService"
android:exported="false"
diff --git a/src/frontends/android/res/layout/profile_detail_view.xml b/src/frontends/android/res/layout/profile_detail_view.xml
new file mode 100644
index 000000000..56a50655f
--- /dev/null
+++ b/src/frontends/android/res/layout/profile_detail_view.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2012 Tobias Brunner
+ Copyright (C) 2012 Giuliano Grassi
+ Copyright (C) 2012 Ralf Sager
+ 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.
+-->
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:padding="10dp" >
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="10dp"
+ android:text="@string/profile_name_label" />
+
+ <EditText
+ android:id="@+id/name"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:inputType="textNoSuggestions"
+ android:hint="@string/profile_name_hint" />
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="10dp"
+ android:text="@string/profile_gateway_label" />
+
+ <EditText
+ android:id="@+id/gateway"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:inputType="textNoSuggestions" />
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="10dp"
+ android:text="@string/profile_username_label" />
+
+ <EditText
+ android:id="@+id/username"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:inputType="textNoSuggestions" />
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="10dp"
+ android:text="@string/profile_password_label" />
+
+ <EditText
+ android:id="@+id/password"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:inputType="textPassword|textNoSuggestions"
+ android:hint="@string/profile_password_hint" />
+
+ </LinearLayout>
+
+</ScrollView> \ No newline at end of file
diff --git a/src/frontends/android/res/values/strings.xml b/src/frontends/android/res/values/strings.xml
index 99859d156..b81af924a 100644
--- a/src/frontends/android/res/values/strings.xml
+++ b/src/frontends/android/res/values/strings.xml
@@ -22,7 +22,14 @@
<!-- VPN profile list -->
<string name="no_profiles">No VPN profiles.</string>
+ <string name="add_profile">Add VPN profile</string>
+
+ <!-- VPN profile details -->
+ <string name="profile_name_label">Profile Name:</string>
+ <string name="profile_name_hint">(use gateway address)</string>
<string name="profile_gateway_label">Gateway:</string>
<string name="profile_username_label">Username:</string>
+ <string name="profile_password_label">Password:</string>
+ <string name="profile_password_hint">(prompt when needed)</string>
</resources>
diff --git a/src/frontends/android/src/org/strongswan/android/ui/VpnProfileDetailActivity.java b/src/frontends/android/src/org/strongswan/android/ui/VpnProfileDetailActivity.java
new file mode 100644
index 000000000..0a8dc1687
--- /dev/null
+++ b/src/frontends/android/src/org/strongswan/android/ui/VpnProfileDetailActivity.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2012 Tobias Brunner
+ * Copyright (C) 2012 Giuliano Grassi
+ * Copyright (C) 2012 Ralf Sager
+ * 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.data.VpnProfileDataSource;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.util.Log;
+import android.widget.EditText;
+
+public class VpnProfileDetailActivity extends Activity
+{
+ private VpnProfileDataSource mDataSource;
+ private Long mId;
+ private VpnProfile mProfile;
+ private EditText mName;
+ private EditText mGateway;
+ private EditText mUsername;
+ private EditText mPassword;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+
+ /* the title is set when we load the profile, if any */
+ getActionBar().setDisplayHomeAsUpEnabled(true);
+
+ mDataSource = new VpnProfileDataSource(this);
+ mDataSource.open();
+
+ setContentView(R.layout.profile_detail_view);
+
+ mName = (EditText)findViewById(R.id.name);
+ mPassword = (EditText)findViewById(R.id.password);
+ mGateway = (EditText)findViewById(R.id.gateway);
+ mUsername = (EditText)findViewById(R.id.username);
+
+ mId = savedInstanceState == null ? null : savedInstanceState.getLong(VpnProfileDataSource.KEY_ID);
+ if (mId == null)
+ {
+ Bundle extras = getIntent().getExtras();
+ mId = extras == null ? null : extras.getLong(VpnProfileDataSource.KEY_ID);
+ }
+
+ loadProfileData();
+ }
+
+ @Override
+ protected void onDestroy()
+ {
+ super.onDestroy();
+ mDataSource.close();
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState)
+ {
+ super.onSaveInstanceState(outState);
+ outState.putLong(VpnProfileDataSource.KEY_ID, mId);
+ }
+
+ /**
+ * Load an existing profile if we got an ID
+ */
+ private void loadProfileData()
+ {
+ getActionBar().setTitle(R.string.add_profile);
+ if (mId != null)
+ {
+ mProfile = mDataSource.getVpnProfile(mId);
+ if (mProfile != null)
+ {
+ mName.setText(mProfile.getName());
+ mGateway.setText(mProfile.getGateway());
+ mUsername.setText(mProfile.getUsername());
+ mPassword.setText(mProfile.getPassword());
+ getActionBar().setTitle(mProfile.getName());
+ }
+ else
+ {
+ Log.e(VpnProfileDetailActivity.class.getSimpleName(),
+ "VPN profile with id " + mId + " not found");
+ finish();
+ }
+ }
+ }
+}