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 #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;
                }
            };
        }
Beispiel #3
0
        private void AnActionButton_Click(object sender, System.EventArgs e)
        {
            Button     actionButton = sender as Button;
            OpenAction openAction   = actionButton.GetTag(DefaultActionIdentificator) as OpenAction;

            if (openAction.ActionRepresentDirectReply())
            {
                notificationActions.Visibility         = ViewStates.Invisible;
                inlineNotificationContainer.Visibility = ViewStates.Visible;
                inlineresponse.Hint = openAction.GetPlaceholderTextForInlineResponse();
                sendinlineresponse.SetTag(DefaultActionIdentificator, openAction);
                sendinlineresponse.Click += Sendinlineresponse_Click;

                SendInlineResponseAvailabityChanged?.Invoke(null, true); //Is currently showing.
            }
            else
            {
                openAction.ClickAction();
                SendInlineResponseAvailabityChanged?.Invoke(null, false); //Here I assume the send inline textbox is not present, because the action simply does not represent a direct reply.
            }
        }
Beispiel #4
0
        protected virtual void ActionButton_Click(object sender, EventArgs e)
        {
            Button     actionButton = sender as Button;
            OpenAction openAction   = actionButton.GetTag(DefaultActionIdentificator) as OpenAction;

            if (openAction.ActionRepresentDirectReply())
            {
                if (new ConfigurationManager(AppPreferences.Default).RetrieveAValue(ConfigurationParameters.EnableQuickReply))
                {
                    NotificationActions.Visibility = ViewStates.Invisible;
                    InlineResponseNotificationContainer.Visibility = ViewStates.Visible;
                    InlineResponse.Hint = openAction.GetPlaceholderTextForInlineResponse();
                    SendInlineResponse.SetTag(DefaultActionIdentificator, openAction);
                    SendInlineResponse.Click += SendInlineResponse_Click;
                    SendInlineResponseAvailabityChanged?.Invoke(null, true);
                }
            }
            else
            {
                openAction.ClickAction();
            }
        }
Beispiel #5
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 #6
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;
                    }
                }
            }
        }