/// <summary>
        ///
        /// </summary>
        /// <param name="notificationImage"></param>
        /// <returns></returns>
        protected virtual async Task <Bitmap> GetNativeImage(NotificationImage notificationImage)
        {
            if (notificationImage is null || notificationImage.HasValue == false)
            {
                return(null);
            }

            if (string.IsNullOrWhiteSpace(notificationImage.ResourceName) == false)
            {
                var imageId = Application.Context.Resources?.GetIdentifier(notificationImage.ResourceName, AndroidIcon.DefaultType, Application.Context.PackageName);
                if (imageId != null)
                {
                    return(await BitmapFactory.DecodeResourceAsync(Application.Context.Resources, imageId.Value));
                }
            }
            if (string.IsNullOrWhiteSpace(notificationImage.FilePath) == false)
            {
                if (File.Exists(notificationImage.FilePath))
                {
                    return(await BitmapFactory.DecodeFileAsync(notificationImage.FilePath));
                }
            }
            if (notificationImage.Binary != null && notificationImage.Binary.Length > 0)
            {
                return(await BitmapFactory.DecodeByteArrayAsync(notificationImage.Binary, 0, notificationImage.Binary.Length));
            }
            return(null);
        }
Пример #2
0
        public void ShowNotificationBadge(bool showBadge)
        {
            try
            {
                LottieAnimationView animationView2 = MainContext.FindViewById <LottieAnimationView>(Resource.Id.animation_view2);

                if (showBadge)
                {
                    NotificationImage.SetImageDrawable(null);

                    animationView2.SetAnimation("NotificationLotti.json");
                    animationView2.PlayAnimation();
                }
                else
                {
                    animationView2.Progress = 0;
                    animationView2.CancelAnimation();
                    NotificationImage.SetImageResource(Resource.Drawable.icon_notification_vector);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
 static void AddNotification(string _content, NotificationImage _img, NotificationType type, Color col, bool rep, bool snd, bool right)
 {
     if (TCTData.Settings.Notifications)
     {
         var n = new NotificationInfo(_content, _img, type, col, rep, snd, right);
         NQ.Add(n);
     }
 }
Пример #4
0
 public NotificationEventArgs(string con, NotificationImage i, NotificationType t, Color c, bool s, bool re, bool r)
 {
     Content = con;
     Image   = i;
     Type    = t;
     Color   = c;
     Sound   = s;
     Repeat  = re;
     Right   = r;
 }
Пример #5
0
        public Notification getNotification(bool generateHaveToAct)
        {
            int  sourceIndex = random.Next(0, sourcesNumber);
            bool isSilent    = random.Next(0, 2) == 0;

            if (generateHaveToAct)
            {
                sourceIndex = mapNameToIndex();
                isSilent    = false;
            }
            string             id = Guid.NewGuid().ToString();
            NotificationSource notificationSource = (NotificationSource)Enum.GetValues(typeof(NotificationSource)).GetValue(sourceIndex);
            string             sourceName         = EnumDescription.getDescription(notificationSource);
            NotificationImage  notificationImage  = (NotificationImage)Enum.GetValues(typeof(NotificationImage)).GetValue(sourceIndex);
            string             sourceImage        = EnumDescription.getDescription(notificationImage);
            NotificationColor  notificationColor  = (NotificationColor)Enum.GetValues(typeof(NotificationColor)).GetValue(sourceIndex);
            Color sourceColor = EnumDescription.getColor(EnumDescription.getDescription(notificationColor));
            Array values      = Enum.GetValues(typeof(NotificationAuthor));
            int   authorIndex = random.Next(values.Length);

            if (generateHaveToAct)
            {
                authorIndex = mapAuthorToIndex();
            }
            NotificationAuthor notificationAuthor = (NotificationAuthor)values.GetValue(authorIndex);
            string             author             = EnumDescription.getDescription(notificationAuthor);

            values = Enum.GetValues(typeof(NotificationIcon));
            NotificationIcon notificationIcon = (NotificationIcon)values.GetValue(authorIndex);
            string           icon             = EnumDescription.getDescription(notificationIcon);
            string           text;

            if (sourceIndex == 2 || sourceIndex == 3) // post or youtube
            {
                values = Enum.GetValues(typeof(NotificationHeader));
                NotificationHeader notificationHeader = (NotificationHeader)values.GetValue(random.Next(values.Length));
                text = EnumDescription.getDescription(notificationHeader);
            }
            else // messengers
            {
                values = Enum.GetValues(typeof(NotificationText));
                NotificationText notificationText = (NotificationText)values.GetValue(random.Next(values.Length));
                text = EnumDescription.getDescription(notificationText);
            }
            if (isSilent)
            {
                sourceColor = EnumDescription.getColor(EnumDescription.getDescription(NotificationColor.Silent));
                sourceImage = "_silent_";
            }
            long         timestamp    = DateTime.Now.Ticks;
            Notification notification = new Notification(id, sourceImage, sourceName, author, icon, text, timestamp, isSilent, sourceColor, generateHaveToAct);

            Debug.Log(string.Format("Notification which is {0} and has the following data: {1} was created", generateHaveToAct ? "correct" : "incorrect", notification));
            return(notification);
        }
Пример #6
0
    public void ShowPopup(Vector3 position, Sprite image)
    {
        GameObject obj = Instantiate(popupPrefab.gameObject) as GameObject;

        obj.transform.position = position;
        obj.transform.SetParent(GameObject.FindGameObjectWithTag("NotificationImageParent").transform);
        NotificationImage notification = obj.GetComponent <NotificationImage>();

        notification.image.sprite = image;
        notification.StartNotification();
    }
Пример #7
0
        public NotificationInfo(string _c, NotificationImage _img, NotificationType t, Color _co, bool _repeat, bool _sound, bool right)
        {
            Content      = _c;
            Image        = _img;
            Type         = t;
            Color        = _co;
            IsRepeatable = _repeat;
            Sound        = _sound;
            Right        = right;

            IsDelivered = false;
        }
Пример #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="notificationImage"></param>
        /// <returns></returns>
        protected virtual async Task <UNNotificationAttachment> GetNativeImage(NotificationImage notificationImage)
        {
            if (notificationImage is null || notificationImage.HasValue == false)
            {
                return(null);
            }

            NSUrl imageAttachment = null;

            if (string.IsNullOrWhiteSpace(notificationImage.ResourceName) == false)
            {
                imageAttachment = NSBundle.MainBundle.GetUrlForResource(Path.GetFileNameWithoutExtension(notificationImage.ResourceName), Path.GetExtension(notificationImage.ResourceName));
            }
            if (string.IsNullOrWhiteSpace(notificationImage.FilePath) == false)
            {
                if (File.Exists(notificationImage.FilePath))
                {
                    imageAttachment = NSUrl.CreateFileUrl(notificationImage.FilePath, false, null);
                }
            }
            if (notificationImage.Binary != null && notificationImage.Binary.Length > 0)
            {
                using (var stream = new MemoryStream(notificationImage.Binary))
                {
                    var image          = Image.FromStream(stream);
                    var imageExtension = image.RawFormat.ToString();

                    var cache = NSSearchPath.GetDirectories(NSSearchPathDirectory.CachesDirectory,
                                                            NSSearchPathDomain.User);
                    var cachesFolder = cache[0];
                    var cacheFile    = $"{cachesFolder}{NSProcessInfo.ProcessInfo.GloballyUniqueString}.{imageExtension}";

                    if (File.Exists(cacheFile))
                    {
                        File.Delete(cacheFile);
                    }

                    await File.WriteAllBytesAsync(cacheFile, notificationImage.Binary);

                    imageAttachment = NSUrl.CreateFileUrl(cacheFile, false, null);
                }
            }

            if (imageAttachment is null)
            {
                return(null);
            }

            var options = new UNNotificationAttachmentOptions();

            return(UNNotificationAttachment.FromIdentifier("image", imageAttachment, options, out _));
        }
Пример #9
0
        public void DisableAllNavigationButton()
        {
            HomeImage.Background = null;
            HomeImage.SetColorFilter(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);

            NotificationImage.Background = null;
            NotificationImage.SetColorFilter(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);

            ProfileImage.Background = null;
            //ProfileImage.SetColorFilter(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);

            TrendImage.Background = null;
            TrendImage.SetColorFilter(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);

            MessagesImage.Background = null;
            MessagesImage.SetColorFilter(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
        }
Пример #10
0
        internal static NotificationError GetImage(NotificationSafeHandle handle, NotificationImage type, out string path)
        {
            NotificationError ret;
            IntPtr            ptr;

            ret = GetImageReferenceType(handle, type, out ptr);

            if (ptr == IntPtr.Zero)
            {
                path = null;
            }
            else
            {
                path = Marshal.PtrToStringAnsi(ptr);
            }

            return(ret);
        }
        internal static ErrorCode GetImage(NotificationSafeHandle handle, NotificationImage type, out string text)
        {
            ErrorCode err;
            IntPtr    ptr;

            err = GetImageReferenceType(handle, type, out ptr);

            if (ptr == IntPtr.Zero)
            {
                text = null;
            }
            else
            {
                text = Marshal.PtrToStringAnsi(ptr);
            }

            return(err);
        }
Пример #12
0
 internal static extern NotificationError SetImage(NotificationSafeHandle handle, NotificationImage type, string path);
Пример #13
0
 internal static extern NotificationError GetImageReferenceType(NotificationSafeHandle handle, NotificationImage type, out IntPtr path);
Пример #14
0
 public static void SendNotification(string content, NotificationImage img, NotificationType t, Color col, bool repeat, bool sound, bool right)
 {
     TCTNotifier.NotificationProvider.SendNotification(content, img, t, col, repeat, sound, right);
 }
 internal static extern ErrorCode GetImageReferenceType(NotificationSafeHandle handle, NotificationImage type, out IntPtr text);
 public static void SendNotification(string _content, NotificationImage img, NotificationType t, Color col, bool rep, bool snd, bool right)
 {
     AddNotification(_content, img, t, col, rep, snd, right);
 }