Skip to content

Commit 8511cfd

Browse files
committed
use the contacts name at sharing, if we share only one
1 parent 68082ab commit 8511cfd

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ android {
5757
}
5858

5959
dependencies {
60-
implementation 'com.simplemobiletools:commons:5.34.6'
60+
implementation 'com.simplemobiletools:commons:5.34.7'
6161
implementation 'joda-time:joda-time:2.10.3'
6262
implementation 'com.googlecode.ez-vcard:ez-vcard:0.10.5'
6363
implementation 'com.github.tibbi:IndicatorFastScroll:c3de1d040a'

app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Activity.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,13 @@ fun SimpleActivity.showContactSourcePicker(currentSource: String, callback: (new
8080
}
8181

8282
fun BaseSimpleActivity.shareContacts(contacts: ArrayList<Contact>) {
83-
val file = getTempFile()
83+
val filename = if (contacts.size == 1) {
84+
"${contacts.first().getNameToDisplay()}.vcf"
85+
} else {
86+
DEFAULT_FILE_NAME
87+
}
88+
89+
val file = getTempFile(filename)
8490
if (file == null) {
8591
toast(R.string.unknown_error_occurred)
8692
return

app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Context.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ fun Context.sendEmailToContacts(contacts: ArrayList<Contact>) {
264264
}
265265
}
266266

267-
fun Context.getTempFile(): File? {
267+
fun Context.getTempFile(filename: String = DEFAULT_FILE_NAME): File? {
268268
val folder = File(cacheDir, "contacts")
269269
if (!folder.exists()) {
270270
if (!folder.mkdir()) {
@@ -273,7 +273,7 @@ fun Context.getTempFile(): File? {
273273
}
274274
}
275275

276-
return File(folder, "contacts.vcf")
276+
return File(folder, filename)
277277
}
278278

279279
fun Context.addContactsToGroup(contacts: ArrayList<Contact>, groupId: Long) {

app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/Constants.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const val IS_FROM_SIMPLE_CONTACTS = "is_from_simple_contacts"
2929
const val ADD_NEW_CONTACT_NUMBER = "add_new_contact_number"
3030
const val FIRST_CONTACT_ID = 1000000
3131
const val FIRST_GROUP_ID = 10000L
32+
const val DEFAULT_FILE_NAME = "contacts.vcf"
3233

3334
// extras used at third party intents
3435
const val KEY_NAME = "name"

0 commit comments

Comments
 (0)