- try (Cursor cursor = db.rawQuery("SELECT name FROM accounts ORDER BY name;", null)) {
- boolean even = false;
- while (cursor.moveToNext()) {
- String acc_name = cursor.getString(0);
-
- LinearLayout r = new LinearLayout(this);
- r.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
- r.setGravity(Gravity.CENTER_VERTICAL);
- 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 LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT, 5f));
- acc_tv.setGravity(Gravity.CENTER_VERTICAL);
- int[] indent_level = new int[]{0};
- String short_acc_name = strip_higher_accounts(acc_name, indent_level);
- acc_tv.setPadding(indent_level[0] * getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin) / 2, 0, 0, 0);
- acc_tv.setText(short_acc_name);
- r.addView(acc_tv);
-
- TextView amt_tv = new TextView(this, null, R.style.account_summary_amounts);
- amt_tv.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT, 1f));
- amt_tv.setTextAlignment(EditText.TEXT_ALIGNMENT_VIEW_END);
- amt_tv.setGravity(Gravity.CENTER_VERTICAL);
+ int rowHeight =
+ (int) (getTheme().obtainStyledAttributes(new int[]{android.R.attr.actionBarSize})
+ .getDimensionPixelSize(0, dp2px(56)) * 0.75);
+
+ boolean showingHiddenAccounts = PreferenceManager.getDefaultSharedPreferences(this)
+ .getBoolean("show_hidden_accounts", false);
+ Log.d("pref", "show_hidden_accounts is " + (showingHiddenAccounts ? "true" : "false"));
+
+ try(SQLiteDatabase db = dbh.getReadableDatabase()) {
+ try (Cursor cursor = db
+ .rawQuery("SELECT name, hidden FROM accounts ORDER BY name;", null))
+ {
+ boolean even = false;
+ String skippingAccountName = null;
+ while (cursor.moveToNext()) {
+ String acc_name = cursor.getString(0);
+ if (skippingAccountName != null) {
+ if (acc_name.startsWith(skippingAccountName + ":")) continue;
+
+ skippingAccountName = null;
+ }
+
+ boolean is_hidden = cursor.getInt(1) == 1;
+
+ if (!showingHiddenAccounts && is_hidden) {
+ skippingAccountName = acc_name;
+ continue;
+ }
+
+ LinearLayout r = new AccountRowLayout(this, acc_name);
+ r.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.WRAP_CONTENT));
+ r.setGravity(Gravity.CENTER_VERTICAL);
+ r.setPadding(getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin), dp2px(3),
+ getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin),
+ dp2px(4));
+ r.setMinimumHeight(rowHeight);
+
+ if (even) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ r.setBackgroundColor(
+ getResources().getColor(R.color.table_row_even_bg, getTheme()));
+ }
+ else {
+ r.setBackgroundColor(getResources().getColor(R.color.table_row_even_bg));
+ }
+ }
+ even = !even;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ r.setContextClickable(true);
+ }
+ r.setOnCreateContextMenuListener(ccml);
+
+
+ TextView acc_tv = new TextView(this, null, R.style.account_summary_account_name);
+ acc_tv.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
+ ViewGroup.LayoutParams.MATCH_PARENT, 5f));
+ acc_tv.setGravity(Gravity.CENTER_VERTICAL);
+ int[] indent_level = new int[]{0};
+ String short_acc_name = strip_higher_accounts(acc_name, indent_level);
+ acc_tv.setPadding(indent_level[0] * getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin) / 2, 0, 0,
+ 0);
+ acc_tv.setText(short_acc_name);
+ if (is_hidden) acc_tv.setTypeface(null, Typeface.ITALIC);
+ r.addView(acc_tv);
+
+ TextView amt_tv = new TextView(this, null, R.style.account_summary_amounts);
+ amt_tv.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
+ ViewGroup.LayoutParams.MATCH_PARENT, 1f));
+ amt_tv.setTextAlignment(EditText.TEXT_ALIGNMENT_VIEW_END);
+ amt_tv.setGravity(Gravity.CENTER_VERTICAL);