Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d8881eb19 |
No files matched your search
+1
-1
@@ -127,7 +127,7 @@ dependencies {
|
||||
|
||||
implementation 'com.google.zxing:core:3.5.4'
|
||||
implementation 'androidx.camera:camera-camera2:1.6.2'
|
||||
implementation 'androidx.camera:camera-lifecycle:1.6.2'
|
||||
implementation 'androidx.camera:camera-lifecycle:1.7.0'
|
||||
implementation 'androidx.camera:camera-view:1.6.2'
|
||||
implementation 'com.github.nextcloud:Android-SingleSignOn:1.3.5'
|
||||
implementation 'com.opencsv:opencsv:5.12.0'
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_LOCAL_NETWORK" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-feature
|
||||
android:name="android.hardware.camera"
|
||||
|
||||
@@ -42,7 +42,6 @@ import net.helcel.cowspent.persistence.CowspentServerSyncHelper
|
||||
import net.helcel.cowspent.theme.ThemeUtils
|
||||
import net.helcel.cowspent.util.CospendClientUtil
|
||||
import net.helcel.cowspent.util.CospendClientUtil.LoginStatus
|
||||
import net.helcel.cowspent.util.LocalNetworkPermissionHelper
|
||||
import net.helcel.cowspent.util.SecureStorage
|
||||
import java.net.URLDecoder
|
||||
import java.util.Locale
|
||||
@@ -73,7 +72,6 @@ class AccountActivity : AppCompatActivity() {
|
||||
private lateinit var preferences: SharedPreferences
|
||||
private var useWebLogin = true
|
||||
private var showLoginDialog by mutableStateOf(false)
|
||||
private val localNetworkPermissionHelper = LocalNetworkPermissionHelper(this)
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
enableEdgeToEdge()
|
||||
@@ -103,9 +101,7 @@ class AccountActivity : AppCompatActivity() {
|
||||
AccountScreen(
|
||||
viewModel = viewModel,
|
||||
onBack = { finish() },
|
||||
onConnect = {
|
||||
withLocalNetworkPermission(CospendClientUtil.formatURL(viewModel.serverUrl)) { login() }
|
||||
},
|
||||
onConnect = { login() },
|
||||
onSsoClick = { isChecked ->
|
||||
if (isChecked) {
|
||||
showLoginDialog = true
|
||||
@@ -198,13 +194,6 @@ class AccountActivity : AppCompatActivity() {
|
||||
.cowspentServerSyncHelper.runAccountProjectsSync()
|
||||
}
|
||||
|
||||
private fun withLocalNetworkPermission(serverUrl: String, action: () -> Unit) {
|
||||
localNetworkPermissionHelper.runWithAccess(
|
||||
listOf(serverUrl),
|
||||
action = action
|
||||
)
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
@@ -224,14 +213,12 @@ class AccountActivity : AppCompatActivity() {
|
||||
viewModel.serverUrl = ssoAccount.url
|
||||
viewModel.username = ssoAccount.userId
|
||||
|
||||
withLocalNetworkPermission(ssoAccount.url) {
|
||||
startInitialAccountSync()
|
||||
startInitialAccountSync()
|
||||
|
||||
val resultData = Intent()
|
||||
resultData.putExtra(MainConstants.CREDENTIALS_CHANGED, CREDENTIALS_CHANGED)
|
||||
setResult(RESULT_OK, resultData)
|
||||
finish()
|
||||
}
|
||||
val resultData = Intent()
|
||||
resultData.putExtra(MainConstants.CREDENTIALS_CHANGED, CREDENTIALS_CHANGED)
|
||||
setResult(RESULT_OK, resultData)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
|
||||
@@ -445,14 +445,13 @@ class EditBillActivity : AppCompatActivity() {
|
||||
val uiAmount = viewModel.parseAmountFromUi(it.value)
|
||||
SupportUtil.round2(uiAmount * viewModel.selectedCurrencyRate)
|
||||
}
|
||||
} else { // FRACTION
|
||||
} else { // PERCENT
|
||||
val totalAmount = viewModel.amountAsDouble
|
||||
val fractionTotal = viewModel.getFractionTotal()
|
||||
viewModel.owersFractionSplit.filter { (id, fraction) ->
|
||||
viewModel.owersSelection[id] == true && (fraction.toIntOrNull() ?: 0) > 0
|
||||
viewModel.owersPercentSplit.filter { (id, percentStr) ->
|
||||
viewModel.owersSelection[id] == true && viewModel.parseAmountFromUi(percentStr) > 0
|
||||
}.mapValues {
|
||||
val fraction = it.value.toInt()
|
||||
val uiAmount = SupportUtil.round2(totalAmount * fraction / fractionTotal)
|
||||
val percent = viewModel.parseAmountFromUi(it.value)
|
||||
val uiAmount = SupportUtil.round2(totalAmount * percent / 100.0)
|
||||
SupportUtil.round2(uiAmount * viewModel.selectedCurrencyRate)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,6 @@ import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.preference.PreferenceManager
|
||||
import net.helcel.cowspent.R
|
||||
import net.helcel.cowspent.android.helper.*
|
||||
import net.helcel.cowspent.model.*
|
||||
@@ -75,28 +74,19 @@ fun EditBillScreen(
|
||||
val canEdit = accessLevel == DBProject.ACCESS_LEVEL_UNKNOWN || accessLevel >= DBProject.ACCESS_LEVEL_PARTICIPANT
|
||||
val context = LocalContext.current
|
||||
val focusRequester = remember { FocusRequester() }
|
||||
val whatFocusRequester = remember { FocusRequester() }
|
||||
val whatFirst = remember(context) {
|
||||
val preferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
preferences.getBoolean(context.getString(R.string.pref_key_extra_features), false) &&
|
||||
preferences.getString(
|
||||
context.getString(R.string.pref_key_bill_field_order),
|
||||
context.getString(R.string.pref_value_bill_amount_first)
|
||||
) == context.getString(R.string.pref_value_bill_what_first)
|
||||
}
|
||||
var amountFocused by remember { mutableStateOf(false) }
|
||||
var amountSelection by remember { mutableStateOf(TextRange(viewModel.amount.length)) }
|
||||
|
||||
// The activity reads the project off the main thread and only then reports whether this is a
|
||||
// new bill, so the flag arrives after the first composition. Keying on it rather than on Unit
|
||||
// is what makes the effect run at all.
|
||||
LaunchedEffect(viewModel.isNewBill, whatFirst) {
|
||||
LaunchedEffect(viewModel.isNewBill) {
|
||||
if (!viewModel.isNewBill) return@LaunchedEffect
|
||||
// The field has to be laid out before it can take focus, which is not yet true on the
|
||||
// pass that composed it. Waiting for the next frame makes this hold whether the flag was
|
||||
// already set or arrived later.
|
||||
withFrameNanos { }
|
||||
(if (whatFirst) whatFocusRequester else focusRequester).requestFocus()
|
||||
focusRequester.requestFocus()
|
||||
}
|
||||
|
||||
StatefulAlertDialog(
|
||||
@@ -192,8 +182,6 @@ fun EditBillScreen(
|
||||
onDateClick = onDateClick,
|
||||
onTimeClick = onTimeClick,
|
||||
amountFocusRequester = focusRequester,
|
||||
whatFocusRequester = whatFocusRequester,
|
||||
whatFirst = whatFirst,
|
||||
amountSelection = amountSelection,
|
||||
onAmountSelectionChange = { amountSelection = it },
|
||||
onAmountFocusChange = { amountFocused = it }
|
||||
@@ -309,18 +297,18 @@ private fun keyboardColors(): KeyboardColors {
|
||||
val (tray, edge) = when {
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE -> if (dark) {
|
||||
colorResource(android.R.color.system_surface_container_dark) to
|
||||
colorResource(android.R.color.system_surface_container_high_dark)
|
||||
colorResource(android.R.color.system_surface_container_high_dark)
|
||||
} else {
|
||||
colorResource(android.R.color.system_surface_container_light) to
|
||||
colorResource(android.R.color.system_surface_container_high_light)
|
||||
colorResource(android.R.color.system_surface_container_high_light)
|
||||
}
|
||||
|
||||
else -> if (dark) {
|
||||
colorResource(android.R.color.system_neutral1_900) to
|
||||
colorResource(android.R.color.system_neutral1_800)
|
||||
colorResource(android.R.color.system_neutral1_800)
|
||||
} else {
|
||||
colorResource(android.R.color.system_neutral1_50) to
|
||||
colorResource(android.R.color.system_neutral1_100)
|
||||
colorResource(android.R.color.system_neutral1_100)
|
||||
}
|
||||
}
|
||||
if (dark) KeyboardColors(
|
||||
@@ -382,8 +370,6 @@ fun BillBasicInfoSection(
|
||||
onDateClick: () -> Unit,
|
||||
onTimeClick: () -> Unit,
|
||||
amountFocusRequester: FocusRequester,
|
||||
whatFocusRequester: FocusRequester,
|
||||
whatFirst: Boolean,
|
||||
amountSelection: TextRange = TextRange(viewModel.amount.length),
|
||||
onAmountSelectionChange: (TextRange) -> Unit = {},
|
||||
onAmountFocusChange: (Boolean) -> Unit = {}
|
||||
@@ -401,100 +387,79 @@ fun BillBasicInfoSection(
|
||||
val currencyDialogTitle =
|
||||
stringResource(R.string.currency_dialog_title, viewModel.mainCurrencyName)
|
||||
|
||||
val amountField: @Composable () -> Unit = {
|
||||
OutlinedTextField(
|
||||
value = TextFieldValue(
|
||||
text = viewModel.amount,
|
||||
selection = TextRange(
|
||||
amountSelection.start.coerceIn(0, viewModel.amount.length),
|
||||
amountSelection.end.coerceIn(0, viewModel.amount.length)
|
||||
)
|
||||
),
|
||||
onValueChange = { nv ->
|
||||
val filteredValue = nv.text.filter { it in "0123456789.,+-*/()" }
|
||||
onAmountSelectionChange(
|
||||
if (filteredValue == nv.text) nv.selection else TextRange(filteredValue.length)
|
||||
)
|
||||
if (filteredValue != viewModel.amount) {
|
||||
viewModel.amount = filteredValue
|
||||
viewModel.updateSplits()
|
||||
}
|
||||
},
|
||||
enabled = canEdit,
|
||||
placeholder = { Text("0") },
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.focusRequester(amountFocusRequester)
|
||||
.onFocusChanged { onAmountFocusChange(it.isFocused) },
|
||||
leadingIcon = {
|
||||
val currencyToShow = viewModel.selectedCurrencyName.ifEmpty {
|
||||
viewModel.mainCurrencyName.ifEmpty { "$" }
|
||||
}
|
||||
TextIconDisplay(
|
||||
textIcon = TextIcon.Symbol(currencyToShow),
|
||||
tint = MaterialTheme.colors.onSurface.copy(alpha = 0.6f)
|
||||
)
|
||||
},
|
||||
trailingIcon = {
|
||||
IconButton(
|
||||
enabled = canEdit,
|
||||
onClick = {
|
||||
val mainLabel = viewModel.mainCurrencyName.ifEmpty { "$" }
|
||||
val options = listOf("$mainLabel | Base") + viewModel.currencies.map {
|
||||
"${it.name} | 1 $mainLabel = ${it.exchangeRate} ${it.name}"
|
||||
}
|
||||
viewModel.showDialog(
|
||||
title = currencyDialogTitle,
|
||||
items = options,
|
||||
onItemSelected = { index ->
|
||||
if (index == 0) {
|
||||
viewModel.resetCurrency()
|
||||
} else {
|
||||
viewModel.convertCurrency(viewModel.currencies[index - 1])
|
||||
}
|
||||
}
|
||||
)
|
||||
OutlinedTextField(
|
||||
value = TextFieldValue(
|
||||
text = viewModel.amount,
|
||||
selection = TextRange(
|
||||
amountSelection.start.coerceIn(0, viewModel.amount.length),
|
||||
amountSelection.end.coerceIn(0, viewModel.amount.length)
|
||||
)
|
||||
),
|
||||
onValueChange = { nv ->
|
||||
val filteredValue = nv.text.filter { it in "0123456789.,+-*/()" }
|
||||
onAmountSelectionChange(
|
||||
if (filteredValue == nv.text) nv.selection else TextRange(filteredValue.length)
|
||||
)
|
||||
if (filteredValue != viewModel.amount) {
|
||||
viewModel.amount = filteredValue
|
||||
viewModel.updateSplits()
|
||||
}
|
||||
},
|
||||
enabled = canEdit,
|
||||
placeholder = { Text("0") },
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.focusRequester(amountFocusRequester)
|
||||
.onFocusChanged { onAmountFocusChange(it.isFocused) },
|
||||
leadingIcon = {
|
||||
val currencyToShow = viewModel.selectedCurrencyName.ifEmpty {
|
||||
viewModel.mainCurrencyName.ifEmpty { "$" }
|
||||
}
|
||||
TextIconDisplay(
|
||||
textIcon = TextIcon.Symbol(currencyToShow),
|
||||
tint = MaterialTheme.colors.onSurface.copy(alpha = 0.6f)
|
||||
)
|
||||
},
|
||||
trailingIcon = {
|
||||
IconButton(
|
||||
enabled = canEdit,
|
||||
onClick = {
|
||||
val mainLabel = viewModel.mainCurrencyName.ifEmpty { "$" }
|
||||
val options = listOf("$mainLabel | Base") + viewModel.currencies.map {
|
||||
"${it.name} | 1 $mainLabel = ${it.exchangeRate} ${it.name}"
|
||||
}
|
||||
) {
|
||||
Icon(Icons.Default.SwapHoriz, contentDescription = "Change Currency")
|
||||
viewModel.showDialog(
|
||||
title = currencyDialogTitle,
|
||||
items = options,
|
||||
onItemSelected = { index ->
|
||||
if (index == 0) {
|
||||
viewModel.resetCurrency()
|
||||
} else {
|
||||
viewModel.convertCurrency(viewModel.currencies[index - 1])
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
},
|
||||
keyboardOptions = KeyboardOptions(
|
||||
keyboardType = KeyboardType.Decimal,
|
||||
imeAction = if (whatFirst) ImeAction.Done else ImeAction.Next
|
||||
),
|
||||
keyboardActions = KeyboardActions(
|
||||
onNext = { focusManager.moveFocus(FocusDirection.Next) },
|
||||
onDone = { focusManager.clearFocus() }
|
||||
)
|
||||
)
|
||||
}
|
||||
) {
|
||||
Icon(Icons.Default.SwapHoriz, contentDescription = "Change Currency")
|
||||
}
|
||||
},
|
||||
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Decimal, imeAction = ImeAction.Next),
|
||||
keyboardActions = KeyboardActions(onNext = { focusManager.moveFocus(FocusDirection.Next) })
|
||||
)
|
||||
|
||||
val whatField: @Composable () -> Unit = {
|
||||
OutlinedTextField(
|
||||
value = viewModel.what,
|
||||
onValueChange = { viewModel.updateWhat(it) },
|
||||
enabled = canEdit,
|
||||
placeholder = { Text(stringResource(R.string.label_what)) },
|
||||
modifier = Modifier.fillMaxWidth().focusRequester(whatFocusRequester),
|
||||
leadingIcon = { Icon(Icons.Default.Title, contentDescription = null) },
|
||||
keyboardOptions = KeyboardOptions(imeAction = if (whatFirst) ImeAction.Next else ImeAction.Done),
|
||||
keyboardActions = KeyboardActions(
|
||||
onNext = { focusManager.moveFocus(FocusDirection.Next) },
|
||||
onDone = { focusManager.clearFocus() }
|
||||
)
|
||||
)
|
||||
}
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
if (whatFirst) {
|
||||
whatField()
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
amountField()
|
||||
} else {
|
||||
amountField()
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
whatField()
|
||||
}
|
||||
OutlinedTextField(
|
||||
value = viewModel.what,
|
||||
onValueChange = { viewModel.updateWhat(it) },
|
||||
enabled = canEdit,
|
||||
placeholder = { Text(stringResource(R.string.label_what)) },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
leadingIcon = { Icon(Icons.Default.Title, contentDescription = null) },
|
||||
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
|
||||
keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() })
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
@@ -619,13 +584,14 @@ fun OwerSelectionSection(
|
||||
)
|
||||
Spacer(Modifier.weight(1f))
|
||||
|
||||
if (viewModel.splitMode != SplitMode.EVEN && viewModel.splitMode != SplitMode.FRACTION) {
|
||||
if (viewModel.splitMode != SplitMode.EVEN) {
|
||||
val diff = viewModel.getDiffSplit()
|
||||
if (abs(diff) > 0.01) {
|
||||
val unit = if (viewModel.splitMode == SplitMode.PERCENT) "%" else ""
|
||||
val diffText =
|
||||
if (diff > 0) "Missing: ${SupportUtil.normalNumberFormat.format(diff)}" else "Excess: ${
|
||||
if (diff > 0) "Missing: ${SupportUtil.normalNumberFormat.format(diff)}$unit" else "Excess: ${
|
||||
SupportUtil.normalNumberFormat.format(-diff)
|
||||
}"
|
||||
}$unit"
|
||||
Text(
|
||||
diffText,
|
||||
color = MaterialTheme.colors.error,
|
||||
@@ -635,7 +601,7 @@ fun OwerSelectionSection(
|
||||
}
|
||||
}
|
||||
|
||||
val splitOptions = listOf(SplitMode.EVEN, SplitMode.CUSTOM, SplitMode.FRACTION)
|
||||
val splitOptions = listOf(SplitMode.EVEN, SplitMode.CUSTOM, SplitMode.PERCENT)
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.padding(start = 8.dp)
|
||||
@@ -657,7 +623,7 @@ fun OwerSelectionSection(
|
||||
text = when (mode) {
|
||||
SplitMode.EVEN -> "="
|
||||
SplitMode.CUSTOM -> "#"
|
||||
SplitMode.FRACTION -> "÷"
|
||||
SplitMode.PERCENT -> "%"
|
||||
},
|
||||
color = if (isSelected) MaterialTheme.colors.onPrimary else MaterialTheme.colors.onSurface,
|
||||
fontSize = 14.sp,
|
||||
@@ -697,23 +663,18 @@ fun OwerSelectionSection(
|
||||
if (isSelected || viewModel.splitMode != SplitMode.EVEN) {
|
||||
val focusManager = LocalFocusManager.current
|
||||
val interactionSource = remember { MutableInteractionSource() }
|
||||
val value = if (viewModel.splitMode == SplitMode.FRACTION) {
|
||||
viewModel.owersFractionSplit[member.id] ?: ""
|
||||
val value = if (viewModel.splitMode == SplitMode.PERCENT) {
|
||||
viewModel.owersPercentSplit[member.id] ?: ""
|
||||
} else {
|
||||
viewModel.owersCustomSplit[member.id] ?: ""
|
||||
}
|
||||
val fractionTotal = viewModel.getFractionTotal()
|
||||
|
||||
BasicTextField(
|
||||
value = value,
|
||||
onValueChange = { nv ->
|
||||
val filteredValue = if (viewModel.splitMode == SplitMode.FRACTION) {
|
||||
nv.filter { it.isDigit() }
|
||||
} else {
|
||||
nv.filter { it in "0123456789,.+-*/" }
|
||||
}
|
||||
if (viewModel.splitMode == SplitMode.FRACTION) {
|
||||
viewModel.owersFractionSplit[member.id] = filteredValue
|
||||
val filteredValue = nv.filter { it in "0123456789,.+-*/" }
|
||||
if (viewModel.splitMode == SplitMode.PERCENT) {
|
||||
viewModel.owersPercentSplit[member.id] = filteredValue
|
||||
} else {
|
||||
viewModel.owersCustomSplit[member.id] = filteredValue
|
||||
}
|
||||
@@ -721,7 +682,7 @@ fun OwerSelectionSection(
|
||||
},
|
||||
modifier = Modifier
|
||||
.width(80.dp)
|
||||
.height(40.dp),
|
||||
.height(46.dp),
|
||||
interactionSource = interactionSource,
|
||||
singleLine = true,
|
||||
enabled = viewModel.splitMode != SplitMode.EVEN && canEdit,
|
||||
@@ -741,16 +702,12 @@ fun OwerSelectionSection(
|
||||
enabled = viewModel.splitMode != SplitMode.EVEN && canEdit,
|
||||
interactionSource = interactionSource,
|
||||
contentPadding = PaddingValues(horizontal = 8.dp, vertical = 0.dp),
|
||||
colors = TextFieldDefaults.outlinedTextFieldColors(
|
||||
colors = TextFieldDefaults.textFieldColors(
|
||||
cursorColor = MaterialTheme.colors.onSurface,
|
||||
backgroundColor = MaterialTheme.colors.onSurface.copy(alpha = 0.02f),
|
||||
unfocusedBorderColor = MaterialTheme.colors.onSurface.copy(alpha = 0.2f),
|
||||
focusedBorderColor = MaterialTheme.colors.primary.copy(alpha = 0.7f),
|
||||
disabledBorderColor = MaterialTheme.colors.onSurface.copy(alpha = 0.14f)
|
||||
),
|
||||
trailingIcon = if (viewModel.splitMode == SplitMode.FRACTION && isSelected && fractionTotal > 0) {
|
||||
{ Text("/$fractionTotal", color = MaterialTheme.colors.onSurface.copy(alpha = 0.65f)) }
|
||||
} else null
|
||||
backgroundColor = Color.Transparent,
|
||||
unfocusedIndicatorColor = Color.Transparent,
|
||||
disabledIndicatorColor = Color.Transparent
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1019,24 +976,24 @@ fun EditBillScreenCustomPreview() {
|
||||
}
|
||||
|
||||
@SuppressLint("ViewModelConstructorInComposable")
|
||||
@Preview(showBackground = true, name = "Fraction Split")
|
||||
@Preview(showBackground = true, name = "Percent Split (%)")
|
||||
@Composable
|
||||
fun EditBillScreenFractionPreview() {
|
||||
fun EditBillScreenPercentPreview() {
|
||||
MaterialTheme {
|
||||
EditBillScreen(
|
||||
viewModel = EditBillViewModel().apply {
|
||||
what = "Fraction Split Pizza"
|
||||
what = "Percent Split Pizza"
|
||||
amount = "100.00"
|
||||
mainCurrencyName = "EUR"
|
||||
members = listOf(
|
||||
DBMember(1, 0, 0, "Alice", true, 1.0, 0, null, null, null, null, null),
|
||||
DBMember(2, 0, 0, "Bob", true, 1.0, 0, null, null, null, null, null)
|
||||
)
|
||||
splitMode = SplitMode.FRACTION
|
||||
splitMode = SplitMode.PERCENT
|
||||
owersSelection[1] = true
|
||||
owersSelection[2] = true
|
||||
owersFractionSplit[1] = "1"
|
||||
owersFractionSplit[2] = "3"
|
||||
owersPercentSplit[1] = "70"
|
||||
owersPercentSplit[2] = "30"
|
||||
},
|
||||
categories = emptyList(),
|
||||
paymentModes = emptyList(),
|
||||
|
||||
@@ -18,7 +18,7 @@ import net.helcel.cowspent.util.SupportUtil
|
||||
import net.helcel.cowspent.util.evalMath
|
||||
|
||||
enum class SplitMode {
|
||||
EVEN, CUSTOM, FRACTION
|
||||
EVEN, CUSTOM, PERCENT
|
||||
}
|
||||
|
||||
class EditBillViewModel : ViewModel() {
|
||||
@@ -55,7 +55,7 @@ class EditBillViewModel : ViewModel() {
|
||||
var owersSelection = mutableStateMapOf<Long, Boolean>()
|
||||
var splitMode by mutableStateOf(SplitMode.EVEN)
|
||||
var owersCustomSplit = mutableStateMapOf<Long, String>()
|
||||
var owersFractionSplit = mutableStateMapOf<Long, String>()
|
||||
var owersPercentSplit = mutableStateMapOf<Long, String>()
|
||||
|
||||
var dialogState by mutableStateOf<DialogState?>(null)
|
||||
|
||||
@@ -93,16 +93,18 @@ class EditBillViewModel : ViewModel() {
|
||||
owersCustomSplit.remove(m.id)
|
||||
}
|
||||
}
|
||||
} else if (splitMode == SplitMode.FRACTION) {
|
||||
} else if (splitMode == SplitMode.PERCENT) {
|
||||
val selectedCount = owersSelection.count { it.value }
|
||||
if (selectedCount > 0) {
|
||||
val evenPercent = 100.0 / selectedCount
|
||||
val evenPercentStr = SupportUtil.round2(evenPercent).toString()
|
||||
members.forEach { m ->
|
||||
if (owersSelection[m.id] == true) {
|
||||
if (owersFractionSplit[m.id].isNullOrEmpty()) {
|
||||
owersFractionSplit[m.id] = "1"
|
||||
if (owersPercentSplit[m.id].isNullOrEmpty()) {
|
||||
owersPercentSplit[m.id] = evenPercentStr
|
||||
}
|
||||
} else {
|
||||
owersFractionSplit.remove(m.id)
|
||||
owersPercentSplit.remove(m.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,12 +117,12 @@ class EditBillViewModel : ViewModel() {
|
||||
if (selected) {
|
||||
if (splitMode == SplitMode.CUSTOM && owersCustomSplit[id].isNullOrEmpty()) {
|
||||
owersCustomSplit[id] = "0"
|
||||
} else if (splitMode == SplitMode.FRACTION && owersFractionSplit[id].isNullOrEmpty()) {
|
||||
owersFractionSplit[id] = "1"
|
||||
} else if (splitMode == SplitMode.PERCENT && owersPercentSplit[id].isNullOrEmpty()) {
|
||||
owersPercentSplit[id] = "0"
|
||||
}
|
||||
} else {
|
||||
owersCustomSplit.remove(id)
|
||||
owersFractionSplit.remove(id)
|
||||
owersPercentSplit.remove(id)
|
||||
}
|
||||
} else {
|
||||
updateSplits()
|
||||
@@ -128,8 +130,11 @@ class EditBillViewModel : ViewModel() {
|
||||
}
|
||||
|
||||
fun getDiffSplit(): Double {
|
||||
return if (splitMode == SplitMode.FRACTION) {
|
||||
0.0
|
||||
return if (splitMode == SplitMode.PERCENT) {
|
||||
val customTotal = owersPercentSplit.entries
|
||||
.filter { owersSelection[it.key] == true }
|
||||
.sumOf { parseAmountFromUi(it.value) }
|
||||
SupportUtil.round2(100.0 - customTotal)
|
||||
} else {
|
||||
val customTotal = owersCustomSplit.entries
|
||||
.filter { owersSelection[it.key] == true }
|
||||
@@ -138,10 +143,6 @@ class EditBillViewModel : ViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
fun getFractionTotal(): Int = owersFractionSplit.entries
|
||||
.filter { owersSelection[it.key] == true }
|
||||
.sumOf { it.value.toIntOrNull()?.coerceAtLeast(0) ?: 0 }
|
||||
|
||||
fun getOwersIds(): List<Long> {
|
||||
return owersSelection.filter { it.value }.keys.toList()
|
||||
}
|
||||
@@ -257,7 +258,7 @@ class EditBillViewModel : ViewModel() {
|
||||
|
||||
owersSelection.clear()
|
||||
owersCustomSplit.clear()
|
||||
owersFractionSplit.clear()
|
||||
owersPercentSplit.clear()
|
||||
|
||||
if (customSplits != null) {
|
||||
splitMode = SplitMode.CUSTOM
|
||||
|
||||
@@ -55,7 +55,6 @@ import net.helcel.cowspent.util.CospendClientUtil
|
||||
import net.helcel.cowspent.util.ExportUtil
|
||||
import net.helcel.cowspent.util.ICallback
|
||||
import net.helcel.cowspent.util.IRefreshBillsListCallback
|
||||
import net.helcel.cowspent.util.LocalNetworkPermissionHelper
|
||||
import net.helcel.cowspent.util.SyncSettings
|
||||
import net.helcel.cowspent.util.SupportUtil
|
||||
import net.helcel.cowspent.util.VersatileProjectSyncClient
|
||||
@@ -91,7 +90,6 @@ class BillsListViewActivity :
|
||||
|
||||
private var mActionMode: ActionMode? = null
|
||||
private lateinit var db: CowspentSQLiteOpenHelper
|
||||
private val localNetworkPermissionHelper = LocalNetworkPermissionHelper(this)
|
||||
|
||||
private val syncCallBack = object : ICallback {
|
||||
override fun onFinish() {
|
||||
@@ -343,23 +341,15 @@ class BillsListViewActivity :
|
||||
}
|
||||
viewModel.isRefreshing = false
|
||||
|
||||
registerBroadcastReceiver()
|
||||
isActivityVisible = true
|
||||
|
||||
synchronize(SyncTrigger.APP_OPEN)
|
||||
}
|
||||
|
||||
private fun configuredServerUrls(projects: List<DBProject>): List<String> = buildList {
|
||||
addAll(projects.filterNot { it.isLocal }.mapNotNull { it.serverUrl })
|
||||
if (CowspentServerSyncHelper.isNextcloudAccountConfigured(applicationContext)) {
|
||||
val preferences = PreferenceManager.getDefaultSharedPreferences(applicationContext)
|
||||
val accountUrl = if (preferences.getBoolean(AccountActivity.SETTINGS_USE_SSO, false)) {
|
||||
preferences.getString(AccountActivity.SETTINGS_SSO_URL, null)
|
||||
} else {
|
||||
preferences.getString(AccountActivity.SETTINGS_URL, null)
|
||||
}
|
||||
accountUrl?.let(::add)
|
||||
lifecycleScope.launch {
|
||||
syncNewlyDiscoveredProjects(withContext(Dispatchers.IO) { db.projects })
|
||||
}
|
||||
|
||||
registerBroadcastReceiver()
|
||||
updateAvatarInDrawer(CowspentServerSyncHelper.isNextcloudAccountConfigured(this))
|
||||
isActivityVisible = true
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
@@ -812,26 +802,6 @@ class BillsListViewActivity :
|
||||
|
||||
@VisibleForTesting
|
||||
internal fun synchronize(trigger: SyncTrigger) {
|
||||
lifecycleScope.launch {
|
||||
val projects = withContext(Dispatchers.IO) { db.projects }
|
||||
localNetworkPermissionHelper.runWithAccess(
|
||||
configuredServerUrls(projects),
|
||||
action = {
|
||||
synchronizeAfterPermission(trigger)
|
||||
if (trigger == SyncTrigger.APP_OPEN) {
|
||||
lifecycleScope.launch {
|
||||
syncNewlyDiscoveredProjects(withContext(Dispatchers.IO) { db.projects })
|
||||
}
|
||||
updateAvatarInDrawer(
|
||||
CowspentServerSyncHelper.isNextcloudAccountConfigured(this@BillsListViewActivity)
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun synchronizeAfterPermission(trigger: SyncTrigger) {
|
||||
val preferences = PreferenceManager.getDefaultSharedPreferences(applicationContext)
|
||||
// isSyncPossible is networkConnected && !offlineMode, so offline mode is already covered
|
||||
// here - including for a manual refresh, which cannot currently override it.
|
||||
|
||||
@@ -31,7 +31,6 @@ class NewProjectActivity : AppCompatActivity() {
|
||||
|
||||
internal val viewModel: NewProjectViewModel by viewModels()
|
||||
private lateinit var db: CowspentSQLiteOpenHelper
|
||||
private val localNetworkPermissionHelper = LocalNetworkPermissionHelper(this)
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
enableEdgeToEdge()
|
||||
@@ -137,16 +136,7 @@ class NewProjectActivity : AppCompatActivity() {
|
||||
viewModel.isAuthenticatedAccount = db.cowspentServerSyncHelper.canCreateAuthenticatedProject(fakeProj)
|
||||
}
|
||||
|
||||
private fun onPressOk() {
|
||||
if (viewModel.projectType == ProjectType.LOCAL) {
|
||||
createProject()
|
||||
} else {
|
||||
localNetworkPermissionHelper.runWithAccess(
|
||||
listOf(getFormattedUrl()),
|
||||
action = { createProject() }
|
||||
)
|
||||
}
|
||||
}
|
||||
private fun onPressOk() = createProject()
|
||||
|
||||
private fun getFormattedUrl(): String {
|
||||
var url = viewModel.projectUrl.trim()
|
||||
|
||||
@@ -38,7 +38,6 @@ import androidx.compose.material.icons.filled.Info
|
||||
import androidx.compose.material.icons.filled.Palette
|
||||
import androidx.compose.material.icons.filled.Restore
|
||||
import androidx.compose.material.icons.filled.Sync
|
||||
import androidx.compose.material.icons.filled.SwapVert
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
@@ -100,9 +99,6 @@ fun SettingsScreen(
|
||||
val keyAutoCategorize = stringResource(R.string.pref_key_auto_categorize)
|
||||
val keyFullSyncDelay = stringResource(R.string.pref_key_full_sync_delay)
|
||||
val keyLastAccountSync = stringResource(R.string.pref_key_last_account_sync_timestamp)
|
||||
val keyBillFieldOrder = stringResource(R.string.pref_key_bill_field_order)
|
||||
val billAmountFirstValue = stringResource(R.string.pref_value_bill_amount_first)
|
||||
val billWhatFirstValue = stringResource(R.string.pref_value_bill_what_first)
|
||||
|
||||
val isNextcloudConfigured = CowspentServerSyncHelper.isNextcloudAccountConfigured(context)
|
||||
|
||||
@@ -161,9 +157,6 @@ fun SettingsScreen(
|
||||
var autoCategorize by remember(keyAutoCategorize) {
|
||||
mutableStateOf(sharedPreferences.getBoolean(keyAutoCategorize, false))
|
||||
}
|
||||
var billFieldOrder by remember(keyBillFieldOrder) {
|
||||
mutableStateOf(sharedPreferences.getString(keyBillFieldOrder, billAmountFirstValue) ?: billAmountFirstValue)
|
||||
}
|
||||
|
||||
val fullSyncDelays = SyncSettings.FULL_SYNC_DELAY_CHOICES_MINUTES
|
||||
val fullSyncDelayLabels = listOf(
|
||||
@@ -327,20 +320,6 @@ fun SettingsScreen(
|
||||
)
|
||||
|
||||
if (extraFeatures) {
|
||||
SettingsListPreference(
|
||||
title = stringResource(R.string.settings_bill_field_order),
|
||||
icon = Icons.Default.SwapVert,
|
||||
value = billFieldOrder,
|
||||
entries = mapOf(
|
||||
billAmountFirstValue to stringResource(R.string.settings_bill_amount_first),
|
||||
billWhatFirstValue to stringResource(R.string.settings_bill_what_first)
|
||||
),
|
||||
onValueChange = { value ->
|
||||
billFieldOrder = value
|
||||
sharedPreferences.edit { putString(keyBillFieldOrder, value) }
|
||||
}
|
||||
)
|
||||
|
||||
SettingsSwitchPreference(
|
||||
title = stringResource(R.string.settings_show_archived),
|
||||
icon = Icons.Default.Archive,
|
||||
|
||||
@@ -67,12 +67,6 @@ class CowspentServerSyncHelper private constructor(private val dbHelper: Cowspen
|
||||
return networkConnected && !offlineMode
|
||||
}
|
||||
|
||||
private fun removeDeletedRemoteProject(project: DBProject) {
|
||||
dbHelper.deleteProject(project.id)
|
||||
projectIdsToSync.removeAll { it == project.id }
|
||||
appContext.sendBroadcast(Intent(MainConstants.BROADCAST_PROJECT_SYNCED))
|
||||
}
|
||||
|
||||
fun addCallbackPull(callback: ICallback) {
|
||||
// Callers register on every resume but the list is only drained when a task actually
|
||||
// starts, so refuse duplicates rather than letting the same callback pile up.
|
||||
@@ -173,8 +167,8 @@ class CowspentServerSyncHelper private constructor(private val dbHelper: Cowspen
|
||||
private var newBillsDialogText = ""
|
||||
private var updatedBillsDialogText = ""
|
||||
private var deletedBillsDialogText = ""
|
||||
|
||||
private var deferred: Deferred<LoginStatus>? = null
|
||||
private var archivedAfterNotFound = false
|
||||
|
||||
init {
|
||||
Log.i(TAG, "SYNC TASK project : ${project.remoteId}")
|
||||
@@ -236,11 +230,9 @@ class CowspentServerSyncHelper private constructor(private val dbHelper: Cowspen
|
||||
}
|
||||
Log.i(TAG, "STARTING SYNCHRONIZATION with Cospend version($version)")
|
||||
var status = pushLocalChanges()
|
||||
if (archivedAfterNotFound) return LoginStatus.OK
|
||||
if (status == LoginStatus.OK) {
|
||||
status = pullRemoteChanges()
|
||||
}
|
||||
if (archivedAfterNotFound) return LoginStatus.OK
|
||||
Log.i(TAG, "SYNCHRONIZATION FINISHED")
|
||||
return status
|
||||
}
|
||||
@@ -262,15 +254,6 @@ class CowspentServerSyncHelper private constructor(private val dbHelper: Cowspen
|
||||
preferences.edit { putString(versionKey(), version) }
|
||||
}
|
||||
|
||||
private fun archiveOnRemoteNotFound(e: NextcloudHttpRequestFailedException): Boolean {
|
||||
if (project.type != ProjectType.COSPEND || e.statusCode != 404) return false
|
||||
val archivedTs = System.currentTimeMillis() / 1000
|
||||
project.archivedTs = archivedTs
|
||||
dbHelper.updateProject(projId = project.id, newArchivedTs = archivedTs)
|
||||
archivedAfterNotFound = true
|
||||
return true
|
||||
}
|
||||
|
||||
private fun pushLocalChanges(): LoginStatus {
|
||||
Log.d(TAG, "PUSH LOCAL CHANGES")
|
||||
|
||||
@@ -587,13 +570,9 @@ class CowspentServerSyncHelper private constructor(private val dbHelper: Cowspen
|
||||
LoginStatus.SSO_TOKEN_MISMATCH
|
||||
} catch (e: NextcloudHttpRequestFailedException) {
|
||||
Log.e(TAG, "Catch SSO HTTP req FAILED", e)
|
||||
if (archiveOnRemoteNotFound(e)) {
|
||||
LoginStatus.OK
|
||||
} else {
|
||||
errorMessages.add(getErrorMessageFromException(e))
|
||||
e.cause?.let { exceptions.add(it) }
|
||||
LoginStatus.REQ_FAILED
|
||||
}
|
||||
errorMessages.add(getErrorMessageFromException(e))
|
||||
e.cause?.let { exceptions.add(it) }
|
||||
LoginStatus.REQ_FAILED
|
||||
}
|
||||
}
|
||||
|
||||
@@ -667,13 +646,9 @@ class CowspentServerSyncHelper private constructor(private val dbHelper: Cowspen
|
||||
LoginStatus.SSO_TOKEN_MISMATCH
|
||||
} catch (e: NextcloudHttpRequestFailedException) {
|
||||
Log.e(TAG, "Catch NC REQ failed", e)
|
||||
if (archiveOnRemoteNotFound(e)) {
|
||||
LoginStatus.OK
|
||||
} else {
|
||||
errorMessages.add(getErrorMessageFromException(e))
|
||||
e.cause?.let { exceptions.add(it) }
|
||||
LoginStatus.REQ_FAILED
|
||||
}
|
||||
errorMessages.add(getErrorMessageFromException(e))
|
||||
e.cause?.let { exceptions.add(it) }
|
||||
LoginStatus.REQ_FAILED
|
||||
}
|
||||
}
|
||||
private fun updateLocalProject(projResponse: ServerResponse.ProjectResponse) {
|
||||
@@ -1381,7 +1356,7 @@ class CowspentServerSyncHelper private constructor(private val dbHelper: Cowspen
|
||||
appContext.sendBroadcast(Intent(MainConstants.BROADCAST_SSO_TOKEN_MISMATCH))
|
||||
}
|
||||
} else {
|
||||
removeDeletedRemoteProject(project!!)
|
||||
dbHelper.deleteProject(project!!.id)
|
||||
}
|
||||
callback.onFinish(project?.id?.toString() ?: "", errorString)
|
||||
}
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
package net.helcel.cowspent.util
|
||||
|
||||
import android.Manifest
|
||||
import android.content.pm.PackageManager
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.widget.Toast
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import net.helcel.cowspent.R
|
||||
import java.net.Inet6Address
|
||||
import java.net.InetAddress
|
||||
|
||||
/** Handles the Android 17 permission for servers that resolve to the local network. */
|
||||
class LocalNetworkPermissionHelper(private val activity: AppCompatActivity) {
|
||||
private var onAllowed: (() -> Unit)? = null
|
||||
private var requestInProgress = false
|
||||
|
||||
private val permissionLauncher = activity.registerForActivityResult(
|
||||
ActivityResultContracts.RequestPermission()
|
||||
) { granted ->
|
||||
requestInProgress = false
|
||||
onAllowed?.takeIf { granted }?.invoke()
|
||||
onAllowed = null
|
||||
if (!granted) showDeniedMessage()
|
||||
}
|
||||
|
||||
fun runWithAccess(serverUrls: Collection<String>, action: () -> Unit) {
|
||||
if (Build.VERSION.SDK_INT < ANDROID_17 || hasPermission()) {
|
||||
action()
|
||||
return
|
||||
}
|
||||
|
||||
activity.lifecycleScope.launch {
|
||||
val isLocalServer = withContext(Dispatchers.IO) {
|
||||
serverUrls.any(::resolvesToLocalNetwork)
|
||||
}
|
||||
if (!isLocalServer || hasPermission()) {
|
||||
action()
|
||||
} else if (!requestInProgress) {
|
||||
onAllowed = action
|
||||
requestInProgress = true
|
||||
if (activity.shouldShowRequestPermissionRationale(Manifest.permission.ACCESS_LOCAL_NETWORK)) {
|
||||
AlertDialog.Builder(activity)
|
||||
.setTitle(R.string.local_network_permission_title)
|
||||
.setMessage(R.string.local_network_permission_rationale)
|
||||
.setPositiveButton(R.string.local_network_permission_continue) { _, _ ->
|
||||
permissionLauncher.launch(Manifest.permission.ACCESS_LOCAL_NETWORK)
|
||||
}
|
||||
.setNegativeButton(android.R.string.cancel) { _, _ -> cancelRequest() }
|
||||
.setOnCancelListener { cancelRequest() }
|
||||
.show()
|
||||
} else {
|
||||
permissionLauncher.launch(Manifest.permission.ACCESS_LOCAL_NETWORK)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun cancelRequest() {
|
||||
requestInProgress = false
|
||||
onAllowed = null
|
||||
showDeniedMessage()
|
||||
}
|
||||
|
||||
private fun hasPermission() = ContextCompat.checkSelfPermission(
|
||||
activity,
|
||||
Manifest.permission.ACCESS_LOCAL_NETWORK
|
||||
) == PackageManager.PERMISSION_GRANTED
|
||||
|
||||
private fun resolvesToLocalNetwork(url: String): Boolean {
|
||||
val host = Uri.parse(url).host?.trim('[', ']')?.lowercase() ?: return false
|
||||
if (host == "localhost" || host.endsWith(".localhost") || host.endsWith(".local") ||
|
||||
host.endsWith(".lan") || host.endsWith(".home") || host.endsWith(".internal")
|
||||
) return true
|
||||
|
||||
return try {
|
||||
InetAddress.getAllByName(host).any { address ->
|
||||
address.isAnyLocalAddress || address.isLoopbackAddress || address.isLinkLocalAddress ||
|
||||
address.isSiteLocalAddress || (address is Inet6Address && (address.address[0].toInt() and 0xfe) == 0xfc)
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
private fun showDeniedMessage() = Toast.makeText(
|
||||
activity,
|
||||
R.string.local_network_permission_denied,
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
|
||||
private companion object {
|
||||
const val ANDROID_17 = 37
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<string name="local_network_permission_title">Allow local network access?</string>
|
||||
<string name="local_network_permission_rationale">Cowspent needs local network access to sync Cospend and Nextcloud servers hosted on your network.</string>
|
||||
<string name="local_network_permission_continue">Continue</string>
|
||||
<string name="local_network_permission_denied">Local network access was denied. Remote server sync is paused.</string>
|
||||
|
||||
<string name="app_name" translatable="false">Cowspent</string>
|
||||
|
||||
<!-- Actions -->
|
||||
@@ -152,9 +147,6 @@
|
||||
<string name="settings_show_archived">Show archived projects</string>
|
||||
<string name="settings_extra_features">Extra Features</string>
|
||||
<string name="settings_extra_features_summary">Experimental and advanced options.</string>
|
||||
<string name="settings_bill_field_order">Bill field order</string>
|
||||
<string name="settings_bill_amount_first">Amount first</string>
|
||||
<string name="settings_bill_what_first">What first</string>
|
||||
<string name="prefill_button">Pre-fill</string>
|
||||
<string name="prefill_mode_off">Nothing</string>
|
||||
<string name="prefill_mode_latest_project">Last from project</string>
|
||||
@@ -193,14 +185,11 @@
|
||||
<string name="pref_key_offline_mode" translatable="false">offlineMode</string>
|
||||
<string name="pref_key_show_archived" translatable="false">showArchived</string>
|
||||
<string name="pref_key_extra_features" translatable="false">betaFeatures</string>
|
||||
<string name="pref_key_bill_field_order" translatable="false">billFieldOrder</string>
|
||||
<string name="pref_key_stats_include_deactivated" translatable="false">statsIncludeDeactivated</string>
|
||||
<string name="pref_key_auto_categorize" translatable="false">autoCategorizeNewBills</string>
|
||||
<string name="pref_key_full_sync_delay" translatable="false">fullSyncDelayMinutes</string>
|
||||
<string name="pref_key_last_account_sync_timestamp" translatable="false">lastAccountSyncTimestamp</string>
|
||||
<string name="pref_key_fill_new_bill_from_last" translatable="false">fillNewBillFromLast</string>
|
||||
<string name="pref_value_bill_amount_first" translatable="false">amount_first</string>
|
||||
<string name="pref_value_bill_what_first" translatable="false">what_first</string>
|
||||
<string name="pref_value_night_mode_no" translatable="false">1</string>
|
||||
<string name="pref_value_night_mode_yes" translatable="false">2</string>
|
||||
<string name="pref_value_night_mode_system" translatable="false">-1</string>
|
||||
|
||||
@@ -43,7 +43,7 @@ class PreviewsTest {
|
||||
@Test fun testEditBillScreen() = renders { net.helcel.cowspent.android.bill_edit.EditBillScreenPreview() }
|
||||
@Test fun testEditBillScreenWeighted() = renders { net.helcel.cowspent.android.bill_edit.EditBillScreenWeightedPreview() }
|
||||
@Test fun testEditBillScreenCustom() = renders { net.helcel.cowspent.android.bill_edit.EditBillScreenCustomPreview() }
|
||||
@Test fun testEditBillScreenFraction() = renders { net.helcel.cowspent.android.bill_edit.EditBillScreenFractionPreview() }
|
||||
@Test fun testEditBillScreenPercent() = renders { net.helcel.cowspent.android.bill_edit.EditBillScreenPercentPreview() }
|
||||
|
||||
@Test fun testUserAvatar() = renders { net.helcel.cowspent.android.helper.UserAvatarPreview() }
|
||||
@Test fun testUserAvatarCustomColor() = renders { net.helcel.cowspent.android.helper.UserAvatarCustomColorPreview() }
|
||||
|
||||
Reference in new issue
Block a user