X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2FAccountSummary.java;h=e34aa6b71d054c45bd838e598cd740f41eaa41ee;hp=77a60074164a85fdad88c2e49d92de395b8a585b;hb=1b884be8a22a3cd1460da24f7378e06cc6f1c51a;hpb=290fdc0c96a468079241e0fb6a90d7ad527f4783 diff --git a/app/src/main/java/net/ktnx/mobileledger/AccountSummary.java b/app/src/main/java/net/ktnx/mobileledger/AccountSummary.java index 77a60074..e34aa6b7 100644 --- a/app/src/main/java/net/ktnx/mobileledger/AccountSummary.java +++ b/app/src/main/java/net/ktnx/mobileledger/AccountSummary.java @@ -28,6 +28,8 @@ import java.lang.ref.WeakReference; import java.util.Date; import java.util.List; +import static net.ktnx.mobileledger.SettingsActivity.PREF_KEY_SHOW_ONLY_STARRED_ACCOUNTS; + public class AccountSummary extends AppCompatActivity { DrawerLayout drawer; @@ -94,7 +96,12 @@ public class AccountSummary extends AppCompatActivity { modelAdapter.startSelection(); if (optMenu != null) { optMenu.findItem(R.id.menu_acc_summary_cancel_selection).setVisible(true); - optMenu.findItem(R.id.menu_acc_summary_hide_selected).setVisible(true); + optMenu.findItem(R.id.menu_acc_summary_confirm_selection).setVisible(true); + optMenu.findItem(R.id.menu_acc_summary_only_starred).setVisible(false); + } + { + FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.btn_add_transaction); + if (fab != null) fab.hide(); } } })); @@ -175,11 +182,11 @@ public class AccountSummary extends AppCompatActivity { if (mShowHiddenAccounts == null) throw new AssertionError(); sBindPreferenceSummaryToValueListener = (preference, value) -> mShowHiddenAccounts - .setChecked(preference.getBoolean("show_hidden_accounts", false)); + .setChecked(preference.getBoolean(PREF_KEY_SHOW_ONLY_STARRED_ACCOUNTS, false)); SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this); pref.registerOnSharedPreferenceChangeListener(sBindPreferenceSummaryToValueListener); - mShowHiddenAccounts.setChecked(pref.getBoolean("show_hidden_accounts", false)); + mShowHiddenAccounts.setChecked(pref.getBoolean(PREF_KEY_SHOW_ONLY_STARRED_ACCOUNTS, false)); return true; } @@ -206,11 +213,11 @@ public class AccountSummary extends AppCompatActivity { public void onShowOnlyStarredClicked(MenuItem mi) { SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this); - boolean flag = pref.getBoolean("show_hidden_accounts", false); + boolean flag = pref.getBoolean(PREF_KEY_SHOW_ONLY_STARRED_ACCOUNTS, false); SharedPreferences.Editor editor = pref.edit(); - editor.putBoolean("show_hidden_accounts", !flag); - Log.d("pref", "Setting show_hidden_accounts to " + (flag ? "false" : "true")); + editor.putBoolean(PREF_KEY_SHOW_ONLY_STARRED_ACCOUNTS, !flag); + Log.d("pref", "Setting show only starred accounts pref to " + (flag ? "false" : "true")); editor.apply(); update_account_table(); @@ -252,11 +259,23 @@ public class AccountSummary extends AppCompatActivity { model.reloadAccounts(); modelAdapter.notifyDataSetChanged(); } - public void onCancelAccSelection(MenuItem item) { + void stopSelection() { modelAdapter.stopSelection(); if (optMenu != null) { optMenu.findItem(R.id.menu_acc_summary_cancel_selection).setVisible(false); - optMenu.findItem(R.id.menu_acc_summary_hide_selected).setVisible(false); + optMenu.findItem(R.id.menu_acc_summary_confirm_selection).setVisible(false); + optMenu.findItem(R.id.menu_acc_summary_only_starred).setVisible(true); + } + { + FloatingActionButton fab = findViewById(R.id.btn_add_transaction); + if (fab != null) fab.show(); } } + public void onCancelAccSelection(MenuItem item) { + stopSelection(); + } + public void onConfirmAccSelection(MenuItem item) { + model.commitSelections(); + stopSelection(); + } }