aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/services/NotificationService.java
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2015-10-21 23:49:06 +0200
committersteckbrief <steckbrief@chefmail.de>2015-10-21 23:49:06 +0200
commit85a25984f4bf4dfa2432fbc2c92f8117cf927fcf (patch)
treeb13aa11f4ce0be81e2b03cf74a00a33e03b2399f /src/main/java/de/thedevstack/conversationsplus/services/NotificationService.java
parent1d9b4e959d70c2f008574f9a75c7eeb4b47c63ef (diff)
Access to preferences moved to global utility class ConversationsPlusPreferences. Unused imports removed. Unnecessary references to XmppConnectionService removed. Bug in call order in StartConversationActivity for the setting hide_offline fixed.
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/services/NotificationService.java')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/services/NotificationService.java30
1 files changed, 9 insertions, 21 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/services/NotificationService.java b/src/main/java/de/thedevstack/conversationsplus/services/NotificationService.java
index e6692d40..1536e8b1 100644
--- a/src/main/java/de/thedevstack/conversationsplus/services/NotificationService.java
+++ b/src/main/java/de/thedevstack/conversationsplus/services/NotificationService.java
@@ -6,7 +6,6 @@ import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
-import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
@@ -32,6 +31,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import de.thedevstack.conversationsplus.ConversationsPlusApplication;
+import de.thedevstack.conversationsplus.ConversationsPlusPreferences;
import de.tzur.conversations.Settings;
import de.thedevstack.conversationsplus.Config;
import de.thedevstack.conversationsplus.R;
@@ -40,7 +40,6 @@ import de.thedevstack.conversationsplus.entities.Conversation;
import de.thedevstack.conversationsplus.entities.Message;
import de.thedevstack.conversationsplus.ui.ConversationActivity;
import de.thedevstack.conversationsplus.ui.ManageAccountActivity;
-import de.thedevstack.conversationsplus.ui.TimePreference;
import de.thedevstack.conversationsplus.utils.GeoHelper;
import de.thedevstack.conversationsplus.utils.UIHelper;
@@ -64,10 +63,10 @@ public class NotificationService {
public boolean notify(final Message message) {
return (message.getStatus() == Message.STATUS_RECEIVED)
- && notificationsEnabled()
+ && ConversationsPlusPreferences.showNotification()
&& !message.getConversation().isMuted()
&& (message.getConversation().getMode() == Conversation.MODE_SINGLE
- || conferenceNotificationsEnabled()
+ || ConversationsPlusPreferences.alwaysNotifyInConference()
|| wasHighlightedOrPrivate(message)
);
}
@@ -93,17 +92,12 @@ public class NotificationService {
mXmppConnectionService.sendBroadcast(i);
}
-
- public boolean notificationsEnabled() {
- return mXmppConnectionService.getPreferences().getBoolean("show_notification", true);
- }
-
public boolean isQuietHours() {
- if (!mXmppConnectionService.getPreferences().getBoolean("enable_quiet_hours", false)) {
+ if (!ConversationsPlusPreferences.enableQuietHours()) {
return false;
}
- final long startTime = mXmppConnectionService.getPreferences().getLong("quiet_hours_start", TimePreference.DEFAULT_VALUE) % Config.MILLISECONDS_IN_DAY;
- final long endTime = mXmppConnectionService.getPreferences().getLong("quiet_hours_end", TimePreference.DEFAULT_VALUE) % Config.MILLISECONDS_IN_DAY;
+ final long startTime = ConversationsPlusPreferences.quietHoursStart() % Config.MILLISECONDS_IN_DAY;
+ final long endTime = ConversationsPlusPreferences.quietHoursEnd() % Config.MILLISECONDS_IN_DAY;
final long nowTime = Calendar.getInstance().getTimeInMillis() % Config.MILLISECONDS_IN_DAY;
if (endTime < startTime) {
@@ -113,10 +107,6 @@ public class NotificationService {
}
}
- public boolean conferenceNotificationsEnabled() {
- return mXmppConnectionService.getPreferences().getBoolean("always_notify_in_conference", false);
- }
-
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
private boolean isInteractive() {
@@ -184,12 +174,10 @@ public class NotificationService {
}
private void updateNotification(final boolean notify) {
- final NotificationManager notificationManager = (NotificationManager) mXmppConnectionService
- .getSystemService(Context.NOTIFICATION_SERVICE);
- final SharedPreferences preferences = mXmppConnectionService.getPreferences();
+ final NotificationManager notificationManager = (NotificationManager) ConversationsPlusApplication.getAppContext().getSystemService(Context.NOTIFICATION_SERVICE);
- final String ringtone = preferences.getString("notification_ringtone", null);
- final boolean vibrate = preferences.getBoolean("vibrate_on_notification", true);
+ final String ringtone = ConversationsPlusPreferences.notificationRingtone();
+ final boolean vibrate = ConversationsPlusPreferences.vibrateOnNotification();
if (notifications.size() == 0) {
notificationManager.cancel(NOTIFICATION_ID);