Merge pull request #202 from gavine99/texttospeech

Text to speech
This commit is contained in:
octoshrimpy
2025-01-12 13:35:27 -05:00
committed by GitHub
19 changed files with 660 additions and 5 deletions
@@ -0,0 +1,50 @@
/*
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
*
* This file is part of QKSMS.
*
* QKSMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* QKSMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
*/
package dev.octoshrimpy.quik.receiver
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import dev.octoshrimpy.quik.interactor.SpeakThreads
import dagger.android.AndroidInjection
import dev.octoshrimpy.quik.repository.ConversationRepository
import javax.inject.Inject
class SpeakThreadsReceiver : BroadcastReceiver() {
@Inject lateinit var speakThread: SpeakThreads
@Inject lateinit var conversationRepo: ConversationRepository
override fun onReceive(context: Context, intent: Intent) {
AndroidInjection.inject(this, context)
val pendingResult = goAsync()
val threadId = intent.getLongExtra("threadId", 0)
val threads = when {
(threadId == -1L) -> conversationRepo.getUnseenIds()
(threadId == -2L) -> conversationRepo.getUnreadIds()
else -> listOf(threadId)
}
speakThread.execute(threads) { pendingResult.finish() }
}
}
@@ -21,6 +21,7 @@ package dev.octoshrimpy.quik.repository
import android.content.ContentUris
import android.content.Context
import android.provider.Telephony
import android.view.View.OnLongClickListener
import dev.octoshrimpy.quik.compat.TelephonyCompat
import dev.octoshrimpy.quik.extensions.anyOf
import dev.octoshrimpy.quik.extensions.asObservable
@@ -201,10 +202,69 @@ class ConversationRepositoryImpl @Inject constructor(
override fun getConversation(threadId: Long): Conversation? {
return Realm.getDefaultInstance()
.apply { refresh() }
.where(Conversation::class.java)
.equalTo("id", threadId)
.findFirst()
.apply { refresh() }
.where(Conversation::class.java)
.equalTo("id", threadId)
.findFirst()
}
override fun getUnseenIds(archived: Boolean): List<Long> {
val conversationIds = ArrayList<Long>()
Realm.getDefaultInstance()
.where(Conversation::class.java)
.notEqualTo("id", 0L)
.equalTo("archived", archived)
.equalTo("blocked", false)
.equalTo("lastMessage.seen", false)
.sort(
arrayOf("lastMessage.date"),
arrayOf(Sort.DESCENDING)
)
.findAllAsync()
.forEach { conversation -> conversationIds.add(conversation.id) }
return conversationIds
}
override fun getUnreadIds(archived: Boolean): List<Long> {
val conversationIds = ArrayList<Long>()
Realm.getDefaultInstance()
.where(Conversation::class.java)
.notEqualTo("id", 0L)
.equalTo("archived", archived)
.equalTo("blocked", false)
.equalTo("lastMessage.read", false)
.sort(
arrayOf("lastMessage.date"),
arrayOf(Sort.DESCENDING)
)
.findAllAsync()
.forEach { conversation -> conversationIds.add(conversation.id) }
return conversationIds
}
override fun getConversationAndLastSenderContactName(threadId: Long): Pair<Conversation?, String?>? {
val conversation = Realm.getDefaultInstance()
.apply { refresh() }
.where(Conversation::class.java)
.equalTo("id", threadId)
.findFirst()
if (conversation === null)
return null
var conversationLastSmsSender: String? = null
if (conversation !== null) {
conversationLastSmsSender = conversation?.recipients?.find { recipient ->
phoneNumberUtils.compare(recipient.address, conversation.lastMessage!!.address)
}?.contact?.name
}
return return Pair(conversation, conversationLastSmsSender)
}
override fun getConversations(vararg threadIds: Long): RealmResults<Conversation> {
@@ -0,0 +1,64 @@
/*
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
*
* This file is part of QKSMS.
*
* QKSMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* QKSMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
*/
package dev.octoshrimpy.quik.interactor
import android.content.res.Resources
import com.moez.QKSMS.manager.SpeakManager
import dev.octoshrimpy.quik.domain.R
import dev.octoshrimpy.quik.extensions.mapNotNull
import dev.octoshrimpy.quik.repository.ConversationRepository
import dev.octoshrimpy.quik.repository.MessageRepository
import io.reactivex.Flowable
import io.reactivex.Single
import javax.inject.Inject
class SpeakThreads @Inject constructor(
private val conversationRepo: ConversationRepository,
private val messageRepo: MessageRepository,
) : Interactor<List<Long>>() {
companion object {
private var noMessagesStr = "No messages" // default value
fun setNoMessagesString(newNoMessagesString: String) {
noMessagesStr = newNoMessagesString
}
}
override fun buildObservable(threadIds: List<Long>): Flowable<*> {
val speakManager = SpeakManager()
if (threadIds.isEmpty())
return Single.just(0)
.doOnSubscribe { speakManager.startSpeakSession(noMessagesStr) }
.map { speakManager.speak(noMessagesStr) }
.doOnTerminate { speakManager.endSpeakSession() }
.toFlowable()
return Flowable.fromIterable(threadIds)
.doOnSubscribe { speakManager.startSpeakSession("threads:" + threadIds.sorted().joinToString()) }
.mapNotNull { threadId -> conversationRepo.getConversationAndLastSenderContactName(threadId) }
.map { conversationAndSender ->
if (speakManager.speakConversationLastSms(conversationAndSender))
messageRepo.markSeen(conversationAndSender.first!!.id)
}
.doOnTerminate { speakManager.endSpeakSession() }
}
}
@@ -0,0 +1,284 @@
package com.moez.QKSMS.manager
import android.content.Context
import android.media.AudioAttributes
import android.media.AudioFocusRequest
import android.media.AudioManager
import android.os.Build
import android.speech.tts.TextToSpeech
import android.speech.tts.UtteranceProgressListener
import android.text.format.DateFormat
import dev.octoshrimpy.quik.model.Conversation
import kotlinx.coroutines.runBlocking
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Locale
import java.util.concurrent.atomic.AtomicReference
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine
class SpeakManager() {
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
private var sessionStopped = false
private fun getSystemTtsEngine(): TextToSpeech? {
// if system TextToSpeech already assigned
var tts = staticTextToSpeech.get()
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)
setContentType(AudioAttributes.CONTENT_TYPE_SPEECH)
build()
}
var localAudioManager: AudioManager? = null
var localAudioFocusRequest: AudioFocusRequest? = null
synchronized(lock) {
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
if (localAudioManager === null)
return null
localAudioFocusRequest =
AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN_TRANSIENT)
.run {
setAudioAttributes(audioAttributes)
setAcceptsDelayedFocusGain(false)
build()
}
if (localAudioFocusRequest === null)
return null
}
// blocking to allow waiting for tts engine response in a synchronous manner
runBlocking {
// get system tts engine
val ttsResult = suspendCoroutine { continuation ->
tts = TextToSpeech(context) { status ->
if (status == TextToSpeech.ERROR) {
tts?.shutdown() // release resources in case of failure to start
continuation.resume(false)
} else
continuation.resume(true)
}
}
// if error reported in onInitListener.onInit from system TextToSpeech Engine
if (!ttsResult)
tts = null
}
// system TextToSpeech not able to be initialised, return failure
if (tts == null)
return null
// old-school setting of audio attribute. > Build.VERSION_CODES.O uses audio focus
tts.setAudioAttributes(audioAttributes)
// handlers for start, done and error utterance events
tts.setOnUtteranceProgressListener(object :
UtteranceProgressListener() {
override fun onStart(utteranceId: String) {
currentSessionId = utteranceId
// request audio focus so other audio can be ducked/paused
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
audioManager?.requestAudioFocus(audioFocusRequest!!)
}
override fun onDone(utteranceId: String) {
currentSessionId = null
// abandon audio focus
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
audioManager?.abandonAudioFocusRequest(audioFocusRequest!!)
}
override fun onError(utteranceId: String) {
currentSessionId = null
// abandon audio focus
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
audioManager?.abandonAudioFocusRequest(audioFocusRequest!!)
}
})
// assign all these local vars to statics at once so if staticTextToSpeech is set then we know all are set
staticTextToSpeech.set(tts)
audioManager = localAudioManager
audioFocusRequest = localAudioFocusRequest
}
return tts
}
private fun formatDateForSpeech(date: Long): String {
fun getFormatter(pattern: String): SimpleDateFormat {
var formattedPattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), pattern)
if (DateFormat.is24HourFormat(context)) {
formattedPattern = formattedPattern
.replace("h", "HH")
.replace("K", "HH")
.replace("\\s+a".toRegex(), "")
}
return SimpleDateFormat(formattedPattern, Locale.getDefault())
}
val now = Calendar.getInstance()
val then = Calendar.getInstance()
val yesterdayCheck = Calendar.getInstance()
val lastWeekCheck = Calendar.getInstance()
then.timeInMillis = date
yesterdayCheck.timeInMillis = date
yesterdayCheck.add(Calendar.DATE, 1)
lastWeekCheck.timeInMillis = date
lastWeekCheck.add(Calendar.DATE, 7)
return when {
(then.get(Calendar.DATE) == now.get(Calendar.DATE)) -> StringBuilder() // today
(yesterdayCheck.get(Calendar.DATE) == now.get(Calendar.DATE)) -> StringBuilder("yesterday") // yesterday
(lastWeekCheck.get(Calendar.DATE) > now.get(Calendar.DATE)) -> StringBuilder("on ").append(getFormatter("EEEE").format(date)) // during last week
(then.get(Calendar.YEAR) == now.get(Calendar.YEAR)) -> StringBuilder("on ").append(getFormatter("MMMM d").format(date)) // this year
else -> StringBuilder("on").append(getFormatter("MMMM d yyyy").format(date)) // otherwise
}.append(" at ").append(getFormatter("h:mm a").format(date)).toString()
}
// toggle is used to stop and not repeat if a sessionId of the same name is currently being read aloud
fun startSpeakSession(sessionId: String? = null, toggle: Boolean = true) {
// get or init system TextToSpeech engine
val tts = getSystemTtsEngine()
if (tts === null)
return
this.sessionId = sessionId
sessionStopped = if ((this.sessionId !== null) && (toggle) && (currentSessionId == sessionId)) {
true // do not output any speech in this session
} else
false
// stop any current speech immediately
stopSpeaking()
}
fun endSpeakSession() {
sessionStopped = true
}
fun stopSpeaking() {
// get or init system TextToSpeech engine
val tts = getSystemTtsEngine()
if (tts === null)
return
currentSessionId = null // no utteranceprogresslistener callback so set this explicitly here
tts.stop()
// abandon audio focus
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
audioManager?.abandonAudioFocusRequest(audioFocusRequest!!)
}
fun speak(utterance: String) {
// if session stopped, return now
if (sessionStopped)
return
// get or init system TextToSpeech engine
val tts = getSystemTtsEngine()
if (tts === null)
return
tts.speak(
utterance,
TextToSpeech.QUEUE_ADD,
null,
sessionId
)
}
fun speakConversationLastSms(conversationAndSender: Pair<Conversation?, String?>): Boolean {
// if session stopped, return now
if (sessionStopped)
return false
// get or init system TextToSpeech engine
val tts = getSystemTtsEngine()
if (tts === null)
return false
// no conversation?, fail
val conversation = conversationAndSender.first
if (conversation === null)
return false
// no text in conversation's last message?, ditch
val conversationLastSms = conversation.lastMessage
val conversationLastSmsText = conversationLastSms?.getText()
if (conversationLastSmsText === null)
return false
val utterance = StringBuilder()
// more than 1 recipient
if (conversation.recipients.count() > 1)
utterance.append("Group SMS ")
// message sender
if (conversationLastSms.isMe())
utterance.append("Sent by you to ")
else
utterance.append("from ")
utterance.append(conversationAndSender.second ?: "an unknown number ")
// message date
if (conversation.date > 0)
utterance.append(formatDateForSpeech(conversationLastSms.date))
// small delay
utterance.append(". ").append(conversationLastSmsText)
speak(utterance.toString())
return true
}
}
@@ -48,6 +48,12 @@ interface ConversationRepository {
fun getConversation(threadId: Long): Conversation?
fun getUnseenIds(archived: Boolean = false): List<Long>
fun getUnreadIds(archived: Boolean = false): List<Long>
fun getConversationAndLastSenderContactName(threadId: Long): Pair<Conversation?, String?>?
/**
* Returns all conversations with an id in [threadIds]
*/
@@ -59,6 +59,7 @@ class Preferences @Inject constructor(
const val NOTIFICATION_ACTION_CALL = 4
const val NOTIFICATION_ACTION_READ = 5
const val NOTIFICATION_ACTION_REPLY = 6
const val NOTIFICATION_ACTION_SPEAK = 7
const val SEND_DELAY_NONE = 0
const val SEND_DELAY_SHORT = 1
@@ -72,6 +73,7 @@ class Preferences @Inject constructor(
const val SWIPE_ACTION_CALL = 4
const val SWIPE_ACTION_READ = 5
const val SWIPE_ACTION_UNREAD = 6
const val SWIPE_ACTION_SPEAK = 7
const val BLOCKING_MANAGER_QKSMS = 0
const val BLOCKING_MANAGER_CC = 1
+23
View File
@@ -175,6 +175,13 @@
<receiver android:name=".receiver.BlockThreadReceiver" />
<receiver android:name=".receiver.MarkSeenReceiver" />
<receiver android:name=".receiver.MarkReadReceiver" />
<receiver
android:name=".receiver.SpeakThreadsReceiver"
android:exported="true">
<intent-filter>
<action android:name="dev.octoshrimpy.quik.intent.action.ACTION_SPEAK_MESSAGES" />
</intent-filter>
</receiver>
<receiver android:name=".receiver.RemoteMessagingReceiver" />
<receiver android:name=".receiver.NightModeReceiver" />
<receiver
@@ -186,6 +193,19 @@
</receiver>
<receiver android:name=".receiver.SendScheduledMessageReceiver" />
<receiver
android:name=".feature.widget.WidgetSpeakUnseenProvider"
android:label="@string/speak_unseen_messages"
android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
<action android:name="dev.octoshrimpy.quik.intent.action.ACTION_NOTIFY_DATASET_CHANGED" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_speak_unseen_info" />
</receiver>
<receiver
android:name=".feature.widget.WidgetProvider"
android:exported="true">
@@ -259,6 +279,9 @@
<package android:name="org.mistergroup.muzutozvednout" />
<package android:name="org.mistergroup.shouldianswer" />
<package android:name="org.mistergroup.shouldianswerpersonal" />
<intent>
<action android:name="android.intent.action.TTS_SERVICE" />
</intent>
</queries>
</manifest>
@@ -25,6 +25,7 @@ import android.content.BroadcastReceiver
import androidx.core.provider.FontRequest
import androidx.emoji.text.EmojiCompat
import androidx.emoji.text.FontRequestEmojiCompatConfig
import com.moez.QKSMS.manager.SpeakManager
import dev.octoshrimpy.quik.R
import dev.octoshrimpy.quik.common.util.CrashlyticsTree
import dev.octoshrimpy.quik.common.util.FileLoggingTree
@@ -43,6 +44,7 @@ import dagger.android.DispatchingAndroidInjector
import dagger.android.HasActivityInjector
import dagger.android.HasBroadcastReceiverInjector
import dagger.android.HasServiceInjector
import dev.octoshrimpy.quik.interactor.SpeakThreads
import io.realm.Realm
import io.realm.RealmConfiguration
import kotlinx.coroutines.Dispatchers
@@ -73,6 +75,12 @@ class QKApplication : Application(), HasActivityInjector, HasBroadcastReceiverIn
override fun onCreate() {
super.onCreate()
// set application context for SpeakManager
SpeakManager.setContext(this)
// set translated "no messages" string for speakThreads interactor
SpeakThreads.setNoMessagesString(getString(R.string.speak_no_messages))
AppComponentManager.init(this)
appComponent.inject(this)
@@ -51,6 +51,7 @@ import dev.octoshrimpy.quik.receiver.MarkArchivedReceiver
import dev.octoshrimpy.quik.receiver.MarkReadReceiver
import dev.octoshrimpy.quik.receiver.MarkSeenReceiver
import dev.octoshrimpy.quik.receiver.RemoteMessagingReceiver
import dev.octoshrimpy.quik.receiver.SpeakThreadsReceiver
import dev.octoshrimpy.quik.repository.ConversationRepository
import dev.octoshrimpy.quik.repository.MessageRepository
import dev.octoshrimpy.quik.util.GlideApp
@@ -294,6 +295,14 @@ class NotificationManagerImpl @Inject constructor(
.setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_CALL).build()
}
Preferences.NOTIFICATION_ACTION_SPEAK -> {
val intent = Intent(context, SpeakThreadsReceiver::class.java).putExtra("threadId", threadId)
val pi = PendingIntent.getBroadcast(context, 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
NotificationCompat.Action.Builder(R.drawable.ic_speaker_black_24dp, actionLabels[action], pi)
.setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_NONE).build()
}
else -> null
}
}
@@ -153,6 +153,7 @@ class ConversationItemTouchCallback @Inject constructor(
Preferences.SWIPE_ACTION_CALL -> R.drawable.ic_call_white_24dp
Preferences.SWIPE_ACTION_READ -> R.drawable.ic_check_white_24dp
Preferences.SWIPE_ACTION_UNREAD -> R.drawable.ic_markunread_black_24dp
Preferences.SWIPE_ACTION_SPEAK -> R.drawable.ic_speaker_black_24dp
else -> null
}
@@ -48,6 +48,7 @@ import dev.octoshrimpy.quik.repository.SyncRepository
import dev.octoshrimpy.quik.util.Preferences
import com.uber.autodispose.android.lifecycle.scope
import com.uber.autodispose.autoDisposable
import dev.octoshrimpy.quik.interactor.SpeakThreads
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.rxkotlin.plusAssign
import io.reactivex.rxkotlin.withLatestFrom
@@ -75,6 +76,7 @@ class MainViewModel @Inject constructor(
private val markUnarchived: MarkUnarchived,
private val markUnpinned: MarkUnpinned,
private val markUnread: MarkUnread,
private val speakThreads: SpeakThreads,
private val navigator: Navigator,
private val permissionManager: PermissionManager,
private val prefs: Preferences,
@@ -466,6 +468,7 @@ class MainViewModel @Inject constructor(
Preferences.SWIPE_ACTION_CALL -> conversationRepo.getConversation(threadId)?.recipients?.firstOrNull()?.address?.let(navigator::makePhoneCall)
Preferences.SWIPE_ACTION_READ -> markRead.execute(listOf(threadId))
Preferences.SWIPE_ACTION_UNREAD -> markUnread.execute(listOf(threadId))
Preferences.SWIPE_ACTION_SPEAK -> speakThreads.execute(listOf(threadId))
}
}
@@ -76,6 +76,7 @@ class SwipeActionsPresenter @Inject constructor(
Preferences.SWIPE_ACTION_CALL -> R.drawable.ic_call_white_24dp
Preferences.SWIPE_ACTION_READ -> R.drawable.ic_check_white_24dp
Preferences.SWIPE_ACTION_UNREAD -> R.drawable.ic_markunread_black_24dp
Preferences.SWIPE_ACTION_SPEAK -> R.drawable.ic_speaker_black_24dp
else -> 0
}
@@ -0,0 +1,64 @@
/*
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
*
* This file is part of QKSMS.
*
* QKSMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* QKSMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
*/
package dev.octoshrimpy.quik.feature.widget
import android.app.PendingIntent
import android.appwidget.AppWidgetManager
import android.appwidget.AppWidgetProvider
import android.content.Context
import android.content.Intent
import android.widget.RemoteViews
import dev.octoshrimpy.quik.R
import dev.octoshrimpy.quik.receiver.SpeakThreadsReceiver
class WidgetSpeakUnseenProvider : AppWidgetProvider() {
override fun onReceive(context: Context, intent: Intent) {
super.onReceive(context, intent)
}
override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {
super.onUpdate(context, appWidgetManager, appWidgetIds)
for (appWidgetId in appWidgetIds)
updateWidget(context, appWidgetId)
}
private fun updateWidget(context: Context?, appWidgetId: Int) {
super.onEnabled(context)
if (context == null)
return
val remoteViews = RemoteViews(context.packageName, R.layout.widget_speak_unseen)
remoteViews.setImageViewResource(R.id.speakUnseenImage, R.drawable.ic_speak_unseen_widget)
// speak unseen intent
val speakUnseenIntent = Intent(context, SpeakThreadsReceiver::class.java)
.putExtra("threadId", -1L)
val speakUnseenPendingIntent = PendingIntent.getBroadcast(context,0,
speakUnseenIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
remoteViews.setOnClickPendingIntent(R.id.speakUnseenImage, speakUnseenPendingIntent)
AppWidgetManager.getInstance(context).updateAppWidget(appWidgetId, remoteViews)
}
}
@@ -40,6 +40,7 @@ import dev.octoshrimpy.quik.receiver.SmsReceiver
import dev.octoshrimpy.quik.receiver.SmsSentReceiver
import dagger.Module
import dagger.android.ContributesAndroidInjector
import dev.octoshrimpy.quik.receiver.SpeakThreadsReceiver
@Module
abstract class BroadcastReceiverBuilderModule {
@@ -68,6 +69,10 @@ abstract class BroadcastReceiverBuilderModule {
@ContributesAndroidInjector()
abstract fun bindMarkReadReceiver(): MarkReadReceiver
@ActivityScope
@ContributesAndroidInjector()
abstract fun bindSpeakThreadsReceiver(): SpeakThreadsReceiver
@ActivityScope
@ContributesAndroidInjector()
abstract fun bindMarkSeenReceiver(): MarkSeenReceiver
Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:viewportWidth="24"
android:viewportHeight="24"
android:width="24dp"
android:height="24dp">
<path
android:pathData="M13 3.7446C13 3.27314 12.8728 2.50021 12.1657 2.14424C11.4151 1.76635 10.7163 2.19354 10.3623 2.51158L4.94661 7.43717H3C1.89543 7.43717 1 8.3326 1 9.43717L1.00001 14.6248C1.00001 15.7293 1.89544 16.6248 3.00001 16.6248H4.95001L10.3623 21.4891C10.7175 21.8081 11.416 22.2331 12.1656 21.8554C12.8717 21.4998 13 20.7286 13 20.2561V3.7446Z"
android:fillColor="#000000" />
</vector>
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2019 Moez Bhatti <moez.bhatti@gmail.com>
~
~ This file is part of QKSMS.
~
~ QKSMS is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ QKSMS is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/speakUnseenImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="2dp"
android:paddingTop="2dp"
android:paddingRight="2dp"
android:paddingBottom="2dp"
android:visibility="visible" />
</FrameLayout>
+4 -1
View File
@@ -255,6 +255,7 @@
<item>Call</item>
<item>Mark read</item>
<item>Mark unread</item>
<item>Speak</item>
</string-array>
<string name="settings_delivery_title">Delivery confirmations</string>
<string name="settings_delivery_summary">Confirm that messages were sent successfully</string>
@@ -409,6 +410,7 @@
<item>Call</item>
<item>Mark read</item>
<item>Reply</item>
<item>Speak</item>
</string-array>
<string name="button_yes">Yes</string>
@@ -495,5 +497,6 @@
<item>LOL</item>
<item>That\'s okay</item>
</string-array>
<string name="speak_no_messages">No Messages</string>
<string name="speak_unseen_messages">Speak unseen messages</string>
</resources>
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2019 Moez Bhatti <moez.bhatti@gmail.com>
~
~ This file is part of QKSMS.
~
~ QKSMS is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ QKSMS is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
-->
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:initialLayout="@layout/widget_speak_unseen"
android:targetCellWidth="1"
android:targetCellHeight="1"
android:previewImage="@drawable/ic_speak_unseen_widget"
android:resizeMode="horizontal|vertical"
android:updatePeriodMillis="0"
android:widgetCategory="home_screen|keyguard" />