summaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt53
-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
3 files changed, 87 insertions, 2 deletions
diff --git a/app/src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt b/app/src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt
new file mode 100644
index 00000000..fd2369e0
--- /dev/null
+++ b/app/src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt
@@ -0,0 +1,53 @@
+package app.passwordstore.ui.pgp
+
+import androidx.compose.foundation.clickable
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.lazy.LazyColumn
+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
+fun KeyList(
+ identifiers: List<GpgIdentifier>,
+ onItemClick: (identifier: GpgIdentifier) -> Unit,
+ modifier: Modifier = Modifier,
+) {
+ LazyColumn(modifier = modifier) {
+ items(identifiers) { identifier ->
+ KeyItem(identifier = identifier, modifier = Modifier.clickable { onItemClick(identifier) })
+ }
+ }
+}
+
+@Composable
+private fun KeyItem(
+ identifier: GpgIdentifier,
+ modifier: Modifier = Modifier,
+) {
+ val label =
+ when (identifier) {
+ is GpgIdentifier.KeyId -> identifier.id.toString()
+ is GpgIdentifier.UserId -> identifier.email
+ }
+ 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>