summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/menu/logmenu.xml8
-rw-r--r--res/values-de/strings.xml7
-rw-r--r--res/values/strings.xml5
-rw-r--r--src/de/blinkt/openvpn/LogWindow.java68
-rw-r--r--src/de/blinkt/openvpn/OpenVpnService.java4
-rw-r--r--src/de/blinkt/openvpn/ProfileManager.java19
6 files changed, 93 insertions, 18 deletions
diff --git a/res/menu/logmenu.xml b/res/menu/logmenu.xml
index 1ab982d8..4b55e73b 100644
--- a/res/menu/logmenu.xml
+++ b/res/menu/logmenu.xml
@@ -25,5 +25,11 @@
android:showAsAction="ifRoom|withText"
android:title="@string/send_logfile"
android:titleCondensed="@string/send"/>
-
+ <item
+ android:id="@+id/edit_vpn"
+ android:alphabeticShortcut="e"
+ android:icon="@android:drawable/ic_menu_edit"
+ android:showAsAction="withText|ifRoom"
+ android:title="@string/edit_vpn"/>
+
</menu> \ No newline at end of file
diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml
index 0bc0577d..2256caff 100644
--- a/res/values-de/strings.xml
+++ b/res/values-de/strings.xml
@@ -189,7 +189,7 @@
<string name="faq_howto_title">Schnellstart</string>
<string name="setting_loadtun_summary">Versuche das tun.ko Kernel Modul zu laden. Benötigt root.</string>
<string name="setting_loadtun">Lade tun Modul</string>
- <!-- Der Author hat die deutsch Übersetzung ganz allein verbrochen :) -->
+ <!-- Der Author hat die deutsche Übersetzung ganz allein verbrochen :) -->
<string name="translationby"></string>
<string name="faq_system_dialogs_title">Warnung beim Verbinden und Benachrichtigungston</string>
<string name="tun_error_helpful">Auf manchen ROM Version sind eventuell die Zugriffsrechte von /dev/tun falsch oder das tun Kernel Modul fehlt. Für Cyanogenmod 9 ROMs mit root gibt einen provisorischen Fix in den generellen Einstellungen.</string>
@@ -200,4 +200,9 @@
<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>
+ <string name="ignore">Ignorieren</string>
+ <string name="restart">Neu verbinden</string>
+ <string name="restart_vpn_after_change">Konfigurationsänderungen werden erst nach einem VPN Neustart aktiv. Jetzt neu verbinden?</string>
+ <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>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d18c9563..29b7069d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -244,4 +244,9 @@
<string name="donatewithpaypal">You can &lt;a href=\"https://www.paypal.com/cgi-bin/webscr?hosted_button_id=R2M6ZP9AF25LS&amp;amp;cmd=_s-xclick\">donate with PayPal&lt;/a> </string>
<string name="onbootrestartsummary">OpenVPN will reconnect a VPN if it was active on system reboot/shutdown. Please read the Connection warning FAQ before using this option.</string>
<string name="onbootrestart">Reconnect on reboot</string>
+ <string name="ignore">Ignore</string>
+ <string name="restart">Restart</string>
+ <string name="restart_vpn_after_change">Configuration changes are applied after restarting the VPN. (Re)start the VPN now?</string>
+ <string name="configuration_changed">Configuration changed</string>
+ <string name="log_no_last_vpn">Could not determine last connected profile for editing</string>
</resources>
diff --git a/src/de/blinkt/openvpn/LogWindow.java b/src/de/blinkt/openvpn/LogWindow.java
index 6cc257a5..94425fa8 100644
--- a/src/de/blinkt/openvpn/LogWindow.java
+++ b/src/de/blinkt/openvpn/LogWindow.java
@@ -32,6 +32,7 @@ import de.blinkt.openvpn.OpenVPN.LogListener;
import de.blinkt.openvpn.OpenVPN.StateListener;
public class LogWindow extends ListActivity implements StateListener {
+ private static final int START_VPN_CONFIG = 0;
private String[] mBconfig=null;
@@ -58,8 +59,8 @@ public class LogWindow extends ListActivity implements StateListener {
OpenVPN.addLogListener(this);
}
-
-
+
+
private void initLogBuffer() {
myEntries.clear();
for (LogItem litem : OpenVPN.getlogbuffer()) {
@@ -70,7 +71,7 @@ public class LogWindow extends ListActivity implements StateListener {
String getLogStr() {
String str = "";
for(String entry:myEntries) {
- str+=entry + '\n';
+ str+=entry + '\n';
}
return str;
}
@@ -205,15 +206,16 @@ public class LogWindow extends ListActivity implements StateListener {
Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.title_cancel);
builder.setMessage(R.string.cancel_connection_query);
+ builder.setNegativeButton(android.R.string.no, null);
builder.setPositiveButton(android.R.string.yes, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- ProfileManager.onBootDelete(getApplicationContext());
+ ProfileManager.setConntectedVpnProfileDisconnected(getApplicationContext());
OpenVpnManagementThread.stopOpenVPN();
}
});
- builder.setNegativeButton(android.R.string.no, null);
+
builder.show();
return true;
} else if(item.getItemId()==R.id.info) {
@@ -221,6 +223,18 @@ public class LogWindow extends ListActivity implements StateListener {
OpenVPN.triggerLogBuilderConfig();
} else if(item.getItemId()==R.id.send) {
ladapter.shareLog();
+ } else if(item.getItemId()==R.id.edit_vpn) {
+ VpnProfile lastConnectedprofile = ProfileManager.getLastConnectedVpn();
+
+ if(lastConnectedprofile!=null) {
+ Intent vprefintent = new Intent(this,VPNPreferences.class)
+ .putExtra(VpnProfile.EXTRA_PROFILEUUID,lastConnectedprofile.getUUIDString());
+ startActivityForResult(vprefintent,START_VPN_CONFIG);
+ } else {
+ Toast.makeText(this, R.string.log_no_last_vpn, Toast.LENGTH_LONG).show();
+ }
+
+
}
return super.onOptionsItemSelected(item);
@@ -241,6 +255,38 @@ public class LogWindow extends ListActivity implements StateListener {
}
@Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode == START_VPN_CONFIG && resultCode==RESULT_OK) {
+ String configuredVPN = data.getStringExtra(VpnProfile.EXTRA_PROFILEUUID);
+
+ final VpnProfile profile = ProfileManager.get(configuredVPN);
+ ProfileManager.getInstance(this).saveProfile(this, profile);
+ // Name could be modified, reset List adapter
+
+ AlertDialog.Builder dialog = new AlertDialog.Builder(this);
+ dialog.setTitle(R.string.configuration_changed);
+ dialog.setMessage(R.string.restart_vpn_after_change);
+
+
+ dialog.setPositiveButton(R.string.restart,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ Intent intent = new Intent(getBaseContext(), LaunchVPN.class);
+ intent.putExtra(LaunchVPN.EXTRA_KEY, profile.getUUIDString());
+ intent.setAction(Intent.ACTION_MAIN);
+ startActivity(intent);
+ }
+
+
+ });
+ dialog.setNegativeButton(R.string.ignore, null);
+ dialog.create().show();
+ }
+ super.onActivityResult(requestCode, resultCode, data);
+ }
+
+ @Override
protected void onStop() {
super.onStop();
OpenVPN.removeSpeedListener(this);
@@ -252,14 +298,14 @@ public class LogWindow extends ListActivity implements StateListener {
setContentView(R.layout.logwindow);
ListView lv = getListView();
-
+
lv.setOnItemLongClickListener(new OnItemLongClickListener() {
-
+
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view,
int position, long id) {
ClipboardManager clipboard = (ClipboardManager)
- getSystemService(Context.CLIPBOARD_SERVICE);
+ getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("Log Entry",((TextView) view).getText());
clipboard.setPrimaryClip(clip);
Toast.makeText(getBaseContext(), R.string.copied_entry, Toast.LENGTH_SHORT).show();
@@ -276,7 +322,7 @@ public class LogWindow extends ListActivity implements StateListener {
@Override
public void updateState(final String status,final String logmessage) {
runOnUiThread(new Runnable() {
-
+
@Override
public void run() {
String prefix=status+ ":";
@@ -285,9 +331,9 @@ public class LogWindow extends ListActivity implements StateListener {
mSpeedView.setText(prefix + logmessage);
}
});
-
+
}
-
+
@Override
protected void onDestroy() {
super.onDestroy();
diff --git a/src/de/blinkt/openvpn/OpenVpnService.java b/src/de/blinkt/openvpn/OpenVpnService.java
index 01def8eb..594b07d4 100644
--- a/src/de/blinkt/openvpn/OpenVpnService.java
+++ b/src/de/blinkt/openvpn/OpenVpnService.java
@@ -67,7 +67,7 @@ public class OpenVpnService extends VpnService implements StateListener {
OpenVpnManagementThread.stopOpenVPN();
mServiceThread=null;
stopSelf();
- ProfileManager.onBootDelete(this);
+ ProfileManager.setConntectedVpnProfileDisconnected(this);
};
private void hideNotification() {
@@ -201,7 +201,7 @@ public class OpenVpnService extends VpnService implements StateListener {
mServiceThread = new Thread(serviceThread, "OpenVPNServiceThread");
mServiceThread.start();
- ProfileManager.setOnBootProfile(this, mProfile);
+ ProfileManager.setConnectedVpnProfile(this, mProfile);
return START_NOT_STICKY;
}
diff --git a/src/de/blinkt/openvpn/ProfileManager.java b/src/de/blinkt/openvpn/ProfileManager.java
index 5d498c67..a40e6fcb 100644
--- a/src/de/blinkt/openvpn/ProfileManager.java
+++ b/src/de/blinkt/openvpn/ProfileManager.java
@@ -26,6 +26,10 @@ public class ProfileManager {
private static ProfileManager instance;
+
+
+
+ private static VpnProfile mLastConnectedVpn=null;
private HashMap<String,VpnProfile> profiles=new HashMap<String, VpnProfile>();
@@ -52,7 +56,7 @@ public class ProfileManager {
return instance;
}
- public static void onBootDelete(Context c) {
+ public static void setConntectedVpnProfileDisconnected(Context c) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(c);
Editor prefsedit = prefs.edit();
prefsedit.putString(ONBOOTPROFILE, null);
@@ -60,12 +64,13 @@ public class ProfileManager {
}
- public static void setOnBootProfile(Context c, VpnProfile bootprofile) {
+ public static void setConnectedVpnProfile(Context c, VpnProfile connectedrofile) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(c);
Editor prefsedit = prefs.edit();
- prefsedit.putString(ONBOOTPROFILE, bootprofile.getUUIDString());
+ prefsedit.putString(ONBOOTPROFILE, connectedrofile.getUUIDString());
prefsedit.apply();
+ mLastConnectedVpn=connectedrofile;
}
@@ -183,6 +188,8 @@ public class ProfileManager {
profiles.remove(vpnentry);
saveProfileList(context);
context.deleteFile(vpnentry + ".vp");
+ if(mLastConnectedVpn==profile)
+ mLastConnectedVpn=null;
}
@@ -193,4 +200,10 @@ public class ProfileManager {
return get(profileUUID);
}
+
+
+ public static VpnProfile getLastConnectedVpn() {
+ return mLastConnectedVpn;
+ }
+
}