Beispiel #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;
         }
     }
 }
Beispiel #2
0
 private void ItemLongClicked(object sender, NotificationItemClickedEventArgs e)
 {
     notification.Visibility = ViewStates.Visible;
     openNotification        = new OpenNotification(e.StatusBarNotification);
     openNotification.Cancel();
     notification.Visibility = ViewStates.Invisible;
 }
Beispiel #3
0
 public virtual void ApplyActionsStyle()
 {
     NotificationActions?.RemoveAllViews();
     if (OpenNotification.HasActions())
     {
         var actions = OpenNotification.RetrieveActions();
         for (int i = 0; i <= actions.Count - 1; i++)
         {
             var        action       = actions[i];
             OpenAction openAction   = new OpenAction(action);
             Button     actionButton = new Button(Application.Context);
             float      weight       = 1f / actions.Count;
             actionButton.LayoutParameters = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MatchParent, weight);
             SetActionTextColor(actionButton);
             SetActionTag(actionButton, openAction);
             actionButton.Click += ActionButton_Click;
             SetActionButtonGravity(actionButton);
             SetActionButtonTextMaxLines(actionButton);
             SetActionButtonTextTypeface(actionButton);
             SetActionButtonBackground(actionButton);
             SetActionText(actionButton, openAction.Title());
             SetActionTextLowercase(actionButton);
             SetActionIcon(actionButton, openAction);
             AddActionToActionsView(actionButton, i);
         }
     }
 }
        private void NotificationAdapterViewHolder_ItemClicked(object sender, NotificationItemClickedEventArgs e)
        {
            openNotification = e.StatusBarNotification;

            if (configurationManager.RetrieveAValue(ConfigurationParameters.TestEnabled))
            {
                Toast.MakeText(floatingNotificationView.Context, "Progress Indeterminate?: " + openNotification.IsProgressIndeterminate().ToString() + "\n"
                               + "Current Progress: " + openNotification.GetProgress().ToString() + "\n"
                               + "Max Progress: " + openNotification.GetProgressMax().ToString() + "\n"
                               + openNotification.GetGroupInfo()
                               , ToastLength.Short).Show();
            }
            //Only do this process if the notification that I want to show is different than the one that
            //the Floating Notification Widget has.
            //If it's the same then simply show it.
            if ((string)floatingNotificationView.GetTag(Resource.String.defaulttag) != openNotification.GetCustomId())
            {
                floatingNotificationView.SetTag(Resource.String.defaulttag, openNotification.GetCustomId());
            }
            if (floatingNotificationView.Visibility != ViewStates.Visible)
            {
                floatingNotificationView.Visibility = ViewStates.Visible;
            }
            else if (floatingNotificationView.Visibility != ViewStates.Visible)
            {
                floatingNotificationView.Visibility = ViewStates.Invisible;
            }
        }
 private void LlNotification_Click(object sender, EventArgs e)
 {
     notification.Visibility = ViewStates.Visible;
     try
     {
         using (OpenNotification openNotification = new OpenNotification(position))
         {
             Activity.RunOnUiThread(() =>
                                    openNotification.ClickNotification()
                                    );
             if (OpenNotification.NotificationIsAutoCancel(position) == true)
             {
                 notification.Visibility = ViewStates.Invisible;
                 titulo.Text             = null;
                 texto.Text = null;
                 when.Text  = null;
                 notificationActions.RemoveAllViews();
             }
         }
     }
     catch
     {
         Log.Wtf("OnNotificationClicked", "Metodo falla porque no existe una notificacion con esta acción");
     }
 }
 private void ItemLongClicked(object sender, NotificationItemClickedEventArgs e)
 {
     position = e.Position;
     notification.Visibility = ViewStates.Visible;
     using (OpenNotification openNotification = new OpenNotification(e.Position))
     {
         //If the notification is removable...
         if (openNotification.IsRemovable())
         {
             //Then remove the notification
             using (NotificationSlave slave = 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;
                     slave.CancelNotification(notiPack, notiTag, notiId);
                 }
                 else
                 {
                     slave.CancelNotification(CatcherHelper.statusBarNotifications[position].Key);
                 }
             }
             notification.Visibility = ViewStates.Invisible;
             titulo.Text             = null;
             texto.Text = null;
             notificationActions.RemoveAllViews();
         }
     }
 }
Beispiel #7
0
 private void CatcherHelper_NotificationRemoved(object sender, EventArgs e)
 {
     floatingNotificationView.Visibility = ViewStates.Gone;
     //Remove tag, notification removed
     openNotification = null;
     floatingNotificationView?.SetTag(Resource.String.defaulttag, null);
 }
Beispiel #8
0
        private void CatcherHelper_NotificationRemoved(object sender, NotificationRemovedEventArgs e)
        {
            Activity?.RunOnUiThread(() =>
            {
                if (configurationManager.RetrieveAValue(ConfigurationParameters.MusicWidgetMethod, "0") == "1")
                {
                    if (e.OpenNotification.RepresentsMediaPlaying())
                    {
                        ThreadPool.QueueUserWorkItem(m =>
                        {
                            MusicController.StopPlayback(e.OpenNotification.GetMediaSessionToken());
                        } //Returns true if the Playback was stopped succesfully (Sometimes it wont work)
                                                     );

                        //In any case, order MusicWidget to stop.
                        WidgetStatusPublisher.RequestShow(new WidgetStatusEventArgs {
                            Show = false, WidgetName = "MusicFragment", Active = false
                        });
                    }
                }

                WidgetStatusPublisher.RequestShow(new WidgetStatusEventArgs {
                    Show = false, WidgetName = "NotificationFragment"
                });

                maincontainer.Visibility = ViewStates.Gone;
                //Remove tag, notification removed
                _openNotification = null;
                maincontainer?.SetTag(Resource.String.defaulttag, null);
            });
        }
 private void OnItemClicked(int position, OpenNotification sbn)
 {
     ItemClicked?.Invoke(this, new NotificationItemClickedEventArgs
     {
         Position = position,
         StatusBarNotification = sbn
     });
 }
        private void ItemClicked(object sender, NotificationItemClickedEventArgs e)
        {
            position = e.Position;
            using (OpenNotification openNotification = new OpenNotification(e.Position))
            {
                ThreadPool.QueueUserWorkItem(method =>
                {
                    var notificationBigPicture = new BitmapDrawable(Resources, openNotification.GetBigPicture());
                    WallpaperPublisher.ChangeWallpaper(new WallpaperChangedEventArgs {
                        Wallpaper = notificationBigPicture, OpacityLevel = 125, SecondsOfAttention = 5
                    });
                });
                titulo.Text  = openNotification.GetTitle();
                texto.Text   = openNotification.GetText();
                appName.Text = openNotification.GetAppName();
                when.Text    = openNotification.GetWhen();
                notificationActions.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.TransformationMethod = null;
                        anActionButton.SetTypeface(Typeface.Create("sans-serif-condensed", TypefaceStyle.Normal), TypefaceStyle.Normal);
                        anActionButton.SetMaxLines(1);
                        anActionButton.SetTextColor(Color.White);
                        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);
                        notificationActions.AddView(anActionButton);
                    }
                    ;
                }
            }
            if (notification.Visibility != ViewStates.Visible)
            {
                notification.Visibility = ViewStates.Visible;
                StartTimeout();
            }

            NotificationClicked?.Invoke(null, EventArgs.Empty);
        }
Beispiel #11
0
        private void Closenotificationbutton_Click(object sender, EventArgs e)
        {
            ImageButton      closenotificationbutton = sender as ImageButton;
            OpenNotification openNotification        = closenotificationbutton.GetTag(DefaultActionIdentificator) as OpenNotification;

            openNotification.Cancel();
            notificationView.SetTag(Resource.String.defaulttag, openNotification.GetCustomId());
            notificationView.Visibility = ViewStates.Invisible;
        }
Beispiel #12
0
        public void ShowNotification(OpenNotification openNotification)
        {
            _openNotification = openNotification;

            Activity.RunOnUiThread(() =>
            {
                if (configurationManager.RetrieveAValue(ConfigurationParameters.TestEnabled))
                {
                    Toast.MakeText(Application.Context, "Progress Indeterminate?: " + _openNotification.IsProgressIndeterminate().ToString() + "\n"
                                   + "Current Progress: " + _openNotification.GetProgress().ToString() + "\n"
                                   + "Max Progress: " + _openNotification.GetProgressMax().ToString() + "\n"
                                   + _openNotification.GetGroupInfo()
                                   , ToastLength.Short).Show();
                }
                switch (_openNotification.Style())
                {
                case BigPictureStyle:
                    new BigPictureStyleNotification(_openNotification, ref maincontainer, this).ApplyStyle();
                    break;

                case MessagingStyle:
                    new MessagingStyleNotification(_openNotification, ref maincontainer, this).ApplyStyle();
                    break;

                case InboxStyle:
                    new InboxStyleNotification(_openNotification, ref maincontainer, this).ApplyStyle();
                    break;

                case BigTextStyle:
                    new BigTextStyleNotification(_openNotification, ref maincontainer, this).ApplyStyle();
                    break;

                case MediaStyle:
                    new MediaStyleNotification(_openNotification, ref maincontainer, this).ApplyStyle();
                    break;

                default:
                    new DefaultStyleNotification(_openNotification, ref maincontainer, this).ApplyStyle();
                    break;
                }

                StartTimeout(false);

                //Now we check if the current showing widget is this, if not, ask for us to be the current showing widget.
                if (WidgetStatusPublisher.CurrentActiveWidget != "NotificationFragment")
                {
                    WidgetStatusPublisher.RequestShow(new WidgetStatusEventArgs {
                        Show = true, WidgetName = "NotificationFragment"
                    });
                    maincontainer.Visibility = ViewStates.Visible; //we make ourselves visible when we are the current showing widget.
                }
                else if (maincontainer.Visibility != ViewStates.Visible)
                {
                    maincontainer.Visibility = ViewStates.Visible;
                }
            });
        }
Beispiel #13
0
 private void CatcherHelper_NotificationRemoved(object sender, EventArgs e)
 {
     Activity?.RunOnUiThread(() =>
     {
         notification.Visibility = ViewStates.Gone;
         //Remove tag, notification removed
         openNotification = null;
         notification?.SetTag(Resource.String.defaulttag, null);
     });
 }
Beispiel #14
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;
                }
            };
        }
Beispiel #15
0
        protected virtual void CloseNotification_Click(object sender, EventArgs e)
        {
            ImageButton      closenotificationbutton = sender as ImageButton;
            OpenNotification openNotification        = closenotificationbutton.GetTag(DefaultActionIdentificator) as OpenNotification;

            openNotification?.Cancel();
            NotificationView.SetTag(Resource.String.defaulttag, openNotification.GetCustomId());
            WidgetStatusPublisher.RequestShow(new WidgetStatusEventArgs {
                Show = false, WidgetName = "NotificationFragment"
            });
            NotificationView.Visibility = ViewStates.Invisible;
        }
Beispiel #16
0
        private void ApplyDefault(OpenNotification notification)
        {
            titulo.Text  = notification.Title();
            texto.Text   = notification.Text();
            appName.Text = notification.AppName();
            subtext.Text = notification.SubText();
            when.Text    = notification.When();
            closenotificationbutton.SetTag(DefaultActionIdentificator, notification);
            closenotificationbutton.Click     += Closenotificationbutton_Click;
            closenotificationbutton.Visibility = notification.IsRemovable() ? ViewStates.Visible : ViewStates.Invisible;

            ApplyActionsStyle(notification);
        }
Beispiel #17
0
 protected virtual void SetProgress()
 {
     if (OpenNotification.GetProgressMax() > 0)
     {
         NotificationProgress.Visibility    = ViewStates.Visible;
         NotificationProgress.Indeterminate = OpenNotification.IsProgressIndeterminate();
         NotificationProgress.Max           = OpenNotification.GetProgressMax();
         NotificationProgress.Progress      = OpenNotification.GetProgress();
     }
     else
     {
         NotificationProgress.Visibility = ViewStates.Gone;
     }
 }
Beispiel #18
0
        public BigPictureStyleNotification(OpenNotification openNotification, ref LinearLayout notificationView, AndroidX.Fragment.App.Fragment notificationFragment)
            : base(openNotification, ref notificationView, notificationFragment)
        {
            var notificationBigPicture = new BitmapDrawable(Resources, OpenNotification.BigPicture());

            WallpaperPublisher.ChangeWallpaper(new WallpaperChangedEventArgs
            {
                BlurLevel          = 5,
                OpacityLevel       = 125,
                SecondsOfAttention = 5,
                Wallpaper          = notificationBigPicture,
                WallpaperPoster    = WallpaperPoster.Notification,
            });
        }
        private void SetPreviousMessages()
        {
            string previousMessages = OpenNotification.GetPreviousMessages();

            if (previousMessages != string.Empty)
            {
                PreviousMessages.Visibility = ViewStates.Visible;
                PreviousMessages.Text       = previousMessages;
            }
            else
            {
                PreviousMessages.Visibility = ViewStates.Gone;
            }
        }
Beispiel #20
0
        public void ApplyActionsStyle(OpenNotification notification)
        {
            notificationActions?.RemoveAllViews();
            if (notification.HasActions())
            {
                var actions = notification.RetrieveActions();
                foreach (Notification.Action action in actions)
                {
                    OpenAction openAction   = new OpenAction(action);
                    Button     actionButton = new Button(Application.Context);
                    float      weight       = 1f / actions.Count;
                    actionButton.LayoutParameters = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MatchParent, weight);
                    actionButton.SetTextColor(Color.White); //Should change in MediaStyle (?)
                    actionButton.SetTag(DefaultActionIdentificator, openAction);
                    actionButton.Click  += AnActionButton_Click;
                    actionButton.Gravity = actionButtonsGravity;
                    actionButton.SetMaxLines(actiontextMaxLines);
                    TypedValue outValue = new TypedValue();
                    Application.Context.Theme.ResolveAttribute(Android.Resource.Attribute.SelectableItemBackground, outValue, true);
                    actionButton.SetBackgroundResource(outValue.ResourceId);
                    actionButton.SetTypeface(Typeface.Create(actionTextsTypeface, TypefaceStyle.Normal), TypefaceStyle.Normal);
                    //notificationActions.SetGravity(actionButtonsContainerGravity);

                    if (notification.Style() != MediaStyle)
                    {
                        actionButton.Text = openAction.Title();
                    }

                    if (actionTextsAreinCapitalLetters == false)
                    {
                        actionButton.TransformationMethod = null; //Disables all caps text.
                    }

                    Handler looper = new Handler(Looper.MainLooper);
                    looper.Post(() =>
                    {
                        if (shouldShowIcons || notification.Style() == MediaStyle)     //The MediaStyle allows icons to be shown.
                        {
                            actionButton.SetCompoundDrawablesRelativeWithIntrinsicBounds(openAction.GetActionIcon(), null, null, null);
                        }

                        notificationActions.AddView(actionButton);
                    });
                }
            }
        }
        private void CatcherHelper_NotificationPosted(object sender, NotificationPostedEventArgs e)
        {
            openNotification = e.OpenNotification;
            if (e.ShouldCauseWakeUp)
            {
                AwakeHelper.TurnOnScreen();
            }

            //if the current floating notification widget does not have a tag, let's set it.

            if (floatingNotificationView.GetTag(Resource.String.defaulttag) == null)
            {
                floatingNotificationView.SetTag(Resource.String.defaulttag, openNotification.GetCustomId());
            }

            if (configurationManager.RetrieveAValue(ConfigurationParameters.TestEnabled))
            {
                Toast.MakeText(floatingNotificationView.Context, "Progress Indeterminate?: " + openNotification.IsProgressIndeterminate().ToString() + "\n"
                               + "Current Progress: " + openNotification.GetProgress().ToString() + "\n"
                               + "Max Progress: " + openNotification.GetProgressMax().ToString() + "\n"
                               + openNotification.GetGroupInfo()
                               , ToastLength.Short).Show();
            }

            if (e.UpdatesPreviousNotification)
            {
                if ((string)floatingNotificationView.GetTag(Resource.String.defaulttag) == openNotification.GetCustomId())
                {
                    floatingNotificationView.SetTag(Resource.String.defaulttag, openNotification.GetCustomId());
                }
            }
            else
            {
                //Is a new notification, so set a new tag.
                floatingNotificationView.SetTag(Resource.String.defaulttag, openNotification.GetCustomId());

                if (floatingNotificationView.Visibility != ViewStates.Visible)
                {
                    if (currentActivityState == ActivityStates.Resumed) //most of the times it won't work, when the Screen turns on then it gets here too quickly
                    //before the lockscreen is in a Resumed state, causing the floating notification not being showed when the screen turns on, TODO.
                    {
                        floatingNotificationView.Visibility = ViewStates.Visible;
                    }
                }
            }
        }
        } = false;                                           //Default value, though, this should be linked somehow with the current status of the view, to ensure robustness.

        public MediaStyleNotification(OpenNotification openNotification, ref LinearLayout notificationView, AndroidX.Fragment.App.Fragment notificationFragment)
            : base(openNotification, ref notificationView, notificationFragment)
        {
            var notificationMediaArtwork = new BitmapDrawable(Application.Context.Resources, OpenNotification.MediaArtwork());

            //Only post the Artwork if this notification isn't the one that keeps the Music Widget Active (because in that case it will cause redundancy, the Music Widget
            //will be already showing the Artwork)
            if (MusicController.MediaSessionAssociatedWThisNotification(openNotification.GetCustomId()) == false)
            {
                WallpaperPublisher.ChangeWallpaper(new WallpaperChangedEventArgs
                {
                    BlurLevel          = 1,
                    OpacityLevel       = 125,
                    SecondsOfAttention = 5,
                    Wallpaper          = notificationMediaArtwork,
                    WallpaperPoster    = WallpaperPoster.Notification,
                });
            }
        }
Beispiel #23
0
        private void ItemClicked(object sender, NotificationItemClickedEventArgs e)
        {
            openNotification = new OpenNotification(e.StatusBarNotification);

            //if the current notification widget does not have a tag, let's set it.

            if (notification.GetTag(Resource.String.defaulttag) == null)
            {
                notification.SetTag(Resource.String.defaulttag, openNotification.GetCustomId());
            }

            if (configurationManager.RetrieveAValue(ConfigurationParameters.TestEnabled))
            {
                Toast.MakeText(Activity, "Progress Indeterminate?: " + openNotification.IsProgressIndeterminate().ToString() + "\n"
                               + "Current Progress: " + openNotification.GetProgress().ToString() + "\n"
                               + "Max Progress: " + openNotification.GetProgressMax().ToString() + "\n"
                               + openNotification.GetGroupInfo()
                               , ToastLength.Short).Show();
            }

            //Only do this process if the notification that I want to show is different than the one that
            //the Notification Widget has.
            //If it's the same then simply show it.
            if ((string)notification.GetTag(Resource.String.defaulttag) != openNotification.GetCustomId())
            {
                styleApplier?.ApplyStyle(openNotification);
                notification.SetTag(Resource.String.defaulttag, openNotification.GetCustomId());
                if (notification.Visibility != ViewStates.Visible)
                {
                    notification.Visibility = ViewStates.Visible;
                }
            }
            else if (notification.Visibility != ViewStates.Visible)
            {
                styleApplier?.ApplyStyle(openNotification);
                notification.Visibility = ViewStates.Visible;
            }
            StartTimeout(false);
        }
Beispiel #24
0
 public NotificationStyle(OpenNotification openNotification, ref LinearLayout notificationView, AndroidX.Fragment.App.Fragment notificationFragment)
 {
     OpenNotification     = openNotification;
     NotificationView     = notificationView;
     NotificationFragment = notificationFragment;
     Resources            = NotificationFragment.Resources;
     NotificationActions  = FindView <LinearLayout>(Resource.Id.notificationActions);
     Title                = FindView <TextView>(Resource.Id.tvTitle);
     Text                 = FindView <TextView>(Resource.Id.tvText);
     ApplicationName      = FindView <TextView>(Resource.Id.tvAppName);
     When                 = FindView <TextView>(Resource.Id.tvWhen);
     Subtext              = FindView <TextView>(Resource.Id.tvnotifSubtext);
     NotificationProgress = FindView <ProgressBar>(Resource.Id.notificationprogress);
     CloseNotification    = FindView <ImageButton>(Resource.Id.closenotificationbutton);
     InlineResponseNotificationContainer = FindView <LinearLayout>(Resource.Id.inlineNotificationContainer);
     PreviousMessages         = FindView <TextView>(Resource.Id.previousMessages);
     Collapse                 = FindView <ImageButton>(Resource.Id.toggleCollapse);
     InlineResponse           = FindView <EditText>(Resource.Id.tvInlineText);
     SendInlineResponse       = FindView <ImageButton>(Resource.Id.sendInlineResponseButton);
     CloseNotification.Click += CloseNotification_Click;
     Collapse.Click          += Collapse_Click;
 }
Beispiel #25
0
        private void NotificationAdapterViewHolder_ItemClicked(object sender, NotificationItemClickedEventArgs e)
        {
            openNotification = new OpenNotification(e.StatusBarNotification);

            if (configurationManager.RetrieveAValue(ConfigurationParameters.TestEnabled))
            {
                Toast.MakeText(floatingNotificationView.Context, "Progress Indeterminate?: " + openNotification.IsProgressIndeterminate().ToString() + "\n"
                               + "Current Progress: " + openNotification.GetProgress().ToString() + "\n"
                               + "Max Progress: " + openNotification.GetProgressMax().ToString() + "\n"
                               + openNotification.GetGroupInfo()
                               , ToastLength.Short).Show();
            }
            //Only do this process if the notification that I want to show is different than the one that
            //the Floating Notification Widget has.
            //If it's the same then simply show it.
            if ((string)floatingNotificationView.GetTag(Resource.String.defaulttag) != openNotification.GetCustomId())
            {
                floatingNotificationAppName.Text = openNotification.AppName();
                floatingNotificationWhen.Text    = openNotification.When();
                floatingNotificationTitle.Text   = openNotification.Title();
                floatingNotificationText.Text    = openNotification.Text();
                floatingNotificationActionsContainer.RemoveAllViews();

                if (openNotification.HasActions() == 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.Title(),
                        };
                        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);
                    }
                    ;
                }
            }
            else
            {
                floatingNotificationAppName.Text = openNotification.AppName();
                floatingNotificationWhen.Text    = openNotification.When();
                floatingNotificationTitle.Text   = openNotification.Title();
                floatingNotificationText.Text    = openNotification.Text();
                floatingNotificationActionsContainer.RemoveAllViews();

                if (openNotification.HasActions() == 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.Title(),
                        };
                        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 if (floatingNotificationView.Visibility != ViewStates.Visible)
            {
                floatingNotificationView.Visibility = ViewStates.Invisible;
            }
        }
Beispiel #26
0
 private void NotificationAdapterViewHolder_ItemLongClicked(object sender, NotificationItemClickedEventArgs e)
 {
     openNotification = new OpenNotification(e.StatusBarNotification);
     openNotification.Cancel();
     floatingNotificationView.Visibility = ViewStates.Gone;
 }
Beispiel #27
0
        private void CatcherHelper_NotificationPosted(object sender, NotificationPostedEventArgs e)
        {
            openNotification = new OpenNotification(e.StatusBarNotification);

            //if the current floating notification widget does not have a tag, let's set it.

            if (floatingNotificationView.GetTag(Resource.String.defaulttag) == null)
            {
                floatingNotificationView.SetTag(Resource.String.defaulttag, openNotification.GetCustomId());
            }

            if (configurationManager.RetrieveAValue(ConfigurationParameters.TestEnabled))
            {
                Toast.MakeText(floatingNotificationView.Context, "Progress Indeterminate?: " + openNotification.IsProgressIndeterminate().ToString() + "\n"
                               + "Current Progress: " + openNotification.GetProgress().ToString() + "\n"
                               + "Max Progress: " + openNotification.GetProgressMax().ToString() + "\n"
                               + openNotification.GetGroupInfo()
                               , ToastLength.Short).Show();
            }

            if (e.UpdatesPreviousNotification)
            {
                if ((string)floatingNotificationView.GetTag(Resource.String.defaulttag) == openNotification.GetCustomId())
                {
                    floatingNotificationAppName.Text = openNotification.AppName();
                    floatingNotificationWhen.Text    = openNotification.When();
                    floatingNotificationTitle.Text   = openNotification.Title();
                    floatingNotificationText.Text    = openNotification.Text();
                    floatingNotificationActionsContainer.RemoveAllViews();

                    if (openNotification.HasActions() == 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.Title(),
                            };
                            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);
                        }
                        ;
                    }
                }
            }
            else
            {
                //Is a new notification, so set a new tag.
                floatingNotificationView.SetTag(Resource.String.defaulttag, openNotification.GetCustomId());

                floatingNotificationAppName.Text = openNotification.AppName();
                floatingNotificationWhen.Text    = openNotification.When();
                floatingNotificationTitle.Text   = openNotification.Title();
                floatingNotificationText.Text    = openNotification.Text();
                floatingNotificationActionsContainer.RemoveAllViews();

                if (openNotification.HasActions() == 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.Title(),
                        };
                        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)
                {
                    if (currentActivityState == ActivityStates.Resumed)
                    {
                        floatingNotificationView.Visibility = ViewStates.Visible;
                    }
                }
            }
        }
Beispiel #28
0
 protected virtual void SetSubtext()
 {
     Subtext.Text = OpenNotification.SubText();
 }
Beispiel #29
0
 protected virtual void SetNotificationActionsVisibility()
 {
     NotificationActions.Visibility = OpenNotification.HasActions() ? ViewStates.Visible : ViewStates.Invisible;
 }
Beispiel #30
0
 protected virtual void SetCloseButtonVisibility()
 {
     CloseNotification.Visibility = OpenNotification.IsRemovable() ? ViewStates.Visible : ViewStates.Invisible;
 }