1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-25 11:26:47 +01:00

Unset notification color for Android 12+

This commit is contained in:
José Rebelo 2022-04-30 20:24:34 +01:00 committed by Gitea
parent fea2d98bd1
commit 1092e1b10a
2 changed files with 12 additions and 2 deletions

View File

@ -380,6 +380,9 @@ public class GBApplication extends Application {
return VERSION.SDK_INT >= Build.VERSION_CODES.Q;
}
public static boolean isRunningTwelveOrLater() {
return VERSION.SDK_INT >= 31; // Build.VERSION_CODES.S, but our target SDK is lower
}
public static boolean isRunningPieOrLater() {
return VERSION.SDK_INT >= Build.VERSION_CODES.P;

View File

@ -151,10 +151,13 @@ public class GB {
.setContentText(text)
.setSmallIcon(connected ? device.getNotificationIconConnected() : device.getNotificationIconDisconnected())
.setContentIntent(getContentIntent(context))
.setColor(context.getResources().getColor(R.color.accent))
.setShowWhen(false)
.setOngoing(true);
if (!GBApplication.isRunningTwelveOrLater()) {
builder.setColor(context.getResources().getColor(R.color.accent));
}
Intent deviceCommunicationServiceIntent = new Intent(context, DeviceCommunicationService.class);
if (connected) {
deviceCommunicationServiceIntent.setAction(DeviceService.ACTION_DISCONNECT);
@ -187,9 +190,13 @@ public class GB {
.setContentText(text)
.setSmallIcon(R.drawable.ic_notification_disconnected)
.setContentIntent(getContentIntent(context))
.setColor(context.getResources().getColor(R.color.accent))
.setShowWhen(false)
.setOngoing(true);
if (!GBApplication.isRunningTwelveOrLater()) {
builder.setColor(context.getResources().getColor(R.color.accent));
}
if (GBApplication.getPrefs().getString("last_device_address", null) != null) {
Intent deviceCommunicationServiceIntent = new Intent(context, DeviceCommunicationService.class);
deviceCommunicationServiceIntent.setAction(DeviceService.ACTION_CONNECT);