diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-08-01 10:22:24 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-08-01 10:22:24 +0200 |
commit | ffd08658e1a9333b6af896aa3fc853c5184fc571 (patch) | |
tree | 3961115c310abb94c08344db719cdb316da96805 /src/main/java/de/pixart/messenger/parser | |
parent | 7b6d679ea2c8557d732fdd79021ef3d2b7d84304 (diff) |
put settings defaults into resource file
Diffstat (limited to 'src/main/java/de/pixart/messenger/parser')
-rw-r--r-- | src/main/java/de/pixart/messenger/parser/MessageParser.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/main/java/de/pixart/messenger/parser/MessageParser.java b/src/main/java/de/pixart/messenger/parser/MessageParser.java index d503eb95e..c5e818f1a 100644 --- a/src/main/java/de/pixart/messenger/parser/MessageParser.java +++ b/src/main/java/de/pixart/messenger/parser/MessageParser.java @@ -17,6 +17,7 @@ import java.util.Set; import java.util.UUID; import de.pixart.messenger.Config; +import de.pixart.messenger.R; import de.pixart.messenger.crypto.OtrService; import de.pixart.messenger.crypto.axolotl.AxolotlService; import de.pixart.messenger.crypto.axolotl.XmppAxolotlMessage; @@ -736,8 +737,14 @@ 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); } } |