Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Pururun committed Apr 8, 2024
1 parent 08e69a0 commit 653b6b9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4,978 deletions.
3 changes: 3 additions & 0 deletions android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,9 @@ dependencies {
implementation(Dependencies.Kotlin.stdlib)
implementation(Dependencies.KotlinX.coroutinesAndroid)

// Accompanist
implementation("com.google.accompanist:accompanist-permissions:0.34.0")

// UI tooling
implementation(Dependencies.Compose.uiToolingPreview)
debugImplementation(Dependencies.Compose.uiTooling)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package net.mullvad.mullvadvpn.compose.screen

import android.Manifest
import android.os.Build
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.navigation.NavHostController
import com.google.accompanist.permissions.ExperimentalPermissionsApi
import com.google.accompanist.permissions.PermissionStatus
import com.google.accompanist.permissions.rememberPermissionState
import com.ramcosta.composedestinations.DestinationsNavHost
import com.ramcosta.composedestinations.navigation.navigate
import com.ramcosta.composedestinations.navigation.popBackStack
Expand All @@ -28,7 +34,7 @@ import org.koin.androidx.compose.koinViewModel

private val changeLogDestinations = listOf(ConnectDestination, OutOfTimeDestination)

@OptIn(ExperimentalComposeUiApi::class)
@OptIn(ExperimentalComposeUiApi::class, ExperimentalPermissionsApi::class)
@Composable
fun MullvadApp() {
val engine = rememberNavHostEngine()
Expand Down Expand Up @@ -68,4 +74,18 @@ fun MullvadApp() {

navController.navigate(ChangelogDestination(it).route)
}

// Globally request notification permission
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
val notificationPermissionState =
rememberPermissionState(Manifest.permission.POST_NOTIFICATIONS)
when (notificationPermissionState.status) {
is PermissionStatus.Denied -> {
SideEffect { notificationPermissionState.launchPermissionRequest() }
}
PermissionStatus.Granted -> {
// Do nothing
}
}
}
}
Loading

0 comments on commit 653b6b9

Please sign in to comment.