mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-03-04 02:57:46 +01:00
close the contact picker after successfull insert or edit
This commit is contained in:
parent
5e5de8b90a
commit
4b645b70b3
@ -1,5 +1,6 @@
|
||||
package com.simplemobiletools.contacts.activities
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.DatePickerDialog
|
||||
import android.content.ClipData
|
||||
import android.content.ContentValues
|
||||
@ -938,6 +939,7 @@ class EditContactActivity : ContactActivity() {
|
||||
contact!!.source = originalContactSource
|
||||
ContactsHelper(this).deleteContact(contact!!)
|
||||
}
|
||||
setResult(Activity.RESULT_OK)
|
||||
finish()
|
||||
} else {
|
||||
toast(R.string.unknown_error_occurred)
|
||||
@ -947,6 +949,7 @@ class EditContactActivity : ContactActivity() {
|
||||
private fun updateContact(photoUpdateStatus: Int) {
|
||||
isSaving = true
|
||||
if (ContactsHelper(this@EditContactActivity).updateContact(contact!!, photoUpdateStatus)) {
|
||||
setResult(Activity.RESULT_OK)
|
||||
finish()
|
||||
} else {
|
||||
toast(R.string.unknown_error_occurred)
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.simplemobiletools.contacts.activities
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.provider.ContactsContract
|
||||
@ -20,6 +21,9 @@ import com.simplemobiletools.contacts.models.Contact
|
||||
import kotlinx.android.synthetic.main.activity_insert_edit_contact.*
|
||||
|
||||
class InsertOrEditContactActivity : SimpleActivity() {
|
||||
private val START_INSERT_ACTIVITY = 1
|
||||
private val START_EDIT_ACTIVITY = 2
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_insert_edit_contact)
|
||||
@ -43,7 +47,7 @@ class InsertOrEditContactActivity : SimpleActivity() {
|
||||
data = ContactsContract.Contacts.CONTENT_URI
|
||||
putExtra(KEY_PHONE, intent.getStringExtra(KEY_PHONE))
|
||||
if (resolveActivity(packageManager) != null) {
|
||||
startActivity(this)
|
||||
startActivityForResult(this, START_INSERT_ACTIVITY)
|
||||
} else {
|
||||
toast(R.string.no_app_found)
|
||||
}
|
||||
@ -63,7 +67,7 @@ class InsertOrEditContactActivity : SimpleActivity() {
|
||||
data = getContactPublicUri(it as Contact)
|
||||
action = ADD_NEW_CONTACT_NUMBER
|
||||
putExtra(KEY_PHONE, intent.getStringExtra(KEY_PHONE))
|
||||
startActivity(this)
|
||||
startActivityForResult(this, START_EDIT_ACTIVITY)
|
||||
}
|
||||
}.apply {
|
||||
addVerticalDividers(true)
|
||||
@ -76,4 +80,11 @@ class InsertOrEditContactActivity : SimpleActivity() {
|
||||
existing_contact_fastscroller.updateBubbleText(item?.getBubbleText() ?: "")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, resultData)
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user