changed received and read confirmation setting to one list and put it to settings class

This commit is contained in:
lookshe 2015-04-14 23:48:28 +02:00
parent 8932dd9fb3
commit 549810783c
10 changed files with 110 additions and 83 deletions

2
TODO
View file

@ -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

View file

@ -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.

View file

@ -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<String> getFeatures() {
ArrayList<String> 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);

View file

@ -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

View file

@ -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();

View file

@ -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);
}
}

View file

@ -119,10 +119,11 @@
<string name="pref_advanced_options">Erweiterte Optionen</string>
<string name="pref_never_send_crash">Sende niemals Absturzberichte</string>
<string name="pref_never_send_crash_summary">Wenn du Absturzberichte einschickst, hilfst du Conversations stetig zu verbessern</string>
<string name="pref_confirm_messages">Empfangsbestätigung senden</string>
<string name="pref_confirm_messages_summary">Informiere deine Kontakte, wenn du eine Nachricht empfangen hast</string>
<string name="pref_confirm_read_messages">Lesebestätigung senden</string>
<string name="pref_confirm_read_messages_summary">Informiere deine Kontakte, wenn du eine Nachricht gelesen hast</string>
<string name="pref_confirm_messages">Lese- und Empfangsbestätigung senden</string>
<string name="pref_confirm_messages_summary">Informiere deine Kontakte, wenn du eine Nachricht empfangen oder gelesen hast</string>
<string name="pref_confirm_messages_none">Keine Bestätigungen</string>
<string name="pref_confirm_messages_received">Nur Empfangsbestätigung</string>
<string name="pref_confirm_messages_read_and_received">Lese- und Empfangsbestätigung</string>
<string name="pref_ui_options">Benutzeroberfläche</string>
<string name="pref_parse_emoticons">Smilies ersetzen</string>
<string name="pref_parse_emoticons_summary">Zeige Smilie-Bilder anstelle von Emoticons.</string>

View file

@ -40,4 +40,16 @@
<item>-1</item>
</integer-array>
<string-array name="confirm_strings">
<item>@string/pref_confirm_messages_none</item>
<item>@string/pref_confirm_messages_received</item>
<item>@string/pref_confirm_messages_read_and_received</item>
</string-array>
<string-array name="confirm_values">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>
</resources>

View file

@ -122,9 +122,10 @@
<string name="pref_never_send_crash">Never send crash reports</string>
<string name="pref_never_send_crash_summary">By sending in stack traces you are helping the ongoing development of Conversations</string>
<string name="pref_confirm_messages">Confirm Messages</string>
<string name="pref_confirm_messages_summary">Let your contact know when you have received a message</string>
<string name="pref_confirm_read_messages">Confirm Read Messages</string>
<string name="pref_confirm_read_messages_summary">Let your contact know when you have read a message</string>
<string name="pref_confirm_messages_summary">Let your contact know when you have received or read a message</string>
<string name="pref_confirm_messages_none">No confirmation</string>
<string name="pref_confirm_messages_received">Confirmation for received message</string>
<string name="pref_confirm_messages_read_and_received">Confirmation for received and read message</string>
<string name="pref_ui_options">UI Options</string>
<string name="pref_parse_emoticons">Parse Emoticons</string>
<string name="pref_parse_emoticons_summary">Replace emoticons with smilies.</string>

View file

@ -43,18 +43,14 @@
</PreferenceScreen>
<CheckBoxPreference
android:defaultValue="true"
android:key="confirm_messages"
<ListPreference
android:defaultValue="2"
android:entries="@array/confirm_strings"
android:entryValues="@array/confirm_values"
android:key="confirm_messages_list"
android:summary="@string/pref_confirm_messages_summary"
android:title="@string/pref_confirm_messages" />
<CheckBoxPreference
android:defaultValue="true"
android:key="confirm_read_message"
android:summary="@string/pref_confirm_read_messages_summary"
android:title="@string/pref_confirm_read_messages" />
<CheckBoxPreference
android:defaultValue="false"
android:key="chat_states"
@ -64,57 +60,68 @@
android:defaultValue="true"
android:key="parse_emoticons"
android:summary="@string/pref_parse_emoticons_summary"
android:title="Parse Emoticons"/>
android:title="@string/pref_parse_emoticons"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_notification_settings" >
<CheckBoxPreference
android:defaultValue="true"
android:key="show_notification"
android:summary="@string/pref_notifications_summary"
android:title="@string/pref_notifications" />
<PreferenceScreen
android:dependency="show_notification"
android:summary="@string/pref_quiet_hours_summary"
android:title="@string/title_pref_quiet_hours">
<PreferenceScreen
android:summary="@string/pref_notification_settings"
android:title="@string/pref_notifications" >
<CheckBoxPreference
android:defaultValue="false"
android:key="enable_quiet_hours"
android:summary="@string/pref_quiet_hours_summary"
android:title="@string/title_pref_enable_quiet_hours" />
<eu.siacs.conversations.ui.TimePreference
android:dependency="enable_quiet_hours"
android:key="quiet_hours_start"
android:negativeButtonText="@string/cancel"
android:positiveButtonText="@string/set"
android:title="@string/title_pref_quiet_hours_start_time" />
<eu.siacs.conversations.ui.TimePreference
android:dependency="enable_quiet_hours"
android:key="quiet_hours_end"
android:negativeButtonText="@string/cancel"
android:positiveButtonText="@string/set"
android:title="@string/title_pref_quiet_hours_end_time" />
</PreferenceScreen>
<CheckBoxPreference
android:defaultValue="true"
android:dependency="show_notification"
android:key="vibrate_on_notification"
android:summary="@string/pref_vibrate_summary"
android:title="@string/pref_vibrate" />
android:defaultValue="true"
android:key="show_notification"
android:summary="@string/pref_notifications_summary"
android:title="@string/pref_notifications" />
<PreferenceScreen
android:dependency="show_notification"
android:summary="@string/pref_quiet_hours_summary"
android:title="@string/title_pref_quiet_hours">
<CheckBoxPreference
android:defaultValue="false"
android:key="enable_quiet_hours"
android:summary="@string/pref_quiet_hours_summary"
android:title="@string/title_pref_enable_quiet_hours" />
<eu.siacs.conversations.ui.TimePreference
android:dependency="enable_quiet_hours"
android:key="quiet_hours_start"
android:negativeButtonText="@string/cancel"
android:positiveButtonText="@string/set"
android:title="@string/title_pref_quiet_hours_start_time" />
<eu.siacs.conversations.ui.TimePreference
android:dependency="enable_quiet_hours"
android:key="quiet_hours_end"
android:negativeButtonText="@string/cancel"
android:positiveButtonText="@string/set"
android:title="@string/title_pref_quiet_hours_end_time" />
</PreferenceScreen>
<CheckBoxPreference
android:defaultValue="true"
android:dependency="show_notification"
android:key="vibrate_on_notification"
android:summary="@string/pref_vibrate_summary"
android:title="@string/pref_vibrate" />
<RingtonePreference
android:defaultValue="content://settings/system/notification_sound"
android:dependency="show_notification"
android:key="notification_ringtone"
android:ringtoneType="notification"
android:summary="@string/pref_sound_summary"
android:title="@string/pref_sound" />
<RingtonePreference
android:defaultValue="content://settings/system/notification_sound"
android:dependency="show_notification"
android:key="notification_ringtone"
android:ringtoneType="notification"
android:summary="@string/pref_sound_summary"
android:title="@string/pref_sound" />
<CheckBoxPreference
android:defaultValue="true"
android:dependency="show_notification"
android:key="always_notify_in_conference"
android:summary="@string/pref_conference_notifications_summary"
android:title="@string/pref_conference_notifications" />
<yuku.ambilwarna.widget.AmbilWarnaPreference
android:defaultValue="0xffffffff"
android:key="led_notify_color"
android:title="@string/pref_led_notification_color"
app:supportsAlpha="true"
android:summary="@string/pref_led_notification_color_summary"/>
<CheckBoxPreference
android:defaultValue="true"
android:dependency="show_notification"
android:key="always_notify_in_conference"
android:summary="@string/pref_conference_notifications_summary"
android:title="@string/pref_conference_notifications" />
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_ui_options" >
<CheckBoxPreference
@ -177,12 +184,6 @@
android:key="keep_foreground_service"
android:title="@string/pref_keep_foreground_service"
android:summary="@string/pref_keep_foreground_service_summary" />
<yuku.ambilwarna.widget.AmbilWarnaPreference
android:defaultValue="0xffffffff"
android:key="led_notify_color"
android:title="@string/pref_led_notification_color"
app:supportsAlpha="true"
android:summary="@string/pref_led_notification_color_summary"/>
</PreferenceCategory>
</PreferenceScreen>