diff options
author | cyberta <cyberta@riseup.net> | 2017-12-14 10:19:03 -0800 |
---|---|---|
committer | cyberta <cyberta@riseup.net> | 2017-12-14 10:19:03 -0800 |
commit | 67ff3447f10c43770dc9ee4dccf358321063d131 (patch) | |
tree | cb29df26bec196f8628947897a5fe9977b00a229 /app/src/main/java/se/leap/bitmaskclient/BitmaskApp.java | |
parent | 18e24819eed388d349dbf6d7cd21534d7074bf5d (diff) | |
parent | 25d215400d500bdb7537e604ed91ced586821ef2 (diff) |
Merge branch '8742_always-on_VPN' into '0.9.8'
8742 always on vpn
See merge request leap/bitmask_android!20
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/BitmaskApp.java')
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/BitmaskApp.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/BitmaskApp.java b/app/src/main/java/se/leap/bitmaskclient/BitmaskApp.java index 953a559d..d7f574b2 100644 --- a/app/src/main/java/se/leap/bitmaskclient/BitmaskApp.java +++ b/app/src/main/java/se/leap/bitmaskclient/BitmaskApp.java @@ -1,6 +1,16 @@ package se.leap.bitmaskclient; +import android.annotation.TargetApi; import android.app.Application; +import android.app.NotificationChannel; +import android.app.NotificationManager; +import android.content.Context; +import android.graphics.Color; +import android.os.Build; + +import de.blinkt.openvpn.core.OpenVPNService; + +import static android.os.Build.VERSION_CODES.O; /** * Created by cyberta on 24.10.17. @@ -13,5 +23,42 @@ public class BitmaskApp extends Application { super.onCreate(); PRNGFixes.apply(); //TODO: add LeakCanary! + if (Build.VERSION.SDK_INT >= O) + createNotificationChannelsForOpenvpn(); } + + + @TargetApi(O) + private void createNotificationChannelsForOpenvpn() { + NotificationManager mNotificationManager = + (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + + // Background message + CharSequence name = getString(R.string.channel_name_background); + NotificationChannel mChannel = new NotificationChannel(OpenVPNService.NOTIFICATION_CHANNEL_BG_ID, + name, NotificationManager.IMPORTANCE_MIN); + + mChannel.setDescription(getString(R.string.channel_description_background)); + mChannel.enableLights(false); + + mChannel.setLightColor(Color.DKGRAY); + mNotificationManager.createNotificationChannel(mChannel); + + // Connection status change messages + + name = getString(R.string.channel_name_status); + mChannel = new NotificationChannel(OpenVPNService.NOTIFICATION_CHANNEL_NEWSTATUS_ID, + name, NotificationManager.IMPORTANCE_DEFAULT); + + + mChannel.setDescription(getString(R.string.channel_description_status)); + mChannel.enableLights(true); + + mChannel.setLightColor(Color.BLUE); + mNotificationManager.createNotificationChannel(mChannel); + + } + + + } |