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 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); } }
/** * Creates an inbox style notification summarizing the unread messages * in the inbox * * @param incomingAlert The alert message from an Urban Airship push * @return An inbox style notification */ private Android.App.Notification CreateInboxNotification(string incomingAlert) { Context context = UAirship.Shared().ApplicationContext; IList <RichPushMessage> unreadMessages = RichPushInbox.Shared().UnreadMessages; int inboxUnreadCount = unreadMessages.Count; // The incoming message is not immediately made available to the inbox because it needs // to first fetch its contents. int totalUnreadCount = inboxUnreadCount + 1; Resources res = UAirship.Shared().ApplicationContext.Resources; string title = res.GetQuantityString(Resource.Plurals.inbox_notification_title, totalUnreadCount, totalUnreadCount); Bitmap largeIcon = BitmapFactory.DecodeResource(res, Resource.Drawable.ua_launcher); var style = new Notification.InboxStyle( new Notification.Builder(context) .SetContentTitle(title) .SetContentText(incomingAlert) .SetLargeIcon(largeIcon) .SetSmallIcon(Resource.Drawable.ua_notification_icon) .SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification)) .SetNumber(totalUnreadCount)); // Add the incoming alert as the first line in bold style.AddLine(Html.FromHtml("<b>" + incomingAlert + "</b>")); // Add any extra messages to the notification style int extraMessages = Math.Min(EXTRA_MESSAGES_TO_SHOW, inboxUnreadCount); for (int i = 0; i < extraMessages; i++) { style.AddLine(unreadMessages [i].Title); } // If we have more messages to show then the EXTRA_MESSAGES_TO_SHOW, add a summary if (inboxUnreadCount > EXTRA_MESSAGES_TO_SHOW) { style.SetSummaryText(context.GetString(Resource.String.inbox_summary, inboxUnreadCount - EXTRA_MESSAGES_TO_SHOW)); } return(style.Build()); }