improving the Dialer screen resuming at pressing the notification
This commit is contained in:
parent
fd228b85a6
commit
69e3a55a18
|
@ -223,7 +223,8 @@
|
|||
|
||||
<activity
|
||||
android:name=".activities.DialerActivity"
|
||||
android:label="@string/dialer">
|
||||
android:label="@string/dialer"
|
||||
android:launchMode="singleTask">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.CALL"/>
|
||||
|
|
|
@ -43,16 +43,25 @@ class DialerActivity : SimpleActivity(), SensorEventListener {
|
|||
initProximityWakeLock()
|
||||
LocalBroadcastManager.getInstance(applicationContext).registerReceiver(messageReceiver, IntentFilter(DIALER_INTENT_FILTER))
|
||||
|
||||
if (intent.action == Intent.ACTION_CALL && intent.data != null && intent.dataString?.contains("tel:") == true) {
|
||||
val action = intent.action
|
||||
val extras = intent.extras
|
||||
if (action == Intent.ACTION_CALL && intent.data != null && intent.dataString?.contains("tel:") == true) {
|
||||
callNumber = Uri.decode(intent.dataString).substringAfter("tel:")
|
||||
initViews()
|
||||
tryFillingOtherEndsName()
|
||||
} else if (intent.action == INCOMING_CALL && intent.extras?.containsKey(CALL_NUMBER) == true && intent.extras?.containsKey(CALL_STATUS) == true) {
|
||||
} else if (action == INCOMING_CALL && extras?.containsKey(CALL_NUMBER) == true && extras.containsKey(CALL_STATUS)) {
|
||||
isIncomingCall = true
|
||||
callNumber = intent.getStringExtra(CALL_NUMBER)
|
||||
initViews()
|
||||
updateUI(intent.getIntExtra(CALL_STATUS, Call.STATE_NEW))
|
||||
tryFillingOtherEndsName()
|
||||
} else if (action == RESUME_DIALER && extras?.containsKey(CALL_NUMBER) == true && extras.containsKey(CALL_STATUS) && extras.containsKey(IS_INCOMING_CALL)) {
|
||||
callNumber = intent.getStringExtra(CALL_NUMBER)
|
||||
callStatus = intent.getIntExtra(CALL_STATUS, Call.STATE_NEW)
|
||||
isIncomingCall = intent.getBooleanExtra(IS_INCOMING_CALL, false)
|
||||
initViews()
|
||||
updateUI(callStatus)
|
||||
tryFillingOtherEndsName()
|
||||
} else {
|
||||
toast(R.string.unknown_error_occurred)
|
||||
finish()
|
||||
|
|
|
@ -34,6 +34,7 @@ const val KEY_NAME = "name"
|
|||
|
||||
// Dialer
|
||||
const val INCOMING_CALL = "incoming_call"
|
||||
const val RESUME_DIALER = "resume_dialer"
|
||||
const val CALL_NUMBER = "call_number"
|
||||
const val CALL_STATUS = "call_status"
|
||||
const val IS_INCOMING_CALL = "is_incoming_call"
|
||||
|
|
|
@ -16,6 +16,7 @@ import com.simplemobiletools.contacts.pro.activities.DialerActivity
|
|||
import com.simplemobiletools.contacts.pro.helpers.CALL_NUMBER
|
||||
import com.simplemobiletools.contacts.pro.helpers.CALL_STATUS
|
||||
import com.simplemobiletools.contacts.pro.helpers.IS_INCOMING_CALL
|
||||
import com.simplemobiletools.contacts.pro.helpers.RESUME_DIALER
|
||||
|
||||
class DialerCallService : Service() {
|
||||
private val CALL_NOTIFICATION_ID = 1
|
||||
|
@ -69,9 +70,12 @@ class DialerCallService : Service() {
|
|||
}
|
||||
|
||||
private fun getLaunchDialerIntent(): PendingIntent {
|
||||
val intent = Intent(this, DialerActivity::class.java)
|
||||
intent.action = Intent.ACTION_MAIN
|
||||
intent.addCategory(Intent.CATEGORY_LAUNCHER)
|
||||
val intent = Intent(this, DialerActivity::class.java).apply {
|
||||
action = RESUME_DIALER
|
||||
putExtra(CALL_NUMBER, callNumber)
|
||||
putExtra(CALL_STATUS, callStatus)
|
||||
putExtra(IS_INCOMING_CALL, isIncomingCall)
|
||||
}
|
||||
return PendingIntent.getActivity(this, 0, intent, 0)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue