-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- api30 미만에 대한 권한 처리가 없었던 부분 추가 - 권한처리가 api 30 을 기점으로 복잡해지므로 splash 과정과 권한 처리를 별도 activity 로 분리 - 프로가드 룰이 없는데 설정되어 있던 부분 수정 (변조로 인한 datastore proto 파일에서 예외 발생) - 헬스커넥트는 api 34 를 기점으로 내부 설치 또는 마켓 설치로 분류되는데, 일부 플레이콘솔 내부테스트에서 브라우저 또는 마켓이 없는 디바이스로 테스트를 하는데 이걸로 리젝 당해서 예외 처리로 수정
- Loading branch information
Showing
13 changed files
with
390 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"version": 3, | ||
"artifactType": { | ||
"type": "APK", | ||
"kind": "Directory" | ||
}, | ||
"applicationId": "com.stepmate.app", | ||
"variantName": "release", | ||
"elements": [ | ||
{ | ||
"type": "SINGLE", | ||
"filters": [], | ||
"attributes": [], | ||
"versionCode": 5, | ||
"versionName": "1.0.0", | ||
"outputFile": "app-release.apk" | ||
} | ||
], | ||
"elementType": "File" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 3 additions & 42 deletions
45
app/src/main/kotlin/com/stepmate/app/ui/StepMateViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,22 @@ | ||
package com.stepmate.app.ui | ||
|
||
import android.content.Context | ||
import android.os.Build | ||
import androidx.lifecycle.SavedStateHandle | ||
import androidx.lifecycle.ViewModel | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import com.stepmate.app.ui.navigation.permission.PermissionRequester | ||
import com.stepmate.domain.usecase.user.GetBodyDataUseCases | ||
import com.stepmate.home.HealthConnector | ||
import com.stepmate.home.HealthConnector.Companion.healthConnectPermissions | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.asStateFlow | ||
import kotlinx.coroutines.flow.first | ||
import kotlinx.coroutines.flow.onEach | ||
import kotlinx.coroutines.flow.update | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
internal class StepMateViewModel @Inject constructor( | ||
@ApplicationContext private val applicationContext: Context, | ||
private val healthConnector: HealthConnector, | ||
private val getBodyDataUseCases: GetBodyDataUseCases, | ||
savedStateHandle: SavedStateHandle, | ||
) : ViewModel() { | ||
|
||
private val _permissionState = MutableStateFlow(false) | ||
val permissionState get() = _permissionState.asStateFlow() | ||
|
||
private val _isBodyDataExist = MutableStateFlow(false) | ||
val isBodyDataExist get() = _isBodyDataExist.asStateFlow() | ||
val isBodyDataExist: Boolean = savedStateHandle["isBodyDataExist"] ?: false | ||
|
||
private val _isNeedReLogin = MutableStateFlow(false) | ||
val isNeedReLogin get() = _isNeedReLogin.asStateFlow() | ||
|
||
suspend fun checkPermission() { | ||
val isNotificationGranted = | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) | ||
PermissionRequester.checkNotification(applicationContext) | ||
else | ||
true | ||
|
||
val isActivityRecognitionGranted = | ||
PermissionRequester.checkActivityRecognition(applicationContext) | ||
|
||
val isExactAlarmGranted = | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) | ||
PermissionRequester.checkExactAlarm(applicationContext) | ||
else | ||
true | ||
|
||
val isHealthConnectGranted = healthConnector.checkPermissions(healthConnectPermissions) | ||
isBodyDataExist() | ||
_permissionState.update { isNotificationGranted && isActivityRecognitionGranted && isExactAlarmGranted && isHealthConnectGranted } | ||
} | ||
|
||
private suspend fun isBodyDataExist() = getBodyDataUseCases().onEach { bodyData -> | ||
_isBodyDataExist.update { bodyData.age != 0 && bodyData.height != 0 && bodyData.weight != 0 } | ||
}.first() | ||
|
||
fun updateIsNeedLogin(bool: Boolean) = _isNeedReLogin.update { bool } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.