Remove dialer from recent apps after hanging up.

This commit is contained in:
fl0w3r
2021-08-16 08:41:11 +05:45
parent 8ef4422a7a
commit b2fe66ef4a

View File

@ -88,8 +88,7 @@ class CallActivity : SimpleActivity() {
if (dialpad_wrapper.isVisible()) { if (dialpad_wrapper.isVisible()) {
dialpad_wrapper.beGone() dialpad_wrapper.beGone()
return return
} } else {
else {
super.onBackPressed() super.onBackPressed()
} }
@ -143,13 +142,7 @@ class CallActivity : SimpleActivity() {
dialpad_hashtag_holder.setOnClickListener { dialpadPressed('#') } dialpad_hashtag_holder.setOnClickListener { dialpadPressed('#') }
dialpad_wrapper.setBackgroundColor(config.backgroundColor) dialpad_wrapper.setBackgroundColor(config.backgroundColor)
arrayOf( arrayOf(call_toggle_microphone, call_toggle_speaker, call_dialpad, dialpad_close, call_sim_image).forEach {
call_toggle_microphone,
call_toggle_speaker,
call_dialpad,
dialpad_close,
call_sim_image
).forEach {
it.applyColorFilter(config.textColor) it.applyColorFilter(config.textColor)
} }
@ -163,20 +156,17 @@ class CallActivity : SimpleActivity() {
private fun toggleSpeaker() { private fun toggleSpeaker() {
isSpeakerOn = !isSpeakerOn isSpeakerOn = !isSpeakerOn
val drawable = val drawable = if (isSpeakerOn) R.drawable.ic_speaker_on_vector else R.drawable.ic_speaker_off_vector
if (isSpeakerOn) R.drawable.ic_speaker_on_vector else R.drawable.ic_speaker_off_vector
call_toggle_speaker.setImageDrawable(getDrawable(drawable)) call_toggle_speaker.setImageDrawable(getDrawable(drawable))
audioManager.isSpeakerphoneOn = isSpeakerOn audioManager.isSpeakerphoneOn = isSpeakerOn
val newRoute = val newRoute = if (isSpeakerOn) CallAudioState.ROUTE_SPEAKER else CallAudioState.ROUTE_EARPIECE
if (isSpeakerOn) CallAudioState.ROUTE_SPEAKER else CallAudioState.ROUTE_EARPIECE
CallManager.inCallService?.setAudioRoute(newRoute) CallManager.inCallService?.setAudioRoute(newRoute)
} }
private fun toggleMicrophone() { private fun toggleMicrophone() {
isMicrophoneOn = !isMicrophoneOn isMicrophoneOn = !isMicrophoneOn
val drawable = val drawable = if (isMicrophoneOn) R.drawable.ic_microphone_vector else R.drawable.ic_microphone_off_vector
if (isMicrophoneOn) R.drawable.ic_microphone_vector else R.drawable.ic_microphone_off_vector
call_toggle_microphone.setImageDrawable(getDrawable(drawable)) call_toggle_microphone.setImageDrawable(getDrawable(drawable))
audioManager.isMicrophoneMute = !isMicrophoneOn audioManager.isMicrophoneMute = !isMicrophoneOn
CallManager.inCallService?.setMuted(!isMicrophoneOn) CallManager.inCallService?.setMuted(!isMicrophoneOn)
@ -185,8 +175,7 @@ class CallActivity : SimpleActivity() {
private fun toggleDialpadVisibility() { private fun toggleDialpadVisibility() {
if (dialpad_wrapper.isVisible()) { if (dialpad_wrapper.isVisible()) {
dialpad_wrapper.beGone() dialpad_wrapper.beGone()
} } else {
else {
dialpad_wrapper.beVisible() dialpad_wrapper.beVisible()
} }
} }
@ -196,12 +185,10 @@ class CallActivity : SimpleActivity() {
return return
} }
caller_name_label.text = caller_name_label.text = if (callContact!!.name.isNotEmpty()) callContact!!.name else getString(R.string.unknown_caller)
if (callContact!!.name.isNotEmpty()) callContact!!.name else getString(R.string.unknown_caller)
if (callContact!!.number.isNotEmpty() && callContact!!.number != callContact!!.name) { if (callContact!!.number.isNotEmpty() && callContact!!.number != callContact!!.name) {
caller_number_label.text = callContact!!.number caller_number_label.text = callContact!!.number
} } else {
else {
caller_number_label.beGone() caller_number_label.beGone()
} }
@ -223,8 +210,7 @@ class CallActivity : SimpleActivity() {
} }
} }
} }
} } catch (ignored: Exception) {
catch (ignored: Exception) {
} }
} }
@ -274,8 +260,7 @@ class CallActivity : SimpleActivity() {
ongoing_call_holder.beVisible() ongoing_call_holder.beVisible()
try { try {
callTimer.scheduleAtFixedRate(getCallTimerUpdateTask(), 1000, 1000) callTimer.scheduleAtFixedRate(getCallTimerUpdateTask(), 1000, 1000)
} } catch (ignored: Exception) {
catch (ignored: Exception) {
} }
} }
@ -300,21 +285,18 @@ class CallActivity : SimpleActivity() {
try { try {
audioManager.mode = AudioManager.MODE_NORMAL audioManager.mode = AudioManager.MODE_NORMAL
} } catch (ignored: Exception) {
catch (ignored: Exception) {
} }
isCallEnded = true isCallEnded = true
if (callDuration > 0) { if (callDuration > 0) {
runOnUiThread { runOnUiThread {
call_status_label.text = call_status_label.text = "${callDuration.getFormattedDuration()} (${getString(R.string.call_ended)})"
"${callDuration.getFormattedDuration()} (${getString(R.string.call_ended)})"
Handler(Looper.getMainLooper()).postDelayed({ Handler(Looper.getMainLooper()).postDelayed({
finishAndRemoveTask() finishAndRemoveTask()
}, 3000) }, 3000)
} }
} } else {
else {
call_status_label.text = getString(R.string.call_ended) call_status_label.text = getString(R.string.call_ended)
finish() finish()
} }
@ -343,18 +325,13 @@ class CallActivity : SimpleActivity() {
if (isOreoMr1Plus()) { if (isOreoMr1Plus()) {
setShowWhenLocked(true) setShowWhenLocked(true)
setTurnScreenOn(true) setTurnScreenOn(true)
} } else {
else {
window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON) window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON)
} }
if (isOreoPlus()) { if (isOreoPlus()) {
(getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager).requestDismissKeyguard( (getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager).requestDismissKeyguard(this, null)
this, } else {
null
)
}
else {
window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD) window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD)
} }
} }
@ -362,10 +339,7 @@ class CallActivity : SimpleActivity() {
private fun initProximitySensor() { private fun initProximitySensor() {
if (proximityWakeLock == null || proximityWakeLock?.isHeld == false) { if (proximityWakeLock == null || proximityWakeLock?.isHeld == false) {
val powerManager = getSystemService(Context.POWER_SERVICE) as PowerManager val powerManager = getSystemService(Context.POWER_SERVICE) as PowerManager
proximityWakeLock = powerManager.newWakeLock( proximityWakeLock = powerManager.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK, "com.simplemobiletools.dialer.pro:wake_lock")
PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK,
"com.simplemobiletools.dialer.pro:wake_lock"
)
proximityWakeLock!!.acquire(10 * MINUTE_SECONDS * 1000L) proximityWakeLock!!.acquire(10 * MINUTE_SECONDS * 1000L)
} }
} }
@ -390,21 +364,13 @@ class CallActivity : SimpleActivity() {
val acceptCallIntent = Intent(this, CallActionReceiver::class.java) val acceptCallIntent = Intent(this, CallActionReceiver::class.java)
acceptCallIntent.action = ACCEPT_CALL acceptCallIntent.action = ACCEPT_CALL
val acceptPendingIntent = val acceptPendingIntent = PendingIntent.getBroadcast(this, 0, acceptCallIntent, PendingIntent.FLAG_CANCEL_CURRENT)
PendingIntent.getBroadcast(this, 0, acceptCallIntent, PendingIntent.FLAG_CANCEL_CURRENT)
val declineCallIntent = Intent(this, CallActionReceiver::class.java) val declineCallIntent = Intent(this, CallActionReceiver::class.java)
declineCallIntent.action = DECLINE_CALL declineCallIntent.action = DECLINE_CALL
val declinePendingIntent = PendingIntent.getBroadcast( val declinePendingIntent = PendingIntent.getBroadcast(this, 1, declineCallIntent, PendingIntent.FLAG_CANCEL_CURRENT)
this,
1,
declineCallIntent,
PendingIntent.FLAG_CANCEL_CURRENT
)
val callerName = val callerName = if (callContact != null && callContact!!.name.isNotEmpty()) callContact!!.name else getString(R.string.unknown_caller)
if (callContact != null && callContact!!.name.isNotEmpty()) callContact!!.name
else getString(R.string.unknown_caller)
val contentTextId = when (callState) { val contentTextId = when (callState) {
Call.STATE_RINGING -> R.string.is_calling Call.STATE_RINGING -> R.string.is_calling
Call.STATE_DIALING -> R.string.dialing Call.STATE_DIALING -> R.string.dialing
@ -422,10 +388,7 @@ class CallActivity : SimpleActivity() {
setOnClickPendingIntent(R.id.notification_accept_call, acceptPendingIntent) setOnClickPendingIntent(R.id.notification_accept_call, acceptPendingIntent)
if (callContactAvatar != null) { if (callContactAvatar != null) {
setImageViewBitmap( setImageViewBitmap(R.id.notification_thumbnail, getCircularBitmap(callContactAvatar!!))
R.id.notification_thumbnail,
getCircularBitmap(callContactAvatar!!)
)
} }
} }
@ -454,15 +417,13 @@ class CallActivity : SimpleActivity() {
bitmap = if (isQPlus()) { bitmap = if (isQPlus()) {
val tmbSize = resources.getDimension(R.dimen.list_avatar_size).toInt() val tmbSize = resources.getDimension(R.dimen.list_avatar_size).toInt()
contentResolver.loadThumbnail(photoUri, Size(tmbSize, tmbSize), null) contentResolver.loadThumbnail(photoUri, Size(tmbSize, tmbSize), null)
} } else {
else {
MediaStore.Images.Media.getBitmap(contentResolver, photoUri) MediaStore.Images.Media.getBitmap(contentResolver, photoUri)
} }
bitmap = getCircularBitmap(bitmap!!) bitmap = getCircularBitmap(bitmap!!)
} } catch (ignored: Exception) {
catch (ignored: Exception) {
return null return null
} }
} }