Commit 89e27fb3 by zhangchengbo

fix:[加入黑名单]后,首页conversations会话依旧展示

parent 319cb23b
......@@ -327,12 +327,13 @@ class MainActivity : SimpleActivity() {
} catch (e: Exception) {
ArrayList()
}
Log.d(TAG, "getCachedConversations: conversations = ${Gson().toJson(conversations)}")
val archived = try {
conversationsDB.getAllArchived()
} catch (e: Exception) {
listOf()
}
Log.d(TAG, "getCachedConversations: archived = ${Gson().toJson(archived)}")
// runOnUiThread {
// setupConversations(conversations, cached = true)
......
......@@ -17,6 +17,7 @@ import android.provider.OpenableColumns
import android.provider.Telephony.*
import android.telephony.SubscriptionManager
import android.text.TextUtils
import android.util.Log
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.request.RequestOptions
......@@ -289,7 +290,7 @@ fun Context.getConversations(threadId: Long? = null, privateContacts: ArrayList<
val conversations = ArrayList<Conversation>()
val simpleContactHelper = SimpleContactsHelper(this)
val blockedNumbers = getBlockedNumbers()
// val blockedNumbers = getBlockedNumbers()
try {
queryCursorUnsafe(uri, projection.toTypedArray(), selection, null, sortOrder) { cursor ->
val id = cursor.getLongValue(Threads._ID)
......@@ -306,7 +307,7 @@ fun Context.getConversations(threadId: Long? = null, privateContacts: ArrayList<
val rawIds = cursor.getStringValue(Threads.RECIPIENT_IDS)
val recipientIds = rawIds.split(" ").filter { it.areDigitsOnly() }.map { it.toInt() }.toMutableList()
val phoneNumbers = getThreadPhoneNumbers(recipientIds)
if (phoneNumbers.isEmpty() || phoneNumbers.any { isNumberBlocked(it, blockedNumbers) }) {
if (phoneNumbers.isEmpty() /*|| phoneNumbers.any { isNumberBlocked(it, blockedNumbers) }*/) {
return@queryCursorUnsafe
}
......@@ -1111,12 +1112,14 @@ fun Context.clearExpiredScheduledMessages(threadId: Long, messagesToDelete: List
try {
messages.filter { it.isScheduled && it.millis() < now }.forEach { msg ->
messagesDB.delete(msg.id)
Log.d("TAG", "getCachedConversations: delete")
}
if (messages.filterNot { it.isScheduled && it.millis() < now }.isEmpty()) {
// delete empty temporary thread
val conversation = conversationsDB.getConversationWithThreadId(threadId)
if (conversation != null && conversation.isScheduled) {
conversationsDB.deleteThreadId(threadId)
Log.d("TAG", "getCachedConversations: deleteThreadId")
}
}
} catch (e: Exception) {
......
......@@ -224,12 +224,13 @@ class RecentsHelper(private val context: Context) {
} while (cursor.moveToNext() && recentCalls.size < maxSize)
}
val blockedNumbers = context.getBlockedNumbers()
/* val blockedNumbers = context.getBlockedNumbers()
val recentResult = recentCalls
.filter { !context.isNumberBlocked(it.phoneNumber, blockedNumbers) }
callback(recentResult)
callback(recentResult)*/
callback(recentCalls)
}
/***
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment