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
+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" />