handle the Dial intent at the dialpad activity

This commit is contained in:
tibbi 2018-11-19 22:59:47 +01:00
parent 5c78872c4e
commit b95a8aec99
2 changed files with 19 additions and 4 deletions

View File

@ -191,7 +191,15 @@
<activity <activity
android:name=".activities.DialpadActivity" android:name=".activities.DialpadActivity"
android:label="@string/dialpad" android:label="@string/dialpad"
android:parentActivityName=".activities.MainActivity"/> android:parentActivityName=".activities.MainActivity">
<intent-filter>
<action android:name="android.intent.action.DIAL"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="tel"/>
</intent-filter>
</activity>
<activity <activity
android:name=".activities.DialerActivity" android:name=".activities.DialerActivity"

View File

@ -2,6 +2,7 @@ package com.simplemobiletools.contacts.pro.activities
import android.content.Intent import android.content.Intent
import android.graphics.Color import android.graphics.Color
import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.view.KeyEvent import android.view.KeyEvent
import android.view.Menu import android.view.Menu
@ -70,6 +71,14 @@ class DialpadActivity : SimpleActivity() {
return true return true
} }
private fun checkDialIntent() {
if (intent.action == Intent.ACTION_DIAL && intent.data != null && intent.dataString?.contains("tel:") == true) {
val number = Uri.decode(intent.dataString).substringAfter("tel:")
dialpad_input.setText(number)
dialpad_input.setSelection(number.length)
}
}
private fun addNumberToContact() { private fun addNumberToContact() {
Intent().apply { Intent().apply {
action = Intent.ACTION_INSERT_OR_EDIT action = Intent.ACTION_INSERT_OR_EDIT
@ -121,9 +130,7 @@ class DialpadActivity : SimpleActivity() {
private fun gotContacts(newContacts: ArrayList<Contact>) { private fun gotContacts(newContacts: ArrayList<Contact>) {
contacts = newContacts contacts = newContacts
Contact.sorting = config.sorting checkDialIntent()
Contact.startWithSurname = config.startNameWithSurname
contacts.sort()
} }
private fun dialpadValueChanged(text: String) { private fun dialpadValueChanged(text: String) {