removed global notifications switch

This commit is contained in:
Daniel Gultsch 2018-09-06 16:56:31 +02:00
parent d86f4ce3a6
commit 39b86de698
4 changed files with 5 additions and 26 deletions

View File

@ -158,17 +158,12 @@ public class NotificationService {
public boolean notify(final Message message) { public boolean notify(final Message message) {
final Conversation conversation = (Conversation) message.getConversation(); final Conversation conversation = (Conversation) message.getConversation();
return message.getStatus() == Message.STATUS_RECEIVED return message.getStatus() == Message.STATUS_RECEIVED
&& notificationsEnabled()
&& !conversation.isMuted() && !conversation.isMuted()
&& (conversation.alwaysNotify() || wasHighlightedOrPrivate(message)) && (conversation.alwaysNotify() || wasHighlightedOrPrivate(message))
&& (!conversation.isWithStranger() || notificationsFromStrangers()) && (!conversation.isWithStranger() || notificationsFromStrangers())
; ;
} }
private boolean notificationsEnabled() {
return mXmppConnectionService.getBooleanPreference("show_notification", R.bool.show_notification);
}
private boolean notificationsFromStrangers() { private boolean notificationsFromStrangers() {
return mXmppConnectionService.getBooleanPreference("notifications_from_strangers", R.bool.notifications_from_strangers); return mXmppConnectionService.getBooleanPreference("notifications_from_strangers", R.bool.notifications_from_strangers);
} }

View File

@ -10,7 +10,6 @@
<bool name="confirm_messages">true</bool> <bool name="confirm_messages">true</bool>
<bool name="chat_states">true</bool> <bool name="chat_states">true</bool>
<bool name="last_activity">false</bool> <bool name="last_activity">false</bool>
<bool name="show_notification">true</bool>
<bool name="vibrate_on_notification">true</bool> <bool name="vibrate_on_notification">true</bool>
<bool name="led">true</bool> <bool name="led">true</bool>
<bool name="enable_quiet_hours">false</bool> <bool name="enable_quiet_hours">false</bool>

View File

@ -108,8 +108,6 @@
<string name="pref_return_to_previous">Quick Sharing</string> <string name="pref_return_to_previous">Quick Sharing</string>
<string name="pref_return_to_previous_summary">Immediately return to previous activity instead of opening the conversation after sharing something</string> <string name="pref_return_to_previous_summary">Immediately return to previous activity instead of opening the conversation after sharing something</string>
<string name="pref_notification_settings">Notification</string> <string name="pref_notification_settings">Notification</string>
<string name="pref_notifications">Notifications</string>
<string name="pref_notifications_summary">Notify when a new message arrives</string>
<string name="pref_vibrate">Vibrate</string> <string name="pref_vibrate">Vibrate</string>
<string name="pref_vibrate_summary">Vibrate when a new message arrives</string> <string name="pref_vibrate_summary">Vibrate when a new message arrives</string>
<string name="pref_led">LED Notification</string> <string name="pref_led">LED Notification</string>

View File

@ -43,20 +43,8 @@
<PreferenceCategory <PreferenceCategory
android:title="@string/pref_notification_settings" android:title="@string/pref_notification_settings"
android:key="notification_category"> android:key="notification_category">
<CheckBoxPreference
android:defaultValue="@bool/show_notification"
android:key="show_notification"
android:summary="@string/pref_notifications_summary"
android:title="@string/pref_notifications" />
<CheckBoxPreference
android:defaultValue="@bool/notifications_from_strangers"
android:dependency="show_notification"
android:key="notifications_from_strangers"
android:summary="@string/pref_notifications_from_strangers_summary"
android:title="@string/pref_notifications_from_strangers" />
<PreferenceScreen <PreferenceScreen
android:key="more_notification_settings" android:key="more_notification_settings"
android:dependency="show_notification"
android:summary="@string/pref_more_notification_settings_summary" android:summary="@string/pref_more_notification_settings_summary"
android:title="@string/pref_more_notification_settings"> android:title="@string/pref_more_notification_settings">
<intent android:action="android.settings.CHANNEL_NOTIFICATION_SETTINGS"> <intent android:action="android.settings.CHANNEL_NOTIFICATION_SETTINGS">
@ -68,33 +56,33 @@
android:value="messages" /> android:value="messages" />
</intent> </intent>
</PreferenceScreen> </PreferenceScreen>
<CheckBoxPreference
android:defaultValue="@bool/notifications_from_strangers"
android:key="notifications_from_strangers"
android:summary="@string/pref_notifications_from_strangers_summary"
android:title="@string/pref_notifications_from_strangers" />
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="@bool/headsup_notifications" android:defaultValue="@bool/headsup_notifications"
android:dependency="show_notification"
android:key="notification_headsup" android:key="notification_headsup"
android:summary="@string/pref_headsup_notifications_summary" android:summary="@string/pref_headsup_notifications_summary"
android:title="@string/pref_headsup_notifications" /> android:title="@string/pref_headsup_notifications" />
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="@bool/vibrate_on_notification" android:defaultValue="@bool/vibrate_on_notification"
android:dependency="show_notification"
android:key="vibrate_on_notification" android:key="vibrate_on_notification"
android:summary="@string/pref_vibrate_summary" android:summary="@string/pref_vibrate_summary"
android:title="@string/pref_vibrate" /> android:title="@string/pref_vibrate" />
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="@bool/led" android:defaultValue="@bool/led"
android:dependency="show_notification"
android:key="led" android:key="led"
android:summary="@string/pref_led_summary" android:summary="@string/pref_led_summary"
android:title="@string/pref_led" /> android:title="@string/pref_led" />
<RingtonePreference <RingtonePreference
android:defaultValue="@string/notification_ringtone" android:defaultValue="@string/notification_ringtone"
android:dependency="show_notification"
android:key="notification_ringtone" android:key="notification_ringtone"
android:ringtoneType="notification" android:ringtoneType="notification"
android:summary="@string/pref_sound_summary" android:summary="@string/pref_sound_summary"
android:title="@string/pref_sound" /> android:title="@string/pref_sound" />
<PreferenceScreen <PreferenceScreen
android:dependency="show_notification"
android:key="quiet_hours" android:key="quiet_hours"
android:summary="@string/pref_quiet_hours_summary" android:summary="@string/pref_quiet_hours_summary"
android:title="@string/title_pref_quiet_hours"> android:title="@string/title_pref_quiet_hours">
@ -126,7 +114,6 @@
</PreferenceScreen> </PreferenceScreen>
<ListPreference <ListPreference
android:defaultValue="@integer/grace_period" android:defaultValue="@integer/grace_period"
android:dependency="show_notification"
android:entries="@array/grace_periods" android:entries="@array/grace_periods"
android:entryValues="@array/grace_periods_values" android:entryValues="@array/grace_periods_values"
android:key="grace_period_length" android:key="grace_period_length"