store the last used contact source

This commit is contained in:
tibbi
2017-12-26 23:32:33 +01:00
parent 81dfc447dc
commit 44bd03b98a
3 changed files with 7 additions and 0 deletions

View File

@ -222,6 +222,7 @@ class ContactActivity : SimpleActivity() {
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(), "") contact = Contact(0, "", "", "", "", ArrayList(), ArrayList(), "")
contact_source.text = config.lastUsedContactSource
contact_source.setOnClickListener { showAccountSourcePicker() } contact_source.setOnClickListener { showAccountSourcePicker() }
} }
@ -337,6 +338,7 @@ class ContactActivity : SimpleActivity() {
source = contact_source.value source = contact_source.value
Thread { Thread {
config.lastUsedContactSource = source
if (id == 0) { if (id == 0) {
insertNewContact() insertNewContact()
} else { } else {

View File

@ -27,4 +27,8 @@ class Config(context: Context) : BaseConfig(context) {
var startNameWithSurname: Boolean var startNameWithSurname: Boolean
get() = prefs.getBoolean(START_NAME_WITH_SURNAME, false) get() = prefs.getBoolean(START_NAME_WITH_SURNAME, false)
set(startNameWithSurname) = prefs.edit().putBoolean(START_NAME_WITH_SURNAME, startNameWithSurname).apply() set(startNameWithSurname) = prefs.edit().putBoolean(START_NAME_WITH_SURNAME, startNameWithSurname).apply()
var lastUsedContactSource: String
get() = prefs.getString(LAST_USED_CONTACT_SOURCE, "")
set(lastUsedContactSource) = prefs.edit().putString(LAST_USED_CONTACT_SOURCE, lastUsedContactSource).apply()
} }

View File

@ -4,6 +4,7 @@ package com.simplemobiletools.contacts.helpers
val CALL_CONTACT_ON_CLICK = "call_contact_on_click" val CALL_CONTACT_ON_CLICK = "call_contact_on_click"
val DISPLAY_CONTACT_SOURCES = "display_contact_sources" val DISPLAY_CONTACT_SOURCES = "display_contact_sources"
val START_NAME_WITH_SURNAME = "start_name_with_surname" val START_NAME_WITH_SURNAME = "start_name_with_surname"
val LAST_USED_CONTACT_SOURCE = "last_used_contact_source"
val CONTACT_ID = "contact_id" val CONTACT_ID = "contact_id"