mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 11:38:51 +01:00
Don't show notifications from blocked contacts
This commit is contained in:
@@ -44,6 +44,15 @@ public class BlockedConversationHelper {
|
||||
prefs.edit().putStringSet(SettingsFragment.BLOCKED_SENDERS, idStrings2).apply();
|
||||
}
|
||||
|
||||
public static Set<Long> getBlockedConversationIds(SharedPreferences prefs) {
|
||||
Set<String> conversations = getBlockedConversations(prefs);
|
||||
Set<Long> ids = new HashSet<>();
|
||||
for (String id : conversations) {
|
||||
ids.add(Long.parseLong(id));
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
public static Set<String> getBlockedConversations(SharedPreferences prefs) {
|
||||
return prefs.getStringSet(SettingsFragment.BLOCKED_SENDERS, new HashSet<String>());
|
||||
}
|
||||
|
||||
@@ -5,8 +5,10 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.PowerManager;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.telephony.SmsMessage;
|
||||
import android.util.Log;
|
||||
import com.moez.QKSMS.common.BlockedConversationHelper;
|
||||
import com.moez.QKSMS.common.ConversationPrefsHelper;
|
||||
import com.moez.QKSMS.data.Message;
|
||||
import com.moez.QKSMS.service.NotificationService;
|
||||
@@ -54,7 +56,8 @@ public class MessagingReceiver extends BroadcastReceiver {
|
||||
Message message = new Message(context, uri);
|
||||
ConversationPrefsHelper prefs = new ConversationPrefsHelper(context, message.getThreadId());
|
||||
|
||||
if (prefs.getNotificationsEnabled()) {
|
||||
if (prefs.getNotificationsEnabled() && !BlockedConversationHelper.getBlockedConversationIds(
|
||||
PreferenceManager.getDefaultSharedPreferences(context)).contains(message.getThreadId())) {
|
||||
Intent messageHandlerIntent = new Intent(context, NotificationService.class);
|
||||
messageHandlerIntent.putExtra(NotificationService.EXTRA_POPUP, true);
|
||||
messageHandlerIntent.putExtra(NotificationService.EXTRA_URI, uri.toString());
|
||||
|
||||
Reference in New Issue
Block a user