Skip to content

Commit

Permalink
Don't show compose/import if no permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
oblakr24 committed Jun 13, 2023
1 parent 35e0625 commit 29c59b9
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 18 deletions.
3 changes: 0 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ dependencies {
// KotlinX Serialization
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0"

// SimpleXML parser
implementation group: 'org.simpleframework', name: 'simple-xml', version: '2.7.1'

// SMS-MMS parsing lib, used for MMS
implementation 'com.klinkerapps:android-smsmms:5.2.6'

Expand Down
26 changes: 15 additions & 11 deletions app/src/main/java/com/rokoblak/chatbackup/home/HomeDrawer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.rokoblak.chatbackup.ui.theme.LocalTypography
data class HomeDrawerUIState(
val darkMode: Boolean?,
val showDefaultSMSLabel: Boolean,
val showComposeAndImport: Boolean,
val versionLabel: String,
)

Expand All @@ -34,16 +35,18 @@ fun HomeDrawer(
.padding(top = 16.dp)
.fillMaxWidth(), horizontalAlignment = Alignment.Start
) {
ButtonWithIcon(modifier = Modifier.padding(horizontal = 16.dp),
text = "Compose",
icon = Icons.Filled.Message,
onClick = { onAction(HomeAction.ComposeClicked) })
Spacer(modifier = Modifier.height(8.dp))
ButtonWithIcon(modifier = Modifier.padding(horizontal = 16.dp),
text = "Import",
icon = Icons.Filled.OpenInNew,
onClick = { onAction(HomeAction.ImportClicked) })
Spacer(modifier = Modifier.height(8.dp))
if (state.showComposeAndImport) {
ButtonWithIcon(modifier = Modifier.padding(horizontal = 16.dp),
text = "Compose",
icon = Icons.Filled.Message,
onClick = { onAction(HomeAction.ComposeClicked) })
Spacer(modifier = Modifier.height(8.dp))
ButtonWithIcon(modifier = Modifier.padding(horizontal = 16.dp),
text = "Import",
icon = Icons.Filled.OpenInNew,
onClick = { onAction(HomeAction.ImportClicked) })
Spacer(modifier = Modifier.height(8.dp))
}
ButtonWithIcon(modifier = Modifier.padding(horizontal = 16.dp),
text = "FAQ",
icon = Icons.Filled.QuestionAnswer,
Expand Down Expand Up @@ -124,7 +127,8 @@ private fun HomeDrawerPreview() {
HomeDrawerUIState(
darkMode = darkMode,
showDefaultSMSLabel = false,
versionLabel = "Version 1.0.0"
versionLabel = "Version 1.0.0",
showComposeAndImport = true,
),
onAction = {})
}
Expand Down
16 changes: 13 additions & 3 deletions app/src/main/java/com/rokoblak/chatbackup/home/HomeScaffold.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ fun HomeScaffold(
@Composable
private fun HomeScaffoldPreview() {
val drawerOpenState = DrawerValue.Closed
val drawerState = HomeDrawerUIState(darkMode = true, showDefaultSMSLabel = true, versionLabel = "Version 1.0.0")
val drawerState = HomeDrawerUIState(
darkMode = true,
showDefaultSMSLabel = true,
versionLabel = "Version 1.0.0",
showComposeAndImport = true
)
val appbarState = HomeAppbarUIState(
hideIcons = false,
showEdit = false,
Expand All @@ -89,9 +94,14 @@ private fun HomeScaffoldPreview() {
appbarState,
drawerState,
HomeContentUIPermissionsState.PermissionsGiven(
HomeContentUIState(title = "title", subtitle = "subtitle", exportEnabled = true, state)
HomeContentUIState(
title = "title",
subtitle = "subtitle",
exportEnabled = true,
state
)
)
),
onAction = {}, onLaunchPermissions = {})
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ class HomeViewModel @Inject constructor(
val drawerState = HomeDrawerUIState(
darkMode = settings.darkMode,
showDefaultSMSLabel = perms.isDefaultSMSHandlerApp,
versionLabel = "Version ${BuildConfig.VERSION_NAME}(${BuildConfig.VERSION_CODE})"
versionLabel = "Version ${BuildConfig.VERSION_NAME}(${BuildConfig.VERSION_CODE})",
showComposeAndImport = perms.hasPermissions
)

val conversations = if (perms.hasPermissions) {
Expand Down

0 comments on commit 29c59b9

Please sign in to comment.