From 091c4d9d9bf34a563d78059ef64efa3aeb6843df Mon Sep 17 00:00:00 2001 From: Naveen Date: Mon, 29 Aug 2022 00:57:20 +0530 Subject: [PATCH] Move helper extension to activity --- .../dialer/activities/DialpadActivity.kt | 6 ++++-- .../com/simplemobiletools/dialer/extensions/Context.kt | 9 --------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/dialer/activities/DialpadActivity.kt b/app/src/main/kotlin/com/simplemobiletools/dialer/activities/DialpadActivity.kt index f1037fe1..dd987b47 100644 --- a/app/src/main/kotlin/com/simplemobiletools/dialer/activities/DialpadActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/dialer/activities/DialpadActivity.kt @@ -19,6 +19,7 @@ import com.simplemobiletools.commons.models.SimpleContact import com.simplemobiletools.dialer.R import com.simplemobiletools.dialer.adapters.ContactsAdapter import com.simplemobiletools.dialer.extensions.* +import com.simplemobiletools.dialer.helpers.ToneGeneratorHelper import com.simplemobiletools.dialer.models.SpeedDial import kotlinx.android.synthetic.main.activity_dialpad.* import kotlinx.android.synthetic.main.activity_dialpad.dialpad_holder @@ -31,6 +32,7 @@ class DialpadActivity : SimpleActivity() { private val russianCharsMap = HashMap() private var hasRussianLocale = false private var privateCursor: Cursor? = null + private var toneGeneratorHelper: ToneGeneratorHelper? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -296,9 +298,9 @@ class DialpadActivity : SimpleActivity() { if (config.dialpadBeeps) { if (char == '+') { // 0 is being long pressed - playOnetimeTone('0') + toneGeneratorHelper?.playTone('0') } else { - playOnetimeTone(char) + toneGeneratorHelper?.playTone(char) } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/dialer/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/dialer/extensions/Context.kt index 0b377fb3..ac7a3e65 100644 --- a/app/src/main/kotlin/com/simplemobiletools/dialer/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/dialer/extensions/Context.kt @@ -7,7 +7,6 @@ import android.net.Uri import android.os.PowerManager import com.simplemobiletools.commons.extensions.telecomManager import com.simplemobiletools.dialer.helpers.Config -import com.simplemobiletools.dialer.helpers.ToneGeneratorHelper import com.simplemobiletools.dialer.models.SIMAccount val Context.config: Config get() = Config.newInstance(applicationContext) @@ -45,11 +44,3 @@ fun Context.areMultipleSIMsAvailable(): Boolean { false } } - -private var toneGeneratorHelperInstance: ToneGeneratorHelper? = null -fun Context.playOnetimeTone(char: Char) { - if (toneGeneratorHelperInstance == null) { - toneGeneratorHelperInstance = ToneGeneratorHelper(this) - } - toneGeneratorHelperInstance?.playTone(char) -}