X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2Factivity%2FNewTransactionActivity.java;h=c2ca87b920b930f08bdab076b3d1fabfdf89cd27;hp=43c10b273d579049d6fdd5680c9f52774f82d11d;hb=91c67b5236491400ead1898a421826adff596987;hpb=0bbdc409d82da31324c031f36607510f17d992e6 diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java index 43c10b27..c2ca87b9 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java @@ -1,5 +1,5 @@ /* - * 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 @@ -19,7 +19,6 @@ package net.ktnx.mobileledger.ui.activity; 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; @@ -43,13 +42,13 @@ import android.widget.TableLayout; 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; @@ -57,7 +56,6 @@ import java.util.Objects; /* * 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) @@ -83,15 +81,12 @@ public class NewTransactionActivity extends AppCompatActivity implements TaskCal 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); @@ -103,7 +98,8 @@ public class NewTransactionActivity extends AppCompatActivity implements TaskCal 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); @@ -139,7 +135,6 @@ public class NewTransactionActivity extends AppCompatActivity implements TaskCal 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()); @@ -300,7 +295,7 @@ public class NewTransactionActivity extends AppCompatActivity implements TaskCal 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); }