/*
- * Copyright © 2018 Damyan Ivanov.
+ * Copyright © 2019 Damyan Ivanov.
* This file is part of Mobile-Ledger.
* Mobile-Ledger is free software: you can distribute it and/or modify it
* under the term of the GNU General Public License as published by
import android.annotation.SuppressLint;
import android.os.Bundle;
-import android.preference.PreferenceManager;
import android.support.design.widget.BaseTransientBottomBar;
import android.support.design.widget.Snackbar;
import android.support.v4.app.DialogFragment;
import android.widget.TableRow;
import android.widget.TextView;
-import net.ktnx.mobileledger.ui.OnSwipeTouchListener;
import net.ktnx.mobileledger.R;
import net.ktnx.mobileledger.async.SaveTransactionTask;
import net.ktnx.mobileledger.async.TaskCallback;
import net.ktnx.mobileledger.model.LedgerTransaction;
import net.ktnx.mobileledger.model.LedgerTransactionAccount;
import net.ktnx.mobileledger.ui.DatePickerFragment;
+import net.ktnx.mobileledger.ui.OnSwipeTouchListener;
import net.ktnx.mobileledger.utils.MLDB;
import java.util.Date;
/*
* TODO: nicer progress while transaction is submitted
- * TODO: latest transactions, maybe with browsing further in the past?
* TODO: reports
* TODO: get rid of the custom session/cookie and auth code?
* (the last problem with the POST was the missing content-length header)
setSupportActionBar(toolbar);
text_date = findViewById(R.id.new_transaction_date);
- text_date.setOnFocusChangeListener(new View.OnFocusChangeListener() {
- @Override
- public void onFocusChange(View v, boolean hasFocus) {
- if (hasFocus) pickTransactionDate(v);
- }
+ text_date.setOnFocusChangeListener((v, hasFocus) -> {
+ if (hasFocus) pickTransactionDate(v);
});
text_descr = findViewById(R.id.new_transaction_description);
MLDB.hook_autocompletion_adapter(this, text_descr, MLDB.DESCRIPTION_HISTORY_TABLE,
- "description");
+ "description", false, findViewById(R.id.new_transaction_acc_1));
hook_text_change_listener(text_descr);
progress = findViewById(R.id.save_transaction_progress);
AutoCompleteTextView acc_name_view = (AutoCompleteTextView) row.getChildAt(0);
TextView amount_view = (TextView) row.getChildAt(1);
hook_swipe_listener(row);
- MLDB.hook_autocompletion_adapter(this, acc_name_view, MLDB.ACCOUNTS_TABLE, "name");
+ MLDB.hook_autocompletion_adapter(this, acc_name_view, MLDB.ACCOUNTS_TABLE, "name", true,
+ amount_view);
hook_text_change_listener(acc_name_view);
hook_text_change_listener(amount_view);
// Log.d("swipe", "hooked to row "+i);
saver = new SaveTransactionTask(this);
- saver.setPref(PreferenceManager.getDefaultSharedPreferences(this));
String date = text_date.getText().toString();
if (date.isEmpty()) date = String.valueOf(new Date().getDate());
LedgerTransaction tr = new LedgerTransaction(date, text_descr.getText().toString());
if (focus) acc.requestFocus();
hook_swipe_listener(row);
- MLDB.hook_autocompletion_adapter(this, acc, MLDB.ACCOUNTS_TABLE, "name");
+ MLDB.hook_autocompletion_adapter(this, acc, MLDB.ACCOUNTS_TABLE, "name", true, amt);
hook_text_change_listener(acc);
hook_text_change_listener(amt);
}