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;
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;
}
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;
+ }
+ });
}
}
}
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");
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">
<CheckBox
<string name="action_submit_transaction_title">Запазване</string>
<string name="account_summary_title">Сметки</string>
<string name="menu_hide_acc_condensed_title">Скриване</string>
- <string name="menu_hide_acc_title">Скриване на сметката</string>
+ <string name="menu_acc_view_transactions">Преглед на трансакциите</string>
<string name="menu_acc_summary_refresh_title">Обновяване</string>
<string name="err_net_error">Мрежова грешка</string>
<string name="menu_acc_summary_show_only_starred_title">Показване само на любимите</string>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ Copyright © 2019 Damyan Ivanov.
+ ~ This file is part of MoLe.
+ ~ MoLe is free software: you can distribute it and/or modify it
+ ~ under the term of the GNU General Public License as published by
+ ~ the Free Software Foundation, either version 3 of the License, or
+ ~ (at your opinion), any later version.
+ ~
+ ~ MoLe is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ ~ GNU General Public License terms for details.
+ ~
+ ~ You should have received a copy of the GNU General Public License
+ ~ along with MoLe. If not, see <https://www.gnu.org/licenses/>.
+ -->
+
+<resources>
+ <string-array name="acc_ctx_menu">
+ <item>Show transactions</item>
+ <!--<item>Expand all</item>-->
+ <!--<item>Collapse all</item>-->
+ </string-array>
+</resources>
\ No newline at end of file
<string name="action_submit_transaction_title">Save</string>
<string name="account_summary_title">Accounts</string>
<string name="menu_acc_summary_refresh_title">Refresh</string>
- <string name="menu_hide_acc_title">Hide account</string>
+ <string name="menu_acc_view_transactions">View transactions</string>
<string name="menu_hide_acc_condensed_title">Hide</string>
<string name="menu_acc_summary_show_only_starred_title">Show only starred</string>
<string name="err_bad_auth">Invalid username or password</string>