Move helper extension to activity

This commit is contained in:
Naveen
2022-08-29 00:57:20 +05:30
parent 004515bc46
commit 091c4d9d9b
2 changed files with 4 additions and 11 deletions

View File

@ -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<Char, Int>()
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)
}
}
}

View File

@ -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)
}