mirror of
				https://github.com/SimpleMobileTools/Simple-Contacts.git
				synced 2025-06-05 21:59:27 +02:00 
			
		
		
		
	improving the Dialer screen resuming at pressing the notification
This commit is contained in:
		| @@ -223,7 +223,8 @@ | |||||||
|  |  | ||||||
|         <activity |         <activity | ||||||
|             android:name=".activities.DialerActivity" |             android:name=".activities.DialerActivity" | ||||||
|             android:label="@string/dialer"> |             android:label="@string/dialer" | ||||||
|  |             android:launchMode="singleTask"> | ||||||
|  |  | ||||||
|             <intent-filter> |             <intent-filter> | ||||||
|                 <action android:name="android.intent.action.CALL"/> |                 <action android:name="android.intent.action.CALL"/> | ||||||
|   | |||||||
| @@ -43,16 +43,25 @@ class DialerActivity : SimpleActivity(), SensorEventListener { | |||||||
|         initProximityWakeLock() |         initProximityWakeLock() | ||||||
|         LocalBroadcastManager.getInstance(applicationContext).registerReceiver(messageReceiver, IntentFilter(DIALER_INTENT_FILTER)) |         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:") |             callNumber = Uri.decode(intent.dataString).substringAfter("tel:") | ||||||
|             initViews() |             initViews() | ||||||
|             tryFillingOtherEndsName() |             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 |             isIncomingCall = true | ||||||
|             callNumber = intent.getStringExtra(CALL_NUMBER) |             callNumber = intent.getStringExtra(CALL_NUMBER) | ||||||
|             initViews() |             initViews() | ||||||
|             updateUI(intent.getIntExtra(CALL_STATUS, Call.STATE_NEW)) |             updateUI(intent.getIntExtra(CALL_STATUS, Call.STATE_NEW)) | ||||||
|             tryFillingOtherEndsName() |             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 { |         } else { | ||||||
|             toast(R.string.unknown_error_occurred) |             toast(R.string.unknown_error_occurred) | ||||||
|             finish() |             finish() | ||||||
|   | |||||||
| @@ -34,6 +34,7 @@ const val KEY_NAME = "name" | |||||||
|  |  | ||||||
| // Dialer | // Dialer | ||||||
| const val INCOMING_CALL = "incoming_call" | const val INCOMING_CALL = "incoming_call" | ||||||
|  | const val RESUME_DIALER = "resume_dialer" | ||||||
| const val CALL_NUMBER = "call_number" | const val CALL_NUMBER = "call_number" | ||||||
| const val CALL_STATUS = "call_status" | const val CALL_STATUS = "call_status" | ||||||
| const val IS_INCOMING_CALL = "is_incoming_call" | 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_NUMBER | ||||||
| import com.simplemobiletools.contacts.pro.helpers.CALL_STATUS | import com.simplemobiletools.contacts.pro.helpers.CALL_STATUS | ||||||
| import com.simplemobiletools.contacts.pro.helpers.IS_INCOMING_CALL | import com.simplemobiletools.contacts.pro.helpers.IS_INCOMING_CALL | ||||||
|  | import com.simplemobiletools.contacts.pro.helpers.RESUME_DIALER | ||||||
|  |  | ||||||
| class DialerCallService : Service() { | class DialerCallService : Service() { | ||||||
|     private val CALL_NOTIFICATION_ID = 1 |     private val CALL_NOTIFICATION_ID = 1 | ||||||
| @@ -69,9 +70,12 @@ class DialerCallService : Service() { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun getLaunchDialerIntent(): PendingIntent { |     private fun getLaunchDialerIntent(): PendingIntent { | ||||||
|         val intent = Intent(this, DialerActivity::class.java) |         val intent = Intent(this, DialerActivity::class.java).apply { | ||||||
|         intent.action = Intent.ACTION_MAIN |             action = RESUME_DIALER | ||||||
|         intent.addCategory(Intent.CATEGORY_LAUNCHER) |             putExtra(CALL_NUMBER, callNumber) | ||||||
|  |             putExtra(CALL_STATUS, callStatus) | ||||||
|  |             putExtra(IS_INCOMING_CALL, isIncomingCall) | ||||||
|  |         } | ||||||
|         return PendingIntent.getActivity(this, 0, intent, 0) |         return PendingIntent.getActivity(this, 0, intent, 0) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user