Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/NightscoutFoundation/xDrip …
…into jamorhamvoice
- Loading branch information
Showing
4 changed files
with
143 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
app/src/main/java/com/eveningoutpost/dexdrip/UtilityModels/XdripNotification.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.eveningoutpost.dexdrip.UtilityModels; | ||
|
||
import android.annotation.TargetApi; | ||
import android.app.Notification; | ||
import android.os.Build; | ||
|
||
/* | ||
* Created by jwoglom on 5/17/2018 | ||
* <p> | ||
* Wrapper for android.app.Notification.Builder that adds the necessary notification | ||
* channel ID if enabled. Identical functionality-wise to XdripNotificationCompat. | ||
*/ | ||
|
||
public class XdripNotification { | ||
|
||
@TargetApi(Build.VERSION_CODES.O) | ||
public static Notification build(Notification.Builder builder) { | ||
if ((Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O)) { | ||
if (Pref.getBooleanDefaultFalse("use_notification_channels")) { | ||
// get dynamic channel based on contents of the builder | ||
try { | ||
final String id = NotificationChannels.getChan(builder).getId(); | ||
builder.setChannelId(id); | ||
} catch (NullPointerException e) { | ||
//noinspection ConstantConditions | ||
builder.setChannelId(null); | ||
} | ||
} else { | ||
//noinspection ConstantConditions | ||
builder.setChannelId(null); | ||
} | ||
return builder.build(); | ||
} else { | ||
return builder.build(); // standard pre-oreo behaviour | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters