diff --git a/app/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt b/app/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt
index 4b41607b4..31548102e 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt
@@ -22,7 +22,7 @@ import java.util.Locale
// To use plaintext SharedPreferences for debugging, set this to true
// It will only apply in Debug builds
private const val DEBUG_PLAINTEXT_PREFERENCES = false
-private const val OLD_PREFS_FILENAME = "secret_keeper"
+private const val DEBUG_PREFERENCES_NAME = "debug_prefs"
data class AccountInfo(
val npub: String,
@@ -114,7 +114,7 @@ object LocalPreferences {
private fun encryptedPreferences(npub: String? = null): SharedPreferences {
return if (BuildConfig.DEBUG && DEBUG_PLAINTEXT_PREFERENCES) {
- val preferenceFile = if (npub == null) "debug_prefs" else "debug_prefs_$npub"
+ val preferenceFile = if (npub == null) DEBUG_PREFERENCES_NAME else "${DEBUG_PREFERENCES_NAME}_$npub"
Amethyst.instance.getSharedPreferences(preferenceFile, Context.MODE_PRIVATE)
} else {
return EncryptedStorage.preferences(npub)
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AccountSwitchBottomSheet.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AccountSwitchBottomSheet.kt
index d0d8a0010..6b793447d 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AccountSwitchBottomSheet.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AccountSwitchBottomSheet.kt
@@ -80,7 +80,7 @@ fun AccountSwitchBottomSheet(
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically
) {
- Text("Select Account", fontWeight = FontWeight.Bold)
+ Text(stringResource(R.string.account_switch_select_account), fontWeight = FontWeight.Bold)
}
accounts.forEach { acc ->
val current = accountUser.pubkeyNpub() == acc.npub
@@ -92,20 +92,24 @@ fun AccountSwitchBottomSheet(
verticalAlignment = Alignment.CenterVertically
) {
Row(
- modifier = Modifier.weight(1f).clickable {
- accountStateViewModel.switchUser(acc.npub)
- },
+ modifier = Modifier
+ .weight(1f)
+ .clickable {
+ accountStateViewModel.switchUser(acc.npub)
+ },
verticalAlignment = Alignment.CenterVertically
) {
Box(
- modifier = Modifier.width(55.dp).padding(0.dp)
+ modifier = Modifier
+ .width(55.dp)
+ .padding(0.dp)
) {
AsyncImageProxy(
model = ResizeImage(acc.profilePicture, 55.dp),
placeholder = BitmapPainter(RoboHashCache.get(context, acc.npub)),
fallback = BitmapPainter(RoboHashCache.get(context, acc.npub)),
error = BitmapPainter(RoboHashCache.get(context, acc.npub)),
- contentDescription = stringResource(id = R.string.profile_image),
+ contentDescription = stringResource(R.string.profile_image),
modifier = Modifier
.width(55.dp)
.height(55.dp)
@@ -113,19 +117,21 @@ fun AccountSwitchBottomSheet(
)
Box(
- modifier = Modifier.size(20.dp).align(Alignment.TopEnd)
+ modifier = Modifier
+ .size(20.dp)
+ .align(Alignment.TopEnd)
) {
if (acc.hasPrivKey) {
Icon(
imageVector = Icons.Default.Key,
- contentDescription = "Has private key",
+ contentDescription = stringResource(R.string.account_switch_has_private_key),
modifier = Modifier.size(20.dp),
tint = MaterialTheme.colors.primary
)
} else {
Icon(
imageVector = Icons.Default.Visibility,
- contentDescription = "Read only, no private key",
+ contentDescription = stringResource(R.string.account_switch_pubkey_only),
modifier = Modifier.size(20.dp),
tint = MaterialTheme.colors.primary
)
@@ -146,7 +152,7 @@ fun AccountSwitchBottomSheet(
if (current) {
Icon(
imageVector = Icons.Default.RadioButtonChecked,
- contentDescription = "Active account",
+ contentDescription = stringResource(R.string.account_switch_active_account),
tint = MaterialTheme.colors.secondary
)
}
@@ -158,7 +164,7 @@ fun AccountSwitchBottomSheet(
) {
Icon(
imageVector = Icons.Default.Logout,
- contentDescription = "Logout",
+ contentDescription = stringResource(R.string.log_out),
tint = MaterialTheme.colors.onSurface
)
}
@@ -172,7 +178,7 @@ fun AccountSwitchBottomSheet(
verticalAlignment = Alignment.CenterVertically
) {
TextButton(onClick = { popupExpanded = true }) {
- Text("Add New Account")
+ Text(stringResource(R.string.account_switch_add_account_btn))
}
}
}
@@ -186,12 +192,12 @@ fun AccountSwitchBottomSheet(
Box {
LoginPage(accountStateViewModel, isFirstLogin = false)
TopAppBar(
- title = { Text(text = "Add New Account") },
+ title = { Text(text = stringResource(R.string.account_switch_add_account_dialog_title)) },
navigationIcon = {
IconButton(onClick = { popupExpanded = false }) {
Icon(
imageVector = Icons.Default.ArrowBack,
- contentDescription = "Back",
+ contentDescription = stringResource(R.string.back),
tint = MaterialTheme.colors.onSurface
)
}
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/DrawerContent.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/DrawerContent.kt
index 8198b7058..09c1aac42 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/DrawerContent.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/DrawerContent.kt
@@ -53,7 +53,6 @@ import com.vitorpamplona.amethyst.model.Account
import com.vitorpamplona.amethyst.model.User
import com.vitorpamplona.amethyst.ui.components.AsyncImageProxy
import com.vitorpamplona.amethyst.ui.components.ResizeImage
-import com.vitorpamplona.amethyst.ui.screen.AccountStateViewModel
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountBackupDialog
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
import kotlinx.coroutines.launch
@@ -64,8 +63,7 @@ fun DrawerContent(
navController: NavHostController,
scaffoldState: ScaffoldState,
sheetState: ModalBottomSheetState,
- accountViewModel: AccountViewModel,
- accountStateViewModel: AccountStateViewModel
+ accountViewModel: AccountViewModel
) {
val accountState by accountViewModel.accountLiveData.observeAsState()
val account = accountState?.account ?: return
@@ -95,8 +93,7 @@ fun DrawerContent(
sheetState,
modifier = Modifier
.fillMaxWidth()
- .weight(1F),
- accountStateViewModel,
+ .weight(1f),
account
)
@@ -227,7 +224,6 @@ fun ListContent(
scaffoldState: ScaffoldState,
sheetState: ModalBottomSheetState,
modifier: Modifier,
- accountViewModel: AccountStateViewModel,
account: Account
) {
val coroutineScope = rememberCoroutineScope()
@@ -268,18 +264,11 @@ fun ListContent(
Spacer(modifier = Modifier.weight(1f))
IconRow(
- title = "Accounts",
+ title = stringResource(R.string.drawer_accounts),
icon = R.drawable.manage_accounts,
tint = MaterialTheme.colors.onBackground,
onClick = { coroutineScope.launch { sheetState.show() } }
)
-
-// IconRow(
-// title = stringResource(R.string.log_out),
-// icon = R.drawable.ic_logout,
-// tint = MaterialTheme.colors.onBackground,
-// onClick = { accountViewModel.logOff() }
-// )
}
if (backupDialogOpen) {
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/MainScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/MainScreen.kt
index 90fac6a13..ff5f893e7 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/MainScreen.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/MainScreen.kt
@@ -61,7 +61,7 @@ fun MainScreen(accountViewModel: AccountViewModel, accountStateViewModel: Accoun
AppTopBar(navController, scaffoldState, accountViewModel)
},
drawerContent = {
- DrawerContent(navController, scaffoldState, sheetState, accountViewModel, accountStateViewModel)
+ DrawerContent(navController, scaffoldState, sheetState, accountViewModel)
},
floatingActionButton = {
FloatingButton(navController, accountStateViewModel)
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index a10ecee71..9874b9513 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -220,5 +220,13 @@
"<Unable to decrypt private message>\n\nYou were cited in a private/encrypted conversation between %1$s and %2$s."
Delete
Don\'t show again
+ Add New Account
+ Accounts
+ Select Account
+ Add New Account
+ Active account
+ Has private key
+ Read only, no private key
+ Back