forked from upstream-mirrors/quik
added feature to speak messages aloud via system TTS service. added "Speak" option to message swipe left/right options. swipe inbox message to read aloud. swipe again to interrupt. added widget that speaks unseen messages and marks messages as seen after reading them. needs string translations for settings_swipe_actions (new item "Speak") and speak_no_messages and speak_unseen_messages
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -153,7 +153,6 @@ class TextViewStyler @Inject constructor(
|
||||
Preferences.TEXT_SIZE_NORMAL -> 16f
|
||||
Preferences.TEXT_SIZE_LARGE -> 18f
|
||||
Preferences.TEXT_SIZE_LARGER -> 20f
|
||||
Preferences.TEXT_SIZE_SUPER -> 40f
|
||||
else -> 16f
|
||||
}
|
||||
|
||||
@@ -162,7 +161,6 @@ class TextViewStyler @Inject constructor(
|
||||
Preferences.TEXT_SIZE_NORMAL -> 14f
|
||||
Preferences.TEXT_SIZE_LARGE -> 16f
|
||||
Preferences.TEXT_SIZE_LARGER -> 18f
|
||||
Preferences.TEXT_SIZE_SUPER -> 36f
|
||||
else -> 14f
|
||||
}
|
||||
|
||||
@@ -171,7 +169,6 @@ class TextViewStyler @Inject constructor(
|
||||
Preferences.TEXT_SIZE_NORMAL -> 12f
|
||||
Preferences.TEXT_SIZE_LARGE -> 14f
|
||||
Preferences.TEXT_SIZE_LARGER -> 16f
|
||||
Preferences.TEXT_SIZE_SUPER -> 32f
|
||||
else -> 12f
|
||||
}
|
||||
|
||||
@@ -180,7 +177,6 @@ class TextViewStyler @Inject constructor(
|
||||
Preferences.TEXT_SIZE_NORMAL -> 20f
|
||||
Preferences.TEXT_SIZE_LARGE -> 22f
|
||||
Preferences.TEXT_SIZE_LARGER -> 26f
|
||||
Preferences.TEXT_SIZE_SUPER -> 52f
|
||||
else -> 20f
|
||||
}
|
||||
|
||||
@@ -189,7 +185,6 @@ class TextViewStyler @Inject constructor(
|
||||
Preferences.TEXT_SIZE_NORMAL -> 18f
|
||||
Preferences.TEXT_SIZE_LARGE -> 20f
|
||||
Preferences.TEXT_SIZE_LARGER -> 24f
|
||||
Preferences.TEXT_SIZE_SUPER -> 48f
|
||||
else -> 18f
|
||||
}
|
||||
|
||||
@@ -198,7 +193,6 @@ class TextViewStyler @Inject constructor(
|
||||
Preferences.TEXT_SIZE_NORMAL -> 32f
|
||||
Preferences.TEXT_SIZE_LARGE -> 36f
|
||||
Preferences.TEXT_SIZE_LARGER -> 40f
|
||||
Preferences.TEXT_SIZE_SUPER -> 80f
|
||||
else -> 32f
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -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,69 @@
|
||||
/*
|
||||
* 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.ImageView
|
||||
import android.widget.RemoteViews
|
||||
import dev.octoshrimpy.quik.R
|
||||
import dev.octoshrimpy.quik.common.util.extensions.getColorCompat
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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("dev.octoshrimpy.quik.intent.action.ACTION_SPEAK_MESSAGES")
|
||||
.setPackage(context.packageName)
|
||||
.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)
|
||||
}
|
||||
|
||||
}
|
||||
+5
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user