From 119e5d035586fd703ed1dd8127cfd62aef27d4ad Mon Sep 17 00:00:00 2001 From: gavine99 Date: Tue, 28 Jan 2025 11:41:56 +1100 Subject: [PATCH 1/6] fix bug in unblock number that crashed app by attempting to execute realm transaction on main thread. moved transaction to execute on io thread. --- .../numbers/BlockedNumbersPresenter.kt | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/blocking/numbers/BlockedNumbersPresenter.kt b/presentation/src/main/java/com/moez/QKSMS/feature/blocking/numbers/BlockedNumbersPresenter.kt index edc77098..8ada8c8a 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/blocking/numbers/BlockedNumbersPresenter.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/blocking/numbers/BlockedNumbersPresenter.kt @@ -39,24 +39,26 @@ class BlockedNumbersPresenter @Inject constructor( super.bindIntents(view) view.unblockAddress() - .doOnNext { id -> - blockingRepo.getBlockedNumber(id)?.address - ?.let(conversationRepo::getThreadId) - ?.let { threadId -> markUnblocked.execute(listOf(threadId)) } - } - .doOnNext(blockingRepo::unblockNumber) - .subscribeOn(Schedulers.io()) - .autoDisposable(view.scope()) - .subscribe() + .observeOn(Schedulers.io()) + .doOnNext { id -> + blockingRepo.getBlockedNumber(id)?.address + ?.let(conversationRepo::getThreadId) + ?.let { threadId -> markUnblocked.execute(listOf(threadId)) } + } + .doOnNext(blockingRepo::unblockNumber) + .subscribeOn(Schedulers.io()) + .autoDisposable(view.scope()) + .subscribe() view.addAddress() - .autoDisposable(view.scope()) - .subscribe { view.showAddDialog() } + .autoDisposable(view.scope()) + .subscribe { view.showAddDialog() } view.saveAddress() - .subscribeOn(Schedulers.io()) - .autoDisposable(view.scope()) - .subscribe { address -> blockingRepo.blockNumber(address) } + .observeOn(Schedulers.io()) + .subscribeOn(Schedulers.io()) + .autoDisposable(view.scope()) + .subscribe { address -> blockingRepo.blockNumber(address) } } } From 76922b583e8dc53e2f6c8c78e662f58dcdcb9a58 Mon Sep 17 00:00:00 2001 From: gavine99 Date: Tue, 28 Jan 2025 15:22:05 +1100 Subject: [PATCH 2/6] changes to make new message notifications silent if any of the recipients of the new message are not in user's contacts. new setting on settings->notifications page --- .../QKSMS/repository/ContactRepositoryImpl.kt | 9 +++++++ .../QKSMS/repository/ContactRepository.kt | 2 ++ .../java/com/moez/QKSMS/util/Preferences.kt | 1 + .../common/util/NotificationManagerImpl.kt | 24 ++++++++++++++++--- .../NotificationPrefsActivity.kt | 2 ++ .../NotificationPrefsState.kt | 1 + .../NotificationPrefsViewModel.kt | 5 ++++ .../layout/notification_prefs_activity.xml | 10 +++++++- presentation/src/main/res/values/strings.xml | 3 +++ 9 files changed, 53 insertions(+), 4 deletions(-) diff --git a/data/src/main/java/com/moez/QKSMS/repository/ContactRepositoryImpl.kt b/data/src/main/java/com/moez/QKSMS/repository/ContactRepositoryImpl.kt index f07aab19..2d48fbb0 100644 --- a/data/src/main/java/com/moez/QKSMS/repository/ContactRepositoryImpl.kt +++ b/data/src/main/java/com/moez/QKSMS/repository/ContactRepositoryImpl.kt @@ -82,6 +82,15 @@ class ContactRepositoryImpl @Inject constructor( } } + override fun getUnmanagedAllContacts(): List { + val realm = Realm.getDefaultInstance() + + return realm + .where(Contact::class.java) + .findAll() + .map { realm.copyFromRealm(it) } + } + override fun getUnmanagedContacts(starred: Boolean): Observable> { val realm = Realm.getDefaultInstance() diff --git a/domain/src/main/java/com/moez/QKSMS/repository/ContactRepository.kt b/domain/src/main/java/com/moez/QKSMS/repository/ContactRepository.kt index a78620a5..88341465 100644 --- a/domain/src/main/java/com/moez/QKSMS/repository/ContactRepository.kt +++ b/domain/src/main/java/com/moez/QKSMS/repository/ContactRepository.kt @@ -33,6 +33,8 @@ interface ContactRepository { fun getUnmanagedContact(lookupKey: String): Contact? + fun getUnmanagedAllContacts(): List + fun getUnmanagedContacts(starred: Boolean = false): Observable> fun getUnmanagedContactGroups(): Observable> diff --git a/domain/src/main/java/com/moez/QKSMS/util/Preferences.kt b/domain/src/main/java/com/moez/QKSMS/util/Preferences.kt index 86a99abc..ff43a3c8 100644 --- a/domain/src/main/java/com/moez/QKSMS/util/Preferences.kt +++ b/domain/src/main/java/com/moez/QKSMS/util/Preferences.kt @@ -107,6 +107,7 @@ class Preferences @Inject constructor( val textSize = rxPrefs.getInteger("textSize", TEXT_SIZE_NORMAL) val blockingManager = rxPrefs.getInteger("blockingManager", BLOCKING_MANAGER_QKSMS) val drop = rxPrefs.getBoolean("drop", false) + val silentNotContact = rxPrefs.getBoolean("silentNotContact", false) val notifAction1 = rxPrefs.getInteger("notifAction1", NOTIFICATION_ACTION_READ) val notifAction2 = rxPrefs.getInteger("notifAction2", NOTIFICATION_ACTION_REPLY) val notifAction3 = rxPrefs.getInteger("notifAction3", NOTIFICATION_ACTION_NONE) diff --git a/presentation/src/main/java/com/moez/QKSMS/common/util/NotificationManagerImpl.kt b/presentation/src/main/java/com/moez/QKSMS/common/util/NotificationManagerImpl.kt index f3fee9f2..ee4bb43e 100644 --- a/presentation/src/main/java/com/moez/QKSMS/common/util/NotificationManagerImpl.kt +++ b/presentation/src/main/java/com/moez/QKSMS/common/util/NotificationManagerImpl.kt @@ -52,6 +52,7 @@ 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.ContactRepository import dev.octoshrimpy.quik.repository.ConversationRepository import dev.octoshrimpy.quik.repository.MessageRepository import dev.octoshrimpy.quik.util.GlideApp @@ -70,7 +71,8 @@ class NotificationManagerImpl @Inject constructor( private val prefs: Preferences, private val messageRepo: MessageRepository, private val permissions: PermissionManager, - private val phoneNumberUtils: PhoneNumberUtils + private val phoneNumberUtils: PhoneNumberUtils, + private val contactRepo: ContactRepository, ) : dev.octoshrimpy.quik.manager.NotificationManager { companion object { @@ -145,12 +147,28 @@ class NotificationManagerImpl @Inject constructor( .setAutoCancel(true) .setContentIntent(contentPI) .setDeleteIntent(seenPI) - .setSound(ringtone) .setLights(Color.WHITE, 500, 2000) .setWhen(conversation.lastMessage?.date ?: System.currentTimeMillis()) .setVibrate(if (prefs.vibration(threadId).get()) VIBRATE_PATTERN else longArrayOf(0)) - // Tell the notification if it's a group message + // if preference set to silence notifications if no recipients in contacts + if (prefs.silentNotContact.get() && run { + val msgRecipientNumbers = conversation.recipients.map { it.address } + + // true if any message recipients are in device's contacts + !contactRepo + .getUnmanagedAllContacts() + .flatMap { it.numbers } + .map { it.address } + .any { contactNumber -> + msgRecipientNumbers.any { phoneNumberUtils.compare(contactNumber, it) } + } + }) + notification.setSilent(true) + else + notification.setSound(ringtone) + + // Tell the notification if it's a group message val messagingStyle = NotificationCompat.MessagingStyle("Me") if (conversation.recipients.size >= 2) { messagingStyle.isGroupConversation = true diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/notificationprefs/NotificationPrefsActivity.kt b/presentation/src/main/java/com/moez/QKSMS/feature/notificationprefs/NotificationPrefsActivity.kt index 1a5d4cd2..37ecdbf5 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/notificationprefs/NotificationPrefsActivity.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/notificationprefs/NotificationPrefsActivity.kt @@ -99,6 +99,8 @@ class NotificationPrefsActivity : QkThemedActivity(), NotificationPrefsView { previews.summary = state.previewSummary previewModeDialog.adapter.selectedItem = state.previewId wake.checkbox.isChecked = state.wakeEnabled + silentNotContact.checkbox.isChecked = state.silentNotContact + silentNotContact.isVisible = state.threadId == 0L vibration.checkbox.isChecked = state.vibrationEnabled ringtone.summary = state.ringtoneName diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/notificationprefs/NotificationPrefsState.kt b/presentation/src/main/java/com/moez/QKSMS/feature/notificationprefs/NotificationPrefsState.kt index 65799cc0..85b7ca81 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/notificationprefs/NotificationPrefsState.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/notificationprefs/NotificationPrefsState.kt @@ -28,6 +28,7 @@ data class NotificationPrefsState( val previewSummary: String = "", val previewId: Int = Preferences.NOTIFICATION_PREVIEWS_ALL, val wakeEnabled: Boolean = false, + val silentNotContact: Boolean = false, val action1Summary: String = "", val action2Summary: String = "", val action3Summary: String = "", diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/notificationprefs/NotificationPrefsViewModel.kt b/presentation/src/main/java/com/moez/QKSMS/feature/notificationprefs/NotificationPrefsViewModel.kt index 405d0bdf..39b531bb 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/notificationprefs/NotificationPrefsViewModel.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/notificationprefs/NotificationPrefsViewModel.kt @@ -79,6 +79,9 @@ class NotificationPrefsViewModel @Inject constructor( disposables += wake.asObservable() .subscribe { enabled -> newState { copy(wakeEnabled = enabled) } } + disposables += prefs.silentNotContact.asObservable() + .subscribe { enabled -> newState { copy(silentNotContact = enabled) } } + disposables += vibration.asObservable() .subscribe { enabled -> newState { copy(vibrationEnabled = enabled) } } @@ -113,6 +116,8 @@ class NotificationPrefsViewModel @Inject constructor( R.id.wake -> wake.set(!wake.get()) + R.id.silentNotContact -> prefs.silentNotContact.set(!prefs.silentNotContact.get()) + R.id.vibration -> vibration.set(!vibration.get()) R.id.ringtone -> view.showRingtonePicker(ringtone.get().takeIf { it.isNotEmpty() }?.let(Uri::parse)) diff --git a/presentation/src/main/res/layout/notification_prefs_activity.xml b/presentation/src/main/res/layout/notification_prefs_activity.xml index 2b8db770..b7266085 100644 --- a/presentation/src/main/res/layout/notification_prefs_activity.xml +++ b/presentation/src/main/res/layout/notification_prefs_activity.xml @@ -70,7 +70,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" app:title="@string/settings_notification_previews_title" - tools:summary="Show name and message" /> + tools:summary="@string/settings_notification_previews_summary" /> + + Button 2 Button 3 Notification previews + Show name and message Wake screen + Silent if not a contact + Silences notifications for messages without recipients in your contacts Vibration Sound None From 136cf929f90e4dc73b4c7dbff79bf5a0328bc16c Mon Sep 17 00:00:00 2001 From: octoshrimpy Date: Tue, 28 Jan 2025 08:48:03 -0700 Subject: [PATCH 3/6] Update short_description.txt makes it fit within 80 char --- metadata/fr-FR/short_description.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata/fr-FR/short_description.txt b/metadata/fr-FR/short_description.txt index 8033a13c..c0d7a188 100644 --- a/metadata/fr-FR/short_description.txt +++ b/metadata/fr-FR/short_description.txt @@ -1 +1 @@ -Remplacement open source de l'application SMS d'origine d'Android. Renaissance de QKSMS. +Remplacement open source de l'appli SMS Android. Renaissance de QKSMS. From 49fdc967ded5b4aada609e156fa40d034b160fcd Mon Sep 17 00:00:00 2001 From: octoshrimpy Date: Tue, 28 Jan 2025 08:54:52 -0700 Subject: [PATCH 4/6] Update build.gradle --- presentation/build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/presentation/build.gradle b/presentation/build.gradle index f8e3ca3c..fef473a5 100644 --- a/presentation/build.gradle +++ b/presentation/build.gradle @@ -30,13 +30,13 @@ android { applicationId 'dev.octoshrimpy.quik' minSdkVersion 23 targetSdkVersion 33 - versionCode 2225 - versionName '4.0.8' + versionCode 2226 + versionName '4.0.9' setProperty("archivesBaseName", "QUIK-v${versionName}") testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" setProperty("archivesBaseName", "QUIK-v${versionName}") - versionNameSuffix '-alpha' + versionNameSuffix '-beta' } signingConfigs { From 8c17e4592da6e03eabfd18e58e960b87e247480f Mon Sep 17 00:00:00 2001 From: octoshrimpy Date: Tue, 28 Jan 2025 08:59:44 -0700 Subject: [PATCH 5/6] Update changelog.json --- data/src/main/assets/changelog.json | 33 ++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/data/src/main/assets/changelog.json b/data/src/main/assets/changelog.json index a29c646e..7927b623 100644 --- a/data/src/main/assets/changelog.json +++ b/data/src/main/assets/changelog.json @@ -1,5 +1,36 @@ -[ { +[ + { + "versionCode": 2226, + "versionName": "4.0.9", + "added": [ + "Basic speech to text for compose (and qkreply)", + "Text to speech", + "Add 'super' font size setting", + "Basic speech to text for compose (and qkreply) take 2", + "Make unread conversations float at the top of conversation lists", + "Select and copy a text part", + "Add 'super' font size setting - take 2", + "Main widget launch appropriate app activities", + "Change convo name from main convo activity", + "Play audio attachments", + "Select all on conversations and compose screens. New compose 'show status' option", + "Build on pull request", + "Update French translation", + "Changes to allow attaching *any* type of file", + "Update French translation" + ], + "fixed": [ + "Bug fix for motion events being used after recycled", + "Disable reply ability to non-replyable messages/conversations", + "Sort blocked messages by lastmessage.date desc", + "Fix fr strings from pr 226. Fixes build", + "Fix pr 225 render issue", + "Fix unblock number bug", + "Silent notifications if no recipients are a contact" + ] + }, + { "versionCode": 2225, "versionName": "4.0.8", "fixed": [ From 862faec98e2e2a4e6868ce563a6343066762de7a Mon Sep 17 00:00:00 2001 From: Inhishonor Date: Tue, 28 Jan 2025 11:01:16 -0800 Subject: [PATCH 6/6] Update Attachment.kt Fix indentation. --- domain/src/main/java/com/moez/QKSMS/model/Attachment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domain/src/main/java/com/moez/QKSMS/model/Attachment.kt b/domain/src/main/java/com/moez/QKSMS/model/Attachment.kt index bb25625e..5b1cdaaa 100644 --- a/domain/src/main/java/com/moez/QKSMS/model/Attachment.kt +++ b/domain/src/main/java/com/moez/QKSMS/model/Attachment.kt @@ -110,7 +110,7 @@ class Attachment( if (resourceBytes != null) return resourceBytes!! - resourceBytes = ByteArray(0) + resourceBytes = ByteArray(0) try { context.contentResolver.openInputStream(getUri())?.use {