From d77b9aefea75491b50f28a6880906ba9496979f2 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Thu, 21 Sep 2017 01:28:24 +0200 Subject: update ics-openvpn: update classes, manifest, resources and build script --- .../blinkt/openvpn/core/ICSOpenVPNApplication.java | 61 +++++++++++++++------- 1 file changed, 43 insertions(+), 18 deletions(-) (limited to 'app/src/main/java/de/blinkt/openvpn/core/ICSOpenVPNApplication.java') diff --git a/app/src/main/java/de/blinkt/openvpn/core/ICSOpenVPNApplication.java b/app/src/main/java/de/blinkt/openvpn/core/ICSOpenVPNApplication.java index db3ae751..e7019f42 100644 --- a/app/src/main/java/de/blinkt/openvpn/core/ICSOpenVPNApplication.java +++ b/app/src/main/java/de/blinkt/openvpn/core/ICSOpenVPNApplication.java @@ -4,7 +4,14 @@ */ package de.blinkt.openvpn.core; + +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 org.acra.ACRA; @@ -12,32 +19,50 @@ import org.acra.ReportingInteractionMode; import org.acra.annotation.ReportsCrashes; */ -import se.leap.bitmaskclient.BuildConfig; import se.leap.bitmaskclient.R; -import de.blinkt.openvpn.core.PRNGFixes; -/* -@ReportsCrashes( - formKey = "", - formUri = "http://reports.blinkt.de/report-icsopenvpn", - reportType = org.acra.sender.HttpSender.Type.JSON, - httpMethod = org.acra.sender.HttpSender.Method.PUT, - formUriBasicAuthLogin="report-icsopenvpn", - formUriBasicAuthPassword="Tohd4neiF9Ai!!!!111eleven", - mode = ReportingInteractionMode.TOAST, - resToastText = R.string.crash_toast_text -) -*/ public class ICSOpenVPNApplication extends Application { + private StatusListener mStatus; + @Override public void onCreate() { super.onCreate(); PRNGFixes.apply(); - if (BuildConfig.DEBUG) { - //ACRA.init(this); - } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) + + createNotificationChannels(); + mStatus = new StatusListener(); + mStatus.init(getApplicationContext()); + + } + + @TargetApi(Build.VERSION_CODES.O) + private void createNotificationChannels() { + 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); - VpnStatus.initLogCache(getApplicationContext().getCacheDir()); + mChannel.setLightColor(Color.BLUE); + mNotificationManager.createNotificationChannel(mChannel); } } -- cgit v1.2.3