aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/build.gradle.kts1
-rw-r--r--app/src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt (renamed from ui-compose/src/main/kotlin/app/passwordstore/ui/pgp/PGPKeyList.kt)16
-rw-r--r--app/src/main/java/app/passwordstore/ui/pgp/PGPKeyListActivity.kt21
-rw-r--r--app/src/main/res/drawable/ic_arrow_back_black_24dp.xml15
-rw-r--r--ui-compose/build.gradle.kts1
-rw-r--r--ui-compose/src/main/kotlin/app/passwordstore/ui/APSAppBar.kt36
-rw-r--r--ui-compose/src/main/kotlin/app/passwordstore/ui/compose/theme/Theme.kt15
-rw-r--r--ui-compose/src/main/kotlin/app/passwordstore/ui/compose/theme/utils.kt27
8 files changed, 117 insertions, 15 deletions
diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 8d0bc6f6..32291d33 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -76,6 +76,7 @@ dependencies {
implementation(libs.androidx.recyclerviewSelection)
implementation(libs.androidx.security)
implementation(libs.androidx.swiperefreshlayout)
+ implementation(libs.compose.ui.tooling)
implementation(libs.dagger.hilt.android)
implementation(libs.kotlin.coroutines.android)
diff --git a/ui-compose/src/main/kotlin/app/passwordstore/ui/pgp/PGPKeyList.kt b/app/src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt
index ccc6fa01..fd2369e0 100644
--- a/ui-compose/src/main/kotlin/app/passwordstore/ui/pgp/PGPKeyList.kt
+++ b/app/src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt
@@ -9,11 +9,12 @@ import androidx.compose.foundation.lazy.items
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
+import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import app.passwordstore.crypto.GpgIdentifier
@Composable
-public fun KeyList(
+fun KeyList(
identifiers: List<GpgIdentifier>,
onItemClick: (identifier: GpgIdentifier) -> Unit,
modifier: Modifier = Modifier,
@@ -37,3 +38,16 @@ private fun KeyItem(
}
Box(modifier = modifier.padding(16.dp).fillMaxWidth()) { Text(text = label) }
}
+
+@Preview
+@Composable
+private fun KeyListPreview() {
+ KeyList(
+ identifiers =
+ listOfNotNull(
+ GpgIdentifier.fromString("john.doe@example.com"),
+ GpgIdentifier.fromString("0xB950AE2813841585")
+ ),
+ onItemClick = {}
+ )
+}
diff --git a/app/src/main/java/app/passwordstore/ui/pgp/PGPKeyListActivity.kt b/app/src/main/java/app/passwordstore/ui/pgp/PGPKeyListActivity.kt
index 3cce4060..4394cff6 100644
--- a/app/src/main/java/app/passwordstore/ui/pgp/PGPKeyListActivity.kt
+++ b/app/src/main/java/app/passwordstore/ui/pgp/PGPKeyListActivity.kt
@@ -6,10 +6,17 @@ import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.ExperimentalMaterial3Api
+import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.res.painterResource
+import androidx.compose.ui.res.stringResource
+import app.passwordstore.R
+import app.passwordstore.ui.APSAppBar
import app.passwordstore.ui.compose.theme.APSTheme
+import app.passwordstore.ui.compose.theme.decideColorScheme
import app.passwordstore.util.viewmodel.PGPKeyListViewModel
import dagger.hilt.android.AndroidEntryPoint
@@ -22,8 +29,18 @@ class PGPKeyListActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
- APSTheme {
- Scaffold { paddingValues ->
+ val context = LocalContext.current
+ APSTheme(colors = decideColorScheme(context)) {
+ Scaffold(
+ topBar = {
+ APSAppBar(
+ title = stringResource(R.string.activity_label_pgp_key_manager),
+ navigationIcon = painterResource(R.drawable.ic_arrow_back_black_24dp),
+ onNavigationIconClick = { finish() },
+ backgroundColor = MaterialTheme.colorScheme.surface,
+ )
+ },
+ ) { paddingValues ->
PGPKeyList(viewModel = viewModel, modifier = Modifier.padding(paddingValues))
}
}
diff --git a/app/src/main/res/drawable/ic_arrow_back_black_24dp.xml b/app/src/main/res/drawable/ic_arrow_back_black_24dp.xml
new file mode 100644
index 00000000..6cf467d6
--- /dev/null
+++ b/app/src/main/res/drawable/ic_arrow_back_black_24dp.xml
@@ -0,0 +1,15 @@
+<!--
+ ~ Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
+ ~ SPDX-License-Identifier: GPL-3.0-only
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:tint="?attr/colorControlNormal"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z" />
+</vector>
diff --git a/ui-compose/build.gradle.kts b/ui-compose/build.gradle.kts
index 8dfee593..8f874f62 100644
--- a/ui-compose/build.gradle.kts
+++ b/ui-compose/build.gradle.kts
@@ -20,5 +20,4 @@ dependencies {
api(libs.compose.foundation.layout)
api(libs.compose.material3)
api(libs.compose.ui.core)
- implementation(projects.cryptoPgpainless)
}
diff --git a/ui-compose/src/main/kotlin/app/passwordstore/ui/APSAppBar.kt b/ui-compose/src/main/kotlin/app/passwordstore/ui/APSAppBar.kt
new file mode 100644
index 00000000..6900b25f
--- /dev/null
+++ b/ui-compose/src/main/kotlin/app/passwordstore/ui/APSAppBar.kt
@@ -0,0 +1,36 @@
+package app.passwordstore.ui
+
+import androidx.compose.material3.Icon
+import androidx.compose.material3.IconButton
+import androidx.compose.material3.SmallTopAppBar
+import androidx.compose.material3.Text
+import androidx.compose.material3.TopAppBarDefaults
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.painter.Painter
+
+@Composable
+public fun APSAppBar(
+ title: String,
+ backgroundColor: Color,
+ navigationIcon: Painter?,
+ onNavigationIconClick: (() -> Unit)?,
+ modifier: Modifier = Modifier,
+) {
+ SmallTopAppBar(
+ title = { Text(text = title) },
+ navigationIcon = {
+ if (navigationIcon != null) {
+ IconButton(onClick = { onNavigationIconClick?.invoke() }) {
+ Icon(
+ painter = navigationIcon,
+ contentDescription = null,
+ )
+ }
+ }
+ },
+ colors = TopAppBarDefaults.smallTopAppBarColors(containerColor = backgroundColor),
+ modifier = modifier,
+ )
+}
diff --git a/ui-compose/src/main/kotlin/app/passwordstore/ui/compose/theme/Theme.kt b/ui-compose/src/main/kotlin/app/passwordstore/ui/compose/theme/Theme.kt
index 9bd8003e..695ff6cc 100644
--- a/ui-compose/src/main/kotlin/app/passwordstore/ui/compose/theme/Theme.kt
+++ b/ui-compose/src/main/kotlin/app/passwordstore/ui/compose/theme/Theme.kt
@@ -1,12 +1,12 @@
package app.passwordstore.ui.compose.theme
-import androidx.compose.foundation.isSystemInDarkTheme
+import androidx.compose.material3.ColorScheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
-private val LightThemeColors =
+internal val LightThemeColors =
lightColorScheme(
primary = md_theme_light_primary,
onPrimary = md_theme_light_onPrimary,
@@ -34,7 +34,7 @@ private val LightThemeColors =
inverseOnSurface = md_theme_light_inverseOnSurface,
inverseSurface = md_theme_light_inverseSurface,
)
-private val DarkThemeColors =
+internal val DarkThemeColors =
darkColorScheme(
primary = md_theme_dark_primary,
onPrimary = md_theme_dark_onPrimary,
@@ -65,15 +65,8 @@ private val DarkThemeColors =
@Composable
public fun APSTheme(
- useDarkTheme: Boolean = isSystemInDarkTheme(),
+ colors: ColorScheme,
content: @Composable () -> Unit,
) {
- val colors =
- if (!useDarkTheme) {
- LightThemeColors
- } else {
- DarkThemeColors
- }
-
MaterialTheme(colorScheme = colors, typography = AppTypography, content = content)
}
diff --git a/ui-compose/src/main/kotlin/app/passwordstore/ui/compose/theme/utils.kt b/ui-compose/src/main/kotlin/app/passwordstore/ui/compose/theme/utils.kt
new file mode 100644
index 00000000..096862dc
--- /dev/null
+++ b/ui-compose/src/main/kotlin/app/passwordstore/ui/compose/theme/utils.kt
@@ -0,0 +1,27 @@
+package app.passwordstore.ui.compose.theme
+
+import android.content.Context
+import android.os.Build
+import androidx.compose.foundation.isSystemInDarkTheme
+import androidx.compose.material3.ColorScheme
+import androidx.compose.material3.dynamicDarkColorScheme
+import androidx.compose.material3.dynamicLightColorScheme
+import androidx.compose.runtime.Composable
+
+@Composable
+public fun decideColorScheme(context: Context): ColorScheme {
+ val isDarkTheme = isSystemInDarkTheme()
+ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
+ if (isDarkTheme) {
+ dynamicDarkColorScheme(context)
+ } else {
+ dynamicLightColorScheme(context)
+ }
+ } else {
+ if (isDarkTheme) {
+ DarkThemeColors
+ } else {
+ LightThemeColors
+ }
+ }
+}