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