forked from upstream-mirrors/quik
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();
|
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) {
|
public static Set<String> getBlockedConversations(SharedPreferences prefs) {
|
||||||
return prefs.getStringSet(SettingsFragment.BLOCKED_SENDERS, new HashSet<String>());
|
return prefs.getStringSet(SettingsFragment.BLOCKED_SENDERS, new HashSet<String>());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,10 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.telephony.SmsMessage;
|
import android.telephony.SmsMessage;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import com.moez.QKSMS.common.BlockedConversationHelper;
|
||||||
import com.moez.QKSMS.common.ConversationPrefsHelper;
|
import com.moez.QKSMS.common.ConversationPrefsHelper;
|
||||||
import com.moez.QKSMS.data.Message;
|
import com.moez.QKSMS.data.Message;
|
||||||
import com.moez.QKSMS.service.NotificationService;
|
import com.moez.QKSMS.service.NotificationService;
|
||||||
@@ -54,7 +56,8 @@ public class MessagingReceiver extends BroadcastReceiver {
|
|||||||
Message message = new Message(context, uri);
|
Message message = new Message(context, uri);
|
||||||
ConversationPrefsHelper prefs = new ConversationPrefsHelper(context, message.getThreadId());
|
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);
|
Intent messageHandlerIntent = new Intent(context, NotificationService.class);
|
||||||
messageHandlerIntent.putExtra(NotificationService.EXTRA_POPUP, true);
|
messageHandlerIntent.putExtra(NotificationService.EXTRA_POPUP, true);
|
||||||
messageHandlerIntent.putExtra(NotificationService.EXTRA_URI, uri.toString());
|
messageHandlerIntent.putExtra(NotificationService.EXTRA_URI, uri.toString());
|
||||||
|
|||||||
Reference in New Issue
Block a user