Example #1
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 override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Android.Resource.Id.Home:
                if (slidingPaneLayout != null)
                {
                    if (slidingPaneLayout.IsOpen)
                    {
                        slidingPaneLayout.ClosePane();
                    }
                    else
                    {
                        slidingPaneLayout.OpenPane();
                    }
                }
                break;

            case Resource.Id.refresh:
                inbox.SetListShownNoAnimation(false);
                RichPushManager.Shared().RefreshMessages();
                break;

            case Resource.Id.preferences:
                this.StartActivity(new Intent(this, typeof(PushPreferencesActivity)));
                break;
            }
            return(true);
        }
 /**
  * Grabs the latest messages from the rich push inbox, and syncs them
  * with the inbox fragment and message view pager if available
  */
 private void UpdateRichPushMessages()
 {
     messages = RichPushManager.Shared().RichPushUser.Inbox.Messages;
     this.inbox.SetMessages(messages);
     if (messagePager != null)
     {
         ((MessageFragmentAdapter)messagePager.Adapter).SetRichPushMessages(messages);
     }
 }
        protected void OnPause()
        {
            base.OnPause();

            // Remove listener for message changes
            RichPushManager.Shared().RemoveListener(this);
            richPushInbox.RemoveListener(this);

            RichPushWidgetUtils.RefreshWidget(this);
        }
        protected void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            this.SetContentView(Resource.Layout.inbox);

            actionBar = SupportActionBar;
            ConfigureActionBar();

            this.richPushInbox = RichPushManager.Shared().RichPushUser.Inbox;

            // Set up the inbox fragment
            this.inbox = (InboxFragment)this.SupportFragmentManager.FindFragmentById(Resource.Id.inbox);
            this.inbox.ListView.ChoiceMode = ChoiceMode.Single;
            this.inbox.ListView.SetBackgroundColor(Color.Black);

            // Set up the message view pager if it exists
            this.messagePager = (CustomViewPager)this.FindViewById(Resource.Id.message_pager);
            if (messagePager != null)
            {
                messagePager.Adapter            = new MessageFragmentAdapter(this.SupportFragmentManager);
                this.messagePager.PageSelected += (sender, e) => {
                    int position = e.P0;
                    messages [position].MarkRead();
                    // Highlight the current item you are viewing in the inbox
                    inbox.ListView.SetItemChecked(position, true);

                    // If we are in actionMode, update the menu items
                    if (actionMode != null)
                    {
                        actionMode.Invalidate();
                    }
                };
            }

            slidingPaneLayout = (CustomSlidingPaneLayout)FindViewById(Resource.Id.sliding_pane_layout);
            if (slidingPaneLayout != null)
            {
                slidingPaneLayout.SetPanelSlideListener(this);
                slidingPaneLayout.OpenPane();

                GlobalLayoutListener l = null;
                l = new GlobalLayoutListener(() => {
                    // If sliding pane layout is slidable, set the actionbar to have an up action
                    actionBar.SetDisplayHomeAsUpEnabled(slidingPaneLayout.IsSlideable);
                    slidingPaneLayout.ViewTreeObserver.RemoveGlobalOnLayoutListener(l);
                });
                slidingPaneLayout.ViewTreeObserver.AddOnGlobalLayoutListener(l);
            }

            // First create, try to show any messages from the intent
            if (savedInstanceState == null)
            {
                this.SetPendingMessageIdFromIntent(Intent);
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            this.SetContentView(Resource.Layout.main);
            this.ConfigureActionBar();

            this.user = RichPushManager.Shared().RichPushUser;

            // If we have a message id and its the first create, set the pending message id if available
            if (savedInstanceState == null)
            {
                pendingMessageId = Intent.GetStringExtra(RichPushApplication.MESSAGE_ID_RECEIVED_KEY);
            }
        }
Example #7
0
        private void SetAlias(string alias)
        {
            alias = UAStringUtil.IsEmpty(alias) ? null : alias;

            PushManager.Shared().Alias = (alias);

            if (UAirship.Shared().AirshipConfigOptions.RichPushEnabled)
            {
                RichPushManager.Shared().RichPushUser.Alias = (alias);
                RichPushManager.Shared().UpdateUser();
            }

            currentAlias = alias;
        }
        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);
            }
        }
        /**
         * Creates a small layout for the app widget
         *
         *
         * @param context Application context
         * @param appWidgetId id of the widget
         * @return RemoteViews for the small layout
         */
        private static RemoteViews CreateSmallLayout(Context context, int appWidgetId)
        {
            RemoteViews remoteViews = new RemoteViews(context.PackageName, Resource.Layout.widget_layout_small);

            // Update the header for the current unread message count
            int    count     = RichPushManager.Shared().RichPushUser.Inbox.UnreadCount;
            String inboxName = context.GetString(Resource.String.inbox_name);
            String header    = context.GetString(Resource.String.header_format_string, count, inboxName);

            remoteViews.SetTextViewText(Resource.Id.widget_header_text, header);

            // Add a click pending intent to launch the inbox
            remoteViews.SetOnClickPendingIntent(Resource.Id.widget_header, CreateInboxActivityPendingIntent(context));

            return(remoteViews);
        }
        private void SetTags(IList <String> tags)
        {
            currentTags.Clear();
            foreach (var tag in tags)
            {
                currentTags.Add(tag);
            }

            PushManager.Shared().Tags = currentTags;

            if (UAirship.Shared().AirshipConfigOptions.RichPushEnabled)
            {
                // FIXME: not sure if this use of ToArray() is safe...
                RichPushManager.Shared().RichPushUser.Tags = new Java.Util.HashSet(currentTags.ToArray());
                RichPushManager.Shared().UpdateUser();
            }
        }
Example #11
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);
        }
        protected void OnResume()
        {
            base.OnResume();

            // Set the navigation to show Inbox
            SetNavigationToInboxActivity();

            // Listen for any rich push message changes
            RichPushManager.Shared().AddListener(this);
            RichPushManager.Shared().RichPushUser.Inbox.AddListener(this);

            // Update the rich push messages to the latest
            UpdateRichPushMessages();

            // Show any pending message ids from the intent
            ShowPendingMessageId();

            StartActionModeIfNecessary();

            // Dismiss any notifications if available
            RichNotificationBuilder.DismissInboxNotification();
        }
Example #13
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);
        }