From cd6538aac9f86081a625dcaadd5b9f38828e4452 Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Fri, 11 May 2018 17:31:05 +0300 Subject: [PATCH] Removed all usages of deprecated code. Signed-off-by: Dimitar Dobrev --- .../Toasts.Forms.Plugin.Sample.iOS.csproj | 1 - Toasts.Forms.Plugin.Droid/AlarmHandler.cs | 5 +++-- Toasts.Forms.Plugin.Droid/NotificationBuilder.cs | 5 +++-- Toasts.Forms.Plugin.Droid/SnackbarNotification.cs | 6 +++--- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Sample/Toasts.Forms.Plugin.Sample.iOS/Toasts.Forms.Plugin.Sample.iOS.csproj b/Sample/Toasts.Forms.Plugin.Sample.iOS/Toasts.Forms.Plugin.Sample.iOS.csproj index c4505e8..91891be 100644 --- a/Sample/Toasts.Forms.Plugin.Sample.iOS/Toasts.Forms.Plugin.Sample.iOS.csproj +++ b/Sample/Toasts.Forms.Plugin.Sample.iOS/Toasts.Forms.Plugin.Sample.iOS.csproj @@ -28,7 +28,6 @@ Default, i386, x86_64 None True - Entitlements.plist False diff --git a/Toasts.Forms.Plugin.Droid/AlarmHandler.cs b/Toasts.Forms.Plugin.Droid/AlarmHandler.cs index 3f1efb4..9a58714 100644 --- a/Toasts.Forms.Plugin.Droid/AlarmHandler.cs +++ b/Toasts.Forms.Plugin.Droid/AlarmHandler.cs @@ -4,6 +4,7 @@ using System.IO; using System.Xml.Serialization; using Android.Graphics; +using Android.Support.V4.App; namespace Plugin.Toasts { @@ -24,12 +25,12 @@ public override void OnReceive(Context context, Intent intent) } // Show Notification - Android.App.Notification.Builder builder = new Android.App.Notification.Builder(Application.Context) + var builder = new NotificationCompat.Builder(Application.Context, NotificationBuilder.DefaultChannelName) .SetContentTitle(options.Title) .SetContentText(options.Description) .SetSmallIcon(options.AndroidOptions.SmallDrawableIcon.Value) // Must have small icon to display .SetPriority((int)NotificationPriority.High) // Must be set to High to get Heads-up notification - .SetDefaults(NotificationDefaults.All) // Must also include vibrate to get Heads-up notification + .SetDefaults((int) NotificationDefaults.All) // Must also include vibrate to get Heads-up notification .SetAutoCancel(true) .SetColor(Color.ParseColor(options.AndroidOptions.HexColor)); diff --git a/Toasts.Forms.Plugin.Droid/NotificationBuilder.cs b/Toasts.Forms.Plugin.Droid/NotificationBuilder.cs index 7a76b5c..75f14d2 100644 --- a/Toasts.Forms.Plugin.Droid/NotificationBuilder.cs +++ b/Toasts.Forms.Plugin.Droid/NotificationBuilder.cs @@ -8,6 +8,7 @@ using System.Xml.Serialization; using Plugin.Toasts.Interfaces; using System.Collections.Concurrent; +using Android.Support.V4.App; namespace Plugin.Toasts { @@ -211,12 +212,12 @@ public INotificationResult Notify(Activity activity, INotificationOptions option options.AndroidOptions.HexColor = "#" + options.AndroidOptions.HexColor; } - Android.App.Notification.Builder builder = new Android.App.Notification.Builder(Application.Context) + var builder = new NotificationCompat.Builder(Application.Context) .SetContentTitle(options.Title) .SetContentText(options.Description) .SetSmallIcon(smallIcon) // Must have small icon to display .SetPriority((int)NotificationPriority.High) // Must be set to High to get Heads-up notification - .SetDefaults(NotificationDefaults.All) // Must also include vibrate to get Heads-up notification + .SetDefaults((int) NotificationDefaults.All) // Must also include vibrate to get Heads-up notification .SetAutoCancel(true) // To allow click event to trigger delete Intent .SetContentIntent(pendingClickIntent) // Must have Intent to accept the click .SetDeleteIntent(pendingDismissIntent) diff --git a/Toasts.Forms.Plugin.Droid/SnackbarNotification.cs b/Toasts.Forms.Plugin.Droid/SnackbarNotification.cs index 40ccc01..bdb59e2 100644 --- a/Toasts.Forms.Plugin.Droid/SnackbarNotification.cs +++ b/Toasts.Forms.Plugin.Droid/SnackbarNotification.cs @@ -36,12 +36,12 @@ public NotificationResult Notify(Activity activity, INotificationOptions options var snackbar = Snackbar.Make(view, builder, Snackbar.LengthLong); if (options.IsClickable) - snackbar.SetAction(options.AndroidOptions.ViewText, new EmptyOnClickListener(id, (toastId, result) => { ToastClosed(toastId, result); }, new NotificationResult() { Action = NotificationAction.Clicked })); + snackbar.SetAction(options.AndroidOptions.ViewText, new EmptyOnClickListener(id, ToastClosed, new NotificationResult() { Action = NotificationAction.Clicked })); else - snackbar.SetAction(options.AndroidOptions.DismissText, new EmptyOnClickListener(id, (toastId, result) => { ToastClosed(toastId, result); }, new NotificationResult() { Action = NotificationAction.Dismissed })); + snackbar.SetAction(options.AndroidOptions.DismissText, new EmptyOnClickListener(id, ToastClosed, new NotificationResult() { Action = NotificationAction.Dismissed })); // Monitor callbacks - snackbar.SetCallback(new ToastCallback(id, (toastId, result) => { ToastClosed(toastId, result); })); + snackbar.AddCallback(new ToastCallback(id, ToastClosed)); // Setup reset events var resetEvent = new ManualResetEvent(false);