2016-07-29 14:00:28 +02:00
|
|
|
/*
|
|
|
|
This file is part of the Diaspora for Android.
|
|
|
|
Diaspora for Android is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
Diaspora for Android 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 for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with the Diaspora for Android.
|
|
|
|
If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2016-03-29 19:38:50 +02:00
|
|
|
package com.github.dfa.diaspora_android.data;
|
2016-03-20 22:49:11 +01:00
|
|
|
|
2016-06-17 19:43:28 +02:00
|
|
|
import android.annotation.SuppressLint;
|
2016-03-20 22:49:11 +01:00
|
|
|
import android.content.Context;
|
|
|
|
import android.content.SharedPreferences;
|
|
|
|
|
2016-08-02 21:32:42 +02:00
|
|
|
import com.github.dfa.diaspora_android.R;
|
2016-10-07 02:43:12 +02:00
|
|
|
import com.github.dfa.diaspora_android.data.DiasporaPodList.DiasporaPod;
|
|
|
|
import com.github.dfa.diaspora_android.data.DiasporaPodList.DiasporaPod.DiasporaPodUrl;
|
2016-10-14 01:26:56 +02:00
|
|
|
import com.github.dfa.diaspora_android.util.ProxyHandler;
|
2016-10-07 02:43:12 +02:00
|
|
|
|
|
|
|
import org.json.JSONException;
|
|
|
|
import org.json.JSONObject;
|
2016-08-02 21:32:42 +02:00
|
|
|
|
2016-03-20 22:49:11 +01:00
|
|
|
/**
|
2016-08-23 21:23:36 +02:00
|
|
|
* Settings
|
2016-07-29 14:00:28 +02:00
|
|
|
* Created by gsantner (https://gsantner.github.io/) on 20.03.16. Part of Diaspora for Android.
|
2016-03-20 22:49:11 +01:00
|
|
|
*/
|
2016-03-26 01:14:17 +01:00
|
|
|
public class AppSettings {
|
2016-06-04 03:48:57 +02:00
|
|
|
private final SharedPreferences prefApp;
|
|
|
|
private final SharedPreferences prefPod;
|
2016-03-25 00:12:00 +01:00
|
|
|
private final Context context;
|
2016-10-07 02:43:12 +02:00
|
|
|
private DiasporaPod currentPod0Cached;
|
2016-03-20 22:49:11 +01:00
|
|
|
|
2016-03-24 11:58:28 +01:00
|
|
|
public AppSettings(Context context) {
|
2016-03-25 00:12:00 +01:00
|
|
|
this.context = context.getApplicationContext();
|
2016-06-04 03:48:57 +02:00
|
|
|
prefApp = this.context.getSharedPreferences("app", Context.MODE_PRIVATE);
|
|
|
|
prefPod = this.context.getSharedPreferences("pod0", Context.MODE_PRIVATE);
|
2016-03-20 22:49:11 +01:00
|
|
|
}
|
|
|
|
|
2016-06-05 17:25:11 +02:00
|
|
|
public Context getApplicationContext() {
|
|
|
|
return context;
|
|
|
|
}
|
|
|
|
|
2016-06-04 03:48:57 +02:00
|
|
|
public void clearPodSettings() {
|
|
|
|
prefPod.edit().clear().apply();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void clearAppSettings() {
|
|
|
|
prefApp.edit().clear().apply();
|
|
|
|
}
|
|
|
|
|
2016-10-25 23:04:16 +02:00
|
|
|
public String getKey(int stringKeyRessourceId){
|
|
|
|
return context.getString(stringKeyRessourceId);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isKeyEqual(String key, int stringKeyRessourceId){
|
|
|
|
return key.equals(getKey(stringKeyRessourceId));
|
|
|
|
}
|
|
|
|
|
2016-08-02 21:32:42 +02:00
|
|
|
private void setString(SharedPreferences pref, int keyRessourceId, String value) {
|
|
|
|
pref.edit().putString(context.getString(keyRessourceId), value).apply();
|
2016-03-24 11:58:28 +01:00
|
|
|
}
|
2016-03-26 01:14:17 +01:00
|
|
|
|
2016-08-02 21:32:42 +02:00
|
|
|
private void setInt(SharedPreferences pref, int keyRessourceId, int value) {
|
|
|
|
pref.edit().putInt(context.getString(keyRessourceId), value).apply();
|
2016-03-24 11:58:28 +01:00
|
|
|
}
|
2016-03-26 01:14:17 +01:00
|
|
|
|
2016-08-02 21:32:42 +02:00
|
|
|
private void setBool(SharedPreferences pref, int keyRessourceId, boolean value) {
|
|
|
|
pref.edit().putBoolean(context.getString(keyRessourceId), value).apply();
|
2016-03-20 22:49:11 +01:00
|
|
|
}
|
|
|
|
|
2016-08-02 21:32:42 +02:00
|
|
|
private void setStringArray(SharedPreferences pref, int keyRessourceId, Object[] values) {
|
2016-08-23 21:23:36 +02:00
|
|
|
StringBuilder sb = new StringBuilder();
|
2016-06-05 17:25:11 +02:00
|
|
|
for (Object value : values) {
|
2016-06-05 13:57:34 +02:00
|
|
|
sb.append("%%%");
|
2016-06-05 17:25:11 +02:00
|
|
|
sb.append(value.toString());
|
2016-06-05 13:57:34 +02:00
|
|
|
}
|
2016-08-02 21:32:42 +02:00
|
|
|
setString(pref, keyRessourceId, sb.toString().replaceFirst("%%%", ""));
|
2016-06-05 13:57:34 +02:00
|
|
|
}
|
|
|
|
|
2016-08-02 21:32:42 +02:00
|
|
|
private String[] getStringArray(SharedPreferences pref, int keyRessourceId) {
|
|
|
|
String value = pref.getString(context.getString(keyRessourceId), "%%%");
|
2016-06-05 17:25:11 +02:00
|
|
|
if (value.equals("%%%")) {
|
2016-06-05 13:57:34 +02:00
|
|
|
return new String[0];
|
|
|
|
}
|
|
|
|
return value.split("%%%");
|
|
|
|
}
|
|
|
|
|
2016-08-02 21:32:42 +02:00
|
|
|
private String getString(SharedPreferences pref, int ressourceId, String defaultValue) {
|
|
|
|
return pref.getString(context.getString(ressourceId), defaultValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean getBoolean(SharedPreferences pref, int ressourceId, boolean defaultValue) {
|
|
|
|
return pref.getBoolean(context.getString(ressourceId), defaultValue);
|
2016-06-04 03:48:57 +02:00
|
|
|
}
|
2016-03-25 00:12:00 +01:00
|
|
|
|
2016-08-07 11:39:20 +02:00
|
|
|
private int getInt(SharedPreferences pref, int ressourceId, int defaultValue) {
|
|
|
|
return pref.getInt(context.getString(ressourceId), defaultValue);
|
|
|
|
}
|
|
|
|
|
2016-10-25 23:04:16 +02:00
|
|
|
public int getColor(SharedPreferences pref, String key, int defaultColor) {
|
|
|
|
return pref.getInt(key, defaultColor);
|
|
|
|
}
|
|
|
|
|
2016-03-24 11:58:28 +01:00
|
|
|
|
2016-03-20 22:49:11 +01:00
|
|
|
/*
|
|
|
|
// Setters & Getters
|
|
|
|
*/
|
2016-03-24 11:58:28 +01:00
|
|
|
public String getProfileId() {
|
2016-08-02 21:32:42 +02:00
|
|
|
return getString(prefPod, R.string.pref_key__podprofile_id, "");
|
2016-03-20 22:49:11 +01:00
|
|
|
}
|
2016-03-24 11:58:28 +01:00
|
|
|
|
|
|
|
public void setProfileId(String profileId) {
|
2016-08-02 21:32:42 +02:00
|
|
|
setString(prefPod, R.string.pref_key__podprofile_id, profileId);
|
2016-03-20 22:49:11 +01:00
|
|
|
}
|
2016-03-24 11:58:28 +01:00
|
|
|
|
|
|
|
public boolean isLoadImages() {
|
2016-08-02 21:32:42 +02:00
|
|
|
return getBoolean(prefApp, R.string.pref_key__load_images, true);
|
2016-03-24 11:58:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getMinimumFontSize() {
|
2016-08-02 21:32:42 +02:00
|
|
|
switch (getString(prefApp, R.string.pref_key__font_size, "")) {
|
2016-06-16 22:55:06 +02:00
|
|
|
case "huge":
|
|
|
|
return 20;
|
|
|
|
case "large":
|
|
|
|
return 16;
|
|
|
|
case "normal":
|
|
|
|
return 8;
|
|
|
|
default:
|
2016-08-02 21:32:42 +02:00
|
|
|
setString(prefApp, R.string.pref_key__font_size, "normal");
|
2016-06-16 22:55:06 +02:00
|
|
|
return 8;
|
|
|
|
}
|
2016-03-24 11:58:28 +01:00
|
|
|
}
|
2016-03-25 00:12:00 +01:00
|
|
|
|
|
|
|
public String getAvatarUrl() {
|
2016-08-02 21:32:42 +02:00
|
|
|
return getString(prefPod, R.string.pref_key__podprofile_avatar_url, "");
|
2016-03-25 00:12:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setAvatarUrl(String avatarUrl) {
|
2016-08-02 21:32:42 +02:00
|
|
|
setString(prefPod, R.string.pref_key__podprofile_avatar_url, avatarUrl);
|
2016-03-25 00:12:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-26 01:14:17 +01:00
|
|
|
public String getName() {
|
2016-08-02 21:32:42 +02:00
|
|
|
return getString(prefPod, R.string.pref_key__podprofile_name, "");
|
2016-03-25 00:12:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-26 01:14:17 +01:00
|
|
|
public void setName(String name) {
|
2016-08-02 21:32:42 +02:00
|
|
|
setString(prefPod, R.string.pref_key__podprofile_name, name);
|
2016-03-25 00:12:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-10-07 02:43:12 +02:00
|
|
|
// TODO: Remove legacy at some time ;)
|
|
|
|
public void upgradeLegacyPoddomain() {
|
|
|
|
String legacy = getString(prefPod, R.string.pref_key__poddomain_legacy, "");
|
|
|
|
if (!legacy.equals("")) {
|
|
|
|
DiasporaPod pod = new DiasporaPod();
|
|
|
|
pod.setName(legacy);
|
|
|
|
pod.getPodUrls().add(new DiasporaPodUrl().setHost(legacy));
|
|
|
|
setPod(pod);
|
|
|
|
}
|
2016-03-25 00:12:00 +01:00
|
|
|
}
|
|
|
|
|
2016-10-07 02:43:12 +02:00
|
|
|
public DiasporaPod getPod() {
|
|
|
|
upgradeLegacyPoddomain();
|
|
|
|
if (currentPod0Cached == null) {
|
|
|
|
String pref = getString(prefPod, R.string.pref_key__current_pod_0, "");
|
|
|
|
|
|
|
|
try {
|
|
|
|
currentPod0Cached = new DiasporaPod().fromJson(new JSONObject(pref));
|
|
|
|
} catch (JSONException e) {
|
|
|
|
currentPod0Cached = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return currentPod0Cached;
|
2016-06-04 03:48:57 +02:00
|
|
|
}
|
2016-06-05 13:57:34 +02:00
|
|
|
|
2016-10-07 02:43:12 +02:00
|
|
|
public void setPod(DiasporaPod pod) {
|
|
|
|
try {
|
|
|
|
setString(prefPod, R.string.pref_key__current_pod_0,
|
|
|
|
pod == null ? null : pod.toJson().toString());
|
|
|
|
currentPod0Cached = pod;
|
|
|
|
} catch (JSONException ignored) {
|
|
|
|
}
|
2016-06-05 13:57:34 +02:00
|
|
|
}
|
|
|
|
|
2016-10-07 02:43:12 +02:00
|
|
|
public boolean hasPod() {
|
|
|
|
upgradeLegacyPoddomain();
|
|
|
|
return !getString(prefPod, R.string.pref_key__current_pod_0, "").equals("");
|
2016-06-05 13:57:34 +02:00
|
|
|
}
|
2016-06-05 17:25:11 +02:00
|
|
|
|
|
|
|
public void setPodAspects(PodAspect[] aspects) {
|
2016-08-02 21:32:42 +02:00
|
|
|
setStringArray(prefPod, R.string.pref_key__podprofile_aspects, aspects);
|
2016-06-05 17:25:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public PodAspect[] getPodAspects() {
|
2016-08-02 21:32:42 +02:00
|
|
|
String[] s = getStringArray(prefPod, R.string.pref_key__podprofile_aspects);
|
2016-06-05 17:25:11 +02:00
|
|
|
PodAspect[] aspects = new PodAspect[s.length];
|
2016-08-02 21:32:42 +02:00
|
|
|
for (int i = 0; i < aspects.length; i++) {
|
2016-06-05 17:25:11 +02:00
|
|
|
aspects[i] = new PodAspect(s[i]);
|
|
|
|
}
|
|
|
|
return aspects;
|
|
|
|
}
|
2016-06-09 01:03:50 +02:00
|
|
|
|
2016-07-18 14:02:18 +02:00
|
|
|
public String[] getFollowedTags() {
|
2016-08-02 21:32:42 +02:00
|
|
|
return getStringArray(prefPod, R.string.pref_key__podprofile_followed_tags);
|
2016-07-18 14:02:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setFollowedTags(String[] tags) {
|
2016-08-02 21:32:42 +02:00
|
|
|
setStringArray(prefPod, R.string.pref_key__podprofile_followed_tags, tags);
|
2016-07-18 14:02:18 +02:00
|
|
|
}
|
|
|
|
|
2016-08-13 14:13:14 +02:00
|
|
|
public int getUnreadMessageCount() {
|
2016-08-07 11:39:20 +02:00
|
|
|
return getInt(prefPod, R.string.pref_key__podprofile_unread_message_count, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setUnreadMessageCount(int unreadMessageCount) {
|
|
|
|
setInt(prefPod, R.string.pref_key__podprofile_unread_message_count, unreadMessageCount);
|
|
|
|
}
|
|
|
|
|
2016-08-13 14:13:14 +02:00
|
|
|
public int getNotificationCount() {
|
2016-08-07 11:39:20 +02:00
|
|
|
return getInt(prefPod, R.string.pref_key__podprofile_notification_count, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setNotificationCount(int notificationCount) {
|
|
|
|
setInt(prefPod, R.string.pref_key__podprofile_notification_count, notificationCount);
|
|
|
|
}
|
|
|
|
|
2016-08-02 23:58:36 +02:00
|
|
|
public boolean isAppendSharedViaApp() {
|
|
|
|
return getBoolean(prefApp, R.string.pref_key__append_shared_via_app, true);
|
|
|
|
}
|
|
|
|
|
2016-06-17 19:43:28 +02:00
|
|
|
@SuppressLint("CommitPrefEdits")
|
2016-10-22 16:01:45 +02:00
|
|
|
public void setProxyHttpEnabled(boolean enabled) {
|
2016-06-09 01:03:50 +02:00
|
|
|
//commit instead of apply because the app is likely to be killed before apply is called.
|
2016-10-13 16:56:31 +02:00
|
|
|
prefApp.edit().putBoolean(context.getString(R.string.pref_key__http_proxy_enabled), enabled).commit();
|
2016-06-09 01:03:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default return value: false
|
2016-08-02 21:32:42 +02:00
|
|
|
*
|
2016-06-09 01:03:50 +02:00
|
|
|
* @return whether proxy is enabled or not
|
|
|
|
*/
|
2016-10-22 16:01:45 +02:00
|
|
|
public boolean isProxyHttpEnabled() {
|
2016-10-13 16:56:31 +02:00
|
|
|
return getBoolean(prefApp, R.string.pref_key__http_proxy_enabled, false);
|
2016-06-09 01:03:50 +02:00
|
|
|
}
|
|
|
|
|
2016-06-16 23:36:52 +02:00
|
|
|
public boolean wasProxyEnabled() {
|
2016-08-02 21:32:42 +02:00
|
|
|
return getBoolean(prefApp, R.string.pref_key__proxy_was_enabled, false);
|
2016-06-16 23:36:52 +02:00
|
|
|
}
|
|
|
|
|
2016-06-17 19:43:28 +02:00
|
|
|
/**
|
|
|
|
* Needed in order to determine, whether the proxy has just been disabled (trigger app restart)
|
|
|
|
* or if proxy was disabled before (do not restart app)
|
2016-08-02 21:32:42 +02:00
|
|
|
*
|
2016-06-17 19:43:28 +02:00
|
|
|
* @param b new value
|
|
|
|
*/
|
|
|
|
@SuppressLint("CommitPrefEdits")
|
2016-06-16 23:36:52 +02:00
|
|
|
public void setProxyWasEnabled(boolean b) {
|
2016-08-02 21:32:42 +02:00
|
|
|
prefApp.edit().putBoolean(context.getString(R.string.pref_key__proxy_was_enabled), b).commit();
|
2016-06-09 01:03:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default value: ""
|
2016-08-02 21:32:42 +02:00
|
|
|
*
|
2016-06-09 01:03:50 +02:00
|
|
|
* @return proxy host
|
|
|
|
*/
|
2016-10-22 16:01:45 +02:00
|
|
|
public String getProxyHttpHost() {
|
2016-10-13 16:56:31 +02:00
|
|
|
return getString(prefApp, R.string.pref_key__http_proxy_host, "");
|
2016-06-09 01:03:50 +02:00
|
|
|
}
|
|
|
|
|
2016-10-13 16:56:31 +02:00
|
|
|
public void setProxyHttpHost(String value) {
|
|
|
|
setString(prefApp, R.string.pref_key__http_proxy_host, value);
|
|
|
|
}
|
2016-10-14 01:26:56 +02:00
|
|
|
|
2016-06-09 01:03:50 +02:00
|
|
|
/**
|
|
|
|
* Default value: 0
|
2016-08-02 21:32:42 +02:00
|
|
|
*
|
2016-06-09 01:03:50 +02:00
|
|
|
* @return proxy port
|
|
|
|
*/
|
2016-10-22 16:01:45 +02:00
|
|
|
public int getProxyHttpPort() {
|
|
|
|
try {
|
2016-10-22 19:21:26 +02:00
|
|
|
String str = getString(prefApp, R.string.pref_key__http_proxy_port, "0");
|
|
|
|
return Integer.parseInt(str);
|
2016-10-25 21:29:16 +02:00
|
|
|
} catch (ClassCastException e) {
|
|
|
|
int port = getInt(prefApp, R.string.pref_key__http_proxy_port, 0);
|
|
|
|
setProxyHttpPort(port);
|
|
|
|
return port;
|
2016-10-22 16:01:45 +02:00
|
|
|
}
|
2016-06-09 01:03:50 +02:00
|
|
|
}
|
2016-07-31 15:16:22 +02:00
|
|
|
|
2016-10-13 16:56:31 +02:00
|
|
|
public void setProxyHttpPort(int value) {
|
2016-10-25 21:29:16 +02:00
|
|
|
setString(prefApp, R.string.pref_key__http_proxy_port, Integer.toString(value));
|
2016-10-13 16:56:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public ProxyHandler.ProxySettings getProxySettings() {
|
2016-10-22 16:01:45 +02:00
|
|
|
return new ProxyHandler.ProxySettings(isProxyHttpEnabled(), getProxyHttpHost(), getProxyHttpPort());
|
2016-10-13 16:56:31 +02:00
|
|
|
}
|
|
|
|
|
2016-08-02 21:32:42 +02:00
|
|
|
public boolean isIntellihideToolbars() {
|
2016-10-14 13:07:07 +02:00
|
|
|
return getBoolean(prefApp, R.string.pref_key__intellihide_toolbars, true);
|
2016-07-31 15:16:22 +02:00
|
|
|
}
|
2016-08-07 02:28:37 +02:00
|
|
|
|
2016-09-18 23:17:18 +02:00
|
|
|
public boolean isChromeCustomTabsEnabled() {
|
|
|
|
return getBoolean(prefApp, R.string.pref_key__chrome_custom_tabs_enabled, true);
|
|
|
|
}
|
|
|
|
|
2016-09-19 01:10:29 +02:00
|
|
|
public boolean isLoggingEnabled() {
|
|
|
|
return getBoolean(prefApp, R.string.pref_key__logging_enabled, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isLoggingSpamEnabled() {
|
|
|
|
return getBoolean(prefApp, R.string.pref_key__logging_spam_enabled, false);
|
|
|
|
}
|
|
|
|
|
2016-08-13 14:13:14 +02:00
|
|
|
public boolean isVisibleInNavExit() {
|
|
|
|
return getBoolean(prefApp, R.string.pref_key__visibility_nav__exit, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isVisibleInNavHelp_license() {
|
2016-08-13 15:31:27 +02:00
|
|
|
return getBoolean(prefApp, R.string.pref_key__visibility_nav__help_license, true);
|
2016-08-13 14:13:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isVisibleInNavPublic_activities() {
|
|
|
|
return getBoolean(prefApp, R.string.pref_key__visibility_nav__public_activities, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isVisibleInNavMentions() {
|
2016-08-28 17:54:35 +02:00
|
|
|
return getBoolean(prefApp, R.string.pref_key__visibility_nav__mentions, false);
|
2016-08-13 14:13:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isVisibleInNavCommented() {
|
2016-08-13 15:31:27 +02:00
|
|
|
return getBoolean(prefApp, R.string.pref_key__visibility_nav__commented, true);
|
2016-08-13 14:13:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isVisibleInNavLiked() {
|
2016-08-13 15:31:27 +02:00
|
|
|
return getBoolean(prefApp, R.string.pref_key__visibility_nav__liked, true);
|
2016-08-13 14:13:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isVisibleInNavActivities() {
|
2016-08-13 15:31:27 +02:00
|
|
|
return getBoolean(prefApp, R.string.pref_key__visibility_nav__activities, true);
|
2016-08-13 14:13:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isVisibleInNavAspects() {
|
2016-08-13 15:31:27 +02:00
|
|
|
return getBoolean(prefApp, R.string.pref_key__visibility_nav__aspects, true);
|
2016-08-13 14:13:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isVisibleInNavFollowed_tags() {
|
2016-08-13 15:31:27 +02:00
|
|
|
return getBoolean(prefApp, R.string.pref_key__visibility_nav__followed_tags, true);
|
2016-08-13 14:13:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isVisibleInNavProfile() {
|
2016-10-22 19:21:26 +02:00
|
|
|
return getBoolean(prefApp, R.string.pref_key__visibility_nav__profile, true);
|
2016-08-07 02:28:37 +02:00
|
|
|
}
|
2016-10-13 16:56:31 +02:00
|
|
|
|
2016-10-25 17:56:35 +02:00
|
|
|
public boolean isVisibleInNavContacts() {
|
|
|
|
return getBoolean(prefApp, R.string.pref_key__visibility_nav__contacts, false);
|
|
|
|
}
|
|
|
|
|
2016-10-13 16:56:31 +02:00
|
|
|
public void setPrimaryColorSettings(int base, int shade) {
|
|
|
|
setInt(prefApp, R.string.pref_key__primary_color_base, base);
|
|
|
|
setInt(prefApp, R.string.pref_key__primary_color_shade, shade);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int[] getPrimaryColorSettings() {
|
|
|
|
return new int[]{
|
|
|
|
getInt(prefApp, R.string.pref_key__primary_color_base, context.getResources().getColor(R.color.md_blue_500)),
|
|
|
|
getInt(prefApp, R.string.pref_key__primary_color_shade, context.getResources().getColor(R.color.primary))
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getPrimaryColor() {
|
|
|
|
return getInt(prefApp, R.string.pref_key__primary_color_shade, context.getResources().getColor(R.color.primary));
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setAccentColorSettings(int base, int shade) {
|
|
|
|
setInt(prefApp, R.string.pref_key__accent_color_base, base);
|
|
|
|
setInt(prefApp, R.string.pref_key__accent_color_shade, shade);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int[] getAccentColorSettings() {
|
|
|
|
return new int[]{
|
|
|
|
getInt(prefApp, R.string.pref_key__accent_color_base, context.getResources().getColor(R.color.md_deep_orange_500)),
|
|
|
|
getInt(prefApp, R.string.pref_key__accent_color_shade, context.getResources().getColor(R.color.accent))
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getAccentColor() {
|
|
|
|
return getInt(prefApp, R.string.pref_key__accent_color_shade, context.getResources().getColor(R.color.accent));
|
|
|
|
}
|
2016-10-14 12:57:17 +02:00
|
|
|
|
|
|
|
public boolean isExtendedNotificationsActivated() {
|
|
|
|
return getBoolean(prefApp, R.string.pref_key__extended_notifications, false);
|
|
|
|
}
|
2016-10-13 16:56:31 +02:00
|
|
|
}
|