package net.ktnx.mobileledger.ui.activity;
+import android.annotation.SuppressLint;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
return;
syncingData = true;
try {
+ if (hint == null)
+ hint = tvAmount.getResources()
+ .getString(R.string.zero_amount);
tvAmount.setHint(hint);
}
finally {
*
* @param item updates the UI elements with the data from the model item
*/
+ @SuppressLint("DefaultLocale")
public void setData(NewTransactionModel.Item item) {
beginUpdates();
try {
LedgerTransactionAccount acc = item.getAccount();
tvAccount.setText(acc.getAccountName());
tvAmount.setText(
- acc.isAmountSet() ? String.format(Locale.US, "%1.2f", acc.getAmount())
- : "");
+ acc.isAmountSet() ? String.format("%1.2f", acc.getAmount()) : "");
lHead.setVisibility(View.GONE);
lAccount.setVisibility(View.VISIBLE);
lPadding.setVisibility(View.GONE);
package net.ktnx.mobileledger.ui.activity;
+import android.annotation.SuppressLint;
+
import androidx.annotation.NonNull;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
static final Pattern reYMD = Pattern.compile("^\\s*(\\d+)\\d*/\\s*(\\d+)\\s*/\\s*(\\d+)\\s*$");
static final Pattern reMD = Pattern.compile("^\\s*(\\d+)\\s*/\\s*(\\d+)\\s*$");
static final Pattern reD = Pattern.compile("\\s*(\\d+)\\s*$");
- private static final String ZERO_AMOUNT_HINT = "0.00";
private final Item header = new Item(this, null, "");
private final Item trailer = new Item(this);
private final ArrayList<Item> items = new ArrayList<>();
// 3a) there must be exactly one empty amount
// 4) empty accounts with empty amounts are ignored
// 5) a row with an empty account name or empty amount is guaranteed to exist
+ @SuppressLint("DefaultLocale")
public void checkTransactionSubmittable(NewTransactionItemsAdapter adapter) {
int accounts = 0;
int accounts_with_values = 0;
if (single_empty_amount) {
if (item.equals(empty_amount)) {
- empty_amount.setAmountHint(String.format(Locale.US, "%1.2f",
- Misc.isZero(running_total) ? 0f : -running_total));
+ empty_amount.setAmountHint(Misc.isZero(running_total) ? null
+ : String.format(
+ "%1.2f",
+ -running_total));
continue;
}
}
else {
// no single empty account and this account's amount is not set
// => hint should be '0.00'
- String hint = item.getAmountHint();
- if ((hint == null) || !hint.equals(ZERO_AMOUNT_HINT)) {
- item.setAmountHint(ZERO_AMOUNT_HINT);
- }
+ item.setAmountHint(null);
}
}
android:width="0dp"
android:foregroundGravity="bottom"
android:gravity="bottom|end"
- android:hint="0.00"
- android:inputType="numberSigned|numberDecimal"
+ android:hint="@string/zero_amount"
+ android:inputType="numberSigned|numberDecimal|number"
android:minWidth="70sp"
android:textAlignment="viewEnd"
android:selectAllOnFocus="true"
- tools:ignore="HardcodedText"
android:imeOptions="actionNext"/>
</LinearLayout>
<string name="err_invalid_url">Грешен или непълен адрес</string>
<string name="btn_color_picker_button">Бутон за избор на цвят</string>
<string name="insecure_scheme_with_auth">ВНИМАНИЕ: Използване на удостоверяване с несигурна схема на достъп</string>
+ <string name="zero_amount">0,00</string>
</resources>
<string name="err_invalid_url">Invalid URL</string>
<string name="btn_color_picker_button">Color picker button</string>
<string name="insecure_scheme_with_auth">WARNING: Insecure http used with authentication</string>
+ <string name="zero_amount">0.00</string>
</resources>