diff options
author | Dániel Zolnai <dzolnai@users.noreply.github.com> | 2016-11-08 14:49:57 +0100 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2016-11-08 14:49:57 +0100 |
commit | df2f911a6e10503bee9e99f61f7c19e6e34148a8 (patch) | |
tree | e86b85cefc76560cf56a9e77aa10d770800cca17 /main | |
parent | f2b2b7e8832092ca9cd80d7f630809fc3761d612 (diff) |
Change activity which opens when tapping notification (#582)
Diffstat (limited to 'main')
-rw-r--r-- | main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java b/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java index 8994eb22..aa75dd3e 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java +++ b/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java @@ -7,6 +7,7 @@ package de.blinkt.openvpn.core; import android.Manifest.permission; import android.annotation.TargetApi; +import android.app.Activity; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; @@ -86,6 +87,7 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac private Handler guiHandler; private Toast mlastToast; private Runnable mOpenVPNThread; + private static Class mNotificationActivityClass; // From: http://stackoverflow.com/questions/3758606/how-to-convert-byte-size-into-human-readable-format-in-java public static String humanReadableByteCount(long bytes, boolean mbit) { @@ -278,9 +280,22 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac } + /** + * Sets the activity which should be opened when tapped on the permanent notification tile. + * + * @param activityClass The activity class to open + */ + public static void setNotificationActivityClass(Class<? extends Activity> activityClass) { + mNotificationActivityClass = activityClass; + } + PendingIntent getLogPendingIntent() { // Let the configure Button show the Log - Intent intent = new Intent(getBaseContext(), LogWindow.class); + Class activityClass = LogWindow.class; + if (mNotificationActivityClass != null) { + activityClass = mNotificationActivityClass; + } + Intent intent = new Intent(getBaseContext(), activityClass); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); PendingIntent startLW = PendingIntent.getActivity(this, 0, intent, 0); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); |