/**
         * Shows a message either in the message view pager, or by launching
         * a new MessageActivity
         * @param messageId the specified message id
         */
        private void ShowMessage(string messageId)
        {
            RichPushMessage message = richPushInbox.GetMessage(messageId);

            // Message is already deleted, skip
            if (message == null)
            {
                return;
            }

            if (slidingPaneLayout != null && slidingPaneLayout.IsOpen)
            {
                slidingPaneLayout.ClosePane();
            }

            message.MarkRead();

            if (messagePager != null)
            {
                this.messagePager.CurrentItem = messages.IndexOf(message);
            }
            else
            {
                Intent intent = new Intent(this, typeof(MessageActivity));
                intent.PutExtra(MessageActivity.EXTRA_MESSAGE_ID_KEY, messageId);
                this.StartActivity(intent);
            }
        }
示例#2
0
        public View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            string          messageId = Arguments.GetString(MESSAGE_ID_KEY);
            RichPushMessage message   = RichPushManager.Shared().RichPushUser.Inbox.GetMessage(messageId);

            if (message == null)
            {
                return(null);
            }


            View view = inflater.Inflate(Resource.Layout.message_dialog, container, true);

            RichPushMessageView messageView = (RichPushMessageView)view.FindViewById(Resource.Id.message_browser);

            messageView.LoadRichPushMessage(message);
            message.MarkRead();

            // Update the widget, this dialog can show a message on any activity
            RichPushWidgetUtils.RefreshWidget(this.Activity);


            Dialog.SetTitle(Resource.String.rich_push_message_dialog_title);

            return(view);
        }
        public void OnMessageOpen(RichPushMessage message)
        {
            message.MarkRead();
            ShowMessage(message.MessageId);

            // If we are in actionMode, update the menu items
            if (actionMode != null)
            {
                actionMode.Invalidate();
            }
        }
        public void OnActivityCreated(Bundle savedInstanceState)
        {
            base.OnActivityCreated(savedInstanceState);

            string          messageId = Arguments.GetString(MESSAGE_ID_KEY);
            RichPushMessage message   = RichPushManager.Shared().RichPushUser.Inbox.GetMessage(messageId);

            if (message != null)
            {
                browser.LoadRichPushMessage(message);
            }
            else
            {
                Logger.Info("Couldn't retrieve message for ID: " + messageId);
            }
        }
示例#5
0
        protected void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            this.SetContentView(Resource.Layout.message);

            string messageId = savedInstanceState == null?this.Intent.GetStringExtra(EXTRA_MESSAGE_ID_KEY) :
                                   savedInstanceState.GetString(EXTRA_MESSAGE_ID_KEY);

            // Get the list of rich push messages
            this.messages = RichPushManager.Shared().RichPushUser.Inbox.Messages;

            // Sets up the MessageViewPager
            this.messagePager = (ViewPager)this.FindViewById(Resource.Id.message_pager);
            MessageFragmentAdapter messageAdapter = new MessageFragmentAdapter(this.SupportFragmentManager);

            this.messagePager.PageSelected += (sender, e) => {
                int _position = e.P0;
                messages [_position].MarkRead();
            };
            messageAdapter.SetRichPushMessages(messages);
            this.messagePager.Adapter = messageAdapter;

            // Get the first item to show
            int             position     = 0;
            RichPushMessage firstMessage = RichPushManager.Shared().RichPushUser.Inbox.GetMessage(messageId);

            if (firstMessage != null)
            {
                position = messages.IndexOf(firstMessage);
                if (position == -1)
                {
                    position = 0;
                }
            }

            // Mark it as read
            messages [position].MarkRead();

            // Sets the current item to the position of the current message
            this.messagePager.CurrentItem = position;

            this.SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            this.SupportActionBar.SetHomeButtonEnabled(true);
        }
        public bool OnPrepareActionMode(ActionMode mode, Android.Views.IMenu menu)
        {
            Logger.Debug("onPrepareActionMode");

            bool selectionContainsRead   = false;
            bool selectionContainsUnread = false;

            foreach (string id in inbox.SelectedMessages)
            {
                RichPushMessage message = richPushInbox.GetMessage(id);
                if (message.IsRead)
                {
                    selectionContainsRead = true;
                }
                else
                {
                    selectionContainsUnread = true;
                }

                if (selectionContainsRead && selectionContainsUnread)
                {
                    break;
                }
            }

            // Show them both
            menu.FindItem(Resource.Id.mark_read).SetVisible(selectionContainsUnread);
            menu.FindItem(Resource.Id.mark_unread).SetVisible(selectionContainsRead);

            // If we have an action selection button update the text
            if (actionSelectionButton != null)
            {
                string selectionText = this.GetString(Resource.String.cab_selection, inbox.SelectedMessages.Count);
                actionSelectionButton.Text = selectionText;
            }

            return(true);
        }
示例#7
0
        public RemoteViews GetViewAt(int position)
        {
            IList <RichPushMessage> messages = RichPushManager.Shared().RichPushUser.Inbox.Messages;

            if (position > messages.Count)
            {
                return(null);
            }

            // Get the data for this position from the content provider
            RichPushMessage message = messages [position];

            // Return a proper item
            String      formatStr = context.Resources.GetString(Resource.String.item_format_string);
            int         itemId    = Resource.Layout.widget_item;
            RemoteViews rv        = new RemoteViews(context.PackageName, itemId);

            rv.SetTextViewText(Resource.Id.widget_item_text, Java.Lang.String.Format(formatStr, message.Title));

            int iconDrawable = message.IsRead ? Resource.Drawable.mark_read : Resource.Drawable.mark_unread;

            rv.SetImageViewResource(Resource.Id.widget_item_icon, iconDrawable);

            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");

            rv.SetTextViewText(Resource.Id.date_sent, dateFormat.Format(message.SentDate));

            // Add the message id to the intent
            Intent fillInIntent = new Intent();
            Bundle extras       = new Bundle();

            extras.PutString(RichPushApplication.MESSAGE_ID_RECEIVED_KEY, message.MessageId);
            fillInIntent.PutExtras(extras);
            rv.SetOnClickFillInIntent(Resource.Id.widget_item, fillInIntent);

            return(rv);
        }
		public void OnMessageOpen (RichPushMessage message)
		{
			message.MarkRead ();
			ShowMessage (message.MessageId);

			// If we are in actionMode, update the menu items
			if (actionMode != null) {
				actionMode.Invalidate ();
			}
		}
			public void BindView (View view, RichPushMessage message)
			{
				bindView (view, message);
			}
示例#10
0
 public void BindView(View view, RichPushMessage message)
 {
     bindView(view, message);
 }