mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-04-02 20:31:05 +02:00
add an option for calling contact on click
This commit is contained in:
parent
db2ee05b5c
commit
209953c878
@ -17,6 +17,7 @@ import com.simplemobiletools.contacts.R
|
||||
import com.simplemobiletools.contacts.adapters.ContactsAdapter
|
||||
import com.simplemobiletools.contacts.dialogs.ChangeSortingDialog
|
||||
import com.simplemobiletools.contacts.extensions.config
|
||||
import com.simplemobiletools.contacts.extensions.startCallIntent
|
||||
import com.simplemobiletools.contacts.helpers.CONTACT_ID
|
||||
import com.simplemobiletools.contacts.helpers.ContactsHelper
|
||||
import com.simplemobiletools.contacts.models.Contact
|
||||
@ -122,7 +123,11 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||
val currAdapter = contacts_list.adapter
|
||||
if (currAdapter == null) {
|
||||
ContactsAdapter(this, contacts, this, contacts_list) {
|
||||
itemClicked(it as Contact)
|
||||
if (config.callContact) {
|
||||
startCallIntent((it as Contact).number)
|
||||
} else {
|
||||
itemClicked(it as Contact)
|
||||
}
|
||||
}.apply {
|
||||
setupDragListener(true)
|
||||
addVerticalDividers(true)
|
||||
|
@ -21,6 +21,7 @@ class SettingsActivity : SimpleActivity() {
|
||||
setupCustomizeColors()
|
||||
setupUseEnglish()
|
||||
setupShowInfoBubble()
|
||||
setupCallContactOnClick()
|
||||
updateTextColors(settings_holder)
|
||||
}
|
||||
|
||||
@ -47,4 +48,12 @@ class SettingsActivity : SimpleActivity() {
|
||||
config.showInfoBubble = settings_show_info_bubble.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupCallContactOnClick() {
|
||||
settings_call_contact_on_click.isChecked = config.callContact
|
||||
settings_call_contact_on_click_holder.setOnClickListener {
|
||||
settings_call_contact_on_click.toggle()
|
||||
config.callContact = settings_call_contact_on_click.isChecked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,4 +12,8 @@ class Config(context: Context) : BaseConfig(context) {
|
||||
var sorting: Int
|
||||
get() = prefs.getInt(SORTING, SORT_BY_NAME)
|
||||
set(sorting) = prefs.edit().putInt(SORTING, sorting).apply()
|
||||
|
||||
var callContact: Boolean
|
||||
get() = prefs.getBoolean(CALL_CONTACT_ON_CLICK, false)
|
||||
set(callContact) = prefs.edit().putBoolean(CALL_CONTACT_ON_CLICK, callContact).apply()
|
||||
}
|
||||
|
@ -1,4 +1,7 @@
|
||||
package com.simplemobiletools.contacts.helpers
|
||||
|
||||
// shared prefs
|
||||
val CALL_CONTACT_ON_CLICK = "call_contact_on_click"
|
||||
|
||||
val SORTING = "sorting"
|
||||
val CONTACT_ID = "contact_id"
|
||||
|
@ -69,5 +69,25 @@
|
||||
android:text="@string/show_info_bubble"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_call_contact_on_click_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:padding="@dimen/activity_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MySwitchCompat
|
||||
android:id="@+id/settings_call_contact_on_click"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:paddingLeft="@dimen/medium_margin"
|
||||
android:paddingStart="@dimen/medium_margin"
|
||||
android:text="@string/call_contact_on_click"/>
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
@ -7,6 +7,9 @@
|
||||
<string name="edit_contact">Kontakt bearbeiten</string>
|
||||
<string name="email">Email</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="call_contact_on_click">Call contact on click</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
|
||||
|
@ -7,6 +7,9 @@
|
||||
<string name="edit_contact">Editar contacto</string>
|
||||
<string name="email">E-mail</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="call_contact_on_click">Call contact on click</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
|
||||
|
@ -7,6 +7,9 @@
|
||||
<string name="edit_contact">Upraviť kontakt</string>
|
||||
<string name="email">Email</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="call_contact_on_click">Zavolať kontaktu po kliknutí</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
|
||||
|
@ -7,6 +7,9 @@
|
||||
<string name="edit_contact">Edit contact</string>
|
||||
<string name="email">Email</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="call_contact_on_click">Call contact on click</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
|
||||
|
Loading…
x
Reference in New Issue
Block a user