From b80df5724052247ef6a92d00fb354728fb1d1554 Mon Sep 17 00:00:00 2001 From: Naveen Date: Sun, 28 Aug 2022 02:17:22 +0530 Subject: [PATCH] Wait a little before stopping tone --- .../com/simplemobiletools/dialer/helpers/CallManager.kt | 5 ++++- .../kotlin/com/simplemobiletools/dialer/helpers/Constants.kt | 2 ++ .../simplemobiletools/dialer/helpers/ToneGeneratorHelper.kt | 3 +-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/dialer/helpers/CallManager.kt b/app/src/main/kotlin/com/simplemobiletools/dialer/helpers/CallManager.kt index 8ff7fa19..5a3b3ad0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/dialer/helpers/CallManager.kt +++ b/app/src/main/kotlin/com/simplemobiletools/dialer/helpers/CallManager.kt @@ -1,6 +1,7 @@ package com.simplemobiletools.dialer.helpers import android.annotation.SuppressLint +import android.os.Handler import android.telecom.Call import android.telecom.InCallService import android.telecom.VideoProfile @@ -169,7 +170,9 @@ class CallManager { fun keypad(c: Char) { call?.playDtmfTone(c) - call?.stopDtmfTone() + Handler().postDelayed({ + call?.stopDtmfTone() + }, DIALPAD_TONE_LENGTH_MS) } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/dialer/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/dialer/helpers/Constants.kt index f3a59130..fed05215 100644 --- a/app/src/main/kotlin/com/simplemobiletools/dialer/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/dialer/helpers/Constants.kt @@ -24,3 +24,5 @@ val tabsList = arrayListOf(TAB_CONTACTS, TAB_FAVORITES, TAB_CALL_HISTORY) private const val PATH = "com.simplemobiletools.dialer.action." const val ACCEPT_CALL = PATH + "accept_call" const val DECLINE_CALL = PATH + "decline_call" + +const val DIALPAD_TONE_LENGTH_MS = 150L // The length of DTMF tones in milliseconds diff --git a/app/src/main/kotlin/com/simplemobiletools/dialer/helpers/ToneGeneratorHelper.kt b/app/src/main/kotlin/com/simplemobiletools/dialer/helpers/ToneGeneratorHelper.kt index e4de767d..6e1453e6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/dialer/helpers/ToneGeneratorHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/dialer/helpers/ToneGeneratorHelper.kt @@ -14,7 +14,7 @@ class ToneGeneratorHelper(context: Context) { fun playTone(char: Char) = playTone(charToTone[char] ?: -1) - fun playTone(tone: Int, durationMs: Int = TONE_LENGTH_MS) { + fun playTone(tone: Int, durationMs: Int = DIALPAD_TONE_LENGTH_MS.toInt()) { if (tone != -1 && !isSilent) { toneGenerator.stopTone() toneGenerator.startTone(tone, durationMs) @@ -22,7 +22,6 @@ class ToneGeneratorHelper(context: Context) { } companion object { - const val TONE_LENGTH_MS = 150 // The length of DTMF tones in milliseconds const val TONE_RELATIVE_VOLUME = 80 // The DTMF tone volume relative to other sounds in the stream const val DIAL_TONE_STREAM_TYPE = STREAM_DTMF