]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/NewTransactionActivity.java
new transction/submit: when no date is entered, use today
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / NewTransactionActivity.java
index c191e78a82ebbc99d5bca50013fc64d26066267a..1f259fba008d217d8a80c1f852952fad25903130 100644 (file)
@@ -33,6 +33,7 @@ import android.widget.TableLayout;
 import android.widget.TableRow;
 import android.widget.TextView;
 
+import java.util.Date;
 import java.util.Objects;
 
 /*
@@ -74,6 +75,7 @@ public class NewTransactionActivity extends AppCompatActivity implements TaskCal
         });
         text_descr = findViewById(R.id.new_transaction_description);
         hook_autocompletion_adapter(text_descr, MobileLedgerDB.DESCRIPTION_HISTORY_TABLE, "description");
+        hook_text_change_listener(text_descr);
 
         progress = findViewById(R.id.save_transaction_progress);
 
@@ -108,7 +110,9 @@ public class NewTransactionActivity extends AppCompatActivity implements TaskCal
         saver = new SaveTransactionTask(this);
 
         saver.setPref(PreferenceManager.getDefaultSharedPreferences(this));
-        LedgerTransaction tr = new LedgerTransaction(text_date.getText().toString(), text_descr.getText().toString());
+        String date = text_date.getText().toString();
+        if (date.isEmpty()) date = String.valueOf(new Date().getDate());
+        LedgerTransaction tr = new LedgerTransaction(date, text_descr.getText().toString());
 
         TableLayout table = findViewById(R.id.new_transaction_accounts_table);
         for ( int i = 0; i < table.getChildCount(); i++ ) {