Commit cd32b84a by zhangchengbo

feat:新增[通讯录]备注名称字段, 数据库版本++

parent 8f570ef2
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
"formatVersion": 1, "formatVersion": 1,
"database": { "database": {
"version": 8, "version": 8,
"identityHash": "177e5b1c59b8f1f208da73418d4a933b", "identityHash": "a7eded73bb1631bb3f91db8aa077585a",
"entities": [ "entities": [
{ {
"tableName": "conversations", "tableName": "conversations",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`thread_id` INTEGER NOT NULL, `snippet` TEXT NOT NULL, `date` INTEGER NOT NULL, `read` INTEGER NOT NULL, `title` TEXT NOT NULL, `photo_uri` TEXT NOT NULL, `is_group_conversation` INTEGER NOT NULL, `phone_number` TEXT NOT NULL, `is_scheduled` INTEGER NOT NULL, `uses_custom_title` INTEGER NOT NULL, `archived` INTEGER NOT NULL, `isSFNumber` INTEGER NOT NULL, PRIMARY KEY(`thread_id`))", "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`thread_id` INTEGER NOT NULL, `snippet` TEXT NOT NULL, `date` INTEGER NOT NULL, `read` INTEGER NOT NULL, `title` TEXT NOT NULL, `photo_uri` TEXT NOT NULL, `is_group_conversation` INTEGER NOT NULL, `phone_number` TEXT NOT NULL, `is_scheduled` INTEGER NOT NULL, `uses_custom_title` INTEGER NOT NULL, `archived` INTEGER NOT NULL, `isSFNumber` INTEGER NOT NULL, `userName` TEXT NOT NULL, PRIMARY KEY(`thread_id`))",
"fields": [ "fields": [
{ {
"fieldPath": "threadId", "fieldPath": "threadId",
...@@ -79,6 +79,12 @@ ...@@ -79,6 +79,12 @@
"columnName": "isSFNumber", "columnName": "isSFNumber",
"affinity": "INTEGER", "affinity": "INTEGER",
"notNull": true "notNull": true
},
{
"fieldPath": "userName",
"columnName": "userName",
"affinity": "TEXT",
"notNull": true
} }
], ],
"primaryKey": { "primaryKey": {
...@@ -342,7 +348,7 @@ ...@@ -342,7 +348,7 @@
"views": [], "views": [],
"setupQueries": [ "setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '177e5b1c59b8f1f208da73418d4a933b')" "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'a7eded73bb1631bb3f91db8aa077585a')"
] ]
} }
} }
\ No newline at end of file
...@@ -28,6 +28,8 @@ abstract class BaseConversationsAdapter( ...@@ -28,6 +28,8 @@ abstract class BaseConversationsAdapter(
activity: SimpleActivity, recyclerView: MyRecyclerView, onRefresh: () -> Unit, itemClick: (Any) -> Unit activity: SimpleActivity, recyclerView: MyRecyclerView, onRefresh: () -> Unit, itemClick: (Any) -> Unit
) : MyRecyclerViewListAdapter<Conversation>(activity, recyclerView, ConversationDiffCallback(), itemClick, onRefresh), ) : MyRecyclerViewListAdapter<Conversation>(activity, recyclerView, ConversationDiffCallback(), itemClick, onRefresh),
RecyclerViewFastScroller.OnPopupTextUpdate { RecyclerViewFastScroller.OnPopupTextUpdate {
private val TAG = "BaseConversationsAdapter"
private var fontSize = activity.getTextSize() private var fontSize = activity.getTextSize()
private var drafts = HashMap<Long, String?>() private var drafts = HashMap<Long, String?>()
...@@ -127,7 +129,10 @@ abstract class BaseConversationsAdapter( ...@@ -127,7 +129,10 @@ abstract class BaseConversationsAdapter(
conversationFrame.isSelected = selectedKeys.contains(conversation.hashCode()) conversationFrame.isSelected = selectedKeys.contains(conversation.hashCode())
conversationAddress.apply { conversationAddress.apply {
text = if (conversation.phoneNumber.contains("**")) { Log.d(TAG, "setupView: conversation = ${Gson().toJson(conversation)}")
text = if(conversation.userName.isNotEmpty()){
conversation.userName
} else if (conversation.phoneNumber.contains("**")) {
conversation.phoneNumber conversation.phoneNumber
} else { } else {
conversation.title conversation.title
...@@ -152,8 +157,7 @@ abstract class BaseConversationsAdapter( ...@@ -152,8 +157,7 @@ abstract class BaseConversationsAdapter(
//短信内容 //短信内容
conversationBodyShort.apply { conversationBodyShort.apply {
text = smsDraft ?: conversation.snippet text = smsDraft ?: conversation.snippet
Log.d("TAG", "setupView: 是否包含零宽度字符 = ${conversation.snippet.contains("\u200B")} ${conversation.snippet.contains("\u200C")} ${conversation.snippet.contains("\u200D")} 短信内容 = ${text}") Log.d(TAG, "setupView: 是否包含零宽度字符 = ${conversation.snippet.contains("\u200B")} ${conversation.snippet.contains("\u200C")} ${conversation.snippet.contains("\u200D")} 短信内容 = ${text}")
// if(text.contains("\u200B"))
setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize * 0.9f) setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize * 0.9f)
} }
......
...@@ -318,7 +318,7 @@ fun Context.getConversations(threadId: Long? = null, privateContacts: ArrayList< ...@@ -318,7 +318,7 @@ fun Context.getConversations(threadId: Long? = null, privateContacts: ArrayList<
val isGroupConversation = phoneNumbers.size > 1 val isGroupConversation = phoneNumbers.size > 1
val read = cursor.getIntValue(Threads.READ) == 1 val read = cursor.getIntValue(Threads.READ) == 1
val archived = if (archiveAvailable) cursor.getIntValue(Threads.ARCHIVED) == 1 else false val archived = if (archiveAvailable) cursor.getIntValue(Threads.ARCHIVED) == 1 else false
val conversation = Conversation(id, snippet, date.toInt(), read, title, photoUri, isGroupConversation, phoneNumbers.first(), isArchived = archived) val conversation = Conversation(id, snippet, date.toInt(), read, title, photoUri, isGroupConversation, phoneNumbers.first(), isArchived = archived, userName = title)
conversations.add(conversation) conversations.add(conversation)
} }
} catch (sqliteException: SQLiteException) { } catch (sqliteException: SQLiteException) {
...@@ -1092,7 +1092,8 @@ fun Context.createTemporaryThread(message: Message, threadId: Long = generateRan ...@@ -1092,7 +1092,8 @@ fun Context.createTemporaryThread(message: Message, threadId: Long = generateRan
phoneNumber = addresses.first(), phoneNumber = addresses.first(),
isScheduled = true, isScheduled = true,
usesCustomTitle = cachedConv?.usesCustomTitle == true, usesCustomTitle = cachedConv?.usesCustomTitle == true,
isArchived = false isArchived = false,
userName = title
) )
try { try {
conversationsDB.insertOrUpdate(conversation) conversationsDB.insertOrUpdate(conversation)
......
...@@ -18,7 +18,8 @@ data class Conversation( ...@@ -18,7 +18,8 @@ data class Conversation(
@ColumnInfo(name = "is_scheduled") var isScheduled: Boolean = false, @ColumnInfo(name = "is_scheduled") var isScheduled: Boolean = false,
@ColumnInfo(name = "uses_custom_title") var usesCustomTitle: Boolean = false, @ColumnInfo(name = "uses_custom_title") var usesCustomTitle: Boolean = false,
@ColumnInfo(name = "archived") var isArchived: Boolean = false, @ColumnInfo(name = "archived") var isArchived: Boolean = false,
@ColumnInfo(name = "isSFNumber") var isSFNumber: Boolean = false @ColumnInfo(name = "isSFNumber") var isSFNumber: Boolean = false,
@ColumnInfo(name = "userName") var userName: String = "",//用于展示通讯录名称
) { ) {
companion object { companion object {
......
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