Esempio n. 1
0
        public RemoteViews GetViewAt (int position)
        {
            var remoteView = new RemoteViews (context.PackageName, Resource.Layout.widget_list_item);
            var rowData = itemList [position];

            // set if is running
            if (rowData.IsRunning) {
                remoteView.SetImageViewResource (Resource.Id.WidgetContinueImageButton, Resource.Drawable.IcWidgetStop);
            } else {
                remoteView.SetImageViewResource (Resource.Id.WidgetContinueImageButton, Resource.Drawable.IcWidgetPlay);
            }

            // set color
            remoteView.SetInt (Resource.Id.WidgetColorView, "setColorFilter", Color.ParseColor (rowData.Color));
            remoteView.SetOnClickFillInIntent (Resource.Id.WidgetContinueImageButton, ConstructFillIntent (rowData));

            // set content
            remoteView.SetTextViewText (
                Resource.Id.DescriptionTextView,
                String.IsNullOrWhiteSpace (rowData.Description) ? context.Resources.GetString (Resource.String.RunningWidgetNoDescription) : rowData.Description);
            remoteView.SetTextViewText (
                Resource.Id.ProjectTextView,
                String.IsNullOrWhiteSpace (rowData.ProjectName) ? context.Resources.GetString (Resource.String.RunningWidgetNoProject) : rowData.ProjectName);
            remoteView.SetTextViewText (Resource.Id.DurationTextView, rowData.TimeValue);

            return remoteView;
        }
Esempio n. 2
0
        public RemoteViews GetViewAt(int position)
        {
            var remoteView = new RemoteViews(context.PackageName, Resource.Layout.widget_list_item);
            var rowData    = itemList [position];

            // set if is running
            if (rowData.IsRunning)
            {
                remoteView.SetImageViewResource(Resource.Id.WidgetContinueImageButton, Resource.Drawable.IcWidgetStop);
            }
            else
            {
                remoteView.SetImageViewResource(Resource.Id.WidgetContinueImageButton, Resource.Drawable.IcWidgetPlay);
            }

            // set color
            remoteView.SetInt(Resource.Id.WidgetColorView, "setColorFilter", Color.ParseColor(rowData.Color));
            remoteView.SetOnClickFillInIntent(Resource.Id.WidgetContinueImageButton, ConstructFillIntent(rowData));

            // set content
            remoteView.SetTextViewText(
                Resource.Id.DescriptionTextView,
                String.IsNullOrWhiteSpace(rowData.Description) ? context.Resources.GetString(Resource.String.RunningWidgetNoDescription) : rowData.Description);
            remoteView.SetTextViewText(
                Resource.Id.ProjectTextView,
                String.IsNullOrWhiteSpace(rowData.ProjectName) ? context.Resources.GetString(Resource.String.RunningWidgetNoProject) : rowData.ProjectName);
            remoteView.SetTextViewText(Resource.Id.DurationTextView, rowData.TimeValue);

            return(remoteView);
        }
        public RemoteViews GetViewAt(int position)
        {
            var remoteView = new RemoteViews(context.PackageName, Resource.Layout.widget_list_item);
            var rowData    = itemList [position];

            // set if is running
            if (rowData.IsRunning)
            {
                remoteView.SetImageViewResource(Resource.Id.WidgetContinueImageButton, Resource.Drawable.IcWidgetStop);
                remoteView.SetViewVisibility(Resource.Id.DurationChronometer, Android.Views.ViewStates.Visible);
                remoteView.SetViewVisibility(Resource.Id.DurationTextView, Android.Views.ViewStates.Gone);
            }
            else
            {
                remoteView.SetImageViewResource(Resource.Id.WidgetContinueImageButton, Resource.Drawable.IcWidgetPlay);
                remoteView.SetViewVisibility(Resource.Id.DurationChronometer, Android.Views.ViewStates.Gone);
                remoteView.SetViewVisibility(Resource.Id.DurationTextView, Android.Views.ViewStates.Visible);
            }

            // set color
            remoteView.SetInt(Resource.Id.WidgetColorView, "setColorFilter", Color.ParseColor(rowData.Color));
            remoteView.SetOnClickFillInIntent(Resource.Id.WidgetContinueImageButton, ConstructFillIntent(rowData));

            // set content
            remoteView.SetTextViewText(
                Resource.Id.DescriptionTextView,
                String.IsNullOrWhiteSpace(rowData.Description) ? context.Resources.GetString(Resource.String.RunningWidgetNoDescription) : rowData.Description);
            remoteView.SetTextViewText(
                Resource.Id.ProjectTextView,
                String.IsNullOrWhiteSpace(rowData.ProjectName) ? context.Resources.GetString(Resource.String.RunningWidgetNoProject) : rowData.ProjectName);
            remoteView.SetTextViewText(Resource.Id.DurationTextView, rowData.TimeValue);

            var time = (long)rowData.Duration.TotalMilliseconds;

            // Format chronometer correctly.
            string format = "00:%s";

            if (time >= 3600000 && time < 36000000)
            {
                format = "0%s";
            }
            else if (time >= 36000000)
            {
                format = "%s";
            }
            var baseTime = SystemClock.ElapsedRealtime();

            remoteView.SetChronometer(Resource.Id.DurationChronometer, baseTime - (long)rowData.Duration.TotalMilliseconds, format, true);


            return(remoteView);
        }
		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;
		}
Esempio n. 5
0
        private void ShowNotification(bool setPlayImage)
        {
            var mainActivity = (MainActivity)CrossCurrentActivity.Current.Activity;

            NotificationCompat.Builder builder = new NotificationCompat.Builder(mainActivity)
                                                 .SetOngoing(true)
                                                 .SetSmallIcon(Resource.Drawable.ic_headset_white);

            var contentView = new RemoteViews(mainActivity.PackageName, Resource.Layout.audioNotificationView);

            contentView.SetOnClickPendingIntent(Resource.Id.btnPlayPause, GetIntentForAction(PlayPauseAction));
            contentView.SetOnClickPendingIntent(Resource.Id.btnStop, GetIntentForAction(StopAction));

            contentView.SetTextViewText(Resource.Id.textViewTitle, AudioTitle);
            contentView.SetImageViewResource(Resource.Id.btnPlayPause, setPlayImage ? Resource.Drawable.ic_pause : Resource.Drawable.ic_play_arrow);
            contentView.SetProgressBar(Resource.Id.audio_progress_bar, mediaPlayer.Duration, mediaPlayer.CurrentPosition, false);

            builder = builder.SetCustomContentView(contentView);

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
            {
                builder.SetVisibility((int)NotificationVisibility.Public);
            }

            // Finally, publish the notification
            var notificationManager = (NotificationManager)mainActivity.GetSystemService(Context.NotificationService);

            //notificationManager.Notify(AudioPlayerNotificationId, notificationBuilder.Build ());
            notificationManager.Notify(AudioPlayerNotificationId, builder.Build());
        }
Esempio n. 6
0
        Notification buildCustomNotification(ServiceActions action)
        {
            PendingIntent pi    = PendingIntent.GetActivity(ApplicationContext, 0, new Intent(ApplicationContext, typeof(MainActivity)), PendingIntentFlags.CancelCurrent);
            PendingIntent play  = PendingIntent.GetService(ApplicationContext, 1, new Intent(ActionPlay), PendingIntentFlags.CancelCurrent);
            PendingIntent pause = PendingIntent.GetService(ApplicationContext, 2, new Intent(ActionPause), PendingIntentFlags.CancelCurrent);

            Android.App.Notification.Builder builder = new Notification.Builder(ApplicationContext);

            var myRemoteView = new RemoteViews(PackageName, Resource.Layout.Notification);

            builder.SetContent(myRemoteView);
            // if play
            if (action == ServiceActions.Play)
            {
                builder.SetSmallIcon(Android.Resource.Drawable.IcMediaPlay);
                myRemoteView.SetTextViewText(Resource.Id.notifyTitle, "KQED 88.5FM LiveStream");
            }
            else if (action == ServiceActions.Pause)
            {
                builder.SetSmallIcon(Android.Resource.Drawable.IcMediaPause);
                myRemoteView.SetTextViewText(Resource.Id.notifyTitle, "Paused: KQED 88.5FM LiveStream");
            }

            myRemoteView.SetOnClickPendingIntent(Resource.Id.notifyBtnPause, pause);
            myRemoteView.SetOnClickPendingIntent(Resource.Id.notifyBtnPlay, play);
            myRemoteView.SetOnClickPendingIntent(Resource.Id.notifyTitle, pi);
            myRemoteView.SetImageViewResource(Resource.Id.notifyImage, Resource.Drawable.KQED);

            return(builder.Notification);
        }
Esempio n. 7
0
        public RemoteViews GetViewAt(int position)
        {
            RemoteViews remoteViews = new RemoteViews(context.PackageName, Resource.Layout.task_item);
            var         item        = TaskWidget.Items[position];
            var         imageName   = item.IconPath.Split('/')[1].Split('.')[0];
            var         background  = Resource.Drawable.task_item_background_false;

            if (item.Status)
            {
                background = Resource.Drawable.task_item_background_true;
            }

            var extras = new Bundle();

            extras.PutInt("ItemNo", item.No);

            var fiIntent = new Intent();

            fiIntent.PutExtras(extras);

            remoteViews.SetOnClickFillInIntent(Resource.Id.task_layout, fiIntent);
            remoteViews.SetInt(Resource.Id.task_layout, "setBackgroundResource", background);
            remoteViews.SetImageViewResource(Resource.Id.task_icon, context.Resources.GetIdentifier(imageName, "drawable", context.PackageName));
            remoteViews.SetTextViewText(Resource.Id.task_content, item.Content);

            return(remoteViews);
        }
Esempio n. 8
0
        /// <summary>
        /// This method is called when clicks are registered.
        /// </summary>
        public override void OnReceive(Context context, Intent intent)
        {
            base.OnReceive(context, intent);
            Log.Debug("pet", intent.Action);

            // Check if the click is from the "Announcement" button
            if (int.TryParse(intent.Action, out int id))
            {
                PetAction action = (PetAction)id;

                int res = PetLogic(action, context);

                if (res == -1)
                {
                    return;
                }

                AppWidgetManager appWidgetManager = AppWidgetManager.GetInstance(context);
                var component = new ComponentName(context, Java.Lang.Class.FromType(typeof(AppWidget)).Name);

                RemoteViews remoteViews = new RemoteViews(context.PackageName, Resource.Layout.Widget);

                remoteViews.SetImageViewResource(Resource.Id.room, res);

                appWidgetManager.UpdateAppWidget(component, remoteViews);
            }
        }
Esempio n. 9
0
        public static RemoteViews NewRemoteViews(string packageName, string remoteViewsText, int drawableId)
        {
            RemoteViews presentation = new RemoteViews(packageName, Resource.Layout.autofill_service_list_item);

            presentation.SetTextViewText(Resource.Id.text, remoteViewsText);
            presentation.SetImageViewResource(Resource.Id.icon, drawableId);
            return(presentation);
        }
        /// <summary>
        /// Creates the remote views.
        /// </summary>
        /// <returns>The remote views.</returns>
        /// <param name="context">Context.</param>
        /// <param name="showPlayIcon">If set to <c>true</c> show play icon.</param>
        public static RemoteViews CreateRemoteViews(Context context, bool showPlayIcon)
        {
            RemoteViews remoteViews = new RemoteViews(context.PackageName, Resource.Layout.remote_view);

            int iconRes = showPlayIcon ? Resource.Drawable.ic_play : Resource.Drawable.ic_stop;

            remoteViews.SetImageViewResource(Resource.Id.play_pause, iconRes);
            return(remoteViews);
        }
Esempio n. 11
0
        public static RemoteViews BuildListView(string packageName, string text, string subtext, int iconId)
        {
            var view = new RemoteViews(packageName, Resource.Layout.autofill_listitem);

            view.SetTextViewText(Resource.Id.text, text);
            view.SetTextViewText(Resource.Id.text2, subtext);
            view.SetImageViewResource(Resource.Id.icon, iconId);
            return(view);
        }
        public static RemoteViews NewRemoteViews(string packageName, string remoteViewsText,
                                                 [DrawableRes] int drawableId)
        {
            var presentation = new RemoteViews(packageName, Resource.Layout.multidataset_service_list_item);

            presentation.SetTextViewText(Resource.Id.text, remoteViewsText);
            presentation.SetImageViewResource(Resource.Id.icon, drawableId);
            return(presentation);
        }
Esempio n. 13
0
        public RemoteViews GetViewAt (int position)
        {
            var remoteView = new RemoteViews (context.PackageName, Resource.Layout.widget_list_item);
            var rowData = itemList [position];

            // set if is running
            if (rowData.IsRunning) {
                remoteView.SetImageViewResource (Resource.Id.WidgetContinueImageButton, Resource.Drawable.IcWidgetStop);
                remoteView.SetViewVisibility (Resource.Id.DurationChronometer, Android.Views.ViewStates.Visible);
                remoteView.SetViewVisibility (Resource.Id.DurationTextView, Android.Views.ViewStates.Gone);
            } else {
                remoteView.SetImageViewResource (Resource.Id.WidgetContinueImageButton, Resource.Drawable.IcWidgetPlay);
                remoteView.SetViewVisibility (Resource.Id.DurationChronometer, Android.Views.ViewStates.Gone);
                remoteView.SetViewVisibility (Resource.Id.DurationTextView, Android.Views.ViewStates.Visible);
            }

            // set color
            remoteView.SetInt (Resource.Id.WidgetColorView, "setColorFilter", Color.ParseColor (rowData.Color));
            remoteView.SetOnClickFillInIntent (Resource.Id.WidgetContinueImageButton, ConstructFillIntent (rowData));

            // set content
            remoteView.SetTextViewText (
                Resource.Id.DescriptionTextView,
                String.IsNullOrWhiteSpace (rowData.Description) ? context.Resources.GetString (Resource.String.RunningWidgetNoDescription) : rowData.Description);
            remoteView.SetTextViewText (
                Resource.Id.ProjectTextView,
                String.IsNullOrWhiteSpace (rowData.ProjectName) ? context.Resources.GetString (Resource.String.RunningWidgetNoProject) : rowData.ProjectName);
            remoteView.SetTextViewText (Resource.Id.DurationTextView, rowData.TimeValue);

            var time = (long)rowData.Duration.TotalMilliseconds;

            // Format chronometer correctly.
            string format = "00:%s";
            if (time >= 3600000 && time < 36000000) {
                format = "0%s";
            } else if (time >= 36000000) {
                format = "%s";
            }
            var baseTime = SystemClock.ElapsedRealtime ();
            remoteView.SetChronometer (Resource.Id.DurationChronometer, baseTime - (long)rowData.Duration.TotalMilliseconds, format, true);


            return remoteView;
        }
Esempio n. 14
0
        public static RemoteViews BuildOverlayPresentation(string text, string subtext, int iconId, Context context)
        {
            var packageName = context.PackageName;
            var view        = new RemoteViews(packageName, Resource.Layout.autofill_listitem);

            view.SetTextViewText(Resource.Id.text1, text);
            view.SetTextViewText(Resource.Id.text2, subtext);
            view.SetImageViewResource(Resource.Id.icon, iconId);
            return(view);
        }
Esempio n. 15
0
        void UpdateTextAndImage(Context context, RemoteViews viewsToUpdate)
        {
            int hour  = DateTime.Now.Hour;
            int month = DateTime.Now.Month;
            int day   = DateTime.Now.Day;

            string date = $"{month}/{day}";

            viewsToUpdate.SetTextViewText(Resource.Id.date, date);

            if (0 <= hour && hour < 3)
            {
                viewsToUpdate.SetImageViewResource(Resource.Id.image, timeContainers[0].imageId);
                viewsToUpdate.SetTextViewText(Resource.Id.timeText, timeContainers[0].timeText);
            }
            else if (3 <= hour && hour < 6)
            {
                viewsToUpdate.SetImageViewResource(Resource.Id.image, timeContainers[1].imageId);
                viewsToUpdate.SetTextViewText(Resource.Id.timeText, timeContainers[1].timeText);
            }
            else if (6 <= hour && hour < 9)
            {
                viewsToUpdate.SetImageViewResource(Resource.Id.image, timeContainers[2].imageId);
                viewsToUpdate.SetTextViewText(Resource.Id.timeText, timeContainers[2].timeText);
            }
            else if (9 <= hour && hour < 12)
            {
                viewsToUpdate.SetImageViewResource(Resource.Id.image, timeContainers[3].imageId);
                viewsToUpdate.SetTextViewText(Resource.Id.timeText, timeContainers[3].timeText);
            }
            else if (12 <= hour && hour < 15)
            {
                viewsToUpdate.SetImageViewResource(Resource.Id.image, timeContainers[4].imageId);
                viewsToUpdate.SetTextViewText(Resource.Id.timeText, timeContainers[4].timeText);
            }
            else if (15 <= hour && hour < 18)
            {
                viewsToUpdate.SetImageViewResource(Resource.Id.image, timeContainers[5].imageId);
                viewsToUpdate.SetTextViewText(Resource.Id.timeText, timeContainers[5].timeText);
            }
            else if (18 <= hour && hour < 21)
            {
                viewsToUpdate.SetImageViewResource(Resource.Id.image, timeContainers[6].imageId);
                viewsToUpdate.SetTextViewText(Resource.Id.timeText, timeContainers[6].timeText);
            }
            else if (21 <= hour)
            {
                viewsToUpdate.SetImageViewResource(Resource.Id.image, timeContainers[7].imageId);
                viewsToUpdate.SetTextViewText(Resource.Id.timeText, timeContainers[7].timeText);
            }
        }
Esempio n. 16
0
        public async Task <RemoteViews> WidgetUpdate(Context context)
        {
            DivisasAccess request = new DivisasAccess();

            divisa = await request.GetDivisasAsync();

            var widgetView = new RemoteViews(context.PackageName, Resource.Layout.Widget);

            if (divisa != null)
            {
                widgetView.SetTextViewText(Resource.Id.textViewCountryReferent, divisa.@base);
                widgetView.SetTextViewText(Resource.Id.textViewCountryEquivalent, "MXN");
                widgetView.SetTextViewText(Resource.Id.textViewRatioReference, "1");
                widgetView.SetTextViewText(Resource.Id.textViewRatioEquivalent, divisa.rates.MXN.ToString());

                widgetView.SetImageViewResource(Resource.Id.imageViewEquivalent, Resource.Drawable.mxn);
                widgetView.SetImageViewResource(Resource.Id.imageViewReferent, Resource.Drawable.usd);
            }

            return(widgetView);
        }
Esempio n. 17
0
        private RemoteViews BuildUpdate(Context context, int[] appWidgetIds)
        {
            RemoteViews updateViews = new RemoteViews(context.PackageName, Resource.Layout.widget);

            Intent i = new Intent(context, typeof(AppWidget));

            i.SetAction(AppWidgetManager.ActionAppwidgetUpdate);
            i.PutExtra(AppWidgetManager.ExtraAppwidgetIds, appWidgetIds);

            PendingIntent pi = PendingIntent.GetBroadcast(context, 0, i, PendingIntentFlags.UpdateCurrent);

            updateViews.SetImageViewResource(Resource.Id.left_die, IMAGES[(int)(Math.Random() * 6)]);
            updateViews.SetOnClickPendingIntent(Resource.Id.left_die, pi);

            updateViews.SetImageViewResource(Resource.Id.right_die, IMAGES[(int)(Math.Random() * 6)]);
            updateViews.SetOnClickPendingIntent(Resource.Id.right_die, pi);

            updateViews.SetOnClickPendingIntent(Resource.Id.background, pi);

            return(updateViews);
        }
Esempio n. 18
0
        /// <summary>
        /// Creates a RemoteViews that will be shown as the bottom bar of the custom tab. </summary>
        /// <param name="showPlayIcon"> If true, a play icon will be shown, otherwise show a pause icon. </param>
        /// <returns> The created RemoteViews instance. </returns>
        public static RemoteViews CreateRemoteViews(Context context, bool showPlayIcon)
        {
            RemoteViews remoteViews = new RemoteViews(context.PackageName, Resource.Layout.remote_view);

            int iconRes =
                showPlayIcon ? Resource.Drawable.ic_play : Resource.Drawable.ic_stop;

            remoteViews.SetImageViewResource(Resource.Id.play_pause, iconRes);

#if DEBUG
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("CreateRemoteViews Finished");
#endif

            return(remoteViews);
        }
Esempio n. 19
0
        public RemoteViews GetViewAt(int position)
        {
            RemoteViews rv = new RemoteViews(context.PackageName, Resource.Layout.panic_button);

            rv.SetTextViewText(Resource.Id.panic_button_counter, Count.ToString());

            //  int iconDrawable = message.IsRead ? Resource.Drawable.pink_button : Resource.Drawable.mark_unread;
            rv.SetImageViewResource(Resource.Id.panic_button_icon, Resource.Drawable.pink_button);

            // 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.panic_button, fillInIntent);

            return(rv);
        }
Esempio n. 20
0
        /// <summary>
        /// Update the notification.
        /// </summary>
        /// <param name="context">
        /// The context.
        /// </param>
        /// <returns>
        /// The updated notification.
        /// </returns>
        public Notification UpdateNotification(Context context)
        {
            bool hasPausedText = this.PausedText != null;
            bool mustUpdate    = this.lastHasPausedText != hasPausedText;

            // Build the RemoteView object
            if (expandedView == null)
            {
                expandedView = new RemoteViews(context.PackageName, Resource.Layout.status_bar_ongoing_event_progress_bar);
                expandedView.SetImageViewResource(Resource.Id.appIcon, this.Icon);
                expandedView.SetTextViewText(Resource.Id.paused_text, this.PausedText);
                expandedView.SetTextViewText(Resource.Id.title, this.Title);

                this.notification.ContentView = expandedView;

                mustUpdate = true;
            }

            if (mustUpdate)
            {
                expandedView.SetViewVisibility(Resource.Id.progress_bar_frame, hasPausedText ? ViewStates.Gone : ViewStates.Visible);
                expandedView.SetViewVisibility(Resource.Id.description, hasPausedText ? ViewStates.Gone : ViewStates.Visible);
                expandedView.SetViewVisibility(Resource.Id.time_remaining, hasPausedText ? ViewStates.Gone : ViewStates.Visible);
                expandedView.SetViewVisibility(Resource.Id.paused_text, hasPausedText ? ViewStates.Visible : ViewStates.Gone);
            }

            if (!hasPausedText)
            {
                expandedView.SetTextViewText(Resource.Id.progress_text, Helpers.GetDownloadProgressPercent(this.CurrentBytes, this.TotalBytes));
                expandedView.SetTextViewText(Resource.Id.description, Helpers.GetDownloadProgressString(this.CurrentBytes, this.TotalBytes));
                expandedView.SetProgressBar(
                    Resource.Id.progress_bar,
                    (int)(this.TotalBytes >> 8),
                    (int)(this.CurrentBytes >> 8),
                    this.TotalBytes <= 0);
                expandedView.SetTextViewText(Resource.Id.time_remaining, string.Format("Time remaining: {0}", Helpers.GetTimeRemaining(this.TimeRemaining)));
            }

            this.lastHasPausedText = hasPausedText;

            return(this.notification);
        }
Esempio n. 21
0
        void CreateInvitationNotification(string sender, string chat)
        {
            var notificationManager = GetSystemService(Context.NotificationService) as NotificationManager;

            var uiIntent = new Intent(this, typeof(MainActivity));

            NotificationCompat.Builder builder = new NotificationCompat.Builder(this);

            string title      = "Invitation!";
            var    remoteView = new RemoteViews(MainActivity.CurrentActivity.PackageName, Resource.Layout.custom_notification);

            remoteView.SetImageViewResource(Resource.Id.notificationImage, Resource.Drawable.icon);
            remoteView.SetTextViewText(Resource.Id.title, title);
            remoteView.SetTextViewText(Resource.Id.text, string.Format("{0} invite you to chat: {1}!", sender, chat));

            Intent acceptIntent = new Intent(MainActivity.CurrentActivity, MainActivity.CurrentActivity.Receiver.Class);

            acceptIntent.PutExtra("sender", sender);
            acceptIntent.PutExtra("chat", chat);
            PendingIntent pendingAcceptIntent = PendingIntent.GetBroadcast(MainActivity.CurrentActivity, 0,
                                                                           acceptIntent, 0);

            remoteView.SetOnClickPendingIntent(Resource.Id.accept, pendingAcceptIntent);

            var notification = builder.SetContentIntent(PendingIntent.GetActivity(this, 0, uiIntent, 0))
                               .SetSmallIcon(Android.Resource.Drawable.SymActionEmail)
                               .SetTicker(title)
                               .SetContentTitle(title)
                               .SetCustomContentView(remoteView)
                               .SetContentIntent(null)
                               .SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification))
                               .SetAutoCancel(true).Build();


            var remView = notification.ContentView;
            var btn     = new Button(MainActivity.CurrentActivity);

            remView.SetOnClickPendingIntent(btn.Id, null);

            notificationManager.Notify(1, notification);
        }
        /// <summary>
        /// Updates the widget display image based on the new state
        /// </summary>
        /// <param name="context">Context.</param>
        /// <param name="newState">New state.</param>
        private void UpdateWidgetDisplay(Context context, int newState)
        {
            var appWidgetManager = AppWidgetManager.GetInstance(context);
            var remoteViews      = new RemoteViews(context.PackageName, Resource.Layout.initial_layout);

            Log.Debug(APP_NAME, "this.GetType().ToString(): {0}", this.GetType().ToString());

            var thisWidget = new ComponentName(context, this.Class);

            Log.Debug(APP_NAME, thisWidget.FlattenToString());
            Log.Debug(APP_NAME, "remoteViews: {0}", remoteViews.ToString());

            int imgResource = Resource.Drawable.bluetooth_off;

            switch ((Android.Bluetooth.State)newState)
            {
            case Android.Bluetooth.State.Off:
            case Android.Bluetooth.State.TurningOn:
            {
                imgResource = Resource.Drawable.bluetooth_off;
                break;
            }

            case Android.Bluetooth.State.On:
            case Android.Bluetooth.State.TurningOff:
            {
                imgResource = Resource.Drawable.bluetooth_on;
                break;
            }

            default:
            {
                imgResource = Resource.Drawable.bluetooth_off;
                break;
            }
            }

            remoteViews.SetImageViewResource(Resource.Id.imgBluetooth, imgResource);
            appWidgetManager.UpdateAppWidget(thisWidget, remoteViews);
        }
Esempio n. 23
0
        /// <summary>
        /// Update the notification.
        /// </summary>
        /// <param name="context">
        /// The context.
        /// </param>
        /// <returns>
        /// The updated notification.
        /// </returns>
        public Notification UpdateNotification(Context context)
        {
            // Build the RemoteView object
            if (expandedView == null)
            {
                expandedView = new RemoteViews(context.PackageName, Resource.Layout.status_bar_ongoing_event_progress_bar);
            }

            expandedView.SetImageViewResource(Resource.Id.appIcon, this.Icon);
            expandedView.SetTextViewText(Resource.Id.title, this.Title);
            expandedView.SetTextViewText(Resource.Id.progress_text, Helpers.GetDownloadProgressPercent(this.CurrentBytes, this.TotalBytes));
            expandedView.SetTextViewText(Resource.Id.description, Helpers.GetDownloadProgressString(this.CurrentBytes, this.TotalBytes));
            expandedView.SetProgressBar(
                Resource.Id.progress_bar,
                (int)(this.TotalBytes >> 8),
                (int)(this.CurrentBytes >> 8),
                this.TotalBytes <= 0);
            expandedView.SetTextViewText(Resource.Id.time_remaining, context.GetString(Resource.String.time_remaining_notification, Helpers.GetTimeRemaining(this.TimeRemaining)));

            this.notification.ContentView = expandedView;

            return(this.notification);
        }
Esempio n. 24
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);
        }
Esempio n. 25
0
        private void StartForeground(bool flag)
        {
            Intent        resultIntent        = new Intent(this, typeof(MainActivity));
            PendingIntent resultPendingIntent = PendingIntent.GetActivity(this, 0, resultIntent, PendingIntentFlags.UpdateCurrent);

            PendingIntent play_pauseAction   = null;
            int           notificationAction = Android.Resource.Drawable.IcMediaPause;

            var intent_receiver = new Intent(Receiver.ButtonPlayNotificationReceiver.ReceiverPlay);

            if (flag)
            {
                notificationAction = Android.Resource.Drawable.IcMediaPause;
                play_pauseAction   = ActionsInNotification(0);
                intent_receiver.PutExtra("buttonflag", false);
            }
            else
            {
                notificationAction = Android.Resource.Drawable.IcMediaPlay;
                play_pauseAction   = ActionsInNotification(1);
                intent_receiver.PutExtra("buttonflag", true);
            }
            SendBroadcast(intent_receiver);

            contentView = new RemoteViews(ApplicationContext.PackageName, Resource.Layout.notification);

            if (info_radio != null)
            {
                contentView.SetImageViewBitmap(Resource.Id.notification_image, GetImageBitmapFromUrl(info_radio.image));
                contentView.SetTextViewText(Resource.Id.notification_text_title, info_radio.track);
                contentView.SetTextViewText(Resource.Id.notification_text_artist, info_radio.artist);
            }
            else
            {
                contentView.SetImageViewBitmap(Resource.Id.notification_image, GetImageBitmapFromUrl("http://medianau.top/images/logo.png"));
                contentView.SetTextViewText(Resource.Id.notification_text_title, "Подключение...");
                contentView.SetTextViewText(Resource.Id.notification_text_artist, "");
            }

            contentView.SetImageViewResource(Resource.Id.notification_button_play, notificationAction);
            contentView.SetOnClickPendingIntent(Resource.Id.notification_button_play, play_pauseAction);
            contentView.SetOnClickPendingIntent(Resource.Id.notification_button_cancel, ActionsInNotification(2));

            NotifyBuilder = new NotificationCompat.Builder(this, Id_Channel);

            notification = NotifyBuilder.SetContentTitle("Radio NAU started!")
                           .SetTicker("Radio NAU started!")
                           .SetContentText("Radio NAU started!")
                           .SetSmallIcon(Resource.Mipmap.logo_min)
                           .SetContentIntent(resultPendingIntent)
                           .SetPriority(Android.Support.V4.App.NotificationCompat.PriorityDefault)
                           .SetSound(null)
                           .SetOngoing(true)
                           .SetAutoCancel(false)
                           .SetVisibility(NotificationCompat.VisibilityPublic)
                           .Build();

            notification.BigContentView = contentView;

            mNotifyManager = (NotificationManager)GetSystemService(Context.NotificationService);
            if (Build.VERSION.SdkInt >= Build.VERSION_CODES.O)
            {
                NotificationChannel channel = new NotificationChannel(Id_Channel, GetString(Resource.String.noti_channel_default), NotificationImportance.High);
                channel.SetShowBadge(false);
                mNotifyManager.CreateNotificationChannel(channel);
            }
            //mNotifyManager.Notify(Id_Notification, notification);
            StartForeground(Id_Notification, notification);
        }
        public static void UpdateNotification(Weather weather)
        {
            // Gets an instance of the NotificationManager service
            NotificationManager mNotifyMgr = (NotificationManager)App.Context.GetSystemService(App.NotificationService);

            InitChannel(mNotifyMgr);

            var wm = WeatherManager.GetInstance();

            // Build update
            RemoteViews updateViews = new RemoteViews(App.Context.PackageName, Resource.Layout.notification_layout);

            string temp = (Settings.IsFahrenheit ?
                           Math.Round(weather.condition.temp_f) : Math.Round(weather.condition.temp_c)) + "º";
            string condition = weather.condition.weather;
            string hitemp    = (Settings.IsFahrenheit ?
                                Math.Round(double.Parse(weather.forecast[0].high_f)) : Math.Round(double.Parse(weather.forecast[0].high_c))) + "º";
            string lotemp = (Settings.IsFahrenheit ?
                             Math.Round(double.Parse(weather.forecast[0].low_f)) : Math.Round(double.Parse(weather.forecast[0].low_c))) + "º";

            // Weather icon
            updateViews.SetImageViewResource(Resource.Id.weather_icon,
                                             wm.GetWeatherIconResource(weather.condition.icon));

            // Location Name
            updateViews.SetTextViewText(Resource.Id.location_name, weather.location.name);

            // Condition text
            updateViews.SetTextViewText(Resource.Id.condition_weather, string.Format("{0} - {1}", temp, condition));

            // Details
            updateViews.SetTextViewText(Resource.Id.condition_details,
                                        string.Format("{0} / {1}", hitemp, lotemp));

            // Update Time
            string timeformat = DateTime.Now.ToString("h:mm tt");

            if (DateFormat.Is24HourFormat(App.Context))
            {
                timeformat = DateTime.Now.ToString("HH:mm");
            }

            updateViews.SetTextViewText(Resource.Id.update_time, timeformat);

            // Progress bar
            updateViews.SetViewVisibility(Resource.Id.refresh_button, ViewStates.Visible);
            updateViews.SetViewVisibility(Resource.Id.refresh_progress, ViewStates.Gone);
            Intent refreshClickIntent = new Intent(App.Context, typeof(Widgets.WeatherWidgetBroadcastReceiver))
                                        .SetAction(Widgets.WeatherWidgetService.ACTION_REFRESHNOTIFICATION);
            PendingIntent prgPendingIntent = PendingIntent.GetBroadcast(App.Context, 0, refreshClickIntent, 0);

            updateViews.SetOnClickPendingIntent(Resource.Id.refresh_button, prgPendingIntent);

            if (!int.TryParse(temp.Replace("º", ""), out int level))
            {
                level = 0;
            }

            int resId = level < 0 ? Resource.Drawable.notification_temp_neg : Resource.Drawable.notification_temp_pos;

            NotificationCompat.Builder mBuilder =
                new NotificationCompat.Builder(App.Context, NOT_CHANNEL_ID)
                .SetContent(updateViews)
                .SetPriority(NotificationCompat.PriorityLow)
                .SetOngoing(true) as NotificationCompat.Builder;

            if (Settings.NotificationIcon == Settings.TEMPERATURE_ICON)
            {
                mBuilder.SetSmallIcon(resId, Math.Abs(level));
            }
            else if (Settings.NotificationIcon == Settings.CONDITION_ICON)
            {
                mBuilder.SetSmallIcon(wm.GetWeatherIconResource(weather.condition.icon));
            }

            Intent onClickIntent = new Intent(App.Context, typeof(MainActivity))
                                   .SetFlags(ActivityFlags.ClearTop | ActivityFlags.NewTask | ActivityFlags.ClearTask);
            PendingIntent clickPendingIntent = PendingIntent.GetActivity(App.Context, 0, onClickIntent, 0);

            mBuilder.SetContentIntent(clickPendingIntent);

            // Builds the notification and issues it.
            mNotification = mBuilder.Build();
            mNotifyMgr.Notify(PERSISTENT_NOT_ID, mNotification);
            IsShowing = true;
        }
Esempio n. 27
0
        private void UpdateWidgetView()
        {
            if (_isShutDowning)
                return;

            Console.WriteLine("WidgetService - UpdateWidgetView");

            try
            {
                // Update widget
                Console.WriteLine("WidgetService - UpdateWidgetView - Getting widgets (0)...");
                RemoteViews viewWidget = new RemoteViews(PackageName, Resource.Layout.WidgetPlayer);
                Console.WriteLine("WidgetService - UpdateWidgetView - Getting widgets (1)...");
                AppWidgetManager manager = AppWidgetManager.GetInstance(this);
                Console.WriteLine("WidgetService - UpdateWidgetView - Getting widgets (2) - appWidgetIds count: {0}", _widgetIds.Length);

                // Update metadata on widget
                if (_audioFile != null)
                {
                    viewWidget.SetTextViewText(Resource.Id.widgetPlayer_lblArtistName, _audioFile.ArtistName);
                    viewWidget.SetTextViewText(Resource.Id.widgetPlayer_lblAlbumTitle, _audioFile.AlbumTitle);
                    viewWidget.SetTextViewText(Resource.Id.widgetPlayer_lblSongTitle, _audioFile.Title);
                }
                else
                {
                    viewWidget.SetTextViewText(Resource.Id.widgetPlayer_lblArtistName, "");
                    viewWidget.SetTextViewText(Resource.Id.widgetPlayer_lblAlbumTitle, "");
                    viewWidget.SetTextViewText(Resource.Id.widgetPlayer_lblSongTitle, "");                                    
                }

                if (_status == PlayerStatusType.Initialized ||
                    _status == PlayerStatusType.Paused ||
                    _status == PlayerStatusType.Stopped)
                {
                    viewWidget.SetImageViewResource(Resource.Id.widgetPlayer_btnPlayPause, Resource.Drawable.player_play);
                }
                else
                {
                    viewWidget.SetImageViewResource(Resource.Id.widgetPlayer_btnPlayPause, Resource.Drawable.player_pause);
                }

                // Update album art on widget
                if (_bitmapAlbumArt == null)
                    viewWidget.SetImageViewResource(Resource.Id.widgetPlayer_imageAlbum, 0);
                else
                    viewWidget.SetImageViewBitmap(Resource.Id.widgetPlayer_imageAlbum, _bitmapAlbumArt);

                Console.WriteLine("WidgetService - UpdateWidgetView - Getting widgets (3) - appWidgetIds count: {0}", _widgetIds.Length);

                foreach (int id in _widgetIds)
                {
                    Console.WriteLine("WidgetService - UpdateWidgetView - Updating widgets - id: {0}", id);
                    manager.UpdateAppWidget(id, viewWidget);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("WidgetService - UpdateWidgetView - Widget exception: {0}", ex);
            }
        }
Esempio n. 28
0
        /// <summary>
        /// Updates the widget display image based on the new state
        /// </summary>
        /// <param name="context">Context.</param>
        /// <param name="newState">New state.</param>
        private void UpdateWidgetDisplay(Context context, int newState)
        {
            var appWidgetManager = AppWidgetManager.GetInstance(context);
            var remoteViews      = new RemoteViews(context.PackageName, Resource.Layout.initial_layout);
            // Log.Debug(Constants.APP_NAME, "this.GetType().ToString(): {0}", this.GetType().ToString());

            var thisWidget = new ComponentName(context, this.Class);
            // Log.Debug(Constants.APP_NAME, thisWidget.FlattenToString());
            // Log.Debug(Constants.APP_NAME, "remoteViews: {0}", remoteViews.ToString());

            int   imgResource  = Resource.Drawable.bluetooth_off;
            State currentState = (Android.Bluetooth.State)newState;

            switch (currentState)
            {
            case Android.Bluetooth.State.Off:
            case Android.Bluetooth.State.TurningOn:
            {
                imgResource = Resource.Drawable.bluetooth_off;
                break;
            }

            case Android.Bluetooth.State.On:
            case Android.Bluetooth.State.TurningOff:
            {
                imgResource = Resource.Drawable.bluetooth_on;
                break;
            }

            case Android.Bluetooth.State.Connecting:
            case Android.Bluetooth.State.Disconnecting:
            {
                imgResource = Resource.Drawable.bluetooth_connecting;
                break;
            }

            case Android.Bluetooth.State.Connected:
            {
                imgResource = Resource.Drawable.bluetooth_connected;
                break;
            }

            case Android.Bluetooth.State.Disconnected:
            {
                imgResource = Resource.Drawable.bluetooth_on;
                break;
            }

            default:
            {
                imgResource = Resource.Drawable.bluetooth_off;
                break;
            }
            }

            remoteViews.SetImageViewResource(Resource.Id.imgBluetooth, imgResource);

            switch (currentState)
            {
            case State.Off:
            {
                Log.Info(Constants.APP_NAME, "Adapter state is 'off', adding click delegate to turn on BT ");
                Intent        enableBluetoothIntent = new Intent(BluetoothAdapter.ActionRequestEnable);
                PendingIntent pendingIntent         = PendingIntent.GetActivity(context, 0, enableBluetoothIntent, PendingIntentFlags.UpdateCurrent);
                remoteViews.SetOnClickPendingIntent(Resource.Id.imgBluetooth, pendingIntent);
                break;
            }

            default:
            {
                Log.Info(Constants.APP_NAME, string.Format("Adapter state is {0}, adding click delegate to turn off BT", currentState.ToString()));
                Intent        disableBluetoothIntent = new Intent(context, typeof(DisableBluetoothService));
                PendingIntent pendingIntent          = PendingIntent.GetService(context, 0, disableBluetoothIntent, PendingIntentFlags.UpdateCurrent);
                remoteViews.SetOnClickPendingIntent(Resource.Id.imgBluetooth, pendingIntent);
                break;
            }
            }

            appWidgetManager.UpdateAppWidget(thisWidget, remoteViews);
        }
Esempio n. 29
0
        private Notification BuildNotification()
        {
            _notificationBuilder = new NotificationCompat.Builder(ApplicationContext);
            _notificationBuilder.SetOngoing(true);
            _notificationBuilder.SetAutoCancel(false);
            _notificationBuilder.SetSmallIcon(Resource.Drawable.NotifIcon);
            //Open up the player screen when the user taps on the notification.
            var launchNowPlayingIntent = new Intent();
            launchNowPlayingIntent.SetAction(LaunchNowPlayingAction);
            var launchNowPlayingPendingIntent = PendingIntent.GetBroadcast(ApplicationContext, 0, launchNowPlayingIntent,
                0);
            _notificationBuilder.SetContentIntent(launchNowPlayingPendingIntent);

            //Grab the notification layouts.
            var notificationView = new RemoteViews(ApplicationContext.PackageName,
                Resource.Layout.notification_custom_layout);
            var expNotificationView = new RemoteViews(ApplicationContext.PackageName,
                Resource.Layout.notification_custom_expanded_layout);

            //Initialize the notification layout buttons.
            var previousTrackIntent = new Intent();
            previousTrackIntent.SetAction(PrevAction);
            var previousTrackPendingIntent = PendingIntent.GetBroadcast(ApplicationContext, 0,
                previousTrackIntent, 0);

            var playPauseTrackIntent = new Intent();
            playPauseTrackIntent.SetAction(PlayPauseAction);
            var playPauseTrackPendingIntent = PendingIntent.GetBroadcast(ApplicationContext, 0,
                playPauseTrackIntent, 0);

            var nextTrackIntent = new Intent();
            nextTrackIntent.SetAction(NextAction);
            var nextTrackPendingIntent = PendingIntent.GetBroadcast(ApplicationContext, 0, nextTrackIntent, 0);

            var stopServiceIntent = new Intent();
            stopServiceIntent.SetAction(StopAction);
            var stopServicePendingIntent = PendingIntent.GetBroadcast(ApplicationContext, 0, stopServiceIntent,
                0);

            //Check if audio is playing and set the appropriate play/pause button.
            if (App.Current.AudioServiceConnection.GetPlaybackService().IsPlayingMusic)
            {
                notificationView.SetImageViewResource(Resource.Id.notification_base_play,
                    Resource.Drawable.btn_playback_pause_light);
                expNotificationView.SetImageViewResource(Resource.Id.notification_expanded_base_play,
                    Resource.Drawable.btn_playback_pause_light);
            }
            else
            {
                notificationView.SetImageViewResource(Resource.Id.notification_base_play,
                    Resource.Drawable.btn_playback_play_light);
                expNotificationView.SetImageViewResource(Resource.Id.notification_expanded_base_play,
                    Resource.Drawable.btn_playback_play_light);
            }

            var song = AudioPlayerHelper.CurrentQueueSong.Song;

            //Set the notification content.
            expNotificationView.SetTextViewText(Resource.Id.notification_expanded_base_line_one, song.Name);
            expNotificationView.SetTextViewText(Resource.Id.notification_expanded_base_line_two, song.ArtistName);
            expNotificationView.SetTextViewText(Resource.Id.notification_expanded_base_line_three, song.Album.Name);

            notificationView.SetTextViewText(Resource.Id.notification_base_line_one, song.Name);
            notificationView.SetTextViewText(Resource.Id.notification_base_line_two, song.ArtistName);

            //the previous and next buttons, always enabled.
            expNotificationView.SetViewVisibility(Resource.Id.notification_expanded_base_previous, ViewStates.Visible);
            expNotificationView.SetViewVisibility(Resource.Id.notification_expanded_base_next, ViewStates.Visible);
            expNotificationView.SetOnClickPendingIntent(Resource.Id.notification_expanded_base_play,
                playPauseTrackPendingIntent);
            expNotificationView.SetOnClickPendingIntent(Resource.Id.notification_expanded_base_next,
                nextTrackPendingIntent);
            expNotificationView.SetOnClickPendingIntent(Resource.Id.notification_expanded_base_previous,
                previousTrackPendingIntent);

            notificationView.SetViewVisibility(Resource.Id.notification_base_previous, ViewStates.Visible);
            notificationView.SetViewVisibility(Resource.Id.notification_base_next, ViewStates.Visible);
            notificationView.SetOnClickPendingIntent(Resource.Id.notification_base_play, playPauseTrackPendingIntent);
            notificationView.SetOnClickPendingIntent(Resource.Id.notification_base_next, nextTrackPendingIntent);
            notificationView.SetOnClickPendingIntent(Resource.Id.notification_base_previous, previousTrackPendingIntent);

            //Set the "Stop Service" pending intents.
            expNotificationView.SetOnClickPendingIntent(Resource.Id.notification_expanded_base_collapse,
                stopServicePendingIntent);
            notificationView.SetOnClickPendingIntent(Resource.Id.notification_base_collapse, stopServicePendingIntent);

            //Set the album art.
            if (song.Album.Artwork != null)
            {
                if (song.Album.Artwork.Image != null)
                {
                    expNotificationView.SetImageViewBitmap(Resource.Id.notification_expanded_base_image,
                        song.Album.Artwork.Image as Bitmap);
                    notificationView.SetImageViewBitmap(Resource.Id.notification_base_image,
                        song.Album.Artwork.Image as Bitmap);
                }
                else
                    ((PclBitmapImage) song.Album.Artwork).PropertyChanged += OnPropertyChanged;
            }
            else
                song.Album.PropertyChanged += OnPropertyChanged;

            //Attach the shrunken layout to the notification.
            _notificationBuilder.SetContent(notificationView);

            //Build the notification object.
            var notification = _notificationBuilder.Build();

            //Attach the expanded layout to the notification and set its flags.
            notification.BigContentView = expNotificationView;
            notification.Flags = NotificationFlags.ForegroundService |
                                 NotificationFlags.NoClear |
                                 NotificationFlags.OngoingEvent;
            return notification;
        }
        private void UpdateNowPlayingNotification()
        {
            Application.SynchronizationContext.Post(_ =>
            {
                try
                {
                    if (isNotifyPlayerActive)
                    {
                        var nm            = GetNotifyManager();
                        var remoteViewExp = new RemoteViews(PackageName, Resource.Layout.layout_notifi_player_exp);

                        remoteViewExp.SetImageViewResource(Resource.Id.ibNotifiAction3,
                                                           netStatus.StatusPlay == CmdHelper.NetStatus.Status.PAUSE
                                ? Resource.Drawable.play_100_black
                                : Resource.Drawable.pause_100_black);

                        Intent itAction = new Intent(BROAD_NOTIFY_PLAYER);
                        itAction.PutExtra("ACT", 0);
                        PendingIntent piAction = PendingIntent.GetBroadcast(this, IntentHelper.GetId(), itAction, 0);
                        remoteViewExp.SetOnClickPendingIntent(Resource.Id.ibNotifiAction1, piAction);

                        itAction = new Intent(BROAD_NOTIFY_PLAYER);
                        itAction.PutExtra("ACT", 1);
                        piAction = PendingIntent.GetBroadcast(this, IntentHelper.GetId(), itAction, 0);
                        remoteViewExp.SetOnClickPendingIntent(Resource.Id.ibNotifiAction2, piAction);

                        itAction = new Intent(BROAD_NOTIFY_PLAYER);
                        itAction.PutExtra("ACT", 2);
                        piAction = PendingIntent.GetBroadcast(this, IntentHelper.GetId(), itAction, 0);
                        remoteViewExp.SetOnClickPendingIntent(Resource.Id.ibNotifiAction3, piAction);

                        itAction = new Intent(BROAD_NOTIFY_PLAYER);
                        itAction.PutExtra("ACT", 3);
                        piAction = PendingIntent.GetBroadcast(this, IntentHelper.GetId(), itAction, 0);
                        remoteViewExp.SetOnClickPendingIntent(Resource.Id.ibNotifiAction4, piAction);

                        var titleName  = netTitleName?.TitleName;
                        var artistName = netArtistName?.ArtistName;

                        if (cmdInputState?.Parameter == "2E")
                        {
                            artistName = netTitleName?.TitleName;
                            titleName  = "Bluetooth";
                        }

                        if (titleName != null)
                        {
                            remoteViewExp.SetTextViewText(Resource.Id.tvNotifiTitle1, titleName);
                            remoteViewExp.SetViewVisibility(Resource.Id.tvNotifiTitle1, ViewStates.Visible);
                        }

                        if (artistName != null)
                        {
                            remoteViewExp.SetTextViewText(Resource.Id.tvNotifiTitle2, artistName);
                            remoteViewExp.SetViewVisibility(Resource.Id.tvNotifiTitle2, ViewStates.Visible);
                        }

                        if (netAlbumName?.AlbumName != null)
                        {
                            remoteViewExp.SetTextViewText(Resource.Id.tvNotifiTitle3, netAlbumName.AlbumName);
                            remoteViewExp.SetViewVisibility(Resource.Id.tvNotifiTitle3, ViewStates.Visible);
                        }

                        if (netArt?.bmArt != null)
                        {
                            remoteViewExp.SetImageViewBitmap(Resource.Id.ivNotifiCover, netArt.bmArt);
                            remoteViewExp.SetViewVisibility(Resource.Id.ivNotifiCover, ViewStates.Visible);
                        }
                        else
                        {
                            remoteViewExp.SetImageViewResource(Resource.Id.ivNotifiCover, Resource.Drawable.app_icon);
                            remoteViewExp.SetViewVisibility(Resource.Id.ivNotifiCover, ViewStates.Visible);
                        }

                        NotificationCompat.Builder nb = new NotificationCompat.Builder(ApplicationContext);


                        Intent intent = new Intent(this, typeof(HomeActivity));
                        intent.PutExtra(INTENT_HOME_TAB, 0);
                        intent.AddFlags(ActivityFlags.ClearTop);
                        intent.AddFlags(ActivityFlags.SingleTop);
                        PendingIntent pendingIntent = PendingIntent.GetActivity(this, IntentHelper.GetId(), intent, 0);
                        nb.SetContentIntent(pendingIntent);

                        nb.SetCustomBigContentView(remoteViewExp);
                        var x = remoteViewExp.Clone();
                        x.SetViewVisibility(Resource.Id.llNotifyExp, ViewStates.Gone);
                        nb.SetCustomContentView(x);

                        nb.SetSmallIcon(Resource.Drawable.av_receiver_100_black);
                        nb.SetOngoing(true);


                        nm.Notify(notifyIdPlayer, nb.Build());
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }, null);
        }
Esempio n. 31
0
        private void CreateNoti()
        {
            try
            {
                BigViews   = new RemoteViews(PackageName, Resource.Layout.CustomNotificationLayout);
                SmallViews = new RemoteViews(PackageName, Resource.Layout.CustomNotificationSmallLayout);

                Intent notificationIntent = new Intent(this, typeof(SplashScreenActivity));
                notificationIntent.SetAction(Intent.ActionMain);
                notificationIntent.AddCategory(Intent.CategoryLauncher);
                notificationIntent.PutExtra("isnoti", true);
                PendingIntent pendingIntent = PendingIntent.GetActivity(this, 0, notificationIntent, PendingIntentFlags.UpdateCurrent);

                Intent previousIntent = new Intent(this, typeof(PlayerService));
                previousIntent.SetAction(ActionRewind);
                PendingIntent ppreviousIntent = PendingIntent.GetService(this, 0, previousIntent, 0);

                Intent playIntent = new Intent(this, typeof(PlayerService));
                playIntent.SetAction(ActionToggle);
                PendingIntent pplayIntent = PendingIntent.GetService(this, 0, playIntent, 0);

                Intent nextIntent = new Intent(this, typeof(PlayerService));
                nextIntent.SetAction(ActionSkip);
                PendingIntent pnextIntent = PendingIntent.GetService(this, 0, nextIntent, 0);

                Intent closeIntent = new Intent(this, typeof(PlayerService));
                closeIntent.SetAction(ActionStop);
                PendingIntent pcloseIntent = PendingIntent.GetService(this, 0, closeIntent, 0);

                Notification = new NotificationCompat.Builder(this, NotificationChannelId)
                               .SetLargeIcon(BitmapFactory.DecodeResource(Resources, Resource.Mipmap.icon))
                               .SetContentTitle(AppSettings.ApplicationName)
                               .SetPriority((int)NotificationPriority.Max)
                               .SetContentIntent(pendingIntent)
                               .SetSmallIcon(Resource.Drawable.icon_notification)
                               .SetTicker(Constant.ArrayListPlay[Constant.PlayPos]?.Title)
                               .SetChannelId(NotificationChannelId)
                               .SetOngoing(true)
                               .SetAutoCancel(true)
                               .SetOnlyAlertOnce(true);

                NotificationChannel mChannel;
                if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
                {
                    NotificationImportance importance = NotificationImportance.Low;
                    mChannel = new NotificationChannel(NotificationChannelId, AppSettings.ApplicationName, importance);
                    MNotificationManager.CreateNotificationChannel(mChannel);

                    MediaSessionCompat mMediaSession = new MediaSessionCompat(Application.Context, AppSettings.ApplicationName);
                    mMediaSession.SetFlags(MediaSessionCompat.FlagHandlesMediaButtons | MediaSessionCompat.FlagHandlesTransportControls);

                    Notification.SetStyle(new Android.Support.V4.Media.App.NotificationCompat.MediaStyle()
                                          .SetMediaSession(mMediaSession.SessionToken).SetShowCancelButton(true)
                                          .SetShowActionsInCompactView(0, 1, 2)
                                          .SetCancelButtonIntent(MediaButtonReceiver.BuildMediaButtonPendingIntent(Application.Context, PlaybackStateCompat.ActionStop)))
                    .AddAction(new NotificationCompat.Action(Resource.Xml.ic_skip_previous, "Previous", ppreviousIntent))
                    .AddAction(new NotificationCompat.Action(Resource.Xml.ic_pause, "Pause", pplayIntent))
                    .AddAction(new NotificationCompat.Action(Resource.Xml.ic_skip_next, "Next", pnextIntent))
                    .AddAction(new NotificationCompat.Action(Resource.Drawable.ic_action_close, "Close", pcloseIntent));
                }
                else
                {
                    string songName   = Methods.FunString.DecodeString(Constant.ArrayListPlay[Constant.PlayPos]?.Title);
                    string genresName = Methods.FunString.DecodeString(Constant.ArrayListPlay[Constant.PlayPos]?.CategoryName) + " " + Application.Context.Resources.GetString(Resource.String.Lbl_Music);

                    BigViews.SetOnClickPendingIntent(Resource.Id.imageView_noti_play, pplayIntent);
                    BigViews.SetOnClickPendingIntent(Resource.Id.imageView_noti_next, pnextIntent);
                    BigViews.SetOnClickPendingIntent(Resource.Id.imageView_noti_prev, ppreviousIntent);
                    BigViews.SetOnClickPendingIntent(Resource.Id.imageView_noti_close, pcloseIntent);
                    SmallViews.SetOnClickPendingIntent(Resource.Id.status_bar_collapse, pcloseIntent);

                    BigViews.SetImageViewResource(Resource.Id.imageView_noti_play, Android.Resource.Drawable.IcMediaPause);
                    BigViews.SetTextViewText(Resource.Id.textView_noti_name, songName);
                    SmallViews.SetTextViewText(Resource.Id.status_bar_track_name, songName);
                    BigViews.SetTextViewText(Resource.Id.textView_noti_artist, genresName);
                    SmallViews.SetTextViewText(Resource.Id.status_bar_artist_name, genresName);
                    BigViews.SetImageViewResource(Resource.Id.imageView_noti, Resource.Mipmap.icon);
                    SmallViews.SetImageViewResource(Resource.Id.status_bar_album_art, Resource.Mipmap.icon);
                    Notification.SetCustomContentView(SmallViews).SetCustomBigContentView(BigViews);
                }

                ShowNotification();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Esempio n. 32
0
        private Notification BuildNotification()
        {
            _notificationBuilder = new NotificationCompat.Builder(ApplicationContext);
            _notificationBuilder.SetOngoing(true);
            _notificationBuilder.SetAutoCancel(false);
            _notificationBuilder.SetSmallIcon(Resource.Drawable.NotifIcon);
            //Open up the player screen when the user taps on the notification.
            var launchNowPlayingIntent = new Intent();

            launchNowPlayingIntent.SetAction(LaunchNowPlayingAction);
            var launchNowPlayingPendingIntent = PendingIntent.GetBroadcast(ApplicationContext, 0, launchNowPlayingIntent,
                                                                           0);

            _notificationBuilder.SetContentIntent(launchNowPlayingPendingIntent);

            //Grab the notification layouts.
            var notificationView = new RemoteViews(ApplicationContext.PackageName,
                                                   Resource.Layout.notification_custom_layout);
            var expNotificationView = new RemoteViews(ApplicationContext.PackageName,
                                                      Resource.Layout.notification_custom_expanded_layout);

            //Initialize the notification layout buttons.
            var previousTrackIntent = new Intent();

            previousTrackIntent.SetAction(PrevAction);
            var previousTrackPendingIntent = PendingIntent.GetBroadcast(ApplicationContext, 0,
                                                                        previousTrackIntent, 0);

            var playPauseTrackIntent = new Intent();

            playPauseTrackIntent.SetAction(PlayPauseAction);
            var playPauseTrackPendingIntent = PendingIntent.GetBroadcast(ApplicationContext, 0,
                                                                         playPauseTrackIntent, 0);

            var nextTrackIntent = new Intent();

            nextTrackIntent.SetAction(NextAction);
            var nextTrackPendingIntent = PendingIntent.GetBroadcast(ApplicationContext, 0, nextTrackIntent, 0);

            var stopServiceIntent = new Intent();

            stopServiceIntent.SetAction(StopAction);
            var stopServicePendingIntent = PendingIntent.GetBroadcast(ApplicationContext, 0, stopServiceIntent,
                                                                      0);

            //Check if audio is playing and set the appropriate play/pause button.
            if (App.Current.AudioServiceConnection.GetPlaybackService().IsPlayingMusic)
            {
                notificationView.SetImageViewResource(Resource.Id.notification_base_play,
                                                      Resource.Drawable.btn_playback_pause_light);
                expNotificationView.SetImageViewResource(Resource.Id.notification_expanded_base_play,
                                                         Resource.Drawable.btn_playback_pause_light);
            }
            else
            {
                notificationView.SetImageViewResource(Resource.Id.notification_base_play,
                                                      Resource.Drawable.btn_playback_play_light);
                expNotificationView.SetImageViewResource(Resource.Id.notification_expanded_base_play,
                                                         Resource.Drawable.btn_playback_play_light);
            }

            var song = AudioPlayerHelper.CurrentQueueSong.Song;

            //Set the notification content.
            expNotificationView.SetTextViewText(Resource.Id.notification_expanded_base_line_one, song.Name);
            expNotificationView.SetTextViewText(Resource.Id.notification_expanded_base_line_two, song.ArtistName);
            expNotificationView.SetTextViewText(Resource.Id.notification_expanded_base_line_three, song.Album.Name);

            notificationView.SetTextViewText(Resource.Id.notification_base_line_one, song.Name);
            notificationView.SetTextViewText(Resource.Id.notification_base_line_two, song.ArtistName);

            //the previous and next buttons, always enabled.
            expNotificationView.SetViewVisibility(Resource.Id.notification_expanded_base_previous, ViewStates.Visible);
            expNotificationView.SetViewVisibility(Resource.Id.notification_expanded_base_next, ViewStates.Visible);
            expNotificationView.SetOnClickPendingIntent(Resource.Id.notification_expanded_base_play,
                                                        playPauseTrackPendingIntent);
            expNotificationView.SetOnClickPendingIntent(Resource.Id.notification_expanded_base_next,
                                                        nextTrackPendingIntent);
            expNotificationView.SetOnClickPendingIntent(Resource.Id.notification_expanded_base_previous,
                                                        previousTrackPendingIntent);

            notificationView.SetViewVisibility(Resource.Id.notification_base_previous, ViewStates.Visible);
            notificationView.SetViewVisibility(Resource.Id.notification_base_next, ViewStates.Visible);
            notificationView.SetOnClickPendingIntent(Resource.Id.notification_base_play, playPauseTrackPendingIntent);
            notificationView.SetOnClickPendingIntent(Resource.Id.notification_base_next, nextTrackPendingIntent);
            notificationView.SetOnClickPendingIntent(Resource.Id.notification_base_previous, previousTrackPendingIntent);

            //Set the "Stop Service" pending intents.
            expNotificationView.SetOnClickPendingIntent(Resource.Id.notification_expanded_base_collapse,
                                                        stopServicePendingIntent);
            notificationView.SetOnClickPendingIntent(Resource.Id.notification_base_collapse, stopServicePendingIntent);

            //Set the album art.
            if (song.Album.Artwork != null)
            {
                if (song.Album.Artwork.Image != null)
                {
                    expNotificationView.SetImageViewBitmap(Resource.Id.notification_expanded_base_image,
                                                           song.Album.Artwork.Image as Bitmap);
                    notificationView.SetImageViewBitmap(Resource.Id.notification_base_image,
                                                        song.Album.Artwork.Image as Bitmap);
                }
                else
                {
                    ((PclBitmapImage)song.Album.Artwork).PropertyChanged += OnPropertyChanged;
                }
            }
            else
            {
                song.Album.PropertyChanged += OnPropertyChanged;
            }

            //Attach the shrunken layout to the notification.
            _notificationBuilder.SetContent(notificationView);

            //Build the notification object.
            var notification = _notificationBuilder.Build();

            //Attach the expanded layout to the notification and set its flags.
            notification.BigContentView = expNotificationView;
            notification.Flags          = NotificationFlags.ForegroundService |
                                          NotificationFlags.NoClear |
                                          NotificationFlags.OngoingEvent;
            return(notification);
        }
Esempio n. 33
0
        private void SetWeatherIcon(RemoteViews widgetView, string icon)
        {
            switch (icon)

            {
            case "01d":
                widgetView.SetImageViewResource(Resource.Id.WeatherIcon, Resource.Drawable.weather_fc_clear_day);
                break;

            case "01n":
                widgetView.SetImageViewResource(Resource.Id.WeatherIcon, Resource.Drawable.weather_fc_clear_night);
                break;

            case "02d":
                widgetView.SetImageViewResource(Resource.Id.WeatherIcon, Resource.Drawable.weather_fc_partly_cloudy_day);
                break;

            case "02n":
                widgetView.SetImageViewResource(Resource.Id.WeatherIcon, Resource.Drawable.weather_fc_partly_cloudy_night);
                break;

            case "03d":
                widgetView.SetImageViewResource(Resource.Id.WeatherIcon, Resource.Drawable.weather_fc_cloudy);
                break;

            case "03n":
                widgetView.SetImageViewResource(Resource.Id.WeatherIcon, Resource.Drawable.weather_fc_cloudy);
                break;

            case "04d":
                widgetView.SetImageViewResource(Resource.Id.WeatherIcon, Resource.Drawable.weather_fc_cloudy);
                break;

            case "04n":
                widgetView.SetImageViewResource(Resource.Id.WeatherIcon, Resource.Drawable.weather_fc_cloudy);
                break;

            case "09d":
                widgetView.SetImageViewResource(Resource.Id.WeatherIcon, Resource.Drawable.weather_fc_rain);
                break;

            case "09n":
                widgetView.SetImageViewResource(Resource.Id.WeatherIcon, Resource.Drawable.weather_fc_rain);
                break;

            case "10d":
                widgetView.SetImageViewResource(Resource.Id.WeatherIcon, Resource.Drawable.weather_fc_10d);
                break;

            case "10n":
                widgetView.SetImageViewResource(Resource.Id.WeatherIcon, Resource.Drawable.weather_fc_10n);
                break;

            case "11d":
                widgetView.SetImageViewResource(Resource.Id.WeatherIcon, Resource.Drawable.weather_fc_11d);
                break;

            case "11n":
                widgetView.SetImageViewResource(Resource.Id.WeatherIcon, Resource.Drawable.weather_fc_11n);
                break;

            case "13d":
                widgetView.SetImageViewResource(Resource.Id.WeatherIcon, Resource.Drawable.weather_fc_snow);
                break;

            case "13n":
                widgetView.SetImageViewResource(Resource.Id.WeatherIcon, Resource.Drawable.weather_fc_13n);
                break;

            case "50d":
                widgetView.SetImageViewResource(Resource.Id.WeatherIcon, Resource.Drawable.weather_fc_fog);
                break;

            case "50n":
                widgetView.SetImageViewResource(Resource.Id.WeatherIcon, Resource.Drawable.weather_fc_fog);
                break;

            default:
                widgetView.SetImageViewResource(Resource.Id.WeatherIcon, Resource.Drawable.weather_fc_clear_day);
                break;
            }
        }
        protected virtual void UpdateWeatherPart(Context context, RemoteViews view, AppWidgetSettings settings, bool isDemoMode)
        {
            var weather = settings.Weather;
            var utcNow  = DateTime.UtcNow;

            if (isDemoMode && weather == null)
            {
                var weatherDataPoint = new WeatherDataPoint
                {
                    Date           = utcNow,
                    Temperature    = 0,
                    MinTemperature = -1,
                    MaxTemperature = 1,
                    WeatherCode    = WeatherCodes.ClearSky,
                    Condition      = context.GetString(Resource.String.DemoCondition)
                };

                weather = new WeatherForecast(providerId: settings.WeatherProviderId, latitude: null, longitude: null,
                                              units: AppSettings.Default.Units, languageCode: AppSettings.Default.Language, link: null,
                                              hasIcons: false)
                {
                    Currently = weatherDataPoint,
                    Daily     = new[] { weatherDataPoint }
                };
            }

            if (weather?.MaxPublishedDate == null)
            {
                return;
            }

            var actualUtcDate = utcNow > weather.MaxPublishedDate ? weather.MaxPublishedDate.Value : utcNow;
            var currently     = weather.FindActualCurrentlyAsync(actualUtcDate).Result;

            if (currently == null)
            {
                return;
            }

            var temperature = string.Empty;

            using (var weatherTools = new WeatherTools
            {
                ProviderUnits = weather.Units,
            })
            {
                var degree = weatherTools.DegreeString;
                if (currently.Temperature.HasValue)
                {
                    temperature = weatherTools.ConvertTemperatureToString(currently.Temperature.Value, "{0:f0}{1}",
                                                                          degree);
                }
                SetTextFormatted(view, Resource.Id.txtTemp, temperature,
                                 weatherTools.IsTemperatureAlerted(currently.Temperature));

                var minTempText = string.Empty;
                var maxTempText = string.Empty;
                var visibility  = ViewStates.Gone;
                var minTemp     = weatherTools
                                  .CalculateMinTemperatureAsync(actualUtcDate, weather, currently.MinTemperature).Result;
                var maxTemp = weatherTools
                              .CalculateMaxTemperatureAsync(actualUtcDate, weather, currently.MaxTemperature).Result;
                if (minTemp.HasValue && maxTemp.HasValue)
                {
                    minTempText = weatherTools.ConvertTemperatureToString(minTemp.Value, "{0:f0}{1}", degree);
                    maxTempText = weatherTools.ConvertTemperatureToString(maxTemp.Value, "{0:f0}{1}", degree);
                    visibility  = ViewStates.Visible;
                }
                SetTextFormatted(view, Resource.Id.txtLow, minTempText, weatherTools.IsTemperatureAlerted(minTemp));
                view.SetViewVisibility(Resource.Id.txtLowIndicator, visibility);
                SetTextFormatted(view, Resource.Id.txtHigh, maxTempText, weatherTools.IsTemperatureAlerted(maxTemp));
                view.SetViewVisibility(Resource.Id.txtHighIndicator, visibility);

                var conditionIconId = weatherTools.GetConditionIconId(WidgetTypes.AppWidget, settings.WidgetIconStyle,
                                                                      currently, true, true);
                view.SetImageViewResource(Resource.Id.imgCondition, conditionIconId);

                //"Небольшой снегопад "
                SetTextFormatted(view, Resource.Id.txtCondition,
                                 (currently.Condition ?? string.Empty).Trim().ToCapital(),
                                 weatherTools.IsConditionExtreme(currently.WeatherCode));
            }

            var locality = (settings.LocationAddress?.GetDisplayLocality() ?? string.Empty).Trim();

            if (string.IsNullOrEmpty(locality) && isDemoMode)
            {
                locality = context.GetString(settings.UseTrackCurrentLocation
                    ? Resource.String.CurrentLocationEmpty
                    : Resource.String.DemoLocality);
            }
            view.SetTextViewText(Resource.Id.txtLocation, locality);
        }
        /// <summary>
        /// Update the notification.
        /// </summary>
        /// <param name="context">
        /// The context.
        /// </param>
        /// <returns>
        /// The updated notification.
        /// </returns>
        public Notification UpdateNotification(Context context)
        {
            bool hasPausedText = this.PausedText != null;
            bool mustUpdate = this.lastHasPausedText != hasPausedText;

            // Build the RemoteView object
            if (expandedView == null)
            {
                expandedView = new RemoteViews(context.PackageName, Resource.Layout.status_bar_ongoing_event_progress_bar);
                expandedView.SetImageViewResource(Resource.Id.appIcon, this.Icon);
                expandedView.SetTextViewText(Resource.Id.paused_text, this.PausedText);
                expandedView.SetTextViewText(Resource.Id.title, this.Title);

                this.notification.ContentView = expandedView;

                mustUpdate = true;
            }

            if (mustUpdate)
            {
                expandedView.SetViewVisibility(Resource.Id.progress_bar_frame, hasPausedText ? ViewStates.Gone : ViewStates.Visible);
                expandedView.SetViewVisibility(Resource.Id.description, hasPausedText ? ViewStates.Gone : ViewStates.Visible);
                expandedView.SetViewVisibility(Resource.Id.time_remaining, hasPausedText ? ViewStates.Gone : ViewStates.Visible);
                expandedView.SetViewVisibility(Resource.Id.paused_text, hasPausedText ? ViewStates.Visible : ViewStates.Gone);
            }

            if (!hasPausedText)
            {
                expandedView.SetTextViewText(Resource.Id.progress_text, Helpers.GetDownloadProgressPercent(this.CurrentBytes, this.TotalBytes));
                expandedView.SetTextViewText(Resource.Id.description, Helpers.GetDownloadProgressString(this.CurrentBytes, this.TotalBytes));
                expandedView.SetProgressBar(
                    Resource.Id.progress_bar,
                    (int)(this.TotalBytes >> 8),
                    (int)(this.CurrentBytes >> 8),
                    this.TotalBytes <= 0);
                expandedView.SetTextViewText(Resource.Id.time_remaining, string.Format("Time remaining: {0}", Helpers.GetTimeRemaining(this.TimeRemaining)));
            }

            this.lastHasPausedText = hasPausedText;

            return this.notification;
        }