mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-02-17 03:51:03 +01:00
remember last used vcard export path
This commit is contained in:
parent
1b7a860cdf
commit
39b432bf4b
@ -520,19 +520,18 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||
}
|
||||
|
||||
private fun exportContacts() {
|
||||
FilePickerDialog(this, pickFile = false, showFAB = true) {
|
||||
ExportContactsDialog(this, it) { file, ignoredContactSources ->
|
||||
ContactsHelper(this).getContacts(true, ignoredContactSources) { contacts ->
|
||||
if (contacts.isEmpty()) {
|
||||
toast(R.string.no_entries_for_exporting)
|
||||
} else {
|
||||
VcfExporter().exportContacts(this, file, contacts, true) { result ->
|
||||
toast(when (result) {
|
||||
VcfExporter.ExportResult.EXPORT_OK -> R.string.exporting_successful
|
||||
VcfExporter.ExportResult.EXPORT_PARTIAL -> R.string.exporting_some_entries_failed
|
||||
else -> R.string.exporting_failed
|
||||
})
|
||||
}
|
||||
ExportContactsDialog(this, config.lastExportPath) { file, ignoredContactSources ->
|
||||
config.lastExportPath = file.absolutePath.getParentPath()
|
||||
ContactsHelper(this).getContacts(true, ignoredContactSources) { contacts ->
|
||||
if (contacts.isEmpty()) {
|
||||
toast(R.string.no_entries_for_exporting)
|
||||
} else {
|
||||
VcfExporter().exportContacts(this, file, contacts, true) { result ->
|
||||
toast(when (result) {
|
||||
VcfExporter.ExportResult.EXPORT_OK -> R.string.exporting_successful
|
||||
VcfExporter.ExportResult.EXPORT_PARTIAL -> R.string.exporting_some_entries_failed
|
||||
else -> R.string.exporting_failed
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.simplemobiletools.contacts.pro.dialogs
|
||||
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.contacts.pro.R
|
||||
@ -17,12 +18,21 @@ import java.util.*
|
||||
class ExportContactsDialog(val activity: SimpleActivity, val path: String, private val callback: (file: File, ignoredContactSources: HashSet<String>) -> Unit) {
|
||||
private var contactSources = ArrayList<ContactSource>()
|
||||
private var ignoreClicks = false
|
||||
private var realPath = if (path.isEmpty()) activity.internalStoragePath else path
|
||||
|
||||
init {
|
||||
val view = (activity.layoutInflater.inflate(R.layout.dialog_export_contacts, null) as ViewGroup).apply {
|
||||
export_contacts_folder.text = activity.humanizePath(path)
|
||||
export_contacts_folder.text = activity.humanizePath(realPath)
|
||||
export_contacts_filename.setText("contacts_${activity.getCurrentFormattedDateTime()}")
|
||||
|
||||
export_contacts_folder.setOnClickListener {
|
||||
activity.hideKeyboard(export_contacts_filename)
|
||||
FilePickerDialog(activity, realPath, false, showFAB = true) {
|
||||
export_contacts_folder.text = activity.humanizePath(it)
|
||||
realPath = it
|
||||
}
|
||||
}
|
||||
|
||||
ContactsHelper(activity).getContactSources {
|
||||
it.mapTo(contactSources) { it.copy() }
|
||||
activity.runOnUiThread {
|
||||
@ -45,7 +55,7 @@ class ExportContactsDialog(val activity: SimpleActivity, val path: String, priva
|
||||
when {
|
||||
filename.isEmpty() -> activity.toast(R.string.empty_name)
|
||||
filename.isAValidFilename() -> {
|
||||
val file = File(path, "$filename.vcf")
|
||||
val file = File(realPath, "$filename.vcf")
|
||||
if (file.exists()) {
|
||||
activity.toast(R.string.name_taken)
|
||||
return@setOnClickListener
|
||||
|
@ -60,6 +60,10 @@ class Config(context: Context) : BaseConfig(context) {
|
||||
get() = prefs.getBoolean(SHOW_DIALPAD_LETTERS, true)
|
||||
set(showDialpadLetters) = prefs.edit().putBoolean(SHOW_DIALPAD_LETTERS, showDialpadLetters).apply()
|
||||
|
||||
var lastExportPath: String
|
||||
get() = prefs.getString(LAST_EXPORT_PATH, "")!!
|
||||
set(lastExportPath) = prefs.edit().putString(LAST_EXPORT_PATH, lastExportPath).apply()
|
||||
|
||||
var speedDial: String
|
||||
get() = prefs.getString(SPEED_DIAL, "")!!
|
||||
set(speedDial) = prefs.edit().putString(SPEED_DIAL, speedDial).apply()
|
||||
|
@ -22,6 +22,7 @@ const val SHOW_CALL_CONFIRMATION = "show_call_confirmation"
|
||||
const val SHOW_DIALPAD_BUTTON = "show_dialpad_button"
|
||||
const val SHOW_DIALPAD_LETTERS = "show_dialpad_letters"
|
||||
const val SPEED_DIAL = "speed_dial"
|
||||
const val LAST_EXPORT_PATH = "last_export_path"
|
||||
|
||||
const val CONTACT_ID = "contact_id"
|
||||
const val SMT_PRIVATE = "smt_private" // used at the contact source of local contacts hidden from other apps
|
||||
|
Loading…
x
Reference in New Issue
Block a user