@@ -69,6 +69,7 @@ public class Notifications extends IntentService {
6969 //public static boolean bg_vibrate;
7070 // public static boolean bg_lights;
7171 // public static boolean bg_sound;
72+ public static boolean compact_persistent_notification ;
7273 public static boolean bg_sound_in_silent ;
7374 public static String bg_notification_sound ;
7475
@@ -171,6 +172,7 @@ public void ReadPerfs(Context context) {
171172 smart_snoozing = prefs .getBoolean ("smart_snoozing" , true );
172173 smart_alerting = prefs .getBoolean ("smart_alerting" , true );
173174 bg_ongoing = prefs .getBoolean ("run_service_in_foreground" , false );
175+ compact_persistent_notification = Pref .getBooleanDefaultFalse ("compact_persistent_notification" );
174176 }
175177
176178/*
@@ -309,7 +311,7 @@ private boolean notificationSetter(Context context) {
309311 final long start = end - (60000 * 60 * 3 ) - (60000 * 10 );
310312 BgGraphBuilder bgGraphBuilder = new BgGraphBuilder (context , start , end );
311313 //BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(context);
312- if (bg_ongoing && ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . JELLY_BEAN ) ) {
314+ if (bg_ongoing ) {
313315 bgOngoingNotification (bgGraphBuilder );
314316 }
315317 if (prefs .getLong ("alerts_disabled_until" , 0 ) > new Date ().getTime ()) {
@@ -600,42 +602,42 @@ public synchronized Notification createOngoingNotification(BgGraphBuilder bgGrap
600602 }
601603 b .setOngoing (Pref .getBoolean ("use_proper_ongoing" , true ));
602604 try {
603- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .LOLLIPOP ) {
604- b .setGroup ("xDrip ongoing" );
605- }
605+ b .setGroup ("xDrip ongoing" );
606606 } catch (Exception e ) {
607607 //
608608 }
609- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .LOLLIPOP ) {
610- b .setVisibility (Pref .getBooleanDefaultFalse ("public_notifications" ) ? Notification .VISIBILITY_PUBLIC : Notification .VISIBILITY_PRIVATE );
611- b .setCategory (NotificationCompat .CATEGORY_STATUS );
612- }
609+ b .setVisibility (Pref .getBooleanDefaultFalse ("public_notifications" ) ? Notification .VISIBILITY_PUBLIC : Notification .VISIBILITY_PRIVATE );
610+ b .setCategory (NotificationCompat .CATEGORY_STATUS );
613611 if (Pref .getBooleanDefaultFalse ("high_priority_notifications" )) {
614612 b .setPriority (Notification .PRIORITY_HIGH );
615613 }
616614 final BestGlucose .DisplayGlucose dg = (use_best_glucose ) ? BestGlucose .getDisplayGlucose () : null ;
617615 final boolean use_color_in_notification = false ; // could be preference option
618616 final SpannableString titleString = new SpannableString (lastReading == null ? "BG Reading Unavailable" : (dg != null ) ? (dg .spannableString (dg .unitized + " " + dg .delta_arrow ,use_color_in_notification ))
619617 : (lastReading .displayValue (mContext ) + " " + lastReading .slopeArrow ()));
620- b .setContentTitle (titleString )
621- .setContentText ("xDrip Data collection service is running." )
622- .setSmallIcon (R .drawable .ic_action_communication_invert_colors_on )
623- .setUsesChronometer (false );
618+ if (!compact_persistent_notification ) {
619+ b .setContentTitle (titleString )
620+ .setContentText ("xDrip Data collection service is running." )
621+ .setSmallIcon (R .drawable .ic_action_communication_invert_colors_on )
622+ .setUsesChronometer (false );
623+ } else {
624+ b .setSmallIcon (R .drawable .ic_action_communication_invert_colors_on )
625+ .setUsesChronometer (false );
626+ }
624627
625628 Bitmap numberIcon = null ;
626629
627- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .M ) {
628- // in case the graphic crashes the system-ui we wont do it immediately after reboot so the
629- // user has a chance to disable the feature
630- if (SystemClock .uptimeMillis () > Constants .MINUTE_IN_MS * 15 ) {
631- if (NumberGraphic .numberIconEnabled ()) {
632- if ((dg != null ) && (!dg .isStale ())) {
633- final Bitmap icon_bitmap = NumberGraphic .getSmallIconBitmap (dg .unitized );
634- if (icon_bitmap != null ) b .setSmallIcon (Icon .createWithBitmap (icon_bitmap ));
635-
636- }
630+ // in case the graphic crashes the system-ui we wont do it immediately after reboot so the
631+ // user has a chance to disable the feature
632+ if (SystemClock .uptimeMillis () > Constants .MINUTE_IN_MS * 15 ) {
633+ if (NumberGraphic .numberIconEnabled ()) {
634+ if ((dg != null ) && (!dg .isStale ())) {
635+ final Bitmap icon_bitmap = NumberGraphic .getSmallIconBitmap (dg .unitized );
636+ if (icon_bitmap != null ) b .setSmallIcon (Icon .createWithBitmap (icon_bitmap ));
637637 }
638+ }
638639
640+ if (!compact_persistent_notification ) {
639641 if (NumberGraphic .largeWithArrowEnabled ()) {
640642 if ((dg != null ) && (!dg .isStale ())) {
641643 numberIcon = NumberGraphic .getLargeWithArrowBitmap (dg .unitized , dg .delta_arrow );
@@ -649,26 +651,26 @@ public synchronized Notification createOngoingNotification(BgGraphBuilder bgGrap
649651 }
650652
651653 if (lastReading != null ) {
654+ if (!compact_persistent_notification ) {
652655
653- b .setWhen (lastReading .timestamp );
654- b .setShowWhen (true );
656+ b .setWhen (lastReading .timestamp );
657+ b .setShowWhen (true );
655658
656- final SpannableString deltaString = new SpannableString ("Delta: " + ((dg != null ) ? (dg .spannableString (dg .unitized_delta + (dg .from_plugin ? " " + context .getString (R .string .p_in_circle ) : "" )))
657- : bgGraphBuilder .unitizedDeltaString (true , true )));
659+ final SpannableString deltaString = new SpannableString ("Delta: " + ((dg != null ) ? (dg .spannableString (dg .unitized_delta + (dg .from_plugin ? " " + context .getString (R .string .p_in_circle ) : "" )))
660+ : bgGraphBuilder .unitizedDeltaString (true , true )));
658661
659- b .setContentText (deltaString );
662+ b .setContentText (deltaString );
660663
661- notifiationBitmap = new BgSparklineBuilder (mContext )
662- .setBgGraphBuilder (bgGraphBuilder )
663- .showHighLine ()
664- .showLowLine ()
665- .setStart (System .currentTimeMillis () - 60000 * 60 * 3 )
666- .showAxes (true )
667- .setBackgroundColor (getCol (X .color_notification_chart_background ))
668- .setShowFiltered (DexCollectionType .hasFiltered () && Pref .getBooleanDefaultFalse ("show_filtered_curve" ))
669- .build ();
664+ notifiationBitmap = new BgSparklineBuilder (mContext )
665+ .setBgGraphBuilder (bgGraphBuilder )
666+ .showHighLine ()
667+ .showLowLine ()
668+ .setStart (System .currentTimeMillis () - 60000 * 60 * 3 )
669+ .showAxes (true )
670+ .setBackgroundColor (getCol (X .color_notification_chart_background ))
671+ .setShowFiltered (DexCollectionType .hasFiltered () && Pref .getBooleanDefaultFalse ("show_filtered_curve" ))
672+ .build ();
670673
671- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .N ) {
672674 Notification .DecoratedCustomViewStyle customViewStyle = new Notification .DecoratedCustomViewStyle ();
673675
674676 iconBitmap = numberIcon != null ? numberIcon : new BgSparklineBuilder (mContext )
@@ -693,29 +695,12 @@ public synchronized Notification createOngoingNotification(BgGraphBuilder bgGrap
693695 b .setStyle (customViewStyle )
694696 .setCustomContentView (collapsedViews )
695697 .setCustomBigContentView (expandedViews );
696- } else {
697- iconBitmap = numberIcon != null ? numberIcon : new BgSparklineBuilder (mContext )
698- .setHeight (64 )
699- .setWidth (64 )
700- .setStart (System .currentTimeMillis () - 60000 * 60 * 3 )
701- .setBgGraphBuilder (bgGraphBuilder )
702- .setBackgroundColor (getCol (X .color_notification_chart_background ))
703- .build ();
704- b .setLargeIcon (iconBitmap );
705-
706- Notification .BigPictureStyle bigPictureStyle = new Notification .BigPictureStyle ();
707- bigPictureStyle .bigPicture (notifiationBitmap )
708- .setSummaryText (deltaString )
709- .setBigContentTitle (titleString );
710- b .setStyle (bigPictureStyle );
711698 }
712699 }
713700
714701 b .setContentIntent (resultPendingIntent );
715- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .KITKAT_WATCH ) {
716- b .setLocalOnly (true );
717- b .setOnlyAlertOnce (true );
718- }
702+ b .setLocalOnly (true );
703+ b .setOnlyAlertOnce (true );
719704 // strips channel ID if disabled
720705 return XdripNotification .build (b );
721706 }
0 commit comments