Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QA] 홈 뷰 QA 1차 #136

Merged
merged 10 commits into from
Apr 1, 2024
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_HEALTH" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />

Expand Down
50 changes: 18 additions & 32 deletions app/src/main/java/sopt/motivoo/presentation/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -38,8 +37,8 @@ import timber.log.Timber

@AndroidEntryPoint
class HomeFragment : BindingFragment<FragmentHomeBinding>(R.layout.fragment_home) {
private var isCreated = false
private val viewModel: HomeViewModel by activityViewModels()
lateinit var alarmManager: AlarmManager

private val requestHomePermissionRequest = registerForActivityResult(
ActivityResultContracts.RequestMultiplePermissions()
Expand All @@ -54,8 +53,9 @@ class HomeFragment : BindingFragment<FragmentHomeBinding>(R.layout.fragment_home
educationGranted = true
}
}

if (!permissionGranted) {
if (educationGranted) intentAppSettings() // TODO :: 교육용 팝업
if (educationGranted && viewModel.isMissionChoiceFinished.value == true) intentAppSettings() // TODO :: 교육용 팝업
else permissionDenied()
} else {
permissionGranted()
Expand All @@ -64,8 +64,8 @@ class HomeFragment : BindingFragment<FragmentHomeBinding>(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()
Expand Down Expand Up @@ -168,25 +168,16 @@ class HomeFragment : BindingFragment<FragmentHomeBinding>(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())
}
Expand All @@ -196,6 +187,18 @@ class HomeFragment : BindingFragment<FragmentHomeBinding>(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<Int>(
HOME_STATE_CONFIRM
Expand Down Expand Up @@ -232,16 +235,6 @@ class HomeFragment : BindingFragment<FragmentHomeBinding>(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()
Expand All @@ -256,11 +249,6 @@ class HomeFragment : BindingFragment<FragmentHomeBinding>(R.layout.fragment_home
}

private fun permissionDenied() {
Toast.makeText(
requireContext(),
"Permission request denied",
Toast.LENGTH_SHORT
).show()
updateBlurEffect()
viewModel.isPermissionGranted.value = false
}
Expand All @@ -275,15 +263,13 @@ class HomeFragment : BindingFragment<FragmentHomeBinding>(R.layout.fragment_home
binding.motivooOtherPieChart.updateBlurEffect()
binding.ivMissionCompleted.updateBlurEffect()
binding.ivStepCount.updateBlurEffect()
binding.tvExercisePercent.updateBlurEffect()
}

private fun removeBlurEffect() {
binding.motivooMyPieChart.removeBlurEffect()
binding.motivooOtherPieChart.removeBlurEffect()
binding.ivMissionCompleted.removeBlurEffect()
binding.ivStepCount.removeBlurEffect()
binding.tvExercisePercent.removeBlurEffect()
}

private fun navigateToExerciseMethodNotion() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class HomeViewModel @Inject constructor(
val userType = MutableLiveData<MotivooUserType>()
val anotherUserType = MutableLiveData<MotivooUserType>()
val isPermissionGranted = MutableLiveData<Boolean>()
val isMissionChoiceFinished = MutableLiveData<Boolean>(false)
val isMissionChoiceFinished = MutableLiveData<Boolean>()
val isCompletedStepCount = MutableLiveData<Boolean>()
val isCompletedMission = MutableLiveData<Boolean>()
val isHighFive = MutableLiveData<Boolean>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
25 changes: 0 additions & 25 deletions app/src/main/res/drawable/ic_clap_sound.xml

This file was deleted.

2 changes: 1 addition & 1 deletion app/src/main/res/layout/bottom_sheet_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/dialog_home_photo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
21 changes: 4 additions & 17 deletions app/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,19 +166,6 @@
app:layout_constraintTop_toTopOf="@id/motivoo_my_pie_chart"
app:layout_constraintVertical_bias="0.3" />

<TextView
android:id="@+id/tv_exercise_percent"
style="@style/Caption2_re"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{vm.isHighFive() ? @string/home_success_hifive : @string/home_exercise_percent}"
android:textColor="@{vm.isHighFive() ? @color/red_400_FF6259 : @color/gray_600_707276}"
app:layout_constraintBottom_toBottomOf="@+id/iv_step_count"
app:layout_constraintEnd_toEndOf="@id/iv_step_count"
app:layout_constraintStart_toStartOf="@id/iv_step_count"
app:layout_constraintTop_toTopOf="@id/iv_step_count"
app:layout_constraintVertical_bias="1.1" />

<com.android.motivoo_design.MotivooOtherPieChart
android:id="@+id/motivoo_other_pie_chart"
iconEnabled="@{vm.isHighFive}"
Expand Down Expand Up @@ -211,12 +198,12 @@
android:id="@+id/motivoo_selected_mission_step_count_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="48dp"
android:layout_marginTop="56dp"
android:paddingHorizontal="16dp"
android:visibility="@{vm.isPermissionGranted() ? View.VISIBLE : View.GONE}"
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"
app:myStepCountText="@{String.valueOf(vm.stepCount)}"
app:otherStepCountText="@{String.valueOf(vm.otherStepCount)}"
app:userType="@{vm.userType}" />
Expand Down Expand Up @@ -250,15 +237,15 @@
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" />
</androidx.constraintlayout.widget.ConstraintLayout>

<ProgressBar
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"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<resources>
<color name="black_090909">#090909</color>
<color name="white_FFFFFF">#FFFFFF</color>
<color name="white_FFFFFF4d">#4dFFFFFF</color>
<color name="pink_FF19A3">#FF19A3</color>
<color name="pink_100_FFE6F5">#FFE6F5</color>
<!--Red-->
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@
<string name="home_child_step_count">자녀 걸음</string>
<string name="home_today_exercise">오늘의 운동</string>
<string name="home_exercise_method">운동 방법</string>
<string name="home_exercise_percent">운동 달성률</string>
<string name="home_verify_exercise">운동 인증하기</string>
<string name="home_success">운동 완료</string>
<string name="home_bottom_sheet_take_photo">사진 찍기</string>
<string name="home_bottom_sheet_select_in_album">앨범에서 선택하기</string>
<string name="home_child">자녀</string>
<string name="home_parent">부모</string>
<string name="home_success_hifive">하이파이브 성공!</string>
<string name="verify_exercise">운동 인증이 완료되었어요!</string>
<string name="verify_exercise_description">오늘도 멋지게 운동을 해내셨군요</string>
<string name="home_exact_alarm_denied_reminder">자정마다 걸음 수를 초기화하려면 알림 및 리마인더를 허용해주세요.</string>
<string name="home_setting">설정으로 이동</string>
<string name="motivoo_logo">motivoo_logo</string>

<!-- my page -->
Expand Down
Loading