blob: d7f574b23915a3bdb973111c58b2d9bc978a0097 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
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.
*/
public class BitmaskApp extends Application {
@Override
public void onCreate() {
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);
}
}
|