summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2012-08-21 01:09:48 +0200
committerArne Schwabe <arne@rfc2549.org>2012-08-21 01:09:48 +0200
commit765818d19bbc5debfc2fd034943c071008b4090c (patch)
tree02966958f730aadc27d583cc9a04b7cadb41c336
parent561313d5521abea226d4e976959b490732add16e (diff)
Add a nice "what to do" screen if no VPN has been added yet
-rw-r--r--missingtranslations.txt14
-rw-r--r--res/layout/file_dialog_main.xml2
-rw-r--r--res/layout/vpn_profile_list.xml49
-rw-r--r--res/values-de/strings.xml8
-rw-r--r--res/values/strings.xml4
-rw-r--r--src/de/blinkt/openvpn/VPNProfileList.java111
6 files changed, 153 insertions, 35 deletions
diff --git a/missingtranslations.txt b/missingtranslations.txt
index bd63ad64..ca4bfb9b 100644
--- a/missingtranslations.txt
+++ b/missingtranslations.txt
@@ -259,4 +259,16 @@ res/values/strings.xml:252: Error: "faq_duplicate_notification_title" is not tra
res/values/strings.xml:253: Error: "faq_duplicate_notification" is not translated in es, ko, zh [MissingTranslation]
<string name="faq_duplicate_notification">If Android is under system memory (RAM) pressure app and service which are not needed at the moment are removed from active memory. This terminates an ongoing VPN connection. To ensure that the connection/Openvpn survices the service runs with higher priority. To run with higher priority the application must display a notification. The key notification icon is imposed by the system as described in the previous FAQ entry. It does not count as app notification for purpose of running with higher priority.</string>
^
-86 errors, 0 warnings
+res/values/strings.xml:254: Error: "no_vpn_profiles_defined" is not translated in es, ko, zh [MissingTranslation]
+ <string name="no_vpn_profiles_defined">No VPN profiles defined.</string>
+ ^
+res/values/strings.xml:255: Error: "add_new_vpn_hint" is not translated in es, ko, zh [MissingTranslation]
+ <string name="add_new_vpn_hint">Use the &lt;img src=\"ic_menu_add\"/> icon to add a new VPN</string>
+ ^
+res/values/strings.xml:256: Error: "vpn_import_hint" is not translated in es, ko, zh [MissingTranslation]
+ <string name="vpn_import_hint">Use the &lt;img src=\"ic_menu_archive\"/> icon to import an existing (.ovpn or .conf) profile from your sdcard.</string>
+ ^
+res/values/strings.xml:257: Error: "faq_hint" is not translated in es, ko, zh [MissingTranslation]
+ <string name="faq_hint">Be sure to also check out the FAQ. There is a quick start guide.</string>
+ ^
+90 errors, 0 warnings
diff --git a/res/layout/file_dialog_main.xml b/res/layout/file_dialog_main.xml
index 2a623dc6..db791663 100644
--- a/res/layout/file_dialog_main.xml
+++ b/res/layout/file_dialog_main.xml
@@ -25,7 +25,7 @@
android:layout_height="wrap_content"
android:text="@string/select_file" >
</Button>
-
+
<Button
android:id="@+id/fdClear"
android:layout_width="wrap_content"
diff --git a/res/layout/vpn_profile_list.xml b/res/layout/vpn_profile_list.xml
new file mode 100644
index 00000000..f4a24ece
--- /dev/null
+++ b/res/layout/vpn_profile_list.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical" >
+
+ <ListView
+ android:id="@android:id/list"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent" />
+
+ <LinearLayout
+ android:id="@android:id/empty"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:orientation="vertical" >
+
+ <TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/no_vpn_profiles_defined"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <Space
+ android:layout_width="match_parent"
+ android:layout_height="10sp" />
+
+ <TextView
+ android:id="@+id/add_new_vpn_hint"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" />
+
+ <TextView
+ android:id="@+id/import_vpn_hint"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" />
+
+<Space
+ android:layout_width="match_parent"
+ android:layout_height="10sp" />
+
+ <TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/faq_hint" />
+ </LinearLayout>
+
+</LinearLayout> \ No newline at end of file
diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml
index 8478d014..01e53c65 100644
--- a/res/values-de/strings.xml
+++ b/res/values-de/strings.xml
@@ -198,7 +198,7 @@
<string name="use_system_proxy_summary">Benutze die System weiten Einstellungen für HTTP/HTTPS Proxies beim Verbinden.</string>
<string name="getproxy_error">Fehler beim Ermittlen der Proxy Einstellungen: %s</string>
<string name="using_proxy">Benutzt Proxy %1$s %2$d</string>
- <string name="onbootrestartsummary">Openvpn wird bei einem Neustart des Telefon das beim herrunterfahren/neu starten aktive VPN weider verbinden. Bitte lesen Sie die FAQ &quot;Warnung beim Verbinden&quot; FAQ bevor Sie diese Option verwenden.</string>
+ <string name="onbootrestartsummary">Openvpn wird bei einem Neustart des Telefon das beim herrunterfahren/neu starten aktive VPN weider verbinden. Bitte lesen Sie die FAQ \"Warnung beim Verbinden\" FAQ bevor Sie diese Option verwenden.</string>
<string name="onbootrestart">Nach Neustart verbinden</string>
<string name="faq_howto_shortcut">Sie können ein Shortcut zum Starten des VPN auf Ihren Startbildschirm legen. Abhängig davon welches Home/Launcher Programm Sie verwenden müssen ein Widget, Shortcut oder Verknüpfung hinzufügen</string>
<string name="donatewithpaypal">&lt;a href=\"https://www.paypal.com/cgi-bin/webscr?hosted_button_id=R2M6ZP9AF25LS&amp;amp;cmd=_s-xclick\">Spenden mit PayPal&lt;/a> </string>
@@ -208,5 +208,9 @@
<string name="configuration_changed">Konfiguration geändert</string>
<string name="log_no_last_vpn">Konnte das zuletzt verbundene Profile beim Versuch des Editieren nicht ermitteln.</string>
<string name="faq_duplicate_notification_title">Doppelte Benachrichtigungen</string>
- <string name="faq_duplicate_notification">Android beendet automatisch Anwendungen und Dienste, die im Hintergrund laufen, wenn der Arbeitsspeicher knapp wird. Wird dabei Openvpn beendet, bricht die VPN Verbindung ab. Um dies zu vermeiden, läuft der VPN Prozess mit einer höheren Priorität. Um eine höhere Prioität nutzen zu können, muss die Anwesenheit des Prozesses dem Benutzer im Form einer Benachrichtigung mitgeteilt werden. Daher zeigt Openvpn für Android immer seine eigene Benachrichtigung an. Die Schlüssel Benachrichtung, die auch im letzen Eintrag erklärt wird, zählt leider nicht als Benachrichtigung, die der Anwendung erlaubt mit höherer Priorität zu arbeiten.</string>
+ <string name="faq_duplicate_notification">Android beendet automatisch Anwendungen und Dienste, die im Hintergrund laufen, wenn der Arbeitsspeicher knapp wird. Wird dabei Openvpn beendet, bricht die VPN Verbindung ab. Um dies zu vermeiden, läuft der VPN Prozess mit einer höheren Priorität. Um eine höhere Prioität nutzen zu können, muss die Anwesenheit des Prozesses dem Benutzer im Form einer Benachrichtigung mitgeteilt werden. Daher zeigt Openvpn für Android immer seine eigene Benachrichtigung an. Die Schlüssel Benachrichtung, die auch im letzen Eintrag erklärt wird, zählt leider nicht als Benachrichtigung, die der Anwendung erlaubt mit höherer Priorität zu arbeiten.</string>
+ <string name="no_vpn_profiles_defined">Keine VPN Profile definiert.</string>
+ <string name="add_new_vpn_hint">Benutzen Sie &lt;img src=\"ic_menu_add\"/> um ein neues VPN anzulegen</string>
+ <string name="vpn_import_hint">Benutzen Sie &lt;img src=\"ic_menu_archive\"/> um ein vorhandenes (.ovpn oder .conf) Profil von Ihrer SD Karte zu importieren</string>
+ <string name="faq_hint">Lesen Sie auch die FAQ. Dort befindet sich eine Schnellstart Anleitung</string>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index f03ee660..1d9c8f67 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -251,4 +251,8 @@
<string name="log_no_last_vpn">Could not determine last connected profile for editing</string>
<string name="faq_duplicate_notification_title">Duplicate notifications</string>
<string name="faq_duplicate_notification">If Android is under system memory (RAM) pressure app and service which are not needed at the moment are removed from active memory. This terminates an ongoing VPN connection. To ensure that the connection/Openvpn survices the service runs with higher priority. To run with higher priority the application must display a notification. The key notification icon is imposed by the system as described in the previous FAQ entry. It does not count as app notification for purpose of running with higher priority.</string>
+ <string name="no_vpn_profiles_defined">No VPN profiles defined.</string>
+ <string name="add_new_vpn_hint">Use the &lt;img src=\"ic_menu_add\"/> icon to add a new VPN</string>
+ <string name="vpn_import_hint">Use the &lt;img src=\"ic_menu_archive\"/> icon to import an existing (.ovpn or .conf) profile from your sdcard.</string>
+ <string name="faq_hint">Be sure to also check out the FAQ. There is a quick start guide.</string>
</resources>
diff --git a/src/de/blinkt/openvpn/VPNProfileList.java b/src/de/blinkt/openvpn/VPNProfileList.java
index b21769af..1e24bfe7 100644
--- a/src/de/blinkt/openvpn/VPNProfileList.java
+++ b/src/de/blinkt/openvpn/VPNProfileList.java
@@ -10,8 +10,12 @@ import android.app.ListFragment;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
+import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
+import android.text.Html;
+import android.text.Html.ImageGetter;
+import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@@ -20,23 +24,32 @@ import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.EditText;
+import android.widget.TextView;
import android.widget.Toast;
public class VPNProfileList extends ListFragment {
-
+
final static int RESULT_VPN_DELETED = Activity.RESULT_FIRST_USER;
-
+
+ private static final int MENU_ADD_PROFILE = Menu.FIRST;
+
+ private static final int START_VPN_CONFIG = 92;
+ private static final int SELECT_PROFILE = 43;
+ private static final int IMPORT_PROFILE = 231;
+
+ private static final int MENU_IMPORT_PROFILE = Menu.FIRST +1;
+
class VPNArrayAdapter extends ArrayAdapter<VpnProfile> {
public VPNArrayAdapter(Context context, int resource,
int textViewResourceId) {
super(context, resource, textViewResourceId);
}
-
+
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
View v = super.getView(position, convertView, parent);
-
+
View titleview = v.findViewById(R.id.vpn_list_item_left);
titleview.setOnClickListener(new OnClickListener() {
@Override
@@ -45,53 +58,90 @@ public class VPNProfileList extends ListFragment {
startVPN(profile);
}
});
-
+
View settingsview = v.findViewById(R.id.quickedit_settings);
settingsview.setOnClickListener(new OnClickListener() {
-
+
@Override
public void onClick(View v) {
mEditProfile =(VpnProfile) getListAdapter().getItem(position);
editVPN(mEditProfile);
-
+
}
});
-
+
return v;
}
}
-
-
-
- private static final int MENU_ADD_PROFILE = Menu.FIRST;
- private static final int START_VPN_CONFIG = 92;
- private static final int SELECT_PROFILE = 43;
- private static final int IMPORT_PROFILE = 231;
- private static final int MENU_IMPORT_PROFILE = Menu.FIRST +1;
-
+
+
+
private ArrayAdapter<VpnProfile> mArrayadapter;
protected VpnProfile mEditProfile=null;
-
-
+
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
+
// Debug load JNI
//OpenVPN.foo();
}
+
+ class MiniImageGetter implements ImageGetter {
+
+
+ @Override
+ public Drawable getDrawable(String source) {
+ Drawable d=null;
+ if ("ic_menu_add".equals(source))
+ d = getActivity().getResources().getDrawable(android.R.drawable.ic_menu_add);
+ else if("ic_menu_archive".equals(source))
+ d = getActivity().getResources().getDrawable(R.drawable.ic_menu_archive);
+
+
+
+ if(d!=null) {
+ d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
+ return d;
+ }else{
+ return null;
+ }
+ }
+ }
+
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View v = inflater.inflate(R.layout.vpn_profile_list, container,false);
+
+ TextView newvpntext = (TextView) v.findViewById(R.id.add_new_vpn_hint);
+ TextView importvpntext = (TextView) v.findViewById(R.id.import_vpn_hint);
+
+
+
+ newvpntext.setText(Html.fromHtml(getString(R.string.add_new_vpn_hint),new MiniImageGetter(),null));
+ importvpntext.setText(Html.fromHtml(getString(R.string.vpn_import_hint),new MiniImageGetter(),null));
+
+
+
+ return v;
+
+ }
+
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
-
setListAdapter();
}
@@ -101,17 +151,17 @@ public class VPNProfileList extends ListFragment {
public int compare(VpnProfile lhs, VpnProfile rhs) {
return lhs.mName.compareTo(rhs.mName);
}
-
+
}
-
+
private void setListAdapter() {
mArrayadapter = new VPNArrayAdapter(getActivity(),R.layout.vpn_list_item,R.id.vpn_item_title);
Collection<VpnProfile> allvpn = getPM().getProfiles();
-
+
TreeSet<VpnProfile> sortedset = new TreeSet<VpnProfile>(new VpnProfileNameComperator());
sortedset.addAll(allvpn);
mArrayadapter.addAll(sortedset);
-
+
setListAdapter(mArrayadapter);
}
@@ -124,7 +174,7 @@ public class VPNProfileList extends ListFragment {
.setAlphabeticShortcut('a')
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM
| MenuItem.SHOW_AS_ACTION_WITH_TEXT);
-
+
menu.add(0, MENU_IMPORT_PROFILE, 0, R.string.menu_import)
.setIcon(R.drawable.ic_menu_archive)
.setAlphabeticShortcut('i')
@@ -212,15 +262,15 @@ public class VPNProfileList extends ListFragment {
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
-
+
if(resultCode == RESULT_VPN_DELETED){
if(mArrayadapter != null && mEditProfile !=null)
mArrayadapter.remove(mEditProfile);
}
-
+
if(resultCode != Activity.RESULT_OK)
return;
-
+
if (requestCode == START_VPN_CONFIG) {
String configuredVPN = data.getStringExtra(VpnProfile.EXTRA_PROFILEUUID);
@@ -228,7 +278,7 @@ public class VPNProfileList extends ListFragment {
getPM().saveProfile(getActivity(), profile);
// Name could be modified, reset List adapter
setListAdapter();
-
+
} else if(requestCode== SELECT_PROFILE) {
String filedata = data.getStringExtra(FileSelect.RESULT_DATA);
Intent startImport = new Intent(getActivity(),ConfigConverter.class);
@@ -260,8 +310,7 @@ public class VPNProfileList extends ListFragment {
intent.putExtra(LaunchVPN.EXTRA_KEY, profile.getUUID().toString());
intent.setAction(Intent.ACTION_MAIN);
startActivity(intent);
-
+
getActivity().finish();
}
-
}