]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionModel.java
NT: correctly disable swiping of top and bottom entries, let all the rest be swiped
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / activity / NewTransactionModel.java
index 62f85ba9bed06220d66cde8722f5750e05593a4e..7c49bf1b4b08a0e49ad9b166ed147367ea7ab894 100644 (file)
@@ -56,6 +56,7 @@ public class NewTransactionModel extends ViewModel {
     private final MutableLiveData<Integer> focusedItem = new MutableLiveData<>(0);
     private final MutableLiveData<Integer> accountCount = new MutableLiveData<>(0);
     private final MutableLiveData<Boolean> simulateSave = new MutableLiveData<>(false);
+    final MutableLiveData<Boolean> showCurrency = new MutableLiveData<>(false);
     public boolean getSimulateSave() {
         return simulateSave.getValue();
     }
@@ -152,6 +153,8 @@ public class NewTransactionModel extends ViewModel {
      3a) there must be exactly one empty amount (with account)
      4) empty accounts with empty amounts are ignored
      5) a row with an empty account name or empty amount is guaranteed to exist
+     6) at least two rows need to be present in the ledger
+
     */
     @SuppressLint("DefaultLocale")
     public void checkTransactionSubmittable(NewTransactionItemsAdapter adapter) {
@@ -257,6 +260,9 @@ public class NewTransactionModel extends ViewModel {
                 adapter.addRow();
             }
 
+            // 6) at least two rows need to be present in the ledger
+            while (this.items.size() < 2) adapter.addRow();
+
 
             debug("submittable", submittable ? "YES" : "NO");
             isSubmittable.setValue(submittable);
@@ -318,6 +324,9 @@ public class NewTransactionModel extends ViewModel {
             items.add(itemCount - 1, acc);
         }
     }
+    public void toggleCurrencyVisible() {
+        showCurrency.setValue(!showCurrency.getValue());
+    }
     enum ItemType {generalData, transactionRow, bottomFiller}
 
     //==========================================================================================