Exemplo n.º 1
0
 private void AlertFinishRoutine()
 {
     DependencyService.Get <MessageBoxService>().ShowAlert(
         $"{Routine.Name} 루틴 완료!",
         $"총 소요 시간 : {CreateTimeToString.TakenTimeToString(ElapsedTime)}",
         async() =>
     {
         await CloseAllNavigationPage();
         DependencyService.Get <INotifySetter>().CancelFinishHabitNotify();
     });
 }
Exemplo n.º 2
0
        private Notification CreateForNotifyHabitCount(Habit habit, TimeSpan countDown, bool isPause, bool isLastHabit)
        {
            var    context = Application.Context;
            string title   = $"{habit.Name}";
            string message = $"{CreateTimeToString.TimeCountToString(countDown)}";

            var fileName = habit.Image.Replace(".png", string.Empty);
            var imageId  = context.Resources.GetIdentifier(fileName, "drawable", context.PackageName);

            string Btn1String;

            if (isPause)
            {
                Btn1String = "카운트";
            }
            else
            {
                Btn1String = "일시정지";
            }

            string Btn2String;

            if (isLastHabit)
            {
                Btn2String = "완료";
            }
            else
            {
                Btn2String = "다음";
            }

            var actionIntent1 = CreateActionIntent("일시정지", habit.Id);
            var pIntent1      = PendingIntent.GetBroadcast(context, 100, actionIntent1, PendingIntentFlags.OneShot);

            var actionIntent2 = CreateActionIntent(Btn2String, habit.Id);
            var pIntent2      = PendingIntent.GetBroadcast(context, 100, actionIntent2, PendingIntentFlags.OneShot);

            var notificationBuilder = new NotificationCompat.Builder(context, COUNT_NOTIFICATION_CHANNEL_ID);
            var notification        = notificationBuilder.SetOngoing(false)
                                      .SetSmallIcon(imageId)
                                      .SetContentTitle(title)
                                      .SetContentText(message)
                                      .SetVibrate(new long[] { -1 })
                                      .SetPriority((int)NotificationImportance.Default)
                                      .SetVisibility(NotificationCompat.VisibilityPublic)
                                      .SetContentIntent(OpenAppIntent())
                                      .SetAutoCancel(false)
                                      .AddAction(0, Btn1String, pIntent1)
                                      .AddAction(0, Btn2String, pIntent2)
                                      .Build();

            return(notification);
        }
Exemplo n.º 3
0
 private void AskIfYouWantStart()
 {
     DependencyService.Get <MessageBoxService>().ShowConfirm(
         $"{Routine.Name} 루틴 시작",
         $"예상 소요 시간 {CreateTimeToString.TakenTimeToString(Routine.TotalTime)}",
         async() =>
     {
         await PopRoutineActionPage();
     },
         () =>
     {
         IsCounting = true;
     });
 }
Exemplo n.º 4
0
        private async Task Save()
        {
            Name = Name.TrimStart().TrimEnd();

            if (string.IsNullOrEmpty(Name))
            {
                await Application.Current.MainPage.DisplayAlert("", StringResources.ForgotRoutineName, StringResources.OK);
            }
            else if (!DaysOfWeek.GetHasADayBeenSelected(Routine.Days))
            {
                await Application.Current.MainPage.DisplayAlert("", StringResources.ForgotRoutineDays, StringResources.OK);
            }
            else if (HasNoHabit)
            {
                await Application.Current.MainPage.DisplayAlert("", StringResources.ForgotHabit, StringResources.OK);
            }
            else
            {
                if (Routine.Id == 0)
                {
                    Routine.Index = App.RoutineService.Routines.Count;
                }
                var id = App.RoutineService.SaveRoutine(Routine);

                foreach (var habit in Habits)
                {
                    habit.RoutineId = id;
                }
                App.HabitService.SaveHabits(Habits);

                foreach (var habit in HabitsForDelete)
                {
                    if (habit.Id != 0)
                    {
                        App.HabitService.DeleteHabit(habit.Id);
                    }
                }

                await ClosePopup();

                var diffString = CreateTimeToString.CreateTimeRemainingString(Routine.NextAlarmTime);
                DependencyService.Get <IToastService>().Show(diffString);
            }
        }
Exemplo n.º 5
0
        private Notification CreateForNotifyFinishHabit(Routine routine, TimeSpan ElapsedTime)
        {
            var    context = Application.Context;
            string title   = $"{routine.Name} 완료";
            string message = $"{CreateTimeToString.TakenTimeToString(ElapsedTime)} 경과";

            var notificationBuilder = new NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID);
            var notification        = notificationBuilder.SetOngoing(false)
                                      .SetSmallIcon(Resource.Drawable.ic_miracle_routine_mini)
                                      .SetContentTitle(title)
                                      .SetContentText(message)
                                      .SetPriority((int)NotificationImportance.High)
                                      .SetVisibility(NotificationCompat.VisibilityPublic)
                                      .SetVibrate(vibrationPattern)
                                      .SetContentIntent(OpenAppIntent())
                                      .SetAutoCancel(true)
                                      .Build();

            return(notification);
        }
Exemplo n.º 6
0
        public void OnIsActiveChanged()
        {
            try
            {
                if (IsInitFinished)
                {
                    App.RoutineService.SaveRoutineAtLocal(this);

                    if (IsActive)
                    {
                        var diffString = CreateTimeToString.CreateTimeRemainingString(NextAlarmTime);
                        DependencyService.Get <IToastService>().Show(diffString);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"{e.Message}");
                Console.WriteLine($"{e.StackTrace}");
                Console.WriteLine($"{e.Data}");
                Console.WriteLine("OnIsActiveChangedException");
            }
        }