mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
fixing a couple crashes
This commit is contained in:
@ -104,9 +104,7 @@ abstract class ContactActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun shareContact() {
|
fun shareContact() {
|
||||||
if (contact != null) {
|
shareContacts(arrayListOf(contact!!))
|
||||||
shareContacts(arrayListOf(contact!!))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun trySendSMS() {
|
fun trySendSMS() {
|
||||||
|
@ -94,6 +94,10 @@ class EditContactActivity : ContactActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
if (contact == null) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.save -> saveContact()
|
R.id.save -> saveContact()
|
||||||
R.id.share -> shareContact()
|
R.id.share -> shareContact()
|
||||||
@ -232,7 +236,11 @@ class EditContactActivity : ContactActivity() {
|
|||||||
Intent().apply {
|
Intent().apply {
|
||||||
action = Intent.ACTION_EDIT
|
action = Intent.ACTION_EDIT
|
||||||
data = getContactPublicUri(contact!!)
|
data = getContactPublicUri(contact!!)
|
||||||
startActivity(this)
|
if (resolveActivity(packageManager) != null) {
|
||||||
|
startActivity(this)
|
||||||
|
} else {
|
||||||
|
toast(R.string.no_app_found)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -713,7 +721,7 @@ class EditContactActivity : ContactActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun saveContact() {
|
private fun saveContact() {
|
||||||
if (isSaving || contact == null) {
|
if (isSaving) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,10 +354,14 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val inputStream = contentResolver.openInputStream(uri)
|
try {
|
||||||
val out = FileOutputStream(tempFile)
|
val inputStream = contentResolver.openInputStream(uri)
|
||||||
inputStream.copyTo(out)
|
val out = FileOutputStream(tempFile)
|
||||||
showImportContactsDialog(tempFile.absolutePath)
|
inputStream.copyTo(out)
|
||||||
|
showImportContactsDialog(tempFile.absolutePath)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
showErrorToast(e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else -> toast(R.string.invalid_file_format)
|
else -> toast(R.string.invalid_file_format)
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,10 @@ class ViewContactActivity : ContactActivity() {
|
|||||||
|
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
if (contact == null) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.edit -> editContact(contact!!)
|
R.id.edit -> editContact(contact!!)
|
||||||
R.id.share -> shareContact()
|
R.id.share -> shareContact()
|
||||||
|
@ -145,7 +145,10 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
|
|||||||
|
|
||||||
val contactsToRemove = ArrayList<Contact>()
|
val contactsToRemove = ArrayList<Contact>()
|
||||||
selectedPositions.sortedDescending().forEach {
|
selectedPositions.sortedDescending().forEach {
|
||||||
contactsToRemove.add(contactItems[it])
|
val contact = contactItems.getOrNull(it)
|
||||||
|
if (contact != null) {
|
||||||
|
contactsToRemove.add(contact)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
contactItems.removeAll(contactsToRemove)
|
contactItems.removeAll(contactsToRemove)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user