From 5acc0ace25d231b9a3c2d7b3e83541008f94031b Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Sat, 15 Dec 2012 20:36:44 +0100 Subject: Minimal rework of notifications for JB --- src/de/blinkt/openvpn/OpenVpnService.java | 39 ++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'src/de/blinkt/openvpn/OpenVpnService.java') diff --git a/src/de/blinkt/openvpn/OpenVpnService.java b/src/de/blinkt/openvpn/OpenVpnService.java index ca199cc..122549a 100644 --- a/src/de/blinkt/openvpn/OpenVpnService.java +++ b/src/de/blinkt/openvpn/OpenVpnService.java @@ -104,19 +104,7 @@ public class OpenVpnService extends VpnService implements StateListener { // Try to set the priority available since API 16 (Jellybean) - if( lowpriority) { - try { - Method setpriority = nbuilder.getClass().getMethod("setPriority", int.class); - // PRIORITY_MIN == -2 - setpriority.invoke(nbuilder, -2 ); - - //ignore exception - } catch (NoSuchMethodException nsm) { - } catch (IllegalArgumentException e) { - } catch (IllegalAccessException e) { - } catch (InvocationTargetException e) { - } - } + jbNotificationExtras(lowpriority, nbuilder); if(tickerText!=null) nbuilder.setTicker(tickerText); @@ -127,6 +115,29 @@ public class OpenVpnService extends VpnService implements StateListener { startForeground(OPENVPN_STATUS, notification); } + private void jbNotificationExtras(boolean lowpriority, + android.app.Notification.Builder nbuilder) { + try { + if( lowpriority) { + Method setpriority = nbuilder.getClass().getMethod("setPriority", int.class); + // PRIORITY_MIN == -2 + setpriority.invoke(nbuilder, -2 ); + +/* PendingIntent cancelconnet=null; + + nbuilder.addAction(android.R.drawable.ic_menu_close_clear_cancel, + getString(R.string.cancel_connection),cancelconnet); */ + } + + //ignore exception + } catch (NoSuchMethodException nsm) { + } catch (IllegalArgumentException e) { + } catch (IllegalAccessException e) { + } catch (InvocationTargetException e) { + } + + } + PendingIntent getLogPendingIntent() { // Let the configure Button show the Log Intent intent = new Intent(getBaseContext(),LogWindow.class); @@ -436,7 +447,7 @@ public class OpenVpnService extends VpnService implements StateListener { } else { mDisplayBytecount = false; } - + // Other notifications are shown, // This also mean we are no longer connected, ignore bytecount messages until next // CONNECTED -- cgit v1.2.3 From 9fe3b7ce6d350474d0827cb6ff6554eafa822378 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Tue, 18 Dec 2012 11:11:47 +0100 Subject: Fix a few warnings and one bug when importing a file with a pkcs12 which cannot be read --- src/de/blinkt/openvpn/OpenVpnService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/de/blinkt/openvpn/OpenVpnService.java') diff --git a/src/de/blinkt/openvpn/OpenVpnService.java b/src/de/blinkt/openvpn/OpenVpnService.java index 122549a..603f86c 100644 --- a/src/de/blinkt/openvpn/OpenVpnService.java +++ b/src/de/blinkt/openvpn/OpenVpnService.java @@ -19,6 +19,7 @@ package de.blinkt.openvpn; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.Locale; import java.util.Vector; import android.app.Notification; @@ -108,6 +109,7 @@ public class OpenVpnService extends VpnService implements StateListener { if(tickerText!=null) nbuilder.setTicker(tickerText); + @SuppressWarnings("deprecation") Notification notification = nbuilder.getNotification(); @@ -451,7 +453,7 @@ public class OpenVpnService extends VpnService implements StateListener { // Other notifications are shown, // This also mean we are no longer connected, ignore bytecount messages until next // CONNECTED - String ticker = state.toLowerCase(); + String ticker = state.toLowerCase(Locale.getDefault()); showNotification(state +" " + logmessage,ticker,false,0); } -- cgit v1.2.3