-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Feat/#52] 위치 권한 요청 다이얼로그 #72
Merged
+72
−16
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
54 changes: 54 additions & 0 deletions
54
core/utils/feature/src/main/java/com/acon/core/utils/feature/permission/PermissionDialog.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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.acon.core.utils.feature.permission | ||
|
||
import android.Manifest | ||
import android.content.Intent | ||
import android.content.pm.PackageManager | ||
import android.net.Uri | ||
import android.provider.Settings | ||
import androidx.activity.compose.rememberLauncherForActivityResult | ||
import androidx.activity.result.contract.ActivityResultContracts | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.core.content.ContextCompat | ||
import com.acon.core.designsystem.component.dialog.AconOneButtonDialog | ||
import com.acon.core.utils.feature.R | ||
|
||
@Composable | ||
internal fun AconPermissionDialog( | ||
onPermissionGranted: () -> Unit, | ||
modifier: Modifier = Modifier | ||
) { | ||
|
||
val context = LocalContext.current | ||
val settingsLauncher = rememberLauncherForActivityResult( | ||
ActivityResultContracts.StartActivityForResult() | ||
) { | ||
if (ContextCompat.checkSelfPermission( | ||
context, | ||
Manifest.permission.ACCESS_FINE_LOCATION | ||
) == PackageManager.PERMISSION_GRANTED | ||
) { onPermissionGranted() } | ||
} | ||
|
||
AconOneButtonDialog( | ||
title = stringResource(R.string.no_permission_title), | ||
content = stringResource(R.string.no_permission_content), | ||
buttonContent = stringResource(R.string.go_to_setting), | ||
onDismissRequest = {}, | ||
onClickConfirm = { | ||
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply { | ||
data = Uri.parse("package:${context.packageName}") | ||
} | ||
settingsLauncher.launch(intent) | ||
} | ||
) | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun AconPermissionDialogPreview() { | ||
AconPermissionDialog({}) | ||
} |
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,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="no_permission_title">\'acon\'에 대해 위치접근\n 권한이 없습니다</string> | ||
<string name="no_permission_content">설정에서 정확한 위치 권한을 허용해주세요</string> | ||
<string name="go_to_setting">설정으로 가기</string> | ||
</resources> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기서 trigger는 권한을 의미하는 것인가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
권한 요청 다이얼로그를 띄울 조건을 명시해준 것입니다!
사실 좋은 방식은 아닌 것 같은데, 사용하는 측에서 편하려면 (제 머리로는) 이게 최선이었어요 ㅠ_ㅠ