mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-02-20 05:20:56 +01:00
properly show the public contact source on all visible places
This commit is contained in:
parent
996a9ead0a
commit
b72c6cb787
@ -226,7 +226,7 @@ class EditContactActivity : SimpleActivity() {
|
|||||||
contact_first_name.setText(contact!!.firstName)
|
contact_first_name.setText(contact!!.firstName)
|
||||||
contact_middle_name.setText(contact!!.middleName)
|
contact_middle_name.setText(contact!!.middleName)
|
||||||
contact_surname.setText(contact!!.surname)
|
contact_surname.setText(contact!!.surname)
|
||||||
contact_source.text = contact!!.source
|
contact_source.text = getPublicContactSource(contact!!.source)
|
||||||
|
|
||||||
contact_toggle_favorite.apply {
|
contact_toggle_favorite.apply {
|
||||||
beVisible()
|
beVisible()
|
||||||
@ -302,11 +302,12 @@ class EditContactActivity : SimpleActivity() {
|
|||||||
private fun setupNewContact() {
|
private fun setupNewContact() {
|
||||||
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE)
|
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE)
|
||||||
supportActionBar?.title = resources.getString(R.string.new_contact)
|
supportActionBar?.title = resources.getString(R.string.new_contact)
|
||||||
contact = Contact(0, "", "", "", "", ArrayList(), ArrayList(), ArrayList(), "", 0, 0, "")
|
contact = Contact(0, "", "", "", "", ArrayList(), ArrayList(), ArrayList(), config.lastUsedContactSource, 0, 0, "")
|
||||||
contact_source.text = config.lastUsedContactSource
|
contact_source.text = getPublicContactSource(contact!!.source)
|
||||||
contact_source.setOnClickListener {
|
contact_source.setOnClickListener {
|
||||||
showContactSourcePicker(contact_source.value) {
|
showContactSourcePicker(contact!!.source) {
|
||||||
contact_source.text = it
|
contact!!.source = it
|
||||||
|
contact_source.text = getPublicContactSource(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -515,7 +516,7 @@ class EditContactActivity : SimpleActivity() {
|
|||||||
phoneNumbers = getFilledPhoneNumbers()
|
phoneNumbers = getFilledPhoneNumbers()
|
||||||
emails = getFilledEmails()
|
emails = getFilledEmails()
|
||||||
events = getFilledEvents()
|
events = getFilledEvents()
|
||||||
source = contact_source.value
|
source = contact!!.source
|
||||||
starred = if (isContactStarred()) 1 else 0
|
starred = if (isContactStarred()) 1 else 0
|
||||||
|
|
||||||
Thread {
|
Thread {
|
||||||
|
@ -4,22 +4,26 @@ import android.support.v7.app.AlertDialog
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.commons.extensions.toast
|
import com.simplemobiletools.commons.extensions.toast
|
||||||
import com.simplemobiletools.commons.extensions.value
|
|
||||||
import com.simplemobiletools.contacts.R
|
import com.simplemobiletools.contacts.R
|
||||||
import com.simplemobiletools.contacts.activities.SimpleActivity
|
import com.simplemobiletools.contacts.activities.SimpleActivity
|
||||||
import com.simplemobiletools.contacts.extensions.config
|
import com.simplemobiletools.contacts.extensions.config
|
||||||
|
import com.simplemobiletools.contacts.extensions.getPublicContactSource
|
||||||
import com.simplemobiletools.contacts.extensions.showContactSourcePicker
|
import com.simplemobiletools.contacts.extensions.showContactSourcePicker
|
||||||
import com.simplemobiletools.contacts.helpers.VcfImporter
|
import com.simplemobiletools.contacts.helpers.VcfImporter
|
||||||
import com.simplemobiletools.contacts.helpers.VcfImporter.ImportResult.IMPORT_FAIL
|
import com.simplemobiletools.contacts.helpers.VcfImporter.ImportResult.IMPORT_FAIL
|
||||||
import kotlinx.android.synthetic.main.dialog_import_contacts.view.*
|
import kotlinx.android.synthetic.main.dialog_import_contacts.view.*
|
||||||
|
|
||||||
class ImportContactsDialog(val activity: SimpleActivity, val path: String, private val callback: (refreshView: Boolean) -> Unit) {
|
class ImportContactsDialog(val activity: SimpleActivity, val path: String, private val callback: (refreshView: Boolean) -> Unit) {
|
||||||
|
private var targetContactSource = ""
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val view = (activity.layoutInflater.inflate(R.layout.dialog_import_contacts, null) as ViewGroup).apply {
|
val view = (activity.layoutInflater.inflate(R.layout.dialog_import_contacts, null) as ViewGroup).apply {
|
||||||
import_contacts_title.text = activity.config.lastUsedContactSource
|
targetContactSource = activity.config.lastUsedContactSource
|
||||||
|
import_contacts_title.text = activity.getPublicContactSource(targetContactSource)
|
||||||
import_contacts_title.setOnClickListener {
|
import_contacts_title.setOnClickListener {
|
||||||
activity.showContactSourcePicker(import_contacts_title.value) {
|
activity.showContactSourcePicker(targetContactSource) {
|
||||||
import_contacts_title.text = it
|
targetContactSource = it
|
||||||
|
import_contacts_title.text = activity.getPublicContactSource(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -32,7 +36,7 @@ class ImportContactsDialog(val activity: SimpleActivity, val path: String, priva
|
|||||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
activity.toast(R.string.importing)
|
activity.toast(R.string.importing)
|
||||||
Thread {
|
Thread {
|
||||||
val result = VcfImporter(activity).importContacts(path, view.import_contacts_title.value)
|
val result = VcfImporter(activity).importContacts(path, targetContactSource)
|
||||||
handleParseResult(result)
|
handleParseResult(result)
|
||||||
dismiss()
|
dismiss()
|
||||||
}.start()
|
}.start()
|
||||||
|
@ -54,7 +54,12 @@ fun SimpleActivity.showContactSourcePicker(currentSource: String, callback: (new
|
|||||||
val sources = it.map { it.name }
|
val sources = it.map { it.name }
|
||||||
var currentSourceIndex = -1
|
var currentSourceIndex = -1
|
||||||
sources.forEachIndexed { index, account ->
|
sources.forEachIndexed { index, account ->
|
||||||
items.add(RadioItem(index, account))
|
var publicAccount = account
|
||||||
|
if (account == config.localAccountName) {
|
||||||
|
publicAccount = getString(com.simplemobiletools.contacts.R.string.phone_storage)
|
||||||
|
}
|
||||||
|
|
||||||
|
items.add(RadioItem(index, publicAccount))
|
||||||
if (account == currentSource) {
|
if (account == currentSource) {
|
||||||
currentSourceIndex = index
|
currentSourceIndex = index
|
||||||
}
|
}
|
||||||
@ -68,6 +73,8 @@ fun SimpleActivity.showContactSourcePicker(currentSource: String, callback: (new
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun SimpleActivity.getPublicContactSource(source: String) = if (source == config.localAccountName) getString(com.simplemobiletools.contacts.R.string.phone_storage) else source
|
||||||
|
|
||||||
fun BaseSimpleActivity.shareContacts(contacts: ArrayList<Contact>) {
|
fun BaseSimpleActivity.shareContacts(contacts: ArrayList<Contact>) {
|
||||||
val file = getTempFile()
|
val file = getTempFile()
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user