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;
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;
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() {
HashMap<String, Void> accountNames = new HashMap<>();
HashMap<String, LedgerAccount> syntheticAccounts = new HashMap<>();
LedgerAccount lastAccount = null, prevAccount = null;
- boolean onlyStarred = Data.optShowOnlyStarred.get();
HttpURLConnection http = NetworkUtil.prepareConnection(profile, "journal");
http.setAllowUserInteraction(false);
}
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);
}
}
- if ((!onlyStarred || !lastAccount.isHiddenByStar()) &&
- lastAccount.isVisible(accountList))
+ if (lastAccount.isVisible(accountList))
accountList.add(lastAccount);
accountNames.put(acct_name, null);
MobileLedgerProfile profile = Data.profile.getValue();
if (profile == null) throw new AssertionError();
String profileUUID = profile.getUuid();
- boolean onlyStarred = Data.optShowOnlyStarred.get();
ArrayList<LedgerAccount> 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();
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;
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;
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 {
public static MutableLiveData<MobileLedgerProfile> profile = new MutableLiveData<>();
public static MutableLiveData<ArrayList<MobileLedgerProfile>> profiles =
new MutableLiveData<>(null);
- public static ObservableValue<Boolean> optShowOnlyStarred = new ObservableValue<>();
public static MutableLiveData<String> accountFilter = new MutableLiveData<>();
private static AtomicInteger backgroundTaskCount = new AtomicInteger(0);
private static Locker profilesLocker = new Locker();
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;
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;