From: Damyan Ivanov Date: Mon, 25 Nov 2019 21:25:52 +0000 (+0200) Subject: NT: account/amount focus also survives re-configuration X-Git-Tag: v0.11.0~27 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=a08a6e0d8f07a3d709aa4efa0cce5d8a444a2dfe;p=mobile-ledger.git NT: account/amount focus also survives re-configuration --- diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemHolder.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemHolder.java index fc175606..f83eec8a 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemHolder.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemHolder.java @@ -38,6 +38,7 @@ import net.ktnx.mobileledger.async.DescriptionSelectedCallback; import net.ktnx.mobileledger.model.Data; import net.ktnx.mobileledger.model.LedgerTransactionAccount; import net.ktnx.mobileledger.model.MobileLedgerProfile; +import net.ktnx.mobileledger.ui.AutoCompleteTextViewWithClear; import net.ktnx.mobileledger.ui.DatePickerFragment; import net.ktnx.mobileledger.utils.Logger; import net.ktnx.mobileledger.utils.MLDB; @@ -96,7 +97,14 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder boolean wasSyncing = syncingData; syncingData = true; try { - adapter.updateFocusedItem(getAdapterPosition()); + final int pos = getAdapterPosition(); + adapter.updateFocusedItem(pos); + if (v instanceof AutoCompleteTextViewWithClear) { + adapter.noteFocusIsOnAccount(pos); + } + else { + adapter.noteFocusIsOnAmount(pos); + } } finally { syncingData = wasSyncing; @@ -233,10 +241,15 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder case transactionRow: // do nothing if a row element already has the focus if (!itemView.hasFocus()) { - focused = tvAccount.requestFocus(); - tvAccount.dismissDropDown(); - if (focused) - Misc.showSoftKeyboard((NewTransactionActivity) tvAccount.getContext()); + if (item.focusIsOnAmount()) { + tvAmount.requestFocus(); + } + else { + focused = tvAccount.requestFocus(); + tvAccount.dismissDropDown(); + if (focused) + Misc.showSoftKeyboard((NewTransactionActivity) tvAccount.getContext()); + } } break; diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemsAdapter.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemsAdapter.java index 452e348e..cb03f3d1 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemsAdapter.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemsAdapter.java @@ -204,4 +204,10 @@ class NewTransactionItemsAdapter extends RecyclerView.Adapter amountHint = new MutableLiveData<>(null); private NewTransactionModel model; private MutableLiveData editable = new MutableLiveData<>(true); + public boolean focusIsOnAmount() { + return focusIsOnAmount; + } + private boolean focusIsOnAmount = false; public Item(NewTransactionModel model) { this.model = model; type = ItemType.bottomFiller; @@ -467,5 +477,8 @@ public class NewTransactionModel extends ViewModel { public void stopObservingEditableFlag(Observer observer) { editable.removeObserver(observer); } + public void setFocusIsOnAmount(boolean flag) { + focusIsOnAmount = flag; + } } }