X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;ds=inline;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2FMobileLedgerApplication.java;h=1bf8b54e7c96ef091f9eaa7f8f19b911a09063df;hb=b7f7df30bf96a995f165b3f7e4321655aac0132a;hp=2cd3db0a0d555859f02419d21389977e6de304d5;hpb=14873dbc3aa249dc5af735c8906be1a19b5f7dda;p=mobile-ledger.git
diff --git a/app/src/main/java/net/ktnx/mobileledger/MobileLedgerApplication.java b/app/src/main/java/net/ktnx/mobileledger/MobileLedgerApplication.java
index 2cd3db0a..1bf8b54e 100644
--- a/app/src/main/java/net/ktnx/mobileledger/MobileLedgerApplication.java
+++ b/app/src/main/java/net/ktnx/mobileledger/MobileLedgerApplication.java
@@ -1,28 +1,34 @@
/*
- * Copyright © 2018 Damyan Ivanov.
- * This file is part of Mobile-Ledger.
- * Mobile-Ledger is free software: you can distribute it and/or modify it
+ * Copyright © 2019 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.
*
- * Mobile-Ledger is distributed in the hope that it will be useful,
+ * 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 Mobile-Ledger. If not, see .
+ * along with MoLe. If not, see .
*/
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 {
@@ -30,25 +36,43 @@ public class MobileLedgerApplication extends Application {
public void onCreate() {
super.onCreate();
updateColorValues();
+ updateMonthNames();
+ 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);
+ }
+ private void updateMonthNames() {
+ Resources rm = getResources();
+ Globals.monthNames = rm.getStringArray(R.array.month_names);
+ }
+ @Override
+ public void onTerminate() {
+ MLDB.done();
+ super.onTerminate();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
updateColorValues();
+ updateMonthNames();
}
private void updateColorValues() {
Resources rm = getResources();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
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.tableRowDarkBG = rm.getColor(R.color.table_row_dark_bg, theme);
+ Globals.tableRowLightBG = rm.getColor(R.color.table_row_light_bg, theme);
+ Globals.primaryDark = rm.getColor(R.color.colorPrimaryDark, 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.tableRowDarkBG = rm.getColor(R.color.table_row_dark_bg);
+ Globals.tableRowLightBG = rm.getColor(R.color.table_row_light_bg);
+ Globals.primaryDark = rm.getColor(R.color.colorPrimaryDark);
Globals.defaultTextColor = rm.getColor(android.R.color.tab_indicator_text);
}
}