From: Damyan Ivanov Date: Fri, 7 Dec 2018 19:05:03 +0000 (+0000) Subject: Lay the ground for hiding accounts from the summary X-Git-Tag: v0.3~295 X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=commitdiff_plain;h=840a4c9631b560d200eac182d22f2e253cdd6147 Lay the ground for hiding accounts from the summary hook context menu listener, add menu item to show hidden accounts --- diff --git a/app/src/main/java/net/ktnx/mobileledger/AccountSummary.java b/app/src/main/java/net/ktnx/mobileledger/AccountSummary.java index 0885b090..25ba0317 100644 --- a/app/src/main/java/net/ktnx/mobileledger/AccountSummary.java +++ b/app/src/main/java/net/ktnx/mobileledger/AccountSummary.java @@ -16,6 +16,7 @@ import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.util.Log; import android.util.TypedValue; +import android.view.ContextMenu; import android.view.Gravity; import android.view.Menu; import android.view.MenuItem; @@ -27,6 +28,7 @@ import android.widget.ProgressBar; import android.widget.TableLayout; import android.widget.TableRow; import android.widget.TextView; +import android.widget.Toast; import java.util.Date; import java.util.regex.Matcher; @@ -41,6 +43,8 @@ public class AccountSummary extends AppCompatActivity { private static long account_list_last_updated; private static boolean account_list_needs_update = true; + private TableRow clickedAccountRow; + public static void preferences_changed() { account_list_needs_update = true; } @@ -210,11 +214,23 @@ public class AccountSummary extends AppCompatActivity { return acc_name; } + public void hideAccountClicked(MenuItem item) { + TextView textView = (TextView) clickedAccountRow.getChildAt(0); + Toast.makeText(this, textView.getText(), Toast.LENGTH_SHORT).show(); + } + @SuppressLint("DefaultLocale") private void update_account_table() { LinearLayout root = findViewById(R.id.account_root); root.removeAllViewsInLayout(); + View.OnCreateContextMenuListener ccml = new View.OnCreateContextMenuListener() { + @Override + public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { + clickedAccountRow = (TableRow) v; + getMenuInflater().inflate(R.menu.account_summary_account_menu, menu); + } + }; try (Cursor cursor = db.rawQuery("SELECT name FROM accounts ORDER BY name;", null)) { boolean even = false; @@ -225,10 +241,13 @@ public class AccountSummary extends AppCompatActivity { TableRow r = new TableRow(this); r.setLayoutParams(new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); r.setGravity(Gravity.CENTER_VERTICAL); - r.setPadding(getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin), dp2px(2), getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin), dp2px(4)); + r.setPadding(getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin), dp2px(3), getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin), dp2px(4)); if (even) r.setBackgroundColor(getResources().getColor(R.color.table_row_even_bg, getTheme())); even = !even; + r.setContextClickable(true); + r.setOnCreateContextMenuListener(ccml); + TextView acc_tv = new TextView(this, null, R.style.account_summary_account_name); acc_tv.setLayoutParams(new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 9f)); diff --git a/app/src/main/res/menu/account_summary.xml b/app/src/main/res/menu/account_summary.xml index f416b53d..9c527466 100644 --- a/app/src/main/res/menu/account_summary.xml +++ b/app/src/main/res/menu/account_summary.xml @@ -8,4 +8,7 @@ android:title="@string/menu_acc_summary_refresh_title" android:onClick="onRefreshAccountSummaryClicked" app:showAsAction="ifRoom" /> + \ No newline at end of file diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index ab25a3fa..1d88ef22 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -25,4 +25,9 @@ Заредени са %d сметки Запазване Сметките накратко + Скриване + Скриване на сметката + Обновяване + Мрежова грешка + Показване на скритите сметки \ 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 813ccf05..d15a1134 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -70,4 +70,7 @@ Save Account Summary Refresh + Hide account + Hide + Show hidden accounts