Exemple #1
0
 private void NotificationAdapterViewHolder_ItemLongClicked(object sender, Notificaciones.NotificationEventArgs.NotificationItemClickedEventArgs e)
 {
     position = e.Position;
     using (OpenNotification openNotification = new OpenNotification(e.Position))
     {
         if (openNotification.IsRemovable())
         {
             using (NotificationSlave notificationSlave = NotificationSlave.NotificationSlaveInstance())
             {
                 if (Build.VERSION.SdkInt < BuildVersionCodes.Lollipop)
                 {
                     int    notiId   = CatcherHelper.statusBarNotifications[position].Id;
                     string notiTag  = CatcherHelper.statusBarNotifications[position].Tag;
                     string notiPack = CatcherHelper.statusBarNotifications[position].PackageName;
                     notificationSlave.CancelNotification(notiPack, notiTag, notiId);
                 }
                 else
                 {
                     notificationSlave.CancelNotification(CatcherHelper.statusBarNotifications[position].Key);
                 }
             }
             floatingNotificationView.Visibility = ViewStates.Gone;
         }
     }
 }
Exemple #2
0
        private void NotificationAdapterViewHolder_ItemClicked(object sender, Notificaciones.NotificationEventArgs.NotificationItemClickedEventArgs e)
        {
            position = e.Position;
            using (OpenNotification notification = new OpenNotification(e.Position))
            {
                position = e.Position;
                using (OpenNotification openNotification = new OpenNotification(e.Position))
                {
                    floatingNotificationAppName.Text = notification.GetAppName();
                    floatingNotificationWhen.Text    = notification.GetWhen();
                    floatingNotificationTitle.Text   = notification.GetTitle();
                    floatingNotificationText.Text    = notification.GetText();
                    floatingNotificationActionsContainer.RemoveAllViews();

                    if (openNotification.NotificationHasActionButtons() == true)
                    {
                        var actions = openNotification.RetrieveActions();
                        foreach (var a in actions)
                        {
                            OpenAction openAction = new OpenAction(a);
                            float      weight     = (float)1 / actions.Count;

                            Button anActionButton = new Button(Application.Context)
                            {
                                LayoutParameters = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MatchParent, weight),
                                Text             = openAction.GetTitle(),
                            };
                            anActionButton.SetTypeface(Typeface.Create("sans-serif-condensed", TypefaceStyle.Normal), TypefaceStyle.Normal);
                            anActionButton.SetMaxLines(1);
                            anActionButton.SetTextColor(Color.Black);
                            anActionButton.Click += (o, eventargs) =>
                            {
                                openAction.ClickAction();
                            };
                            anActionButton.Gravity = GravityFlags.CenterVertical;
                            TypedValue outValue = new TypedValue();
                            Application.Context.Theme.ResolveAttribute(Android.Resource.Attribute.SelectableItemBackgroundBorderless, outValue, true);
                            anActionButton.SetBackgroundResource(outValue.ResourceId);
                            anActionButton.SetCompoundDrawablesRelativeWithIntrinsicBounds(openAction.GetActionIcon(), null, null, null);
                            floatingNotificationActionsContainer.AddView(anActionButton);
                        }
                        ;
                    }
                }

                if (floatingNotificationView.Visibility != ViewStates.Visible)
                {
                    floatingNotificationView.Visibility = ViewStates.Visible;
                }
                else
                {
                    floatingNotificationView.Visibility = ViewStates.Invisible;
                }
            };
        }