/*
- * Copyright © 2018 Damyan Ivanov.
+ * Copyright © 2019 Damyan Ivanov.
* This file is part of Mobile-Ledger.
* Mobile-Ledger is free software: you can distribute it and/or modify it
* under the term of the GNU General Public License as published by
package net.ktnx.mobileledger;
import android.app.Application;
+import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
+import android.preference.PreferenceManager;
+import net.ktnx.mobileledger.model.Data;
import net.ktnx.mobileledger.utils.Globals;
+import net.ktnx.mobileledger.utils.MLDB;
+
+import static net.ktnx.mobileledger.ui.activity.SettingsActivity.PREF_KEY_SHOW_ONLY_STARRED_ACCOUNTS;
public class MobileLedgerApplication extends Application {
public void onCreate() {
super.onCreate();
updateColorValues();
+ MLDB.init(this);
+ 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);
+ }
+ @Override
+ public void onTerminate() {
+ MLDB.done();
+ super.onTerminate();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
Resources.Theme theme = getTheme();
Globals.table_row_odd_bg = rm.getColor(R.color.table_row_odd_bg, theme);
Globals.table_row_even_bg = rm.getColor(R.color.table_row_even_bg, theme);
+ Globals.primaryDark = rm.getColor(R.color.design_default_color_primary_dark, theme);
+ Globals.defaultTextColor = rm.getColor(android.R.color.tab_indicator_text, theme);
}
else {
Globals.table_row_odd_bg = rm.getColor(R.color.table_row_odd_bg);
Globals.table_row_even_bg = rm.getColor(R.color.table_row_even_bg);
+ Globals.primaryDark = rm.getColor(R.color.design_default_color_primary_dark);
+ Globals.defaultTextColor = rm.getColor(android.R.color.tab_indicator_text);
}
}
}