forked from upstream-mirrors/quik
add delay send mms. add group send to individual recipients - sms and mms. add immediate show messages in convo, not wait for sent. new qktransaction that replaces android/smsmms transaction with mods for quik. lots of code cleanups and removing superfluous code. some bug fixes.
This commit is contained in:
@@ -14,33 +14,24 @@ import java.text.SimpleDateFormat
|
||||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
import javax.inject.Inject
|
||||
import kotlin.coroutines.resume
|
||||
import kotlin.coroutines.suspendCoroutine
|
||||
|
||||
|
||||
class SpeakManager() {
|
||||
class SpeakManager @Inject constructor (private val context: Context) {
|
||||
companion object {
|
||||
// system TextToSpeech engine
|
||||
private var staticTextToSpeech = AtomicReference<TextToSpeech>(null)
|
||||
|
||||
val lock = Any()
|
||||
|
||||
private var context: Context? = null
|
||||
|
||||
// currently speaking sessionId
|
||||
private var currentSessionId: String? = null
|
||||
|
||||
// audio manager items for audio focus
|
||||
private var audioManager: AudioManager? = null
|
||||
private var audioFocusRequest: AudioFocusRequest? = null
|
||||
|
||||
fun setContext(inContext: Context) {
|
||||
synchronized(lock) {
|
||||
if (context !== null)
|
||||
return
|
||||
context = inContext
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var sessionId: String? = null
|
||||
@@ -53,12 +44,9 @@ class SpeakManager() {
|
||||
if (tts !== null)
|
||||
return tts
|
||||
|
||||
// if context not set then the global engine can not be instantiated
|
||||
if (context === null)
|
||||
return null
|
||||
|
||||
val audioAttributes = AudioAttributes.Builder(). run {
|
||||
setUsage(AudioAttributes.USAGE_ASSISTANT)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
||||
setUsage(AudioAttributes.USAGE_ASSISTANT)
|
||||
setContentType(AudioAttributes.CONTENT_TYPE_SPEECH)
|
||||
build()
|
||||
}
|
||||
@@ -70,7 +58,7 @@ class SpeakManager() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// init audio manager and audio focus request first time through only
|
||||
localAudioManager =
|
||||
context?.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
if (localAudioManager === null)
|
||||
return null
|
||||
|
||||
@@ -199,10 +187,9 @@ class SpeakManager() {
|
||||
|
||||
this.sessionId = sessionId
|
||||
|
||||
sessionStopped = if ((this.sessionId !== null) && (toggle) && (currentSessionId == sessionId)) {
|
||||
true // do not output any speech in this session
|
||||
} else
|
||||
false
|
||||
// do not output any speech in this session
|
||||
sessionStopped =
|
||||
(this.sessionId !== null) && (toggle) && (currentSessionId == sessionId)
|
||||
|
||||
// stop any current speech immediately
|
||||
stopSpeaking()
|
||||
@@ -212,7 +199,7 @@ class SpeakManager() {
|
||||
sessionStopped = true
|
||||
}
|
||||
|
||||
fun stopSpeaking() {
|
||||
private fun stopSpeaking() {
|
||||
// get or init system TextToSpeech engine
|
||||
val tts = getSystemTtsEngine()
|
||||
if (tts === null)
|
||||
|
||||
@@ -21,7 +21,7 @@ package dev.octoshrimpy.quik.manager
|
||||
interface WidgetManager {
|
||||
|
||||
companion object {
|
||||
const val ACTION_NOTIFY_DATASET_CHANGED = "dev.octoshrimpy.quik.intent.action.ACTION_NOTIFY_DATASET_CHANGED"
|
||||
const val ACTION_NOTIFY_DATASET_CHANGED = "action.ACTION_NOTIFY_DATASET_CHANGED"
|
||||
}
|
||||
|
||||
fun sendDatasetChanged()
|
||||
|
||||
Reference in New Issue
Block a user