Localization
This commit is contained in:
parent
3f09577411
commit
3d6fe3bcb2
8 changed files with 51 additions and 15 deletions
|
@ -56,6 +56,10 @@ android {
|
|||
excludes += "/META-INF/{AL2.0,LGPL2.1}"
|
||||
}
|
||||
}
|
||||
|
||||
androidResources {
|
||||
generateLocaleConfig = true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
|
|
@ -46,6 +46,7 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.compose.ui.draw.rotate
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.input.ImeAction
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
|
@ -262,7 +263,7 @@ fun AddWalletButton(
|
|||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Filled.Add,
|
||||
contentDescription = "Add wallet",
|
||||
contentDescription = stringResource(R.string.home_add_wallet),
|
||||
modifier = Modifier.rotate(angle)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -18,7 +18,9 @@ import androidx.compose.runtime.mutableStateOf
|
|||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import eu.m724.coincounter.R
|
||||
import eu.m724.coincounter.ui.theme.CoinCounterTheme
|
||||
import eu.m724.coincounter.wallet.compose.TransactionDialog
|
||||
import eu.m724.coincounter.wallet.compose.WalletActivityView
|
||||
|
@ -52,7 +54,10 @@ class WalletActivity : ComponentActivity() {
|
|||
FloatingActionButton(onClick = {
|
||||
transactionDialogShown = true
|
||||
}) {
|
||||
Icon(Icons.Filled.Create, "New transaction")
|
||||
Icon(
|
||||
imageVector = Icons.Filled.Create,
|
||||
contentDescription = stringResource(R.string.wallet_new_transaction)
|
||||
)
|
||||
}
|
||||
}
|
||||
) { innerPadding ->
|
||||
|
|
|
@ -34,6 +34,7 @@ import androidx.compose.ui.focus.focusRequester
|
|||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.input.ImeAction
|
||||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
|
@ -87,7 +88,7 @@ fun TransactionDialog(
|
|||
.weight(1f)
|
||||
.focusRequester(firstFocus)
|
||||
.focusProperties { next = secondFocus },
|
||||
supportingText = { Text("Label") },
|
||||
supportingText = { Text(stringResource(R.string.create_transaction_label)) },
|
||||
keyboardOptions = KeyboardOptions.Default.copy(
|
||||
imeAction = ImeAction.Next
|
||||
),
|
||||
|
@ -106,7 +107,7 @@ fun TransactionDialog(
|
|||
.focusRequester(secondFocus),
|
||||
supportingText = {
|
||||
Text(
|
||||
text = "Value",
|
||||
text = stringResource(R.string.create_transaction_value),
|
||||
color = if (!valueValid) MaterialTheme.colorScheme.error else Color.Unspecified
|
||||
)
|
||||
},
|
||||
|
@ -117,7 +118,11 @@ fun TransactionDialog(
|
|||
isError = !valueValid,
|
||||
trailingIcon = {
|
||||
if (!valueValid)
|
||||
Icon(painterResource(id = R.drawable.baseline_error_24), "error", tint = MaterialTheme.colorScheme.error)
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.baseline_error_24),
|
||||
contentDescription = stringResource(R.string.create_transaction_value_error),
|
||||
tint = MaterialTheme.colorScheme.error
|
||||
)
|
||||
},
|
||||
singleLine = true
|
||||
)
|
||||
|
@ -129,7 +134,7 @@ fun TransactionDialog(
|
|||
checked = absoluteChecked,
|
||||
onCheckedChange = { absoluteChecked = it }
|
||||
)
|
||||
Text(text = "Absolute")
|
||||
Text(text = stringResource(R.string.create_transaction_absolute))
|
||||
}
|
||||
}
|
||||
Row(
|
||||
|
@ -142,7 +147,7 @@ fun TransactionDialog(
|
|||
onDismiss()
|
||||
}
|
||||
) {
|
||||
Text(text = "Cancel")
|
||||
Text(text = stringResource(R.string.create_transaction_cancel))
|
||||
}
|
||||
TextButton(
|
||||
onClick = {
|
||||
|
@ -150,11 +155,12 @@ fun TransactionDialog(
|
|||
if (doubleValue != null) {
|
||||
onConfirm(label, (doubleValue * 100).toInt(), absoluteChecked) // TODO handle fixed point
|
||||
} else {
|
||||
Toast.makeText(context, "Value is not a number", Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context,
|
||||
context.getString(R.string.create_transaction_nan), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
) {
|
||||
Text("Create transaction")
|
||||
Text(stringResource(R.string.create_transaction_confirm))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,10 @@ import androidx.compose.material3.Text
|
|||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.Dialog
|
||||
import eu.m724.coincounter.R
|
||||
|
||||
/**
|
||||
* A dialog that's shown when you long click on wallet name
|
||||
|
@ -37,13 +39,13 @@ fun ActionsDialog(
|
|||
modifier = Modifier.padding(16.dp)
|
||||
) {
|
||||
TextButton(onClick = onRename) {
|
||||
Text("Rename wallet")
|
||||
Text(stringResource(R.string.wallet_actions_rename))
|
||||
}
|
||||
TextButton(onClick = onDelete) {
|
||||
Text("Delete wallet")
|
||||
Text(stringResource(R.string.wallet_actions_delete))
|
||||
}
|
||||
TextButton(onClick = onDismiss) {
|
||||
Text("Cancel")
|
||||
Text(stringResource(R.string.wallet_actions_cancel))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,10 @@ import androidx.compose.runtime.setValue
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.Dialog
|
||||
import eu.m724.coincounter.R
|
||||
|
||||
@Composable
|
||||
fun RenameDialog(
|
||||
|
@ -52,7 +54,7 @@ fun RenameDialog(
|
|||
.fillMaxWidth()
|
||||
.weight(1f)
|
||||
.focusRequester(focusRequester),
|
||||
supportingText = { Text("New name") },
|
||||
supportingText = { Text(stringResource(R.string.wallet_rename_name)) },
|
||||
singleLine = true
|
||||
)
|
||||
}
|
||||
|
@ -66,14 +68,14 @@ fun RenameDialog(
|
|||
onDismiss()
|
||||
}
|
||||
) {
|
||||
Text(text = "Cancel")
|
||||
Text(text = stringResource(R.string.wallet_rename_cancel))
|
||||
}
|
||||
TextButton(
|
||||
onClick = {
|
||||
onRename(value)
|
||||
}
|
||||
) {
|
||||
Text("Rename")
|
||||
Text(stringResource(R.string.wallet_rename_confirm))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
1
app/src/main/res/resources.properties
Normal file
1
app/src/main/res/resources.properties
Normal file
|
@ -0,0 +1 @@
|
|||
unqualifiedResLocale=en
|
|
@ -2,4 +2,19 @@
|
|||
<string name="app_name">Coin Counter</string>
|
||||
<string name="title_activity_main">Coin Counter</string>
|
||||
<string name="title_activity_wallet">WalletActivity</string>
|
||||
<string name="create_transaction_confirm">Create transaction</string>
|
||||
<string name="create_transaction_nan">Value must be a number</string>
|
||||
<string name="create_transaction_cancel">Cancel</string>
|
||||
<string name="create_transaction_absolute">Absolute</string>
|
||||
<string name="create_transaction_value_error">Error</string>
|
||||
<string name="create_transaction_value">Value</string>
|
||||
<string name="create_transaction_label">Label</string>
|
||||
<string name="wallet_actions_rename">Rename wallet</string>
|
||||
<string name="wallet_actions_delete">Delete wallet</string>
|
||||
<string name="wallet_actions_cancel">Cancel</string>
|
||||
<string name="wallet_rename_name">New name</string>
|
||||
<string name="wallet_rename_cancel">Cancel</string>
|
||||
<string name="wallet_rename_confirm">Rename</string>
|
||||
<string name="wallet_new_transaction">New transaction</string>
|
||||
<string name="home_add_wallet">Create wallet</string>
|
||||
</resources>
|
Loading…
Reference in a new issue