mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-06-05 21:49:23 +02:00
Move helper extension to activity
This commit is contained in:
@ -19,6 +19,7 @@ import com.simplemobiletools.commons.models.SimpleContact
|
|||||||
import com.simplemobiletools.dialer.R
|
import com.simplemobiletools.dialer.R
|
||||||
import com.simplemobiletools.dialer.adapters.ContactsAdapter
|
import com.simplemobiletools.dialer.adapters.ContactsAdapter
|
||||||
import com.simplemobiletools.dialer.extensions.*
|
import com.simplemobiletools.dialer.extensions.*
|
||||||
|
import com.simplemobiletools.dialer.helpers.ToneGeneratorHelper
|
||||||
import com.simplemobiletools.dialer.models.SpeedDial
|
import com.simplemobiletools.dialer.models.SpeedDial
|
||||||
import kotlinx.android.synthetic.main.activity_dialpad.*
|
import kotlinx.android.synthetic.main.activity_dialpad.*
|
||||||
import kotlinx.android.synthetic.main.activity_dialpad.dialpad_holder
|
import kotlinx.android.synthetic.main.activity_dialpad.dialpad_holder
|
||||||
@ -31,6 +32,7 @@ class DialpadActivity : SimpleActivity() {
|
|||||||
private val russianCharsMap = HashMap<Char, Int>()
|
private val russianCharsMap = HashMap<Char, Int>()
|
||||||
private var hasRussianLocale = false
|
private var hasRussianLocale = false
|
||||||
private var privateCursor: Cursor? = null
|
private var privateCursor: Cursor? = null
|
||||||
|
private var toneGeneratorHelper: ToneGeneratorHelper? = null
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
@ -296,9 +298,9 @@ class DialpadActivity : SimpleActivity() {
|
|||||||
if (config.dialpadBeeps) {
|
if (config.dialpadBeeps) {
|
||||||
if (char == '+') {
|
if (char == '+') {
|
||||||
// 0 is being long pressed
|
// 0 is being long pressed
|
||||||
playOnetimeTone('0')
|
toneGeneratorHelper?.playTone('0')
|
||||||
} else {
|
} else {
|
||||||
playOnetimeTone(char)
|
toneGeneratorHelper?.playTone(char)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import android.net.Uri
|
|||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
import com.simplemobiletools.commons.extensions.telecomManager
|
import com.simplemobiletools.commons.extensions.telecomManager
|
||||||
import com.simplemobiletools.dialer.helpers.Config
|
import com.simplemobiletools.dialer.helpers.Config
|
||||||
import com.simplemobiletools.dialer.helpers.ToneGeneratorHelper
|
|
||||||
import com.simplemobiletools.dialer.models.SIMAccount
|
import com.simplemobiletools.dialer.models.SIMAccount
|
||||||
|
|
||||||
val Context.config: Config get() = Config.newInstance(applicationContext)
|
val Context.config: Config get() = Config.newInstance(applicationContext)
|
||||||
@ -45,11 +44,3 @@ fun Context.areMultipleSIMsAvailable(): Boolean {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var toneGeneratorHelperInstance: ToneGeneratorHelper? = null
|
|
||||||
fun Context.playOnetimeTone(char: Char) {
|
|
||||||
if (toneGeneratorHelperInstance == null) {
|
|
||||||
toneGeneratorHelperInstance = ToneGeneratorHelper(this)
|
|
||||||
}
|
|
||||||
toneGeneratorHelperInstance?.playTone(char)
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user