2019-02-07 22:39:33 +01:00
|
|
|
package com.beemdevelopment.aegis;
|
2018-05-11 20:08:51 +02:00
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.SharedPreferences;
|
2019-06-22 09:58:35 +02:00
|
|
|
import android.content.res.Resources;
|
|
|
|
import android.os.Build;
|
2018-05-11 20:08:51 +02:00
|
|
|
import android.preference.PreferenceManager;
|
|
|
|
|
2019-06-22 09:58:35 +02:00
|
|
|
import java.util.Locale;
|
|
|
|
|
2018-05-11 20:08:51 +02:00
|
|
|
public class Preferences {
|
|
|
|
private SharedPreferences _prefs;
|
|
|
|
|
|
|
|
public Preferences(Context context) {
|
|
|
|
_prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
}
|
|
|
|
|
2019-03-25 21:32:29 +01:00
|
|
|
public boolean isTapToRevealEnabled() {
|
|
|
|
return _prefs.getBoolean("pref_tap_to_reveal", false);
|
|
|
|
}
|
|
|
|
|
2019-09-11 20:51:02 +02:00
|
|
|
public boolean isSearchAccountNameEnabled() { return _prefs.getBoolean("pref_search_names", false); }
|
|
|
|
|
2018-05-11 20:08:51 +02:00
|
|
|
public boolean isSecureScreenEnabled() {
|
2019-06-19 14:19:49 +02:00
|
|
|
// screen security should be enabled by default, but not for debug builds
|
|
|
|
return _prefs.getBoolean("pref_secure_screen", !BuildConfig.DEBUG);
|
2018-05-11 20:08:51 +02:00
|
|
|
}
|
|
|
|
|
2018-09-19 00:10:03 +02:00
|
|
|
public boolean isAccountNameVisible() {
|
2019-09-15 21:04:36 +02:00
|
|
|
return _prefs.getBoolean("pref_account_name", true);
|
2018-05-11 20:08:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isIntroDone() {
|
|
|
|
return _prefs.getBoolean("pref_intro", false);
|
|
|
|
}
|
|
|
|
|
2019-04-07 18:18:50 +02:00
|
|
|
public boolean isAutoLockEnabled() {
|
|
|
|
return _prefs.getBoolean("pref_auto_lock", true);
|
|
|
|
}
|
|
|
|
|
2018-05-11 20:08:51 +02:00
|
|
|
public void setIntroDone(boolean done) {
|
|
|
|
_prefs.edit().putBoolean("pref_intro", done).apply();
|
|
|
|
}
|
|
|
|
|
2019-03-26 00:06:39 +01:00
|
|
|
public void setTapToRevealTime(int number) {
|
|
|
|
_prefs.edit().putInt("pref_tap_to_reveal_time", number).apply();
|
|
|
|
}
|
|
|
|
|
2019-03-31 22:34:25 +02:00
|
|
|
public void setCurrentSortCategory(SortCategory category) {
|
|
|
|
_prefs.edit().putInt("pref_current_sort_category", category.ordinal()).apply();
|
|
|
|
}
|
|
|
|
|
2019-05-15 21:29:45 +02:00
|
|
|
public SortCategory getCurrentSortCategory() {
|
|
|
|
return SortCategory.fromInteger(_prefs.getInt("pref_current_sort_category", 0));
|
2019-03-31 22:34:25 +02:00
|
|
|
}
|
|
|
|
|
2019-03-26 00:06:39 +01:00
|
|
|
public int getTapToRevealTime() {
|
|
|
|
return _prefs.getInt("pref_tap_to_reveal_time", 30);
|
|
|
|
}
|
|
|
|
|
2019-05-15 21:29:45 +02:00
|
|
|
public Theme getCurrentTheme() {
|
|
|
|
return Theme.fromInteger(_prefs.getInt("pref_current_theme", 0));
|
2019-03-28 00:54:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setCurrentTheme(Theme theme) {
|
|
|
|
_prefs.edit().putInt("pref_current_theme", theme.ordinal()).apply();
|
|
|
|
}
|
|
|
|
|
2019-05-15 21:29:45 +02:00
|
|
|
public ViewMode getCurrentViewMode() {
|
|
|
|
return ViewMode.fromInteger(_prefs.getInt("pref_current_view_mode", 0));
|
2019-04-01 01:21:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setCurrentViewMode(ViewMode viewMode) {
|
|
|
|
_prefs.edit().putInt("pref_current_view_mode", viewMode.ordinal()).apply();
|
|
|
|
}
|
|
|
|
|
2018-05-11 20:08:51 +02:00
|
|
|
public int getTimeout() {
|
|
|
|
return _prefs.getInt("pref_timeout", -1);
|
|
|
|
}
|
2019-06-22 09:58:35 +02:00
|
|
|
|
|
|
|
public Locale getLocale() {
|
|
|
|
String lang = _prefs.getString("pref_lang", "system");
|
|
|
|
|
|
|
|
if (lang.equals("system")) {
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
|
|
|
return Resources.getSystem().getConfiguration().getLocales().get(0);
|
|
|
|
} else {
|
|
|
|
return Resources.getSystem().getConfiguration().locale;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return new Locale(lang);
|
|
|
|
}
|
2018-05-11 20:08:51 +02:00
|
|
|
}
|