diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 61121899..7345c535 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -13,7 +13,7 @@ - + diff --git a/app/src/main/java/sopt/motivoo/presentation/home/HomeFragment.kt b/app/src/main/java/sopt/motivoo/presentation/home/HomeFragment.kt index 82695f79..40471ca0 100644 --- a/app/src/main/java/sopt/motivoo/presentation/home/HomeFragment.kt +++ b/app/src/main/java/sopt/motivoo/presentation/home/HomeFragment.kt @@ -12,7 +12,6 @@ import android.provider.Settings import android.transition.TransitionManager import android.view.View import android.view.ViewGroup -import android.widget.Toast import androidx.activity.OnBackPressedCallback import androidx.activity.result.contract.ActivityResultContracts import androidx.core.content.ContextCompat @@ -38,8 +37,8 @@ import timber.log.Timber @AndroidEntryPoint class HomeFragment : BindingFragment(R.layout.fragment_home) { - private var isCreated = false private val viewModel: HomeViewModel by activityViewModels() + lateinit var alarmManager: AlarmManager private val requestHomePermissionRequest = registerForActivityResult( ActivityResultContracts.RequestMultiplePermissions() @@ -54,8 +53,9 @@ class HomeFragment : BindingFragment(R.layout.fragment_home educationGranted = true } } + if (!permissionGranted) { - if (educationGranted) intentAppSettings() // TODO :: 교육용 팝업 + if (educationGranted && viewModel.isMissionChoiceFinished.value == true) intentAppSettings() // TODO :: 교육용 팝업 else permissionDenied() } else { permissionGranted() @@ -64,8 +64,8 @@ class HomeFragment : BindingFragment(R.layout.fragment_home override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - isCreated = true binding.vm = viewModel + alarmManager = context?.getSystemService(Context.ALARM_SERVICE) as AlarmManager backPressed() initHomePermissionsState() @@ -168,25 +168,16 @@ class HomeFragment : BindingFragment(R.layout.fragment_home } private fun checkPermissionIfUnSelectedMission() { - if (viewModel.isMissionChoiceFinished.value == false) { + if (viewModel.isMissionChoiceFinished.value != true) { requestHomePermissionRequest.launch(HOME_REQUIRED_PERMISSIONS) } } private fun checkHomeAlarmPermission(homeState: HomeState.FetchHomeData) { if (checkPermission()) { - val alarmManager = context?.getSystemService(Context.ALARM_SERVICE) as AlarmManager if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { if (!alarmManager.canScheduleExactAlarms()) { - requireContext().showSnackbar( - binding.root, - "자정마다 걸음 수를 초기화하려면 알림 및 리마인더를 허용해주세요.", - "설정으로 이동", - true - ) { - val intent = Intent(Settings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM) - startActivity(intent) - } + requestScheduleExactAlarm() } else { startStepCountService(homeState.homeData.userId.toInt()) } @@ -196,6 +187,18 @@ class HomeFragment : BindingFragment(R.layout.fragment_home } } + private fun requestScheduleExactAlarm() { + requireContext().showSnackbar( + binding.root, + getString(R.string.home_exact_alarm_denied_reminder), + getString(R.string.home_setting), + true + ) { + val intent = Intent(Settings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM) + startActivity(intent) + } + } + private fun handleBackNavStack() { findNavController().currentBackStackEntry?.savedStateHandle?.getLiveData( HOME_STATE_CONFIRM @@ -232,16 +235,6 @@ class HomeFragment : BindingFragment(R.layout.fragment_home } } - override fun onResume() { - super.onResume() - if (isCreated) { - isCreated = false - } else { - initHomePermissionsState() - viewModel.postMissionTodayChoice() - } - } - private fun initHomePermissionsState() { checkPermission().also { if (it) permissionGranted() @@ -256,11 +249,6 @@ class HomeFragment : BindingFragment(R.layout.fragment_home } private fun permissionDenied() { - Toast.makeText( - requireContext(), - "Permission request denied", - Toast.LENGTH_SHORT - ).show() updateBlurEffect() viewModel.isPermissionGranted.value = false } @@ -275,7 +263,6 @@ class HomeFragment : BindingFragment(R.layout.fragment_home binding.motivooOtherPieChart.updateBlurEffect() binding.ivMissionCompleted.updateBlurEffect() binding.ivStepCount.updateBlurEffect() - binding.tvExercisePercent.updateBlurEffect() } private fun removeBlurEffect() { @@ -283,7 +270,6 @@ class HomeFragment : BindingFragment(R.layout.fragment_home binding.motivooOtherPieChart.removeBlurEffect() binding.ivMissionCompleted.removeBlurEffect() binding.ivStepCount.removeBlurEffect() - binding.tvExercisePercent.removeBlurEffect() } private fun navigateToExerciseMethodNotion() { diff --git a/app/src/main/java/sopt/motivoo/presentation/home/service/StepCountService.kt b/app/src/main/java/sopt/motivoo/presentation/home/service/StepCountService.kt index a9aa5ff1..6c9f37e8 100644 --- a/app/src/main/java/sopt/motivoo/presentation/home/service/StepCountService.kt +++ b/app/src/main/java/sopt/motivoo/presentation/home/service/StepCountService.kt @@ -152,7 +152,7 @@ class StepCountService : LifecycleService() { getString(R.string.notification_title, stepCount), getString(R.string.notification_content) ), - ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC + ServiceInfo.FOREGROUND_SERVICE_TYPE_HEALTH ) } else { startForeground( diff --git a/app/src/main/java/sopt/motivoo/presentation/home/viewmodel/HomeViewModel.kt b/app/src/main/java/sopt/motivoo/presentation/home/viewmodel/HomeViewModel.kt index 58299a19..595905df 100644 --- a/app/src/main/java/sopt/motivoo/presentation/home/viewmodel/HomeViewModel.kt +++ b/app/src/main/java/sopt/motivoo/presentation/home/viewmodel/HomeViewModel.kt @@ -38,7 +38,7 @@ class HomeViewModel @Inject constructor( val userType = MutableLiveData() val anotherUserType = MutableLiveData() val isPermissionGranted = MutableLiveData() - val isMissionChoiceFinished = MutableLiveData(false) + val isMissionChoiceFinished = MutableLiveData() val isCompletedStepCount = MutableLiveData() val isCompletedMission = MutableLiveData() val isHighFive = MutableLiveData() diff --git a/app/src/main/java/sopt/motivoo/util/extension/ContextExt.kt b/app/src/main/java/sopt/motivoo/util/extension/ContextExt.kt index ef51fe4e..be9becfc 100644 --- a/app/src/main/java/sopt/motivoo/util/extension/ContextExt.kt +++ b/app/src/main/java/sopt/motivoo/util/extension/ContextExt.kt @@ -79,7 +79,7 @@ fun Context.sendNotification( applicationContext, applicationContext.getString(R.string.step_count_notification_channel_id) ).apply { - setSmallIcon(R.drawable.ic_clap_sound) + setSmallIcon(R.mipmap.ic_motivoo) setContentTitle(title) setContentText(messageBody) setContentIntent(contentPendingIntent) diff --git a/app/src/main/res/drawable/ic_clap_sound.xml b/app/src/main/res/drawable/ic_clap_sound.xml deleted file mode 100644 index 94d6bb5c..00000000 --- a/app/src/main/res/drawable/ic_clap_sound.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/bottom_sheet_home.xml b/app/src/main/res/layout/bottom_sheet_home.xml index bf9e5248..25ce3ffd 100644 --- a/app/src/main/res/layout/bottom_sheet_home.xml +++ b/app/src/main/res/layout/bottom_sheet_home.xml @@ -87,7 +87,7 @@ android:id="@+id/pv_loading" android:layout_width="0dp" android:layout_height="0dp" - android:background="@color/gray_600_7072764d" + android:background="@color/white_FFFFFF4d" android:padding="150dp" android:visibility="invisible" app:layout_constraintBottom_toBottomOf="parent" diff --git a/app/src/main/res/layout/dialog_home_photo.xml b/app/src/main/res/layout/dialog_home_photo.xml index 63811024..320dfa86 100644 --- a/app/src/main/res/layout/dialog_home_photo.xml +++ b/app/src/main/res/layout/dialog_home_photo.xml @@ -35,7 +35,7 @@ android:id="@+id/pv_loading" android:layout_width="0dp" android:layout_height="0dp" - android:background="@color/gray_600_7072764d" + android:background="@color/white_FFFFFF4d" android:padding="150dp" android:visibility="invisible" app:layout_constraintBottom_toBottomOf="parent" diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index 30281d62..47988237 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -166,19 +166,6 @@ app:layout_constraintTop_toTopOf="@id/motivoo_my_pie_chart" app:layout_constraintVertical_bias="0.3" /> - - @@ -250,7 +237,7 @@ android:visibility="@{vm.isPermissionGranted() ? View.GONE : View.VISIBLE}" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@id/tv_exercise_percent" + app:layout_constraintTop_toBottomOf="@id/iv_step_count" tools:visibility="invisible" /> @@ -258,7 +245,7 @@ android:id="@+id/pv_loading" android:layout_width="0dp" android:layout_height="0dp" - android:background="@color/gray_600_7072764d" + android:background="@color/white_FFFFFF4d" android:padding="150dp" android:visibility="invisible" app:layout_constraintBottom_toBottomOf="parent" diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 401d517d..d7748263 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -2,6 +2,7 @@ #090909 #FFFFFF + #4dFFFFFF #FF19A3 #FFE6F5 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ca5e4ae0..f4a4aac5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -66,16 +66,16 @@ 자녀 걸음 오늘의 운동 운동 방법 - 운동 달성률 운동 인증하기 운동 완료 사진 찍기 앨범에서 선택하기 자녀 부모 - 하이파이브 성공! 운동 인증이 완료되었어요! 오늘도 멋지게 운동을 해내셨군요 + 자정마다 걸음 수를 초기화하려면 알림 및 리마인더를 허용해주세요. + 설정으로 이동 motivoo_logo