add a setting for selecting what should happen on contact click
This commit is contained in:
parent
b1c8b5a941
commit
962ff318e6
|
@ -1,11 +1,16 @@
|
|||
package com.simplemobiletools.contacts.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||
import com.simplemobiletools.commons.extensions.useEnglishToggled
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
import com.simplemobiletools.contacts.R
|
||||
import com.simplemobiletools.contacts.extensions.config
|
||||
import com.simplemobiletools.contacts.helpers.ON_CLICK_CALL_CONTACT
|
||||
import com.simplemobiletools.contacts.helpers.ON_CLICK_EDIT_CONTACT
|
||||
import com.simplemobiletools.contacts.helpers.ON_CLICK_VIEW_CONTACT
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
import java.util.*
|
||||
|
||||
|
@ -25,6 +30,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
setupShowContactThumbnails()
|
||||
setupShowPhoneNumbers()
|
||||
setupStartNameWithSurname()
|
||||
setupOnContactClick()
|
||||
updateTextColors(settings_holder)
|
||||
}
|
||||
|
||||
|
@ -83,4 +89,25 @@ class SettingsActivity : SimpleActivity() {
|
|||
config.startNameWithSurname = settings_start_with_surname.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupOnContactClick() {
|
||||
settings_on_contact_click.text = getOnContactClickText()
|
||||
settings_on_contact_click_holder.setOnClickListener {
|
||||
val items = arrayListOf(
|
||||
RadioItem(ON_CLICK_CALL_CONTACT, getString(R.string.call_contact)),
|
||||
RadioItem(ON_CLICK_VIEW_CONTACT, getString(R.string.view_contact)),
|
||||
RadioItem(ON_CLICK_EDIT_CONTACT, getString(R.string.edit_contact)))
|
||||
|
||||
RadioGroupDialog(this@SettingsActivity, items, config.onContactClick) {
|
||||
config.onContactClick = it as Int
|
||||
settings_on_contact_click.text = getOnContactClickText()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getOnContactClickText() = getString(when (config.onContactClick) {
|
||||
ON_CLICK_CALL_CONTACT -> R.string.call_contact
|
||||
ON_CLICK_VIEW_CONTACT -> R.string.view_contact
|
||||
else -> R.string.edit_contact
|
||||
})
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ class ViewContactActivity : ContactActivity() {
|
|||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.edit -> editContact()
|
||||
R.id.edit -> editContact(contact!!)
|
||||
R.id.share -> shareContact()
|
||||
R.id.delete -> deleteContact()
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
|
@ -210,13 +210,6 @@ class ViewContactActivity : ContactActivity() {
|
|||
contact_events_holder.beVisibleIf(events.isNotEmpty())
|
||||
}
|
||||
|
||||
private fun editContact() {
|
||||
Intent(applicationContext, EditContactActivity::class.java).apply {
|
||||
putExtra(CONTACT_ID, contact!!.id)
|
||||
startActivity(this)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupTypePickers() {
|
||||
if (contact!!.phoneNumbers.isEmpty()) {
|
||||
val numberHolder = contact_numbers_holder.getChildAt(0)
|
||||
|
|
|
@ -19,7 +19,7 @@ import com.simplemobiletools.commons.views.MyRecyclerView
|
|||
import com.simplemobiletools.contacts.R
|
||||
import com.simplemobiletools.contacts.activities.SimpleActivity
|
||||
import com.simplemobiletools.contacts.extensions.config
|
||||
import com.simplemobiletools.contacts.extensions.openContact
|
||||
import com.simplemobiletools.contacts.extensions.editContact
|
||||
import com.simplemobiletools.contacts.extensions.shareContacts
|
||||
import com.simplemobiletools.contacts.helpers.ContactsHelper
|
||||
import com.simplemobiletools.contacts.interfaces.RefreshContactsListener
|
||||
|
@ -104,8 +104,7 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: MutableList<Co
|
|||
}
|
||||
|
||||
private fun editContact() {
|
||||
activity.openContact(contactItems[selectedPositions.first()])
|
||||
finishActMode()
|
||||
activity.editContact(contactItems[selectedPositions.first()])
|
||||
}
|
||||
|
||||
private fun askConfirmDelete() {
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.simplemobiletools.commons.extensions.isLollipopPlus
|
|||
import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.contacts.BuildConfig
|
||||
import com.simplemobiletools.contacts.R
|
||||
import com.simplemobiletools.contacts.activities.EditContactActivity
|
||||
import com.simplemobiletools.contacts.activities.ViewContactActivity
|
||||
import com.simplemobiletools.contacts.helpers.CONTACT_ID
|
||||
import com.simplemobiletools.contacts.helpers.Config
|
||||
|
@ -21,13 +22,20 @@ import java.io.File
|
|||
|
||||
val Context.config: Config get() = Config.newInstance(applicationContext)
|
||||
|
||||
fun Context.openContact(contact: Contact) {
|
||||
fun Context.viewContact(contact: Contact) {
|
||||
Intent(applicationContext, ViewContactActivity::class.java).apply {
|
||||
putExtra(CONTACT_ID, contact.id)
|
||||
startActivity(this)
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.editContact(contact: Contact) {
|
||||
Intent(applicationContext, EditContactActivity::class.java).apply {
|
||||
putExtra(CONTACT_ID, contact.id)
|
||||
startActivity(this)
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.sendEmailIntent(recipient: String) {
|
||||
Intent(Intent.ACTION_SENDTO).apply {
|
||||
data = Uri.fromParts("mailto", recipient, null)
|
||||
|
|
|
@ -13,10 +13,10 @@ import com.simplemobiletools.contacts.activities.MainActivity
|
|||
import com.simplemobiletools.contacts.activities.SimpleActivity
|
||||
import com.simplemobiletools.contacts.adapters.ContactsAdapter
|
||||
import com.simplemobiletools.contacts.extensions.config
|
||||
import com.simplemobiletools.contacts.extensions.openContact
|
||||
import com.simplemobiletools.contacts.extensions.editContact
|
||||
import com.simplemobiletools.contacts.extensions.tryStartCall
|
||||
import com.simplemobiletools.contacts.helpers.Config
|
||||
import com.simplemobiletools.contacts.helpers.ContactsHelper
|
||||
import com.simplemobiletools.contacts.extensions.viewContact
|
||||
import com.simplemobiletools.contacts.helpers.*
|
||||
import com.simplemobiletools.contacts.models.Contact
|
||||
import kotlinx.android.synthetic.main.fragment_layout.view.*
|
||||
|
||||
|
@ -119,15 +119,17 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
|||
if (currAdapter == null || forceListRedraw) {
|
||||
forceListRedraw = false
|
||||
ContactsAdapter(activity as SimpleActivity, contacts, activity, this is FavoritesFragment, fragment_list, fragment_fastscroller) {
|
||||
if (false) {
|
||||
val contact = it as Contact
|
||||
if (contact.phoneNumbers.isNotEmpty()) {
|
||||
(activity as SimpleActivity).tryStartCall(it)
|
||||
} else {
|
||||
activity!!.toast(R.string.no_phone_number_found)
|
||||
when (config.onContactClick) {
|
||||
ON_CLICK_CALL_CONTACT -> {
|
||||
val contact = it as Contact
|
||||
if (contact.phoneNumbers.isNotEmpty()) {
|
||||
(activity as SimpleActivity).tryStartCall(it)
|
||||
} else {
|
||||
activity!!.toast(R.string.no_phone_number_found)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
context!!.openContact(it as Contact)
|
||||
ON_CLICK_VIEW_CONTACT -> context!!.viewContact(it as Contact)
|
||||
ON_CLICK_EDIT_CONTACT -> context!!.editContact(it as Contact)
|
||||
}
|
||||
}.apply {
|
||||
setupDragListener(true)
|
||||
|
|
|
@ -47,4 +47,8 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
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()
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ const val LAST_USED_CONTACT_SOURCE = "last_used_contact_source"
|
|||
const val LAST_USED_VIEW_PAGER_PAGE = "last_used_view_pager_page"
|
||||
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 CONTACT_ID = "contact_id"
|
||||
|
||||
|
@ -51,3 +52,7 @@ const val HOME_FAX = "HOME;FAX"
|
|||
const val PAGER = "PAGER"
|
||||
const val MOBILE = "MOBILE"
|
||||
const val VOICE = "VOICE"
|
||||
|
||||
const val ON_CLICK_CALL_CONTACT = 1
|
||||
const val ON_CLICK_VIEW_CONTACT = 2
|
||||
const val ON_CLICK_EDIT_CONTACT = 3
|
||||
|
|
|
@ -170,5 +170,40 @@
|
|||
android:text="@string/start_name_with_surname"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_on_contact_click_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingBottom="@dimen/bigger_margin"
|
||||
android:paddingLeft="@dimen/normal_margin"
|
||||
android:paddingRight="@dimen/normal_margin"
|
||||
android:paddingTop="@dimen/bigger_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_on_contact_click_label"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toLeftOf="@+id/settings_on_contact_click"
|
||||
android:layout_toStartOf="@+id/settings_on_contact_click"
|
||||
android:paddingLeft="@dimen/medium_margin"
|
||||
android:paddingRight="@dimen/medium_margin"
|
||||
android:text="@string/on_contact_click"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_on_contact_click"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginEnd="@dimen/small_margin"
|
||||
android:layout_marginRight="@dimen/small_margin"
|
||||
android:background="@null"
|
||||
android:clickable="false"/>
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
<string name="show_contact_thumbnails">Zeige Vorschaubilder für Kontakte</string>
|
||||
<string name="on_contact_click">Beim Klicken auf den Kontakt</string>
|
||||
<string name="call_contact">Kontakt anrufen</string>
|
||||
<string name="open_contact">Kontakt bearbeiten</string>
|
||||
<string name="view_contact">Kontaktdetails ansehen</string>
|
||||
|
||||
<!-- Emails -->
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
<string name="show_contact_thumbnails">Afficher les vignettes des contacts</string>
|
||||
<string name="on_contact_click">Sur appui du contact</string>
|
||||
<string name="call_contact">Appeler le contact</string>
|
||||
<string name="open_contact">Ouvrir l\éditeur de contact</string>
|
||||
<string name="view_contact">Voir les détails du contact</string>
|
||||
|
||||
<!-- Emails -->
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
<string name="show_contact_thumbnails">Show contact thumbnails</string>
|
||||
<string name="on_contact_click">On contact click</string>
|
||||
<string name="call_contact">Call contact</string>
|
||||
<string name="open_contact">Open contact editor</string>
|
||||
<string name="view_contact">View contact details</string>
|
||||
|
||||
<!-- Emails -->
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
<string name="show_contact_thumbnails">Show contact thumbnails</string>
|
||||
<string name="on_contact_click">On contact click</string>
|
||||
<string name="call_contact">Call contact</string>
|
||||
<string name="open_contact">Open contact editor</string>
|
||||
<string name="view_contact">View contact details</string>
|
||||
|
||||
<!-- Emails -->
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
<string name="show_contact_thumbnails">Показывать фото контакта</string>
|
||||
<string name="on_contact_click">При нажатии на контакт</string>
|
||||
<string name="call_contact">Позвонить контакту</string>
|
||||
<string name="open_contact">Открыть редактор контактов</string>
|
||||
<string name="view_contact">Просмотреть подробности о контакте</string>
|
||||
|
||||
<!-- Emails -->
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
<string name="show_contact_thumbnails">Zobraziť obrázky kontaktov</string>
|
||||
<string name="on_contact_click">Po kliknutí na kontakt</string>
|
||||
<string name="call_contact">Zavolať kontakt</string>
|
||||
<string name="open_contact">Otvoriť editor kontaktov</string>
|
||||
<string name="view_contact">Zobraziť údaje kontaktu</string>
|
||||
|
||||
<!-- Emails -->
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
<string name="show_contact_thumbnails">Show contact thumbnails</string>
|
||||
<string name="on_contact_click">On contact click</string>
|
||||
<string name="call_contact">Call contact</string>
|
||||
<string name="open_contact">Open contact editor</string>
|
||||
<string name="view_contact">View contact details</string>
|
||||
|
||||
<!-- Emails -->
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
<string name="show_contact_thumbnails">Show contact thumbnails</string>
|
||||
<string name="on_contact_click">On contact click</string>
|
||||
<string name="call_contact">Call contact</string>
|
||||
<string name="open_contact">Open contact editor</string>
|
||||
<string name="view_contact">View contact details</string>
|
||||
|
||||
<!-- Emails -->
|
||||
|
|
Loading…
Reference in New Issue