From 549810783ce651f27bdd386488b6690195522372 Mon Sep 17 00:00:00 2001 From: lookshe Date: Tue, 14 Apr 2015 23:48:28 +0200 Subject: changed received and read confirmation setting to one list and put it to settings class --- TODO | 2 +- src/main/java/de/tzur/conversations/Settings.java | 20 +++- .../conversations/generator/AbstractGenerator.java | 3 +- .../siacs/conversations/parser/MessageParser.java | 2 +- .../services/XmppConnectionService.java | 10 +- .../siacs/conversations/ui/SettingsActivity.java | 5 +- src/main/res/values-de/strings.xml | 9 +- src/main/res/values/arrays.xml | 12 ++ src/main/res/values/strings.xml | 7 +- src/main/res/xml/preferences.xml | 123 +++++++++++---------- 10 files changed, 110 insertions(+), 83 deletions(-) diff --git a/TODO b/TODO index f0589307..d4f6bc84 100644 --- a/TODO +++ b/TODO @@ -1,10 +1,10 @@ settings: - cleanup and structure - remove/fix "enter is send" and "show enter key" -- received/read message in one setting list with "don't notify", "send received" and "send received and read" code: - check parseTimestamp - change crash reports +- notification with emojicon textview general: - add comments to code of XEPs - add comments in general diff --git a/src/main/java/de/tzur/conversations/Settings.java b/src/main/java/de/tzur/conversations/Settings.java index 72084285..c919d60c 100644 --- a/src/main/java/de/tzur/conversations/Settings.java +++ b/src/main/java/de/tzur/conversations/Settings.java @@ -15,7 +15,7 @@ public final class Settings { */ public static void initSettingsClassWithPreferences(SharedPreferences preferences) { Log.d("SETTING", "Initializing settings"); - String[] preferenceNames = { "parse_emoticons", "send_button_status", "led_notification_color", "auto_download_file_wlan", "auto_download_file_link" }; + String[] preferenceNames = { "parse_emoticons", "send_button_status", "led_notification_color", "auto_download_file_wlan", "auto_download_file_link", "confirm_messages_list" }; for (String name : preferenceNames) { Settings.synchronizeSettingsClassWithPreferences(preferences, name); } @@ -44,6 +44,16 @@ public final class Settings { case "auto_download_file_link": Settings.DOWNLOAD_IMAGE_LINKS = preferences.getBoolean(name, Settings.DOWNLOAD_IMAGE_LINKS); break; + case "confirm_messages_list": + int iPref = Settings.CONFIRM_MESSAGE_RECEIVED && Settings.CONFIRM_MESSAGE_READ ? 2 : Settings.CONFIRM_MESSAGE_RECEIVED ? 1 : 0; + try { + iPref = Integer.valueOf(preferences.getString(name, new Integer(iPref).toString())); + } catch (NumberFormatException e) { + // ignored, fallback-value set above + } + Settings.CONFIRM_MESSAGE_RECEIVED = iPref >= 1; + Settings.CONFIRM_MESSAGE_READ = iPref >= 2; + break; } } /** @@ -66,6 +76,14 @@ public final class Settings { * Boolean if automatic downloads should be done only jif connected to WLAN. */ public static boolean DOWNLOAD_ONLY_WLAN = true; + /** + * Boolean if confirm received messages + */ + public static boolean CONFIRM_MESSAGE_RECEIVED = true; + /** + * Boolean if confirm read message + */ + public static boolean CONFIRM_MESSAGE_READ = true; /** * This is a utility class - private constructor avoids any instantiation. diff --git a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java index 79626511..186b4b98 100644 --- a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java +++ b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java @@ -12,6 +12,7 @@ import java.util.List; import java.util.Locale; import java.util.TimeZone; +import de.tzur.conversations.Settings; import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.utils.PhoneHelper; @@ -81,7 +82,7 @@ public abstract class AbstractGenerator { public List getFeatures() { ArrayList features = new ArrayList<>(); features.addAll(Arrays.asList(FEATURES)); - if (mXmppConnectionService.confirmMessages()) { + if (Settings.CONFIRM_MESSAGE_RECEIVED) { features.addAll(Arrays.asList(MESSAGE_CONFIRMATION_FEATURES)); } Collections.sort(features); diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index 064a1662..9f36f1e9 100644 --- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java +++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java @@ -582,7 +582,7 @@ public class MessageParser extends AbstractParser implements if ((message == null) || (message.getBody() == null)) { return; } - if ((mXmppConnectionService.confirmMessages()) + if ((Settings.CONFIRM_MESSAGE_RECEIVED) && ((packet.getId() != null))) { if (packet.hasChild("markable", "urn:xmpp:chat-markers:0")) { MessagePacket receipt = mXmppConnectionService diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 0e531d57..fc670efd 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -2107,14 +2107,6 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa return getPreferences().getBoolean("force_encryption", false); } - public boolean confirmMessages() { - return getPreferences().getBoolean("confirm_messages", true); - } - - public boolean confirmMessagesRead() { - return getPreferences().getBoolean("confirm_read_message", true); - } - public boolean sendChatStates() { return getPreferences().getBoolean("chat_states", false); } @@ -2191,7 +2183,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa public void sendReadMarker(final Conversation conversation) { final Message markable = conversation.getLatestMarkableMessage(); this.markRead(conversation); - if (confirmMessagesRead() && markable != null && markable.getRemoteMsgId() != null) { + if (Settings.CONFIRM_MESSAGE_READ && markable != null && markable.getRemoteMsgId() != null) { Log.d(Config.LOGTAG, conversation.getAccount().getJid().toBareJid() + ": sending read marker to " + markable.getCounterpart().toString()); Account account = conversation.getAccount(); final Jid to = markable.getCounterpart(); diff --git a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java index 1c1ff3b9..2115b23b 100644 --- a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java @@ -59,6 +59,8 @@ public class SettingsActivity extends XmppActivity implements @Override public void onSharedPreferenceChanged(SharedPreferences preferences, String name) { + // need to synchronize the settings class first + Settings.synchronizeSettingsClassWithPreferences(getPreferences(), name); switch (name) { case "resource": String resource = preferences.getString("resource", "mobile") @@ -75,7 +77,7 @@ public class SettingsActivity extends XmppActivity implements case "keep_foreground_service": xmppConnectionService.toggleForegroundService(); break; - case "confirm_messages": + case "confirm_messages_list": if (xmppConnectionServiceBound) { for (Account account : xmppConnectionService.getAccounts()) { if (!account.isOptionSet(Account.OPTION_DISABLED)) { @@ -85,7 +87,6 @@ public class SettingsActivity extends XmppActivity implements } break; } - Settings.synchronizeSettingsClassWithPreferences(getPreferences(), name); } } diff --git a/src/main/res/values-de/strings.xml b/src/main/res/values-de/strings.xml index 9b48bfd5..ccb3c990 100644 --- a/src/main/res/values-de/strings.xml +++ b/src/main/res/values-de/strings.xml @@ -119,10 +119,11 @@ Erweiterte Optionen Sende niemals Absturzberichte Wenn du Absturzberichte einschickst, hilfst du Conversations stetig zu verbessern - Empfangsbestätigung senden - Informiere deine Kontakte, wenn du eine Nachricht empfangen hast - Lesebestätigung senden - Informiere deine Kontakte, wenn du eine Nachricht gelesen hast + Lese- und Empfangsbestätigung senden + Informiere deine Kontakte, wenn du eine Nachricht empfangen oder gelesen hast + Keine Bestätigungen + Nur Empfangsbestätigung + Lese- und Empfangsbestätigung Benutzeroberfläche Smilies ersetzen Zeige Smilie-Bilder anstelle von Emoticons. diff --git a/src/main/res/values/arrays.xml b/src/main/res/values/arrays.xml index c413a3c4..942117d8 100644 --- a/src/main/res/values/arrays.xml +++ b/src/main/res/values/arrays.xml @@ -40,4 +40,16 @@ -1 + + @string/pref_confirm_messages_none + @string/pref_confirm_messages_received + @string/pref_confirm_messages_read_and_received + + + + 0 + 1 + 2 + + diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 03c1386f..d454cc1f 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -122,9 +122,10 @@ Never send crash reports By sending in stack traces you are helping the ongoing development of Conversations Confirm Messages - Let your contact know when you have received a message - Confirm Read Messages - Let your contact know when you have read a message + Let your contact know when you have received or read a message + No confirmation + Confirmation for received message + Confirmation for received and read message UI Options Parse Emoticons Replace emoticons with smilies. diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml index 72b6a7c8..9cf2ed93 100644 --- a/src/main/res/xml/preferences.xml +++ b/src/main/res/xml/preferences.xml @@ -43,18 +43,14 @@ - - - + android:title="@string/pref_parse_emoticons"/> - - + - - - - + android:defaultValue="true" + android:key="show_notification" + android:summary="@string/pref_notifications_summary" + android:title="@string/pref_notifications" /> + + + + + + - + - + + + + - -- cgit v1.2.3