remove the notion of local account name and type

This commit is contained in:
tibbi 2019-01-06 12:10:45 +01:00
parent d804ed58d5
commit 4dcb46c7ab
8 changed files with 0 additions and 48 deletions

View File

@ -73,12 +73,10 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
if (it) {
handlePermission(PERMISSION_WRITE_CONTACTS) {
handlePermission(PERMISSION_GET_ACCOUNTS) {
storeLocalAccountData()
initFragments()
}
}
} else {
storeLocalAccountData()
initFragments()
}
}
@ -279,24 +277,6 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
}
}
private fun storeLocalAccountData() {
if (config.localAccountType == "-1") {
ContactsHelper(this).getContactSources { sources ->
var localAccountType = ""
var localAccountName = ""
sources.forEach {
if (localAccountTypes.contains(it.type)) {
localAccountType = it.type
localAccountName = it.name
}
}
config.localAccountType = localAccountType
config.localAccountName = localAccountName
}
}
}
private fun getInactiveTabIndexes(activeIndex: Int) = (0 until tabsList.size).filter { it != activeIndex }
private fun initFragments() {

View File

@ -22,10 +22,6 @@ class FilterContactSourcesAdapter(val activity: SimpleActivity, private val cont
selectedKeys.add(contactSource.hashCode())
}
if (contactSource.name == activity.config.localAccountName && contactSource.type == activity.config.localAccountType) {
contactSource.name = activity.getString(R.string.phone_storage)
}
if (contactSource.type == SMT_PRIVATE && displayContactSources.contains(SMT_PRIVATE)) {
selectedKeys.add(contactSource.hashCode())
}

View File

@ -10,7 +10,6 @@ import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.commons.extensions.value
import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.contacts.pro.R
import com.simplemobiletools.contacts.pro.extensions.config
import com.simplemobiletools.contacts.pro.helpers.ContactsHelper
import com.simplemobiletools.contacts.pro.helpers.SMT_PRIVATE
import com.simplemobiletools.contacts.pro.models.ContactSource
@ -35,11 +34,6 @@ class CreateNewGroupDialog(val activity: BaseSimpleActivity, val callback: (newG
}
val contactSources = ArrayList<ContactSource>()
if (activity.config.localAccountName.isNotEmpty()) {
val localAccountName = activity.config.localAccountName
contactSources.add(ContactSource(localAccountName, activity.config.localAccountType, localAccountName))
}
ContactsHelper(activity).getContactSources {
it.filter { it.type.contains("google", true) }.mapTo(contactSources) { ContactSource(it.name, it.type, it.name) }
val phoneSecret = activity.getString(R.string.phone_storage_hidden)

View File

@ -72,10 +72,6 @@ fun SimpleActivity.showContactSourcePicker(currentSource: String, callback: (new
sources.forEachIndexed { index, account ->
var publicAccount = account
if (account == config.localAccountName) {
publicAccount = getString(R.string.phone_storage)
}
items.add(RadioItem(index, publicAccount))
if (currentSource == SMT_PRIVATE && account == getString(R.string.phone_storage_hidden)) {
currentSourceIndex = index

View File

@ -197,7 +197,6 @@ fun Context.hasContactPermissions() = hasPermission(PERMISSION_READ_CONTACTS) &&
fun Context.getPublicContactSource(source: String, callback: (String) -> Unit) {
when (source) {
config.localAccountName -> callback(getString(R.string.phone_storage))
SMT_PRIVATE -> callback(getString(R.string.phone_storage_hidden))
else -> {
Thread {

View File

@ -32,14 +32,6 @@ class Config(context: Context) : BaseConfig(context) {
get() = prefs.getString(LAST_USED_CONTACT_SOURCE, "")
set(lastUsedContactSource) = prefs.edit().putString(LAST_USED_CONTACT_SOURCE, lastUsedContactSource).apply()
var localAccountName: String
get() = prefs.getString(LOCAL_ACCOUNT_NAME, "-1")
set(localAccountName) = prefs.edit().putString(LOCAL_ACCOUNT_NAME, localAccountName).apply()
var localAccountType: String
get() = prefs.getString(LOCAL_ACCOUNT_TYPE, "-1")
set(localAccountType) = prefs.edit().putString(LOCAL_ACCOUNT_TYPE, localAccountType).apply()
var onContactClick: Int
get() = prefs.getInt(ON_CONTACT_CLICK, ON_CLICK_VIEW_CONTACT)
set(onContactClick) = prefs.edit().putInt(ON_CONTACT_CLICK, onContactClick).apply()

View File

@ -10,7 +10,6 @@ const val SHOW_ONLY_CONTACTS_WITH_NUMBERS = "show_only_contacts_with_numbers"
const val IGNORED_CONTACT_SOURCES = "ignored_contact_sources_2"
const val START_NAME_WITH_SURNAME = "start_name_with_surname"
const val LAST_USED_CONTACT_SOURCE = "last_used_contact_source"
const val LOCAL_ACCOUNT_NAME = "local_account_name"
const val LOCAL_ACCOUNT_TYPE = "local_account_type"
const val ON_CONTACT_CLICK = "on_contact_click"
const val SHOW_CONTACT_FIELDS = "show_contact_fields"

View File

@ -862,10 +862,6 @@ class ContactsHelper(val context: Context) {
}
sources.addAll(contentResolverAccounts)
if (sources.isEmpty() && context.config.localAccountName.isEmpty() && context.config.localAccountType.isEmpty()) {
sources.add(ContactSource("", "", ""))
}
return sources
}