-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace ManageExternalStorage with ReadMedia
add Permission Handling remove GMS and DependencyInfoBlock
- Loading branch information
Showing
8 changed files
with
284 additions
and
64 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
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
81 changes: 81 additions & 0 deletions
81
app/src/main/java/com/bera/whitehole/ui/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,81 @@ | ||
package com.bera.whitehole.ui | ||
|
||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.AlertDialog | ||
import androidx.compose.material3.Divider | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.unit.dp | ||
|
||
@Composable | ||
fun PermissionDialog( | ||
permissionTextProvider: PermissionTextProvider, | ||
isPermanentlyDeclined: Boolean, | ||
onDismiss: () -> Unit, | ||
onOkClick: () -> Unit, | ||
onGoToAppSettingsClick: () -> Unit, | ||
modifier: Modifier = Modifier | ||
) { | ||
AlertDialog( | ||
onDismissRequest = onDismiss, | ||
confirmButton = { | ||
Column( | ||
modifier = Modifier.fillMaxWidth() | ||
) { | ||
Divider() | ||
Text( | ||
text = if(isPermanentlyDeclined) { | ||
"Grant permission" | ||
} else { | ||
"OK" | ||
}, | ||
fontWeight = FontWeight.Bold, | ||
textAlign = TextAlign.Center, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.clickable { | ||
if (isPermanentlyDeclined) { | ||
onGoToAppSettingsClick() | ||
} else { | ||
onOkClick() | ||
} | ||
} | ||
.padding(8.dp) | ||
) | ||
} | ||
}, | ||
title = { | ||
Text(text = "Permission required") | ||
}, | ||
text = { | ||
Text( | ||
text = permissionTextProvider.getDescription( | ||
isPermanentlyDeclined = isPermanentlyDeclined | ||
) | ||
) | ||
}, | ||
modifier = modifier | ||
) | ||
} | ||
|
||
interface PermissionTextProvider { | ||
fun getDescription(isPermanentlyDeclined: Boolean): String | ||
} | ||
|
||
class PhotosPermissionTextProvider: PermissionTextProvider { | ||
override fun getDescription(isPermanentlyDeclined: Boolean): String { | ||
return if(isPermanentlyDeclined) { | ||
"It seems you permanently declined photos permission. " + | ||
"You can go to the app settings to grant it." | ||
} else { | ||
"This app needs access to your photos so that you can back " + | ||
"them up to Telegram." | ||
} | ||
} | ||
} |
Oops, something went wrong.