aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-11-21 11:03:38 +0100
committerDaniel Gultsch <daniel@gultsch.de>2016-11-21 11:03:38 +0100
commit6631705aea8d5506056b6e91883a893012d37325 (patch)
treed0863da56c0e3d19e0633b2ae10b66cc7518f174
parent7b99346a4be2ffa97053079dc72ff4e4bb94ab7a (diff)
use constants for some preferences
Diffstat (limited to '')
-rw-r--r--src/main/java/eu/siacs/conversations/services/XmppConnectionService.java13
-rw-r--r--src/main/java/eu/siacs/conversations/ui/SettingsActivity.java20
-rw-r--r--src/main/java/eu/siacs/conversations/ui/XmppActivity.java2
3 files changed, 20 insertions, 15 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
index 1fa81ceb..c8a19019 100644
--- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
@@ -93,6 +93,7 @@ import eu.siacs.conversations.parser.MessageParser;
import eu.siacs.conversations.parser.PresenceParser;
import eu.siacs.conversations.persistance.DatabaseBackend;
import eu.siacs.conversations.persistance.FileBackend;
+import eu.siacs.conversations.ui.SettingsActivity;
import eu.siacs.conversations.ui.UiCallback;
import eu.siacs.conversations.utils.ConversationsFileObserver;
import eu.siacs.conversations.utils.CryptoHelper;
@@ -567,7 +568,7 @@ public class XmppConnectionService extends Service {
}
break;
case ACTION_DISABLE_FOREGROUND:
- getPreferences().edit().putBoolean("keep_foreground_service", false).commit();
+ getPreferences().edit().putBoolean(SettingsActivity.KEEP_FOREGROUND_SERVICE, false).commit();
toggleForegroundService();
break;
case ACTION_DISMISS_ERROR_NOTIFICATIONS:
@@ -767,15 +768,15 @@ public class XmppConnectionService extends Service {
}
private boolean manuallyChangePresence() {
- return getPreferences().getBoolean("manually_change_presence", false);
+ return getPreferences().getBoolean(SettingsActivity.MANUALLY_CHANGE_PRESENCE, false);
}
private boolean treatVibrateAsSilent() {
- return getPreferences().getBoolean("treat_vibrate_as_silent", false);
+ return getPreferences().getBoolean(SettingsActivity.TREAT_VIBRATE_AS_SILENT, false);
}
private boolean awayWhenScreenOff() {
- return getPreferences().getBoolean("away_when_screen_off", false);
+ return getPreferences().getBoolean(SettingsActivity.AWAY_WHEN_SCREEN_IS_OFF, false);
}
private String getCompressPicturesPreference() {
@@ -874,7 +875,7 @@ public class XmppConnectionService extends Service {
this.accounts = databaseBackend.getAccounts();
if (!keepForegroundService() && databaseBackend.startTimeCountExceedsThreshold()) {
- getPreferences().edit().putBoolean("keep_foreground_service",true).commit();
+ getPreferences().edit().putBoolean(SettingsActivity.KEEP_FOREGROUND_SERVICE,true).commit();
Log.d(Config.LOGTAG,"number of restarts exceeds threshold. enabling foreground service");
}
@@ -963,7 +964,7 @@ public class XmppConnectionService extends Service {
}
private boolean keepForegroundService() {
- return getPreferences().getBoolean("keep_foreground_service",false);
+ return getPreferences().getBoolean(SettingsActivity.KEEP_FOREGROUND_SERVICE,false);
}
@Override
diff --git a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java
index 7fcb1e3c..e3e05d7d 100644
--- a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java
@@ -35,6 +35,11 @@ import eu.siacs.conversations.xmpp.jid.Jid;
public class SettingsActivity extends XmppActivity implements
OnSharedPreferenceChangeListener {
+ public static final String KEEP_FOREGROUND_SERVICE = "keep_foreground_service";
+ public static final String AWAY_WHEN_SCREEN_IS_OFF = "away_when_screen_off";
+ public static final String TREAT_VIBRATE_AS_SILENT = "treat_vibrate_as_silent";
+ public static final String MANUALLY_CHANGE_PRESENCE = "manually_change_presence";
+
public static final int REQUEST_WRITE_LOGS = 0xbf8701;
private SettingsFragment mSettingsFragment;
@@ -227,10 +232,10 @@ public class SettingsActivity extends XmppActivity implements
final List<String> resendPresence = Arrays.asList(
"confirm_messages",
"xa_on_silent_mode",
- "away_when_screen_off",
+ AWAY_WHEN_SCREEN_IS_OFF,
"allow_message_correction",
- "treat_vibrate_as_silent",
- "manually_change_presence",
+ TREAT_VIBRATE_AS_SILENT,
+ MANUALLY_CHANGE_PRESENCE,
"last_activity");
if (name.equals("resource")) {
String resource = preferences.getString("resource", "mobile")
@@ -248,19 +253,18 @@ public class SettingsActivity extends XmppActivity implements
}
}
}
- } else if (name.equals("keep_foreground_service")) {
- boolean foreground_service = preferences.getBoolean("keep_foreground_service",false);
+ } else if (name.equals(KEEP_FOREGROUND_SERVICE)) {
+ boolean foreground_service = preferences.getBoolean(KEEP_FOREGROUND_SERVICE,false);
if (!foreground_service) {
xmppConnectionService.clearStartTimeCounter();
}
xmppConnectionService.toggleForegroundService();
} else if (resendPresence.contains(name)) {
if (xmppConnectionServiceBound) {
- if (name.equals("away_when_screen_off")
- || name.equals("manually_change_presence")) {
+ if (name.equals(AWAY_WHEN_SCREEN_IS_OFF) || name.equals(MANUALLY_CHANGE_PRESENCE)) {
xmppConnectionService.toggleScreenEventReceiver();
}
- if (name.equals("manually_change_presence") && !noAccountUsesPgp()) {
+ if (name.equals(MANUALLY_CHANGE_PRESENCE) && !noAccountUsesPgp()) {
Toast.makeText(this, R.string.republish_pgp_keys, Toast.LENGTH_LONG).show();
}
xmppConnectionService.refreshAllPresences();
diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
index d961497c..0307e8bf 100644
--- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
@@ -994,7 +994,7 @@ public abstract class XmppActivity extends Activity {
}
protected boolean manuallyChangePresence() {
- return getPreferences().getBoolean("manually_change_presence", false);
+ return getPreferences().getBoolean(SettingsActivity.MANUALLY_CHANGE_PRESENCE, false);
}
protected void unregisterNdefPushMessageCallback() {