From: Damyan Ivanov Date: Thu, 28 Mar 2019 17:45:40 +0000 (+0200) Subject: rework showing of account's transactions with a context menu X-Git-Tag: v0.9~59 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=685885185ce21d286a1eb6dadeb86829ece75250;p=mobile-ledger.git rework showing of account's transactions with a context menu not a common option and the ordinary click on the amounts will be used to expand large commodity lists --- diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryAdapter.java b/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryAdapter.java index c2ec0e96..bd71fd74 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryAdapter.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryAdapter.java @@ -31,9 +31,11 @@ import android.widget.TextView; import net.ktnx.mobileledger.R; import net.ktnx.mobileledger.model.Data; import net.ktnx.mobileledger.model.LedgerAccount; +import net.ktnx.mobileledger.ui.activity.MainActivity; import net.ktnx.mobileledger.utils.LockHolder; import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.recyclerview.widget.RecyclerView; @@ -159,6 +161,8 @@ public class AccountSummaryAdapter this.expanderContainer = itemView.findViewById(R.id.account_expander_container); this.expander = itemView.findViewById(R.id.account_expander); + MainActivity activity = (MainActivity) row.getContext(); + expanderContainer.addOnLayoutChangeListener( (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> { int w = right - left; @@ -169,6 +173,27 @@ public class AccountSummaryAdapter } else v.setPadding(0, 0, 0, 0); }); + + itemView.setOnLongClickListener(new View.OnLongClickListener() { + @Override + public boolean onLongClick(View v) { + AlertDialog.Builder builder = new AlertDialog.Builder(itemView.getContext()); + LedgerAccount acc = + (LedgerAccount) v.findViewById(R.id.account_summary_row).getTag(); + builder.setTitle(acc.getName()); + builder.setItems(R.array.acc_ctx_menu, (dialog, which) -> { + switch(which) { + case 0: + // show transactions + activity.showAccountTransactions(acc); + break; + } + dialog.dismiss(); + }); + builder.show(); + return true; + } + }); } } } diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java index cd58740e..9f2777b2 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java @@ -378,14 +378,18 @@ public class MainActivity extends ProfileThemedActivity { public void onLatestTransactionsClicked(View view) { drawer.closeDrawers(); - showTransactionsFragment(null); + showTransactionsFragment((String) null); } private void resetFragmentBackStack() { // fragmentManager.popBackStack(0, FragmentManager.POP_BACK_STACK_INCLUSIVE); } - private void showTransactionsFragment(LedgerAccount account) { - if (account != null) TransactionListFragment.accountFilter.set(account.getName()); + private void showTransactionsFragment(String accName) { + TransactionListFragment.accountFilter.set(accName); + TransactionListFragment.accountFilter.notifyObservers(); mViewPager.setCurrentItem(1, true); + } + private void showTransactionsFragment(LedgerAccount account) { + showTransactionsFragment((account == null) ? (String) null : account.getName()); // FragmentTransaction ft = fragmentManager.beginTransaction(); // if (transactionListFragment == null) { // Log.d("flow", "MainActivity creating TransactionListFragment"); diff --git a/app/src/main/res/layout/account_summary_row.xml b/app/src/main/res/layout/account_summary_row.xml index 257ef602..1fb4588c 100644 --- a/app/src/main/res/layout/account_summary_row.xml +++ b/app/src/main/res/layout/account_summary_row.xml @@ -23,6 +23,7 @@ xmlns:tools="http://schemas.android.com/tools" android:id="@+id/account_summary_row" android:layout_width="match_parent" + android:longClickable="true" android:layout_height="wrap_content"> Запазване Сметки Скриване - Скриване на сметката + Преглед на трансакциите Обновяване Мрежова грешка Показване само на любимите diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml new file mode 100644 index 00000000..17b63296 --- /dev/null +++ b/app/src/main/res/values/arrays.xml @@ -0,0 +1,24 @@ + + + + + Show transactions + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c2d25380..50b808c8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -86,7 +86,7 @@ Save Accounts Refresh - Hide account + View transactions Hide Show only starred Invalid username or password