]> git.ktnx.net Git - mobile-ledger.git/commitdiff
drop accounts.hidden and "hidden by star" handling
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 5 Jul 2020 14:42:59 +0000 (17:42 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 5 Jul 2020 14:42:59 +0000 (17:42 +0300)
long gone from the interface

app/src/main/java/net/ktnx/mobileledger/async/CommitAccountsTask.java
app/src/main/java/net/ktnx/mobileledger/async/CommitAccountsTaskParams.java
app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java
app/src/main/java/net/ktnx/mobileledger/model/LedgerAccount.java
app/src/main/java/net/ktnx/mobileledger/model/MobileLedgerProfile.java
app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryAdapter.java
app/src/main/java/net/ktnx/mobileledger/utils/MobileLedgerDatabase.java
app/src/main/res/raw/create_db.sql
app/src/main/res/raw/sql_35.sql [new file with mode: 0644]

index 00b33336e405930588fa854b96a7b1bf8a093687..eb3dfbba51b0997424114ac55ba5a59782eebc80 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2019 Damyan Ivanov.
+ * Copyright © 2020 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
@@ -48,9 +48,6 @@ public class CommitAccountsTask
                         db.execSQL("UPDATE accounts SET hidden=? WHERE profile=? AND name=?",
                                 new Object[]{acc.isHiddenByStarToBe() ? 1 : 0, profile, acc.getName()
                                 });
-
-                        acc.setHiddenByStar(acc.isHiddenByStarToBe());
-                        if (!params[0].showOnlyStarred || !acc.isHiddenByStar()) newList.add(acc);
                     }
                     db.setTransactionSuccessful();
                 }
index ae3a0b9a66b39a15457982ff18a80074a4f4ebdc..90728282bdb4642498b216b711bee30156dc14f2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2019 Damyan Ivanov.
+ * Copyright © 2020 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
@@ -22,9 +22,7 @@ import net.ktnx.mobileledger.utils.ObservableList;
 
 public class CommitAccountsTaskParams {
     ObservableList<LedgerAccount> accountList;
-    boolean showOnlyStarred;
     public CommitAccountsTaskParams(ObservableList<LedgerAccount> accountList, boolean showOnlyStarred) {
         this.accountList = accountList;
-        this.showOnlyStarred = showOnlyStarred;
     }
 }
index d7c1996f51403c448d43278a57f45c4017c9f637..1f4ee97238debc8b1b1be6a1921d93ff0f07579f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2019 Damyan Ivanov.
+ * Copyright © 2020 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
@@ -248,7 +248,6 @@ public class RetrieveTransactionsTask
                                         LedgerAccount acc = profile.tryLoadAccount(db, aName);
                                         if (acc == null) {
                                             acc = new LedgerAccount(aName);
-                                            acc.setHiddenByStar(lastAccount.isHiddenByStar());
                                             acc.setExpanded(!lastAccount.hasSubAccounts() ||
                                                             lastAccount.isExpanded());
                                         }
index 256be6f082f7ee936f94943efde6782cf82386c3..a762e3a9dba1d8a3dc295d605b3ee73bb56fbec7 100644 (file)
@@ -31,7 +31,6 @@ public class LedgerAccount {
     private String shortName;
     private int level;
     private String parentName;
-    private boolean hiddenByStar;
     private boolean hiddenByStarToBe;
     private boolean expanded;
     private List<LedgerAmount> amounts;
@@ -40,12 +39,10 @@ public class LedgerAccount {
 
     public LedgerAccount(String name) {
         this.setName(name);
-        hiddenByStar = false;
     }
 
     public LedgerAccount(String name, float amount) {
         this.setName(name);
-        this.hiddenByStar = false;
         this.expanded = true;
         this.amounts = new ArrayList<LedgerAmount>();
         this.addAmount(amount);
@@ -65,8 +62,6 @@ public class LedgerAccount {
     //  - it is starred (not hidden by a star)
     //  - and it has an expanded parent or is a top account
     public boolean isVisible() {
-        if (hiddenByStar) return false;
-
         if (level == 0) return true;
 
         return isVisible(Data.accounts);
@@ -82,12 +77,6 @@ public class LedgerAccount {
     public boolean isParentOf(LedgerAccount potentialChild) {
         return potentialChild.getName().startsWith(name + ":");
     }
-    public boolean isHiddenByStar() {
-        return hiddenByStar;
-    }
-    public void setHiddenByStar(boolean hiddenByStar) {
-        this.hiddenByStar = hiddenByStar;
-    }
     private void stripName() {
         level = 0;
         shortName = name;
@@ -159,10 +148,6 @@ public class LedgerAccount {
     public String getParentName() {
         return parentName;
     }
-    public void togglehidden() {
-        hiddenByStar = !hiddenByStar;
-    }
-
     public boolean isHiddenByStarToBe() {
         return hiddenByStarToBe;
     }
index 2de99c8f3b30f8880a250d0b628df52985004faa..32122c6cd32b55e967e525f05461cd5a4d0940e0 100644 (file)
@@ -269,15 +269,14 @@ public final class MobileLedgerProfile {
     public void storeAccount(SQLiteDatabase db, LedgerAccount acc) {
         // replace into is a bad idea because it would reset hidden to its default value
         // we like the default, but for new accounts only
-        db.execSQL("update accounts set level = ?, keep = 1, hidden=?, expanded=? " +
+        db.execSQL("update accounts set level = ?, keep = 1, expanded=? " +
                    "where profile=? and name = ?",
-                new Object[]{acc.getLevel(), acc.isHiddenByStar(), acc.isExpanded(), uuid,
-                             acc.getName()
+                new Object[]{acc.getLevel(), acc.isExpanded(), uuid, acc.getName()
                 });
-        db.execSQL("insert into accounts(profile, name, name_upper, parent_name, level, hidden, " +
-                   "expanded, keep) " + "select ?,?,?,?,?,?,?,1 where (select changes() = 0)",
+        db.execSQL("insert into accounts(profile, name, name_upper, parent_name, level, " +
+                   "expanded, keep) " + "select ?,?,?,?,?,?,1 where (select changes() = 0)",
                 new Object[]{uuid, acc.getName(), acc.getName().toUpperCase(), acc.getParentName(),
-                             acc.getLevel(), acc.isHiddenByStar(), acc.isExpanded()
+                             acc.getLevel(), acc.isExpanded()
                 });
 //        debug("accounts", String.format("Stored account '%s' in DB [%s]", acc.getName(), uuid));
     }
@@ -403,16 +402,15 @@ public final class MobileLedgerProfile {
     }
     @Nullable
     public LedgerAccount tryLoadAccount(SQLiteDatabase db, String accName) {
-        try (Cursor cursor = db.rawQuery(
-                "SELECT a.hidden, a.expanded, (select 1 from accounts a2 " +
-                "where a2.profile = a.profile and a2.name like a.name||':%' limit 1) " +
-                "FROM accounts a WHERE a.profile = ? and a.name=?", new String[]{uuid, accName}))
+        try (Cursor cursor = db.rawQuery("SELECT a.expanded, (select 1 from accounts a2 " +
+                                         "where a2.profile = a.profile and a2.name like a" +
+                                         ".name||':%' limit 1) " +
+                                         "FROM accounts a WHERE a.profile = ? and a.name=?", new String[]{uuid, accName}))
         {
             if (cursor.moveToFirst()) {
                 LedgerAccount acc = new LedgerAccount(accName);
-                acc.setHiddenByStar(cursor.getInt(0) == 1);
-                acc.setExpanded(cursor.getInt(1) == 1);
-                acc.setHasSubAccounts(cursor.getInt(2) == 1);
+                acc.setExpanded(cursor.getInt(0) == 1);
+                acc.setHasSubAccounts(cursor.getInt(1) == 1);
 
                 try (Cursor c2 = db.rawQuery(
                         "SELECT value, currency FROM account_values WHERE profile = ? " +
index 47cc14b45bc5311858e0522a2cc05c1bf52d588d..0540438ddcd6c47e4e7d9e873c393cd4a50cdb66 100644 (file)
@@ -19,7 +19,6 @@ package net.ktnx.mobileledger.ui.account_summary;
 
 import android.content.Context;
 import android.content.res.Resources;
-import android.graphics.Typeface;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -70,15 +69,6 @@ public class AccountSummaryAdapter
                     holder.accountExpanderContainer.setVisibility(View.GONE);
                 }
 
-                if (acc.isHiddenByStar()) {
-                    holder.tvAccountName.setTypeface(null, Typeface.ITALIC);
-                    holder.tvAccountAmounts.setTypeface(null, Typeface.ITALIC);
-                }
-                else {
-                    holder.tvAccountName.setTypeface(null, Typeface.NORMAL);
-                    holder.tvAccountAmounts.setTypeface(null, Typeface.NORMAL);
-                }
-
                 holder.row.setTag(R.id.POS, position);
         }
     }
index ffdeb9e4cd39fde15d2c73922aed206e06b8c8f6..b2a01f4d4f7bdf4e985ba3c81477aa96911f6b2e 100644 (file)
@@ -34,7 +34,7 @@ import static net.ktnx.mobileledger.utils.Logger.debug;
 
 public class MobileLedgerDatabase extends SQLiteOpenHelper {
     private static final String DB_NAME = "MoLe.db";
-    private static final int LATEST_REVISION = 34;
+    private static final int LATEST_REVISION = 35;
     private static final String CREATE_DB_SQL = "create_db";
 
     private final Application mContext;
index da3e8d8b2eb73866df59419ad6a7c8eba3aa2715..14a0311ad831a1d49e046ae6d208eafab2446f02 100644 (file)
@@ -12,7 +12,7 @@
 --
 -- You should have received a copy of the GNU General Public License
 -- along with MoLe. If not, see <https://www.gnu.org/licenses/>.
-create table accounts(profile varchar not null, name varchar not null, name_upper varchar not null, hidden boolean not null default 0, keep boolean not null default 0, level integer not null, parent_name varchar, expanded default 1, amounts_expanded boolean default 0);
+create table accounts(profile varchar not null, name varchar not null, name_upper varchar not null, keep boolean not null default 0, level integer not null, parent_name varchar, expanded default 1, amounts_expanded boolean default 0);
 create unique index un_accounts on accounts(profile, name);
 create table options(profile varchar not null, name varchar not null, value varchar);
 create unique index un_options on options(profile,name);
@@ -26,4 +26,4 @@ create unique index un_transactions_data_hash on transactions(profile,data_hash)
 create index idx_transaction_description on transactions(description);
 create table transaction_accounts(profile varchar not null, transaction_id integer not null, account_name varchar not null, currency varchar not null default '', amount decimal not null, comment varchar, constraint fk_transaction_accounts_acc foreign key(profile,account_name) references accounts(profile,account_name), constraint fk_transaction_accounts_trn foreign key(profile, transaction_id) references transactions(profile,id));
 create table currencies(id integer not null primary key, name varchar not null, position varchar not null, has_gap boolean not null);
--- updated to revision 34
\ No newline at end of file
+-- updated to revision 35
\ No newline at end of file
diff --git a/app/src/main/res/raw/sql_35.sql b/app/src/main/res/raw/sql_35.sql
new file mode 100644 (file)
index 0000000..0a77c3e
--- /dev/null
@@ -0,0 +1,18 @@
+-- Copyright © 2020 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/>.
+create table accounts_new(profile varchar not null, name varchar not null, name_upper varchar not null, keep boolean not null default 0, level integer not null, parent_name varchar, expanded default 1, amounts_expanded boolean default 0);
+insert into accounts_new(profile, name, name_upper, keep, level, parent_name, expanded, amounts_expanded) select profile, name, name_upper, keep, level, parent_name, expanded, amounts_expanded from accounts;
+drop table accounts;
+alter table accounts_new rename to accounts;