diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java
index d8f4097a9..44c0db159 100644
--- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java
+++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java
@@ -17,6 +17,7 @@ import java.util.Set;
import java.util.UUID;
import eu.siacs.conversations.Config;
+import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.OtrService;
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlMessage;
@@ -750,8 +751,15 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
private static SimpleDateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm:ss");
private void activateGracePeriod(Account account) {
- long duration = mXmppConnectionService.getPreferences().getLong("race_period_length", 144) * 1000;
- Log.d(Config.LOGTAG,account.getJid().toBareJid()+": activating grace period till "+TIME_FORMAT.format(new Date(System.currentTimeMillis() + duration)));
+
+ long duration;
+ long defaultValue = mXmppConnectionService.getResources().getInteger(R.integer.grace_period);
+ try {
+ duration = Long.parseLong(mXmppConnectionService.getPreferences().getString("grace_period_length", String.valueOf(defaultValue))) * 1000;
+ } catch (NumberFormatException e) {
+ duration = defaultValue * 1000;
+ }
+ Log.d(Config.LOGTAG,account.getJid().toBareJid()+": activating grace period ("+duration+") till "+TIME_FORMAT.format(new Date(System.currentTimeMillis() + duration)));
account.activateGracePeriod(duration);
}
}
diff --git a/src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java b/src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java
index 18512997c..01a2a8ef1 100644
--- a/src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java
+++ b/src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java
@@ -33,6 +33,7 @@ import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import eu.siacs.conversations.Config;
+import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.DownloadableFile;
public class AbstractConnectionManager {
@@ -50,12 +51,13 @@ public class AbstractConnectionManager {
}
public long getAutoAcceptFileSize() {
+ long defaultValue = this.getXmppConnectionService().getResources().getInteger(R.integer.auto_accept_filesize);
String config = this.mXmppConnectionService.getPreferences().getString(
- "auto_accept_file_size", "524288");
+ "auto_accept_file_size", String.valueOf(defaultValue));
try {
return Long.parseLong(config);
} catch (NumberFormatException e) {
- return 524288;
+ return defaultValue;
}
}
diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java
index d73f5d98b..539a4dedb 100644
--- a/src/main/java/eu/siacs/conversations/services/NotificationService.java
+++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java
@@ -85,7 +85,7 @@ public class NotificationService {
}
public boolean notificationsEnabled() {
- return mXmppConnectionService.getPreferences().getBoolean("show_notification", true);
+ return mXmppConnectionService.getPreferences().getBoolean("show_notification", mXmppConnectionService.getResources().getBoolean(R.bool.show_notification));
}
private boolean notificationsFromStrangers() {
@@ -94,7 +94,7 @@ public class NotificationService {
}
public boolean isQuietHours() {
- if (!mXmppConnectionService.getPreferences().getBoolean("enable_quiet_hours", false)) {
+ if (!mXmppConnectionService.getPreferences().getBoolean("enable_quiet_hours", mXmppConnectionService.getResources().getBoolean(R.bool.enable_quiet_hours))) {
return false;
}
final long startTime = mXmppConnectionService.getPreferences().getLong("quiet_hours_start", TimePreference.DEFAULT_VALUE) % Config.MILLISECONDS_IN_DAY;
@@ -725,7 +725,7 @@ public class NotificationService {
errors.add(account);
}
}
- if (mXmppConnectionService.getPreferences().getBoolean(SettingsActivity.KEEP_FOREGROUND_SERVICE, false)) {
+ if (mXmppConnectionService.getPreferences().getBoolean(SettingsActivity.KEEP_FOREGROUND_SERVICE, mXmppConnectionService.getResources().getBoolean(R.bool.enable_foreground_service))) {
notificationManager.notify(FOREGROUND_NOTIFICATION_ID, createForegroundNotification());
}
final NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mXmppConnectionService);
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
index cc18e2605..170fed794 100644
--- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
@@ -865,7 +865,7 @@ public class XmppConnectionService extends Service {
}
private boolean manuallyChangePresence() {
- return getPreferences().getBoolean(SettingsActivity.MANUALLY_CHANGE_PRESENCE, false);
+ return getPreferences().getBoolean(SettingsActivity.MANUALLY_CHANGE_PRESENCE, getResources().getBoolean(R.bool.manually_change_presence));
}
private boolean treatVibrateAsSilent() {
@@ -873,11 +873,11 @@ public class XmppConnectionService extends Service {
}
private boolean awayWhenScreenOff() {
- return getPreferences().getBoolean(SettingsActivity.AWAY_WHEN_SCREEN_IS_OFF, false);
+ return getPreferences().getBoolean(SettingsActivity.AWAY_WHEN_SCREEN_IS_OFF, getResources().getBoolean(R.bool.away_when_screen_off));
}
private String getCompressPicturesPreference() {
- return getPreferences().getString("picture_compression", "auto");
+ return getPreferences().getString("picture_compression", getResources().getString(R.string.picture_compression));
}
private Presence.Status getTargetPresence() {
@@ -1091,7 +1091,7 @@ public class XmppConnectionService extends Service {
}
private boolean keepForegroundService() {
- return getPreferences().getBoolean(SettingsActivity.KEEP_FOREGROUND_SERVICE,false);
+ return getPreferences().getBoolean(SettingsActivity.KEEP_FOREGROUND_SERVICE,getResources().getBoolean(R.bool.enable_foreground_service));
}
@Override
@@ -2746,7 +2746,7 @@ public class XmppConnectionService extends Service {
}
public void createContact(Contact contact) {
- boolean autoGrant = getPreferences().getBoolean("grant_new_contacts", true);
+ boolean autoGrant = getPreferences().getBoolean("grant_new_contacts", getResources().getBoolean(R.bool.grant_new_contacts));
if (autoGrant) {
contact.setOption(Contact.Options.PREEMPTIVE_GRANT);
contact.setOption(Contact.Options.ASKING);
@@ -3256,7 +3256,7 @@ public class XmppConnectionService extends Service {
public long getAutomaticMessageDeletionDate() {
try {
- final long timeout = Long.parseLong(getPreferences().getString(SettingsActivity.AUTOMATIC_MESSAGE_DELETION, "0")) * 1000;
+ final long timeout = Long.parseLong(getPreferences().getString(SettingsActivity.AUTOMATIC_MESSAGE_DELETION, String.valueOf(getResources().getInteger(R.integer.automatic_message_deletion)))) * 1000;
return timeout == 0 ? timeout : System.currentTimeMillis() - timeout;
} catch (NumberFormatException e) {
return 0;
@@ -3264,35 +3264,35 @@ public class XmppConnectionService extends Service {
}
public boolean confirmMessages() {
- return getPreferences().getBoolean("confirm_messages", true);
+ return getPreferences().getBoolean("confirm_messages", getResources().getBoolean(R.bool.confirm_messages));
}
public boolean allowMessageCorrection() {
- return getPreferences().getBoolean("allow_message_correction", true);
+ return getPreferences().getBoolean("allow_message_correction", getResources().getBoolean(R.bool.allow_message_correction));
}
public boolean sendChatStates() {
- return getPreferences().getBoolean("chat_states", false);
+ return getPreferences().getBoolean("chat_states", getResources().getBoolean(R.bool.chat_states));
}
private boolean respectAutojoin() {
- return getPreferences().getBoolean("autojoin", true);
+ return getPreferences().getBoolean("autojoin", getResources().getBoolean(R.bool.autojoin));
}
public boolean indicateReceived() {
- return getPreferences().getBoolean("indicate_received", false);
+ return getPreferences().getBoolean("indicate_received", getResources().getBoolean(R.bool.indicate_received));
}
public boolean useTorToConnect() {
- return Config.FORCE_ORBOT || getPreferences().getBoolean("use_tor", false);
+ return Config.FORCE_ORBOT || getPreferences().getBoolean("use_tor", getResources().getBoolean(R.bool.use_tor));
}
public boolean showExtendedConnectionOptions() {
- return getPreferences().getBoolean("show_connection_options", false);
+ return getPreferences().getBoolean("show_connection_options", getResources().getBoolean(R.bool.show_connection_options));
}
public boolean broadcastLastActivity() {
- return getPreferences().getBoolean(SettingsActivity.BROADCAST_LAST_ACTIVITY, false);
+ return getPreferences().getBoolean(SettingsActivity.BROADCAST_LAST_ACTIVITY, getResources().getBoolean(R.bool.last_activity));
}
public int unreadCount() {
@@ -3446,7 +3446,7 @@ public class XmppConnectionService extends Service {
public void updateMemorizingTrustmanager() {
final MemorizingTrustManager tm;
- final boolean dontTrustSystemCAs = getPreferences().getBoolean("dont_trust_system_cas", false);
+ final boolean dontTrustSystemCAs = getPreferences().getBoolean("dont_trust_system_cas", getResources().getBoolean(R.bool.dont_trust_system_cas));
if (dontTrustSystemCAs) {
tm = new MemorizingTrustManager(getApplicationContext(), null);
} else {
@@ -3903,7 +3903,7 @@ public class XmppConnectionService extends Service {
if (name != null && !name.trim().isEmpty()) {
bookmark.setBookmarkName(name.trim());
}
- bookmark.setAutojoin(getPreferences().getBoolean("autojoin",true));
+ bookmark.setAutojoin(getPreferences().getBoolean("autojoin",getResources().getBoolean(R.bool.autojoin)));
account.getBookmarks().add(bookmark);
pushBookmarks(account);
conversation.setBookmark(bookmark);
@@ -3959,7 +3959,7 @@ public class XmppConnectionService extends Service {
}
public boolean blindTrustBeforeVerification() {
- return getPreferences().getBoolean(SettingsActivity.BLIND_TRUST_BEFORE_VERIFICATION, true);
+ return getPreferences().getBoolean(SettingsActivity.BLIND_TRUST_BEFORE_VERIFICATION, getResources().getBoolean(R.bool.btbv));
}
public ShortcutService getShortcutService() {
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
index 72f2007c3..9debe440d 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
@@ -1714,15 +1714,15 @@ public class ConversationActivity extends XmppActivity
}
public boolean useSendButtonToIndicateStatus() {
- return getPreferences().getBoolean("send_button_status", false);
+ return getPreferences().getBoolean("send_button_status", getResources().getBoolean(R.bool.send_button_status));
}
public boolean indicateReceived() {
- return getPreferences().getBoolean("indicate_received", false);
+ return getPreferences().getBoolean("indicate_received", getResources().getBoolean(R.bool.indicate_received));
}
public boolean useGreenBackground() {
- return getPreferences().getBoolean("use_green_background",true);
+ return getPreferences().getBoolean("use_green_background",getResources().getBoolean(R.bool.use_green_background));
}
protected boolean trustKeysIfNeeded(int requestCode) {
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
index 0805488b0..fe973f8b1 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
@@ -1249,7 +1249,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
if (conference && c.getNextCounterpart() != null) {
action = SendButtonAction.CANCEL;
} else {
- String setting = activity.getPreferences().getString("quick_action", "recent");
+ String setting = activity.getPreferences().getString("quick_action", activity.getResources().getString(R.string.quick_action));
if (!setting.equals("none") && UIHelper.receivedLocationQuestion(conversation.getLatestMessage())) {
setting = "location";
} else if (setting.equals("recent")) {
diff --git a/src/main/java/eu/siacs/conversations/ui/MagicCreateActivity.java b/src/main/java/eu/siacs/conversations/ui/MagicCreateActivity.java
index f0c722951..0b7db2bbf 100644
--- a/src/main/java/eu/siacs/conversations/ui/MagicCreateActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/MagicCreateActivity.java
@@ -38,6 +38,15 @@ public class MagicCreateActivity extends XmppActivity implements TextWatcher {
}
+ @Override
+ public void onStart() {
+ super.onStart();
+ final int theme = findTheme();
+ if (this.mTheme != theme) {
+ recreate();
+ }
+ }
+
@Override
protected void onCreate(final Bundle savedInstanceState) {
if (getResources().getBoolean(R.bool.portrait_only)) {
diff --git a/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java b/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java
index c79782fd6..8dd1b23a2 100644
--- a/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java
@@ -194,7 +194,7 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer
if (intent == null) {
return;
}
- this.mReturnToPrevious = getPreferences().getBoolean("return_to_previous", false);
+ this.mReturnToPrevious = getPreferences().getBoolean("return_to_previous", getResources().getBoolean(R.bool.return_to_previous));
final String type = intent.getType();
final String action = intent.getAction();
Log.d(Config.LOGTAG, "action: "+action+ ", type:"+type);
diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
index 540d8defa..442c8ef02 100644
--- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
@@ -361,7 +361,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
}
Conversation conversation = xmppConnectionService.findOrCreateConversation(bookmark.getAccount(), jid, true, true, true);
conversation.setBookmark(bookmark);
- if (!bookmark.autojoin() && getPreferences().getBoolean("autojoin", true)) {
+ if (!bookmark.autojoin() && getPreferences().getBoolean("autojoin", getResources().getBoolean(R.bool.autojoin))) {
bookmark.setAutojoin(true);
xmppConnectionService.pushBookmarks(bookmark.getAccount());
}
@@ -507,7 +507,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
jid.setError(getString(R.string.bookmark_already_exists));
} else {
final Bookmark bookmark = new Bookmark(account, conferenceJid.toBareJid());
- bookmark.setAutojoin(getPreferences().getBoolean("autojoin", true));
+ bookmark.setAutojoin(getPreferences().getBoolean("autojoin", getResources().getBoolean(R.bool.autojoin)));
String nick = conferenceJid.getResourcepart();
if (nick != null && !nick.isEmpty()) {
bookmark.setNick(nick);
diff --git a/src/main/java/eu/siacs/conversations/ui/WelcomeActivity.java b/src/main/java/eu/siacs/conversations/ui/WelcomeActivity.java
index 1ef05d241..5dc4b83f2 100644
--- a/src/main/java/eu/siacs/conversations/ui/WelcomeActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/WelcomeActivity.java
@@ -24,6 +24,15 @@ public class WelcomeActivity extends XmppActivity {
}
+ @Override
+ public void onStart() {
+ super.onStart();
+ final int theme = findTheme();
+ if (this.mTheme != theme) {
+ recreate();
+ }
+ }
+
@Override
protected void onCreate(final Bundle savedInstanceState) {
if (getResources().getBoolean(R.bool.portrait_only)) {
diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
index 0586a1f9a..9c2e9bae2 100644
--- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
@@ -403,7 +403,7 @@ public abstract class XmppActivity extends Activity {
setTheme(this.mTheme);
this.mUsingEnterKey = usingEnterKey();
- mUseSubject = getPreferences().getBoolean("use_subject", true);
+ mUseSubject = getPreferences().getBoolean("use_subject", getResources().getBoolean(R.bool.use_subject));
final ActionBar ab = getActionBar();
if (ab!=null) {
ab.setDisplayHomeAsUpEnabled(true);
@@ -411,7 +411,7 @@ public abstract class XmppActivity extends Activity {
}
public boolean isDarkTheme() {
- return getPreferences().getString("theme", "light").equals("dark");
+ return getPreferences().getString("theme", getResources().getString(R.string.theme)).equals("dark");
}
public int getThemeResource(int r_attr_name, int r_drawable_def) {
@@ -444,7 +444,7 @@ public abstract class XmppActivity extends Activity {
}
protected boolean usingEnterKey() {
- return getPreferences().getBoolean("display_enter_key", false);
+ return getPreferences().getBoolean("display_enter_key", getResources().getBoolean(R.bool.display_enter_key));
}
protected SharedPreferences getPreferences() {
@@ -984,11 +984,11 @@ public abstract class XmppActivity extends Activity {
}
protected boolean neverCompressPictures() {
- return getPreferences().getString("picture_compression", "auto").equals("never");
+ return getPreferences().getString("picture_compression", getResources().getString(R.string.picture_compression)).equals("never");
}
protected boolean manuallyChangePresence() {
- return getPreferences().getBoolean(SettingsActivity.MANUALLY_CHANGE_PRESENCE, false);
+ return getPreferences().getBoolean(SettingsActivity.MANUALLY_CHANGE_PRESENCE, getResources().getBoolean(R.bool.manually_change_presence));
}
protected void unregisterNdefPushMessageCallback() {
@@ -1038,8 +1038,8 @@ public abstract class XmppActivity extends Activity {
}
protected int findTheme() {
- Boolean dark = getPreferences().getString(SettingsActivity.THEME, "light").equals("dark");
- Boolean larger = getPreferences().getBoolean("use_larger_font", false);
+ Boolean dark = getPreferences().getString(SettingsActivity.THEME, getResources().getString(R.string.theme)).equals("dark");
+ Boolean larger = getPreferences().getBoolean("use_larger_font", getResources().getBoolean(R.bool.use_larger_font));
if(dark) {
if(larger)
diff --git a/src/main/res/values/defaults.xml b/src/main/res/values/defaults.xml
index c58942c88..f7a84db05 100644
--- a/src/main/res/values/defaults.xml
+++ b/src/main/res/values/defaults.xml
@@ -7,4 +7,37 @@
false
false
false
+ true
+ true
+ false
+ false
+ true
+ true
+ true
+ false
+ content://settings/system/notification_sound
+ 144
+ 524288
+ auto
+ light
+ true
+ true
+ false
+ false
+ recent
+ false
+ true
+ 0
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+ false
diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml
index 4efd609d6..af095ca3b 100644
--- a/src/main/res/xml/preferences.xml
+++ b/src/main/res/xml/preferences.xml
@@ -4,7 +4,7 @@
@@ -19,25 +19,25 @@
@@ -54,19 +54,19 @@
android:title="@string/pref_headsup_notifications"
android:summary="@string/pref_headsup_notifications_summary"/>
@@ -100,62 +100,62 @@
android:key="grace_period_length"
android:title="@string/pref_notification_grace_period"
android:summary="@string/pref_notification_grace_period_summary"
- android:defaultValue="144"
+ android:defaultValue="@integer/grace_period"
android:entries="@array/grace_periods"
android:entryValues="@array/grace_periods_values"
/>
@@ -178,7 +178,7 @@
@@ -186,11 +186,11 @@
android:key="automatic_message_deletion"
android:title="@string/pref_automatically_delete_messages"
android:summary="@string/pref_automatically_delete_messages_description"
- android:defaultValue="0"
+ android:defaultValue="@integer/automatic_message_deletion"
android:entries="@array/automatic_message_deletion"
android:entryValues="@array/automatic_message_deletion_values" />
@@ -199,7 +199,7 @@
android:summary="@string/pref_remove_trusted_certificates_summary"
android:title="@string/pref_remove_trusted_certificates_title"/>
@@ -220,12 +220,12 @@
android:key="connection_options"
android:title="@string/pref_connection_options">
@@ -237,20 +237,20 @@
android:summary="@string/pref_enter_is_send_summary"
android:title="@string/pref_enter_is_send"/>
@@ -293,7 +293,7 @@