public static NotificationBuilder FromInstance(NotificationInstance notif) { NotificationBuilder builder = new NotificationBuilder(notif.id, notif.title, notif.body); if (notif.smallIcon != null) { builder.setSmallIcon(notif.smallIcon.name); } if (notif.largeIcon != null) { builder.setLargeIcon(notif.largeIcon.name); } if ((notif.ticker != null) && (notif.ticker.Length > 0)) { builder.setTicker(notif.ticker); } int defaultFlags = 0; if (notif.defaultSound) { defaultFlags |= 1; } else if (notif.soundFile != null) { builder.setSound(notif.soundFile.name); } if (notif.defaultVibrate) { defaultFlags |= 2; } else if (notif.vibroPattern != null) { long[] pattern = notif.vibroPattern.ToArray(); builder.setVibrate(pattern); } if (defaultFlags > 0) { builder.setDefaults(defaultFlags); } if (notif.number > 0) { builder.setNumber(notif.number); } if ((notif.group != null) && (notif.group.Length > 0)) { builder.setGroup(notif.group); } if ((notif.sortKey != null) && (notif.sortKey.Length > 0)) { builder.setSortKey(notif.sortKey); } if (notif.hasColor) { builder.setColor("#" + ColorUtils.ToHtmlStringRGB(notif.color)); } builder.setGroupId(notif.groupId); builder.setAutoCancel(notif.autoCancel); builder.setAlertOnlyOnce(notif.alertOnce); if (notif.isRepeating) { builder.setRepeating(true); long num2 = ((notif.intervalHours * 0xe10) + (notif.intervalMinutes * 60)) + notif.intervalSeconds; long interval = num2 * 0x3e8L; builder.setInterval(interval); } long num4 = ((notif.delayHours * 0xe10) + (notif.delayMinutes * 60)) + notif.delaySeconds; long delayMilliseconds = num4 * 0x3e8L; builder.setDelay(delayMilliseconds); return(builder); }
/// <summary> /// Builds notification from NotificationInstance - created in editor /// </summary> /// <param name="notif">Instance created in Notifications Window</param> /// <returns>Notification buildder</returns> public static NotificationBuilder FromInstance(NotificationInstance notif) { NotificationBuilder builder = new NotificationBuilder(notif.id, notif.title, notif.body); if (notif.smallIcon != null) { builder.setSmallIcon(notif.smallIcon.name); } if (notif.largeIcon != null) { builder.setLargeIcon(notif.largeIcon.name); } if (notif.ticker != null && notif.ticker.Length > 0) { builder.setTicker(notif.ticker); } int defaults = 0; // Handle sound if (notif.defaultSound) { defaults |= NotificationBuilder.DEFAULT_SOUND; } else { if (notif.soundFile != null) { builder.setSound(notif.soundFile.name); } } // Handle vibrate if (notif.defaultVibrate) { defaults |= NotificationBuilder.DEFAULT_VIBRATE; } else { if (notif.vibroPattern != null) { long[] vibratePattern = notif.vibroPattern.ToArray(); builder.setVibrate(vibratePattern); } } if (defaults > 0) { builder.setDefaults(defaults); } if (notif.number > 0) { builder.setNumber(notif.number); } if (notif.group != null && notif.group.Length > 0) { builder.setGroup(notif.group); } if (notif.sortKey != null && notif.sortKey.Length > 0) { builder.setSortKey(notif.sortKey); } if (notif.hasColor) { builder.setColor("#" + ColorUtility.ToHtmlStringRGB(notif.color)); } builder.setAutoCancel(notif.autoCancel); builder.setAlertOnlyOnce(notif.alertOnce); // Repeating and interval if (notif.isRepeating) { builder.setRepeating(true); long intervalSeconds = notif.intervalHours * 3600 + notif.intervalMinutes * 60 + notif.intervalSeconds; long milis = intervalSeconds * 1000; builder.setInterval(milis); } // Delay long delaySeconds = notif.delayHours * 3600 + notif.delayMinutes * 60 + notif.delaySeconds; long delayMilis = delaySeconds * 1000; builder.setDelay(delayMilis); return(builder); }