add a Call button at the dialpad activity

This commit is contained in:
tibbi 2018-09-27 15:09:01 +02:00
parent cacbbcedc1
commit d024bc7551
2 changed files with 33 additions and 7 deletions

View File

@ -13,9 +13,11 @@ import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.isLollipopPlus import com.simplemobiletools.commons.helpers.isLollipopPlus
import com.simplemobiletools.contacts.R import com.simplemobiletools.contacts.R
import com.simplemobiletools.contacts.adapters.ContactsAdapter import com.simplemobiletools.contacts.adapters.ContactsAdapter
import com.simplemobiletools.contacts.dialogs.CallConfirmationDialog
import com.simplemobiletools.contacts.extensions.afterTextChanged import com.simplemobiletools.contacts.extensions.afterTextChanged
import com.simplemobiletools.contacts.extensions.callContact import com.simplemobiletools.contacts.extensions.callContact
import com.simplemobiletools.contacts.extensions.config import com.simplemobiletools.contacts.extensions.config
import com.simplemobiletools.contacts.extensions.startCallIntent
import com.simplemobiletools.contacts.helpers.ContactsHelper import com.simplemobiletools.contacts.helpers.ContactsHelper
import com.simplemobiletools.contacts.helpers.KEY_PHONE import com.simplemobiletools.contacts.helpers.KEY_PHONE
import com.simplemobiletools.contacts.helpers.LOCATION_DIALPAD import com.simplemobiletools.contacts.helpers.LOCATION_DIALPAD
@ -42,6 +44,7 @@ class DialpadActivity : SimpleActivity() {
dialpad_hashtag.setOnClickListener { dialpadPressed("#", it) } dialpad_hashtag.setOnClickListener { dialpadPressed("#", it) }
dialpad_clear_char.setOnClickListener { clearChar(it) } dialpad_clear_char.setOnClickListener { clearChar(it) }
dialpad_clear_char.setOnLongClickListener { clearInput(); true } dialpad_clear_char.setOnLongClickListener { clearInput(); true }
dialpad_call_button.setOnClickListener { initCall() }
dialpad_input.afterTextChanged { dialpadValueChanged(it) } dialpad_input.afterTextChanged { dialpadValueChanged(it) }
ContactsHelper(this).getContacts { gotContacts(it) } ContactsHelper(this).getContacts { gotContacts(it) }
disableKeyboardPopping() disableKeyboardPopping()
@ -143,4 +146,17 @@ class DialpadActivity : SimpleActivity() {
dialpad_fastscroller.updateBubbleText(item?.getBubbleText() ?: "") dialpad_fastscroller.updateBubbleText(item?.getBubbleText() ?: "")
} }
} }
private fun initCall() {
val number = dialpad_input.value
if (number.isNotEmpty()) {
if (config.showCallConfirmation) {
CallConfirmationDialog(this, number) {
startCallIntent(number)
}
} else {
startCallIntent(number)
}
}
}
} }

View File

@ -2,12 +2,10 @@
<android.support.constraint.ConstraintLayout <android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/dialpad_holder" android:id="@+id/dialpad_holder"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_marginBottom="@dimen/activity_margin"
android:focusableInTouchMode="true"> android:focusableInTouchMode="true">
<com.simplemobiletools.commons.views.MyRecyclerView <com.simplemobiletools.commons.views.MyRecyclerView
@ -181,11 +179,10 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/activity_margin" android:layout_marginLeft="@dimen/activity_margin"
android:text="*" android:text="*"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toTopOf="@+id/dialpad_call_button"
app:layout_constraintEnd_toStartOf="@+id/dialpad_0" app:layout_constraintEnd_toStartOf="@+id/dialpad_0"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"/>
tools:layout_editor_absoluteY="0dp"/>
<com.simplemobiletools.commons.views.MyTextView <com.simplemobiletools.commons.views.MyTextView
android:id="@+id/dialpad_0" android:id="@+id/dialpad_0"
@ -193,7 +190,7 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="0" android:text="0"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toTopOf="@+id/dialpad_call_button"
app:layout_constraintEnd_toStartOf="@+id/dialpad_hashtag" app:layout_constraintEnd_toStartOf="@+id/dialpad_hashtag"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/dialpad_asterisk"/> app:layout_constraintStart_toEndOf="@+id/dialpad_asterisk"/>
@ -205,9 +202,22 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="@dimen/activity_margin" android:layout_marginRight="@dimen/activity_margin"
android:text="#" android:text="#"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toTopOf="@+id/dialpad_call_button"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/dialpad_0"/> app:layout_constraintStart_toEndOf="@+id/dialpad_0"/>
<ImageView
android:id="@+id/dialpad_call_button"
android:layout_width="@dimen/dialpad_button_size"
android:layout_height="@dimen/dialpad_button_size"
android:layout_marginBottom="@dimen/activity_margin"
android:background="@drawable/circle_background"
android:elevation="@dimen/medium_margin"
android:padding="@dimen/normal_margin"
android:src="@drawable/ic_phone_big"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>