Commit 9a26ec88 by zhangchengbo

feat:添加[保存至已有联系人]功能

parent 565ed28f
...@@ -249,15 +249,6 @@ class ConversationsAdapter( ...@@ -249,15 +249,6 @@ class ConversationsAdapter(
} }
} }
private fun addNumberToContact() {
val conversation = getSelectedItems().firstOrNull() ?: return
Intent().apply {
action = Intent.ACTION_INSERT_OR_EDIT
type = "vnd.android.cursor.item/contact"
putExtra(KEY_PHONE, conversation.phoneNumber)
activity.launchActivityIntent(this)
}
}
private fun pinConversation(pin: Boolean) { private fun pinConversation(pin: Boolean) {
val conversations = getSelectedItems() val conversations = getSelectedItems()
......
...@@ -75,6 +75,9 @@ class ThreadAdapter( ...@@ -75,6 +75,9 @@ class ThreadAdapter(
5->{ 5->{
activity.addNumberToContact(phoneNumber) activity.addNumberToContact(phoneNumber)
} }
6->{
activity.addNumberOrEditToContact(phoneNumber)
}
} }
} }
} }
......
...@@ -11,6 +11,15 @@ import com.simplemobiletools.commons.helpers.* ...@@ -11,6 +11,15 @@ import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.models.SimpleContact import com.simplemobiletools.commons.models.SimpleContact
import java.util.Locale import java.util.Locale
fun SimpleActivity.addNumberOrEditToContact(phoneNumber: String) {
Intent().apply {
action = Intent.ACTION_INSERT_OR_EDIT
type = "vnd.android.cursor.item/contact"
putExtra(KEY_PHONE, phoneNumber)
launchActivityIntent(this)
}
}
fun SimpleActivity.addNumberToContact(recipient: String) { fun SimpleActivity.addNumberToContact(recipient: String) {
Intent().apply { Intent().apply {
action = Intent.ACTION_EDIT action = Intent.ACTION_EDIT
......
...@@ -19,8 +19,10 @@ class TipPopup(mContext: Context, private val sureResult: (Int,String) -> Unit) ...@@ -19,8 +19,10 @@ class TipPopup(mContext: Context, private val sureResult: (Int,String) -> Unit)
private val tvSendSms by lazy { findViewById<TextView>(R.id.tv_send_sms) } private val tvSendSms by lazy { findViewById<TextView>(R.id.tv_send_sms) }
private val tvCopy by lazy { findViewById<TextView>(R.id.tv_copy_phone_number) } private val tvCopy by lazy { findViewById<TextView>(R.id.tv_copy_phone_number) }
private val tvAddContacts by lazy { findViewById<TextView>(R.id.tv_add_contacts) } private val tvAddContacts by lazy { findViewById<TextView>(R.id.tv_add_contacts) }
private val tvSaveContacts by lazy { findViewById<TextView>(R.id.tv_save_contacts) }
private val tvCancel by lazy { findViewById<TextView>(R.id.tv_cancel_pop) } private val tvCancel by lazy { findViewById<TextView>(R.id.tv_cancel_pop) }
private var phoneNumbers :String = "" private var phoneNumbers :String = ""
init { init {
setContentView(R.layout.d_ui_tips_popup) setContentView(R.layout.d_ui_tips_popup)
...@@ -55,6 +57,10 @@ class TipPopup(mContext: Context, private val sureResult: (Int,String) -> Unit) ...@@ -55,6 +57,10 @@ class TipPopup(mContext: Context, private val sureResult: (Int,String) -> Unit)
sureResult.invoke(5,phoneNumbers) sureResult.invoke(5,phoneNumbers)
dismiss() dismiss()
} }
tvSaveContacts.setOnClickListener {
sureResult.invoke(6,phoneNumbers)
dismiss()
}
} }
fun setPhoneNumberData(phoneNumber: String) { fun setPhoneNumberData(phoneNumber: String) {
......
...@@ -105,6 +105,25 @@ ...@@ -105,6 +105,25 @@
android:textColor="@color/md_grey_black" android:textColor="@color/md_grey_black"
android:textSize="16sp" /> android:textSize="16sp" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/divider_height"
android:layout_marginStart="20dp"
android:layout_marginEnd="15dp"
android:background="@color/divider_grey" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_save_contacts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="5dp"
android:minHeight="30dp"
android:text="保存至已有联系人"
android:textColor="@color/md_grey_black"
android:textSize="16sp" />
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_cancel_pop" android:id="@+id/tv_cancel_pop"
android:layout_width="match_parent" android:layout_width="match_parent"
......
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