From 9620c937d83a50772d5d329fd92b9a055cef56ad Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sun, 22 Dec 2019 14:21:49 +0200 Subject: [PATCH] drop functionality for limiting account tree display to selected accounts not used since the introduction of collapsible sub-trees --- app/src/main/java/net/ktnx/mobileledger/App.java | 10 ---------- .../mobileledger/async/RetrieveTransactionsTask.java | 8 +++----- .../ktnx/mobileledger/async/UpdateAccountsTask.java | 2 -- .../main/java/net/ktnx/mobileledger/model/Data.java | 6 ++---- .../ui/account_summary/AccountSummaryViewModel.java | 7 ------- 5 files changed, 5 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/App.java b/app/src/main/java/net/ktnx/mobileledger/App.java index 920187e9..bec320e0 100644 --- a/app/src/main/java/net/ktnx/mobileledger/App.java +++ b/app/src/main/java/net/ktnx/mobileledger/App.java @@ -18,11 +18,9 @@ package net.ktnx.mobileledger; import android.app.Application; -import android.content.SharedPreferences; import android.content.res.Configuration; import android.content.res.Resources; import android.database.sqlite.SQLiteDatabase; -import android.preference.PreferenceManager; import android.util.Log; import net.ktnx.mobileledger.model.Data; @@ -36,8 +34,6 @@ import java.net.MalformedURLException; import java.net.PasswordAuthentication; import java.net.URL; -import static net.ktnx.mobileledger.ui.activity.SettingsActivity.PREF_KEY_SHOW_ONLY_STARRED_ACCOUNTS; - public class App extends Application { public static App instance; private MobileLedgerDatabase dbHelper; @@ -52,12 +48,6 @@ public class App extends Application { instance = this; super.onCreate(); updateMonthNames(); - SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(this); - Data.optShowOnlyStarred.set(p.getBoolean(PREF_KEY_SHOW_ONLY_STARRED_ACCOUNTS, false)); - SharedPreferences.OnSharedPreferenceChangeListener handler = - (preference, value) -> Data.optShowOnlyStarred - .set(preference.getBoolean(PREF_KEY_SHOW_ONLY_STARRED_ACCOUNTS, false)); - p.registerOnSharedPreferenceChangeListener(handler); Authenticator.setDefault(new Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { diff --git a/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java b/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java index 5aebe219..807e4375 100644 --- a/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java +++ b/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java @@ -122,7 +122,6 @@ public class RetrieveTransactionsTask HashMap accountNames = new HashMap<>(); HashMap syntheticAccounts = new HashMap<>(); LedgerAccount lastAccount = null, prevAccount = null; - boolean onlyStarred = Data.optShowOnlyStarred.get(); HttpURLConnection http = NetworkUtil.prepareConnection(profile, "journal"); http.setAllowUserInteraction(false); @@ -218,8 +217,8 @@ public class RetrieveTransactionsTask } acc.setHasSubAccounts(true); acc.removeAmounts(); // filled below when amounts are parsed - if ((!onlyStarred || !acc.isHiddenByStar()) && - acc.isVisible(accountList)) accountList.add(acc); + if (acc.isVisible(accountList)) + accountList.add(acc); L(String.format("gap-filling with %s", aName)); accountNames.put(aName, null); profile.storeAccount(db, acc); @@ -227,8 +226,7 @@ public class RetrieveTransactionsTask } } - if ((!onlyStarred || !lastAccount.isHiddenByStar()) && - lastAccount.isVisible(accountList)) + if (lastAccount.isVisible(accountList)) accountList.add(lastAccount); accountNames.put(acct_name, null); diff --git a/app/src/main/java/net/ktnx/mobileledger/async/UpdateAccountsTask.java b/app/src/main/java/net/ktnx/mobileledger/async/UpdateAccountsTask.java index 667bf998..8beab181 100644 --- a/app/src/main/java/net/ktnx/mobileledger/async/UpdateAccountsTask.java +++ b/app/src/main/java/net/ktnx/mobileledger/async/UpdateAccountsTask.java @@ -37,11 +37,9 @@ public class UpdateAccountsTask extends AsyncTask newList = new ArrayList<>(); String sql = "SELECT a.name from accounts a WHERE a.profile = ?"; - if (onlyStarred) sql += " AND a.hidden = 0"; sql += " ORDER BY a.name"; SQLiteDatabase db = App.getDatabase(); diff --git a/app/src/main/java/net/ktnx/mobileledger/model/Data.java b/app/src/main/java/net/ktnx/mobileledger/model/Data.java index 223a61e8..4a79095a 100644 --- a/app/src/main/java/net/ktnx/mobileledger/model/Data.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/Data.java @@ -21,6 +21,8 @@ import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.os.AsyncTask; +import androidx.lifecycle.MutableLiveData; + import net.ktnx.mobileledger.App; import net.ktnx.mobileledger.async.RetrieveTransactionsTask; import net.ktnx.mobileledger.ui.activity.MainActivity; @@ -29,7 +31,6 @@ import net.ktnx.mobileledger.utils.Locker; import net.ktnx.mobileledger.utils.Logger; import net.ktnx.mobileledger.utils.MLDB; import net.ktnx.mobileledger.utils.ObservableList; -import net.ktnx.mobileledger.utils.ObservableValue; import java.lang.ref.WeakReference; import java.util.ArrayList; @@ -38,8 +39,6 @@ import java.util.List; import java.util.Locale; import java.util.concurrent.atomic.AtomicInteger; -import androidx.lifecycle.MutableLiveData; - import static net.ktnx.mobileledger.utils.Logger.debug; public final class Data { @@ -51,7 +50,6 @@ public final class Data { public static MutableLiveData profile = new MutableLiveData<>(); public static MutableLiveData> profiles = new MutableLiveData<>(null); - public static ObservableValue optShowOnlyStarred = new ObservableValue<>(); public static MutableLiveData accountFilter = new MutableLiveData<>(); private static AtomicInteger backgroundTaskCount = new AtomicInteger(0); private static Locker profilesLocker = new Locker(); diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryViewModel.java b/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryViewModel.java index 3e9af7ba..45a088cc 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryViewModel.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryViewModel.java @@ -17,11 +17,9 @@ package net.ktnx.mobileledger.ui.account_summary; -import android.content.Context; import android.os.AsyncTask; import net.ktnx.mobileledger.async.CommitAccountsTask; -import net.ktnx.mobileledger.async.CommitAccountsTaskParams; import net.ktnx.mobileledger.async.UpdateAccountsTask; import net.ktnx.mobileledger.model.Data; import net.ktnx.mobileledger.model.LedgerAccount; @@ -33,11 +31,6 @@ import androidx.lifecycle.ViewModel; import static net.ktnx.mobileledger.utils.Logger.debug; public class AccountSummaryViewModel extends ViewModel { - static void commitSelections(Context context) { - CAT task = new CAT(); - task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, - new CommitAccountsTaskParams(Data.accounts, Data.optShowOnlyStarred.get())); - } static public void scheduleAccountListReload() { if (Data.profile.getValue() == null) return; -- 2.39.5