diff --git a/android-smsmms/src/main/java/com/android/mms/transaction/RetryScheduler.java b/android-smsmms/src/main/java/com/android/mms/transaction/RetryScheduler.java
index 414f14e7..a107f3ba 100755
--- a/android-smsmms/src/main/java/com/android/mms/transaction/RetryScheduler.java
+++ b/android-smsmms/src/main/java/com/android/mms/transaction/RetryScheduler.java
@@ -143,6 +143,11 @@ public class RetryScheduler implements Observer {
case PduHeaders.RESPONSE_STATUS_ERROR_PERMANENT_MESSAGE_NOT_FOUND:
errorString = R.string.service_message_not_found;
break;
+ case PduHeaders.RESPONSE_STATUS_ERROR_CONTENT_NOT_ACCEPTED:
+ case PduHeaders.RESPONSE_STATUS_ERROR_PERMANENT_CONTENT_NOT_ACCEPTED:
+ errorString = R.string.service_message_content_not_accepted;
+ break;
+
}
if (errorString != 0) {
DownloadManager.init(mContext.getApplicationContext());
diff --git a/android-smsmms/src/main/res/values/strings.xml b/android-smsmms/src/main/res/values/strings.xml
index c48bc4b8..edcfd758 100755
--- a/android-smsmms/src/main/res/values/strings.xml
+++ b/android-smsmms/src/main/res/values/strings.xml
@@ -20,6 +20,7 @@ limitations under the License.
Invalid destination address.
Service not activated on network.
Message expired or not available.
+ Message content is not accepted.
Couldn\'t send due to network problem.
Currently can\'t send your message. It will be sent when the service becomes available.
Can\'t download right now. Try again later.
diff --git a/data/src/main/AndroidManifest.xml b/data/src/main/AndroidManifest.xml
index b1ca12fe..a65cc645 100644
--- a/data/src/main/AndroidManifest.xml
+++ b/data/src/main/AndroidManifest.xml
@@ -19,4 +19,5 @@
+
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": [
diff --git a/data/src/main/java/com/moez/QKSMS/extensions/UriExtensions.kt b/data/src/main/java/com/moez/QKSMS/extensions/UriExtensions.kt
new file mode 100644
index 00000000..7ebe330a
--- /dev/null
+++ b/data/src/main/java/com/moez/QKSMS/extensions/UriExtensions.kt
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2017 Moez Bhatti
+ *
+ * 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 .
+ */
+package dev.octoshrimpy.quik.extensions
+
+import android.content.Context
+import android.net.Uri
+
+fun Uri.resourceExists(context: Context): Boolean {
+ // check if resource at uri still exists
+ try {
+ return context.contentResolver.query(
+ this, null, null, null, null
+ )?.use {
+ it.moveToFirst()
+ } ?: false
+ }
+ catch (e: Exception) { /* nothing */ }
+
+ return false
+}
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/data/src/main/java/com/moez/QKSMS/repository/MessageRepositoryImpl.kt b/data/src/main/java/com/moez/QKSMS/repository/MessageRepositoryImpl.kt
index e776c705..5cb96793 100644
--- a/data/src/main/java/com/moez/QKSMS/repository/MessageRepositoryImpl.kt
+++ b/data/src/main/java/com/moez/QKSMS/repository/MessageRepositoryImpl.kt
@@ -25,7 +25,6 @@ import android.content.ContentValues
import android.content.Context
import android.content.Intent
import android.graphics.BitmapFactory
-import android.media.MediaScannerConnection
import android.net.Uri
import android.os.Build
import android.os.Environment
@@ -65,14 +64,7 @@ import io.realm.Case
import io.realm.Realm
import io.realm.RealmResults
import io.realm.Sort
-import okio.buffer
-import okio.source
import timber.log.Timber
-import java.io.File
-import java.io.FileNotFoundException
-import java.io.FileOutputStream
-import java.io.IOException
-import java.util.*
import java.util.concurrent.TimeUnit
import javax.inject.Inject
import javax.inject.Singleton
@@ -189,9 +181,9 @@ class MessageRepositoryImpl @Inject constructor(
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
values.put(MediaStore.MediaColumns.IS_PENDING, 1)
values.put(MediaStore.MediaColumns.RELATIVE_PATH, when {
- part.isImage() -> "${Environment.DIRECTORY_PICTURES}/QKSMS"
- part.isVideo() -> "${Environment.DIRECTORY_MOVIES}/QKSMS"
- else -> "${Environment.DIRECTORY_DOWNLOADS}/QKSMS"
+ part.isImage() -> "${Environment.DIRECTORY_PICTURES}/QUIK"
+ part.isVideo() -> "${Environment.DIRECTORY_MOVIES}/QUIK"
+ else -> "${Environment.DIRECTORY_DOWNLOADS}/QUIK"
})
}
@@ -376,27 +368,37 @@ class MessageRepositoryImpl @Inject constructor(
parts += MMSPart("text", ContentType.TEXT_PLAIN, bytes)
}
- // Attach contacts
+ // Attach those that can't be compressed (ie. everything but not images)
parts += attachments
- .mapNotNull { attachment -> attachment as? Attachment.Contact }
- .map { attachment -> attachment.vCard.toByteArray() }
- .map { vCard ->
- remainingBytes -= vCard.size
- MMSPart("contact", ContentType.TEXT_VCARD, vCard)
- }
+ // filter out images
+ .filter { !it.isImage(context) }
+ // filter out items that have no data available (ie user may have deleted
+ // the file from storage)
+ .filter { it.getResourceBytes(context).isNotEmpty() }
+ .map {
+ remainingBytes -= it.getResourceBytes(context).size
+ MMSPart(
+ it.getName(context),
+ it.getType(context),
+ it.getResourceBytes(context)
+ )
+ }
val imageBytesByAttachment = attachments
- .mapNotNull { attachment -> attachment as? Attachment.Image }
- .associateWith { attachment ->
- val uri = attachment.getUri() ?: return@associateWith byteArrayOf()
- when (attachment.isGif(context)) {
- true -> ImageUtils.getScaledGif(context, uri, maxWidth, maxHeight)
- false -> ImageUtils.getScaledImage(context, uri, maxWidth, maxHeight)
- }
+ // filter out non-images
+ .filter { it.isImage(context) }
+ // filter out items that have no data available (ie user may have deleted
+ // the file from storage)
+ .filter { it.getResourceBytes(context).isNotEmpty() }
+ .associateWith {
+ when (it.getType(context) == "image/gif") {
+ true -> ImageUtils.getScaledGif(context, it.getUri(), maxWidth, maxHeight)
+ false -> ImageUtils.getScaledImage(context, it.getUri(), maxWidth, maxHeight)
}
- .toMutableMap()
+ }
+ .toMutableMap()
- val imageByteCount = imageBytesByAttachment.values.sumBy { byteArray -> byteArray.size }
+ val imageByteCount = imageBytesByAttachment.values.sumOf { it.size }
if (imageByteCount > remainingBytes) {
imageBytesByAttachment.forEach { (attachment, originalBytes) ->
val uri = attachment.getUri() ?: return@forEach
@@ -426,9 +428,9 @@ class MessageRepositoryImpl @Inject constructor(
val newHeight = (newWidth / aspectRatio).toInt()
attempts++
- scaledBytes = when (attachment.isGif(context)) {
- true -> ImageUtils.getScaledGif(context, uri, newWidth, newHeight, 80)
- false -> ImageUtils.getScaledImage(context, uri, newWidth, newHeight, 80)
+ scaledBytes = when (attachment.getType(context) == "image/gif") {
+ true -> ImageUtils.getScaledGif(context, attachment.getUri(), newWidth, newHeight)
+ false -> ImageUtils.getScaledImage(context, attachment.getUri(), newWidth, newHeight)
}
Timber.d("Compression attempt $attempts: ${scaledBytes.size / 1024}/${maxBytes.toInt() / 1024}Kb ($width*$height -> $newWidth*$newHeight)")
@@ -440,7 +442,7 @@ class MessageRepositoryImpl @Inject constructor(
}
imageBytesByAttachment.forEach { (attachment, bytes) ->
- parts += when (attachment.isGif(context)) {
+ parts += when (attachment.getType(context) == "image/gif") {
true -> MMSPart("image", ContentType.IMAGE_GIF, bytes)
false -> MMSPart("image", ContentType.IMAGE_JPEG, bytes)
}
diff --git a/domain/src/main/java/com/moez/QKSMS/interactor/SendScheduledMessage.kt b/domain/src/main/java/com/moez/QKSMS/interactor/SendScheduledMessage.kt
index 8b76318b..0047fdd8 100644
--- a/domain/src/main/java/com/moez/QKSMS/interactor/SendScheduledMessage.kt
+++ b/domain/src/main/java/com/moez/QKSMS/interactor/SendScheduledMessage.kt
@@ -47,7 +47,7 @@ class SendScheduledMessage @Inject constructor(
}
.map { message ->
val threadId = TelephonyCompat.getOrCreateThreadId(context, message.recipients)
- val attachments = message.attachments.mapNotNull(Uri::parse).map { Attachment.Image(it) }
+ val attachments = message.attachments.mapNotNull(Uri::parse).map { Attachment(it) }
SendMessage.Params(message.subId, threadId, message.recipients, message.body, attachments)
}
.flatMap(sendMessage::buildObservable)
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 c354f60f..5b1cdaaa 100644
--- a/domain/src/main/java/com/moez/QKSMS/model/Attachment.kt
+++ b/domain/src/main/java/com/moez/QKSMS/model/Attachment.kt
@@ -21,33 +21,106 @@ package dev.octoshrimpy.quik.model
import android.content.Context
import android.net.Uri
import android.os.Build
+import android.provider.OpenableColumns
import androidx.core.view.inputmethod.InputContentInfoCompat
-sealed class Attachment {
- data class Image(
- private val uri: Uri? = null,
- private val inputContent: InputContentInfoCompat? = null
- ) : Attachment() {
+class Attachment(
+ private val uri: Uri? = null,
+ private val inputContent: InputContentInfoCompat? = null
+) {
+ private var resourceBytes: ByteArray? = null
- fun getUri(): Uri? {
- return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
- inputContent?.contentUri ?: uri
- } else {
- uri
- }
- }
-
- fun isGif(context: Context): Boolean {
- return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1 && inputContent != null) {
- inputContent.description.hasMimeType("image/gif")
- } else {
- uri?.let(context.contentResolver::getType) == "image/gif"
- }
- }
+ fun getUri(): Uri {
+ return (
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1)
+ inputContent?.contentUri ?: uri ?: Uri.EMPTY
+ else uri ?: Uri.EMPTY
+ )
}
- data class Contact(val vCard: String) : Attachment()
+ fun getType(context: Context): String {
+ return context.contentResolver.getType(getUri()) ?: "application/octect-stream"
+ }
+
+ fun getName(context: Context): String {
+ try {
+ context.contentResolver.query(
+ getUri(),
+ arrayOf(OpenableColumns.DISPLAY_NAME),
+ null,
+ null,
+ null
+ )
+ ?.use { cursor ->
+ val nameIndex = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME)
+ if (nameIndex == -1)
+ return "unknown"
+ cursor.moveToFirst()
+ return cursor.getString(nameIndex) ?: "unknown"
+ }
+ }
+ catch (e: Exception) { /* nothing*/ }
+
+ return "unknown"
+ }
+
+ fun isVCard(context: Context): Boolean {
+ return (getType(context) == "text/x-vcard")
+ }
+
+ fun hasDisplayableImage(context: Context): Boolean {
+ val mimeType = getType(context)
+ return (mimeType.startsWith("image/") || mimeType.startsWith("video/"))
+ }
+
+ fun isAudio(context: Context): Boolean {
+ val mimeType = getType(context)
+ return (mimeType.startsWith("audio/"))
+ }
+
+ fun isImage(context: Context): Boolean {
+ val mimeType = getType(context)
+ return (mimeType.startsWith("image/"))
+ }
+
+ fun getSize(context: Context): Long {
+ try {
+ context.contentResolver.query(
+ getUri(),
+ arrayOf(OpenableColumns.SIZE),
+ null,
+ null,
+ null
+ )
+ ?.use {
+ val sizeIndex = it.getColumnIndex(OpenableColumns.SIZE)
+ if (sizeIndex == -1)
+ return -1
+ it.moveToFirst()
+ return it.getLong(sizeIndex)
+ }
+ }
+ catch (e: Exception) { /* nothing */ }
+
+ return -1
+ }
+
+ fun getResourceBytes(context: Context): ByteArray {
+ if (resourceBytes != null)
+ return resourceBytes!!
+
+ resourceBytes = ByteArray(0)
+
+ try {
+ context.contentResolver.openInputStream(getUri())?.use {
+ resourceBytes = it.readBytes()
+ }
+ } catch (e: Exception) {
+ }
+
+ return resourceBytes!!
+ }
}
diff --git a/domain/src/main/java/com/moez/QKSMS/model/MmsPart.kt b/domain/src/main/java/com/moez/QKSMS/model/MmsPart.kt
index f9b62eb4..0afb53b1 100644
--- a/domain/src/main/java/com/moez/QKSMS/model/MmsPart.kt
+++ b/domain/src/main/java/com/moez/QKSMS/model/MmsPart.kt
@@ -40,11 +40,13 @@ open class MmsPart : RealmObject() {
fun getUri() = "content://mms/part/$id".toUri()
fun getSummary(): String? = when {
+ type == "application/smil" -> null
type == "text/plain" -> text
- type == "text/x-vCard" -> "Contact card"
+ type == "text/x-vcard" -> "Contact card"
type.startsWith("image") -> "Photo"
type.startsWith("video") -> "Video"
- else -> null
+ type.startsWith("audio") -> "Audio"
+ else -> type.substring(type.indexOf('/') + 1)
}
}
\ No newline at end of file
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..ce10166d 100644
--- a/domain/src/main/java/com/moez/QKSMS/util/Preferences.kt
+++ b/domain/src/main/java/com/moez/QKSMS/util/Preferences.kt
@@ -80,6 +80,10 @@ class Preferences @Inject constructor(
const val BLOCKING_MANAGER_CC = 1
const val BLOCKING_MANAGER_SIA = 2
const val BLOCKING_MANAGER_CB = 3
+
+ const val MESSAGE_LINK_HANDLING_BLOCK = 0
+ const val MESSAGE_LINK_HANDLING_ALLOW = 1
+ const val MESSAGE_LINK_HANDLING_ASK = 2
}
// Internal
@@ -107,6 +111,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)
@@ -123,6 +128,7 @@ class Preferences @Inject constructor(
val autoDelete = rxPrefs.getInteger("autoDelete", 0)
val longAsMms = rxPrefs.getBoolean("longAsMms", false)
val mmsSize = rxPrefs.getInteger("mmsSize", 300)
+ val messageLinkHandling = rxPrefs.getInteger("messageLinkHandling", MESSAGE_LINK_HANDLING_ASK)
val logging = rxPrefs.getBoolean("logging", false)
val unreadAtTop = rxPrefs.getBoolean("unreadAtTop", false)
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.
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 {
diff --git a/presentation/src/main/AndroidManifest.xml b/presentation/src/main/AndroidManifest.xml
index 4153b2c3..e2bddfa4 100644
--- a/presentation/src/main/AndroidManifest.xml
+++ b/presentation/src/main/AndroidManifest.xml
@@ -43,6 +43,7 @@
+
-
-
-
-
-
-
+
-
-
-
-
-
-
+
? = null) {
+ fun showCompose(body: String? = null, attachments: List? = null, mode: String? = null) {
val intent = Intent(context, ComposeActivity::class.java)
intent.putExtra(Intent.EXTRA_TEXT, body)
+ intent.putExtra("mode", mode)
- images?.takeIf { it.isNotEmpty() }?.let {
- intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, ArrayList(images))
+ attachments?.takeIf { it.isNotEmpty() }?.let {
+ intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, ArrayList(attachments))
}
startActivity(intent)
diff --git a/presentation/src/main/java/com/moez/QKSMS/common/QkMediaPlayer.kt b/presentation/src/main/java/com/moez/QKSMS/common/QkMediaPlayer.kt
index a28d98e6..623bd519 100644
--- a/presentation/src/main/java/com/moez/QKSMS/common/QkMediaPlayer.kt
+++ b/presentation/src/main/java/com/moez/QKSMS/common/QkMediaPlayer.kt
@@ -9,6 +9,7 @@ object QkMediaPlayer : MediaPlayer() {
private var onCompletionListener: OnCompletionListener? = null
enum class PlayingState {
+ None,
Stopped,
Playing,
Paused
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..e61fb28c 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
@@ -188,6 +206,12 @@ class NotificationManagerImpl @Inject constructor(
}
}
+ // remove system generated contextual actions (they're generated from message links) unless
+ // the user has explicitly set to allow message links
+ notification.setAllowSystemGeneratedContextualActions(
+ (prefs.messageLinkHandling.get() == Preferences.MESSAGE_LINK_HANDLING_ALLOW)
+ )
+
// Set the large icon
val avatar = conversation.recipients.takeIf { it.size == 1 }
?.first()?.contact?.photoUri
diff --git a/presentation/src/main/java/com/moez/QKSMS/common/util/extensions/ViewExtensions.kt b/presentation/src/main/java/com/moez/QKSMS/common/util/extensions/ViewExtensions.kt
index dbb98d11..110e137c 100644
--- a/presentation/src/main/java/com/moez/QKSMS/common/util/extensions/ViewExtensions.kt
+++ b/presentation/src/main/java/com/moez/QKSMS/common/util/extensions/ViewExtensions.kt
@@ -53,20 +53,29 @@ fun EditText.hideKeyboard() {
imm.hideSoftInputFromWindow(windowToken, 0)
}
-fun ImageView.setTint(color: Int) {
- imageTintList = ColorStateList.valueOf(color)
+fun ImageView.setTint(color: Int?) {
+ imageTintList =
+ if (color == null) null
+ else ColorStateList.valueOf(color)
}
-fun ProgressBar.setTint(color: Int) {
- indeterminateTintList = ColorStateList.valueOf(color)
- progressTintList = ColorStateList.valueOf(color)
+fun ProgressBar.setTint(color: Int?) {
+ indeterminateTintList =
+ if (color == null) null
+ else ColorStateList.valueOf(color)
+ progressTintList =
+ if (color == null) null
+ else ColorStateList.valueOf(color)
+
}
-fun View.setBackgroundTint(color: Int) {
+fun View.setBackgroundTint(color: Int?) {
// API 21 doesn't support this
- backgroundTintList = ColorStateList.valueOf(color)
+ backgroundTintList =
+ if (color == null) null
+ else ColorStateList.valueOf(color)
}
fun View.setPadding(left: Int? = null, top: Int? = null, right: Int? = null, bottom: Int? = null) {
@@ -83,55 +92,67 @@ fun View.setVisible(visible: Boolean, invisible: Int = View.GONE) {
* the view no longer work. Also problematic when we try to long press on an image in the message
* view
*/
-fun View.forwardTouches(parent: View) {
- var isLongClick = false
- var textInitiallySelectable = false
- if (this@forwardTouches is TextView)
- textInitiallySelectable = this@forwardTouches.isTextSelectable
+
+class CancelableSimpleOnGestureListener(view: View, parentView: View) : SimpleOnGestureListener() {
+ private var lastUpEvent: MotionEvent? = null
+ private val parent = parentView
+ private val thisView = view
+ private var textInitiallySelectable = false
+
+ init {
+ if (thisView is TextView)
+ textInitiallySelectable = thisView.isTextSelectable
+ }
+
+ fun cancelCurrentClick() {
+ lastUpEvent?.recycle()
+ lastUpEvent = null
+ }
+
+ override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
+ if (lastUpEvent !== null) {
+ parent.onTouchEvent(e)
+ parent.onTouchEvent(lastUpEvent)
+ lastUpEvent?.recycle()
+ lastUpEvent = null
+ }
+ return true
+ }
+
+ override fun onSingleTapUp(e: MotionEvent): Boolean {
+ lastUpEvent = MotionEvent.obtain(e)
+ thisView.onTouchEvent(e)
+ return true
+ }
+
+ override fun onDown(e: MotionEvent): Boolean {
+ thisView.onTouchEvent(e)
+ return true
+ }
+
+ override fun onLongPress(e: MotionEvent) {
+ parent.onTouchEvent(e)
+ // this is kinda odd but we have to 'bounce' the text selectable value so it doesn't
+ // start selecting text on a long press, but will start selecting it on the next double-tap
+ if (thisView is TextView) {
+ thisView.setTextIsSelectable(false)
+ thisView.setTextIsSelectable(textInitiallySelectable)
+ }
+ }
+}
+
+fun View.forwardTouches(parent: View): CancelableSimpleOnGestureListener {
+ val gestureListener = CancelableSimpleOnGestureListener(this, parent)
setOnTouchListener(object : OnTouchListener {
- private val gestureDetector =
- GestureDetector(parent.context, object : SimpleOnGestureListener() {
- private var lastUpEvent: MotionEvent? = null
-
- override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
- parent.onTouchEvent(e)
- if (lastUpEvent !== null) {
- parent.onTouchEvent(lastUpEvent)
- lastUpEvent?.recycle()
- lastUpEvent = null
- }
- return true
- }
-
- override fun onSingleTapUp(e: MotionEvent): Boolean {
- onTouchEvent(e)
- lastUpEvent = MotionEvent.obtain(e)
- return true
- }
-
- override fun onDown(e: MotionEvent): Boolean {
- isLongClick = false
- onTouchEvent(e)
- return true
- }
-
- override fun onLongPress(e: MotionEvent) {
- parent.onTouchEvent(e)
- isLongClick = true
- // this is kinda odd but we have to 'bounce' the text selectable value so it doesn't
- // start selecting text on a long press, but will start selecting it on the next double-tap
- if (this@forwardTouches is TextView) {
- (this@forwardTouches as TextView).setTextIsSelectable(false)
- (this@forwardTouches as TextView).setTextIsSelectable(textInitiallySelectable)
- }
- }
- })
+ val gestureDetector = GestureDetector(parent.context, gestureListener)
override fun onTouch(v: View, e: MotionEvent): Boolean {
return gestureDetector.onTouchEvent(e)
}
})
+
+ return gestureListener
}
fun ViewPager.addOnPageChangeListener(listener: (Int) -> Unit) {
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) }
}
}
diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/AttachmentAdapter.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/AttachmentAdapter.kt
index f1e2d78f..3761d404 100644
--- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/AttachmentAdapter.kt
+++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/AttachmentAdapter.kt
@@ -19,7 +19,11 @@
package dev.octoshrimpy.quik.feature.compose
import android.content.Context
+import android.content.Intent
+import android.media.MediaMetadataRetriever
+import android.provider.MediaStore.MATCH_DEFAULT
import android.view.LayoutInflater
+import android.view.View
import android.view.ViewGroup
import androidx.core.view.isVisible
import com.bumptech.glide.Glide
@@ -27,25 +31,22 @@ import dev.octoshrimpy.quik.R
import dev.octoshrimpy.quik.common.base.QkAdapter
import dev.octoshrimpy.quik.common.base.QkViewHolder
import dev.octoshrimpy.quik.common.util.extensions.getDisplayName
-import dev.octoshrimpy.quik.extensions.mapNotNull
+import dev.octoshrimpy.quik.extensions.resourceExists
import dev.octoshrimpy.quik.model.Attachment
import ezvcard.Ezvcard
-import io.reactivex.Observable
-import io.reactivex.android.schedulers.AndroidSchedulers
-import io.reactivex.schedulers.Schedulers
import io.reactivex.subjects.PublishSubject
import io.reactivex.subjects.Subject
+import kotlinx.android.synthetic.main.attachment_file_list_item.*
import kotlinx.android.synthetic.main.attachment_contact_list_item.*
-import kotlinx.android.synthetic.main.attachment_image_list_item.*
-import kotlinx.android.synthetic.main.attachment_image_list_item.view.*
import javax.inject.Inject
+
class AttachmentAdapter @Inject constructor(
private val context: Context
) : QkAdapter() {
companion object {
- private const val VIEW_TYPE_IMAGE = 0
+ private const val VIEW_TYPE_FILE = 0
private const val VIEW_TYPE_CONTACT = 1
}
@@ -53,14 +54,13 @@ class AttachmentAdapter @Inject constructor(
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
val inflater = LayoutInflater.from(parent.context)
- val view = when (viewType) {
- VIEW_TYPE_IMAGE -> inflater.inflate(R.layout.attachment_image_list_item, parent, false)
- .apply { thumbnailBounds.clipToOutline = true }
- VIEW_TYPE_CONTACT -> inflater.inflate(R.layout.attachment_contact_list_item, parent, false)
-
- else -> null!! // Impossible
- }
+ val view = inflater.inflate(
+ if (viewType == VIEW_TYPE_CONTACT) R.layout.attachment_contact_list_item
+ else R.layout.attachment_file_list_item,
+ parent,
+ false
+ )
return QkViewHolder(view).apply {
view.setOnClickListener {
@@ -73,26 +73,81 @@ class AttachmentAdapter @Inject constructor(
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
val attachment = getItem(position)
- when (attachment) {
- is Attachment.Image -> Glide.with(context)
- .load(attachment.getUri())
- .into(holder.thumbnail)
-
- is Attachment.Contact -> Observable.just(attachment.vCard)
- .mapNotNull { vCard -> Ezvcard.parse(vCard).first() }
- .map { vcard -> vcard.getDisplayName() ?: "" }
- .subscribeOn(Schedulers.computation())
- .observeOn(AndroidSchedulers.mainThread())
- .subscribe { displayName ->
- holder.name?.text = displayName
- holder.name?.isVisible = displayName.isNotEmpty()
- }
+ if (attachment.isVCard(context)) {
+ val displayName = Ezvcard.parse(
+ String(attachment.getResourceBytes(context))
+ ).first().getDisplayName() ?: ""
+ holder.name.text = displayName
+ holder.name.isVisible = displayName.isNotEmpty()
+ return
}
+
+ // if attachment uri is missing
+ if (!attachment.getUri().resourceExists(context)) {
+ holder.thumbnail.setImageResource(android.R.drawable.ic_delete)
+ holder.fileName.text = context.getString(R.string.attachment_missing)
+ holder.fileName.visibility = View.VISIBLE
+ return
+ }
+
+ val uri = attachment.getUri()
+ val mimeType = attachment.getType(context)
+
+ // if attachment mime type is image/* or video/*, use image/frame
+ if (attachment.hasDisplayableImage(context)) {
+ Glide
+ .with(context)
+ .load(uri)
+ .into(holder.thumbnail)
+ return
+ }
+
+ // if audio mime type, try and use embedded image if one exists
+ if (attachment.isAudio(context)) {
+ val metaDataRetriever = MediaMetadataRetriever()
+ metaDataRetriever.setDataSource(context, uri)
+ val embeddedPicture = metaDataRetriever.embeddedPicture
+ if (embeddedPicture != null) {
+ Glide
+ .with(context)
+ .load(embeddedPicture)
+ .into(holder.thumbnail)
+ return
+ }
+ }
+
+ // try and use icon from default app for type
+ val intent = Intent(Intent.ACTION_VIEW).setDataAndType(uri, mimeType)
+ val appIcon = context
+ .packageManager
+ .resolveActivity(intent, MATCH_DEFAULT)
+ ?.loadIcon(context.packageManager)
+ if (appIcon != null)
+ Glide
+ .with(context)
+ .load(appIcon)
+ .into(holder.thumbnail)
+ else if (mimeType?.startsWith("audio/") == true)
+ // else, if audio, use default local audio icon
+ Glide
+ .with(context)
+ .load(R.drawable.ic_round_volume_up_24)
+ .into(holder.thumbnail)
+ else
+ // else, use default attachment icon
+ Glide
+ .with(context)
+ .load(R.drawable.ic_attachment_black_24dp)
+ .into(holder.thumbnail)
+
+ // else, show file name
+ holder.fileName.text = attachment.getName(context)
+ holder.fileName.visibility = View.VISIBLE
}
- override fun getItemViewType(position: Int) = when (getItem(position)) {
- is Attachment.Image -> VIEW_TYPE_IMAGE
- is Attachment.Contact -> VIEW_TYPE_CONTACT
+ override fun getItemViewType(position: Int) = when (getItem(position).isVCard(context)) {
+ true -> VIEW_TYPE_CONTACT
+ else -> VIEW_TYPE_FILE
}
}
\ No newline at end of file
diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt
index ace8d547..06f12a9a 100644
--- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt
+++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt
@@ -43,6 +43,7 @@ import androidx.appcompat.app.AlertDialog
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.app.ActivityCompat
+import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelProviders
@@ -71,10 +72,12 @@ import dev.octoshrimpy.quik.feature.contacts.ContactsActivity
import dev.octoshrimpy.quik.model.Attachment
import dev.octoshrimpy.quik.model.Recipient
import io.reactivex.Observable
+import io.reactivex.Single
import io.reactivex.subjects.PublishSubject
import io.reactivex.subjects.Subject
import kotlinx.android.synthetic.main.compose_activity.*
import kotlinx.android.synthetic.main.main_activity.toolbar
+import kotlinx.coroutines.reactive.publish
import java.text.SimpleDateFormat
import java.util.*
import javax.inject.Inject
@@ -82,15 +85,6 @@ import javax.inject.Inject
class ComposeActivity : QkThemedActivity(), ComposeView {
- companion object {
- private const val SelectContactRequestCode = 0
- private const val TakePhotoRequestCode = 1
- private const val AttachPhotoRequestCode = 2
- private const val AttachContactRequestCode = 3
-
- private const val CameraDestinationKey = "camera_destination"
- }
-
@Inject lateinit var attachmentAdapter: AttachmentAdapter
@Inject lateinit var chipsAdapter: ChipsAdapter
@Inject lateinit var dateFormatter: DateFormatter
@@ -103,19 +97,22 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
override val chipDeletedIntent: Subject by lazy { chipsAdapter.chipDeleted }
override val menuReadyIntent: Observable = menu.map { Unit }
override val optionsItemIntent: Subject = PublishSubject.create()
+ override val scheduleAction: Subject = PublishSubject.create()
override val sendAsGroupIntent by lazy { sendAsGroupBackground.clicks() }
override val messageClickIntent: Subject by lazy { messageAdapter.clicks }
override val messagePartClickIntent: Subject by lazy { messageAdapter.partClicks }
override val messagesSelectedIntent by lazy { messageAdapter.selectionChanges }
override val cancelSendingIntent: Subject by lazy { messageAdapter.cancelSending }
+ override val sendNowIntent: Subject by lazy { messageAdapter.sendNow }
override val attachmentDeletedIntent: Subject by lazy { attachmentAdapter.attachmentDeleted }
override val textChangedIntent by lazy { message.textChanges() }
override val attachIntent by lazy { Observable.merge(attach.clicks(), attachingBackground.clicks()) }
override val cameraIntent by lazy { Observable.merge(camera.clicks(), cameraLabel.clicks()) }
- override val galleryIntent by lazy { Observable.merge(gallery.clicks(), galleryLabel.clicks()) }
+ override val attachImageFileIntent by lazy { Observable.merge(gallery.clicks(), galleryLabel.clicks()) }
+ override val attachAnyFileIntent by lazy { Observable.merge(attachAFileIcon.clicks(), attachAFileLabel.clicks()) }
override val scheduleIntent by lazy { Observable.merge(schedule.clicks(), scheduleLabel.clicks()) }
override val attachContactIntent by lazy { Observable.merge(contact.clicks(), contactLabel.clicks()) }
- override val attachmentSelectedIntent: Subject = PublishSubject.create()
+ override val attachAnyFileSelectedIntent: Subject = PublishSubject.create()
override val contactSelectedIntent: Subject = PublishSubject.create()
override val inputContentIntent by lazy { message.inputContentSelected }
override val scheduleSelectedIntent: Subject = PublishSubject.create()
@@ -125,6 +122,7 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
override val viewQksmsPlusIntent: Subject = PublishSubject.create()
override val backPressedIntent: Subject = PublishSubject.create()
override val confirmDeleteIntent: Subject> = PublishSubject.create()
+ override val messageLinkAskIntent: Subject by lazy { messageAdapter.messageLinkClicks }
private val viewModel by lazy { ViewModelProviders.of(this, viewModelFactory)[ComposeViewModel::class.java] }
@@ -330,6 +328,10 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
)
constraintSet.applyTo(constraintLayout)
}
+
+ // if scheduling mode is set, show schedule dialog
+ if (state.scheduling)
+ scheduleAction.onNext(true)
}
override fun clearSelection() = messageAdapter.clearSelection()
@@ -350,6 +352,23 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
.show()
}
+ override fun showMessageLinkAskDialog(uri: Uri) {
+ AlertDialog.Builder(this)
+ .setTitle(R.string.messageLinkHandling_dialog_title)
+ .setMessage(getString(R.string.messageLinkHandling_dialog_body, uri.toString()))
+ .setPositiveButton(
+ R.string.messageLinkHandling_dialog_positive
+ ) { _, _ ->
+ ContextCompat.startActivity(
+ this,
+ Intent(Intent.ACTION_VIEW).setData(uri),
+ null
+ )
+ }
+ .setNegativeButton(R.string.messageLinkHandling_dialog_negative) { _, _ -> { } }
+ .show()
+ }
+
override fun requestDefaultSms() {
navigator.showDefaultSmsDialog(this)
}
@@ -386,7 +405,7 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
val intent = Intent(Intent.ACTION_PICK)
.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE)
- startActivityForResult(Intent.createChooser(intent, null), AttachContactRequestCode)
+ startActivityForResult(Intent.createChooser(intent, null), ComposeView.AttachContactRequestCode)
}
override fun showContacts(sharing: Boolean, chips: List) {
@@ -395,7 +414,7 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
val intent = Intent(this, ContactsActivity::class.java)
.putExtra(ContactsActivity.SharingKey, sharing)
.putExtra(ContactsActivity.ChipsKey, serialized)
- startActivityForResult(intent, SelectContactRequestCode)
+ startActivityForResult(intent, ComposeView.SelectContactRequestCode)
}
override fun themeChanged() {
@@ -415,17 +434,17 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
val intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
.putExtra(MediaStore.EXTRA_OUTPUT, cameraDestination)
- startActivityForResult(Intent.createChooser(intent, null), TakePhotoRequestCode)
+ startActivityForResult(Intent.createChooser(intent, null), ComposeView.TakePhotoRequestCode)
}
- override fun requestGallery() {
+ override fun requestGallery(mimeType: String, requestCode: Int) {
val intent = Intent(Intent.ACTION_PICK)
.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true)
.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION)
.putExtra(Intent.EXTRA_LOCAL_ONLY, false)
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
- .setType("image/*")
- startActivityForResult(Intent.createChooser(intent, null), AttachPhotoRequestCode)
+ .setType(mimeType)
+ startActivityForResult(Intent.createChooser(intent, null), requestCode)
}
override fun setDraft(draft: String) {
@@ -473,36 +492,43 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
- when {
- requestCode == SelectContactRequestCode -> {
+ if (resultCode != Activity.RESULT_OK)
+ return
+
+ when (requestCode) {
+ ComposeView.SelectContactRequestCode -> {
chipsSelectedIntent.onNext(data?.getSerializableExtra(ContactsActivity.ChipsKey)
?.let { serializable -> serializable as? HashMap }
?: hashMapOf())
}
- requestCode == TakePhotoRequestCode && resultCode == Activity.RESULT_OK -> {
- cameraDestination?.let(attachmentSelectedIntent::onNext)
+
+ ComposeView.TakePhotoRequestCode -> {
+ cameraDestination?.let(attachAnyFileSelectedIntent::onNext)
}
- requestCode == AttachPhotoRequestCode && resultCode == Activity.RESULT_OK -> {
+
+ ComposeView.AttachAFileRequestCode -> {
data?.clipData?.itemCount
- ?.let { count -> 0 until count }
- ?.mapNotNull { i -> data.clipData?.getItemAt(i)?.uri }
- ?.forEach(attachmentSelectedIntent::onNext)
- ?: data?.data?.let(attachmentSelectedIntent::onNext)
+ ?.let { count -> 0 until count }
+ ?.mapNotNull { i -> data.clipData?.getItemAt(i)?.uri }
+ ?.forEach(attachAnyFileSelectedIntent::onNext)
+ ?: data?.data?.let(attachAnyFileSelectedIntent::onNext)
}
- requestCode == AttachContactRequestCode && resultCode == Activity.RESULT_OK -> {
+
+ ComposeView.AttachContactRequestCode -> {
data?.data?.let(contactSelectedIntent::onNext)
}
+
else -> super.onActivityResult(requestCode, resultCode, data)
}
}
override fun onSaveInstanceState(outState: Bundle) {
- outState.putParcelable(CameraDestinationKey, cameraDestination)
+ outState.putParcelable(ComposeView.CameraDestinationKey, cameraDestination)
super.onSaveInstanceState(outState)
}
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
- cameraDestination = savedInstanceState.getParcelable(CameraDestinationKey)
+ cameraDestination = savedInstanceState.getParcelable(ComposeView.CameraDestinationKey)
super.onRestoreInstanceState(savedInstanceState)
}
diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivityModule.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivityModule.kt
index 209680be..1a599bd8 100644
--- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivityModule.kt
+++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivityModule.kt
@@ -78,22 +78,14 @@ class ComposeActivityModule {
val uris = mutableListOf()
activity.intent.getParcelableExtra(Intent.EXTRA_STREAM)?.run(uris::add)
activity.intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM)?.run(uris::addAll)
- return Attachments(uris.mapNotNull { uri ->
- val mimeType = activity.contentResolver.getType(uri)
- when {
- ContentType.isImageType(mimeType) -> {
- Attachment.Image(uri)
- }
- ContentType.TEXT_VCARD.equals(mimeType, true) -> {
- val inputStream = activity.contentResolver.openInputStream(uri)
- val text = inputStream?.reader(Charset.forName("utf-8"))?.readText()
- text?.let(Attachment::Contact)
- }
+ return Attachments(uris.mapNotNull { Attachment(it) })
+ }
- else -> null
- }
- })
+ @Provides
+ @Named("mode")
+ fun provideSharedAction(activity: ComposeActivity): String {
+ return activity.intent.getStringExtra("mode") ?: "";
}
@Provides
diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeState.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeState.kt
index b5bf5a43..ca8f6475 100644
--- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeState.kt
+++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeState.kt
@@ -42,6 +42,7 @@ data class ComposeState(
val scheduled: Long = 0,
val attachments: List = ArrayList(),
val attaching: Boolean = false,
+ val scheduling: Boolean = false,
val remaining: String = "",
val subscription: SubscriptionInfoCompat? = null,
val canSend: Boolean = false,
diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeView.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeView.kt
index af37016d..d5b96e11 100644
--- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeView.kt
+++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeView.kt
@@ -29,6 +29,15 @@ import io.reactivex.subjects.Subject
interface ComposeView : QkView {
+ companion object {
+ const val SelectContactRequestCode = 0
+ const val TakePhotoRequestCode = 1
+ const val AttachAFileRequestCode = 4
+ const val AttachContactRequestCode = 3
+
+ const val CameraDestinationKey = "camera_destination"
+ }
+
val activityVisibleIntent: Observable
val chipsSelectedIntent: Subject>
val chipDeletedIntent: Subject
@@ -39,14 +48,17 @@ interface ComposeView : QkView {
val messagePartClickIntent: Subject
val messagesSelectedIntent: Observable>
val cancelSendingIntent: Subject
+ val sendNowIntent: Subject
val attachmentDeletedIntent: Subject
val textChangedIntent: Observable
val attachIntent: Observable
val cameraIntent: Observable<*>
- val galleryIntent: Observable<*>
+ val attachAnyFileIntent: Observable<*>
+ val attachImageFileIntent: Observable<*>
val scheduleIntent: Observable<*>
+ val scheduleAction: Observable<*>
val attachContactIntent: Observable<*>
- val attachmentSelectedIntent: Observable
+ val attachAnyFileSelectedIntent: Observable
val contactSelectedIntent: Observable
val inputContentIntent: Observable
val scheduleSelectedIntent: Observable
@@ -56,11 +68,13 @@ interface ComposeView : QkView {
val viewQksmsPlusIntent: Subject
val backPressedIntent: Observable
val confirmDeleteIntent: Observable>
+ val messageLinkAskIntent: Observable
fun clearSelection()
fun toggleSelectAll()
fun expandMessages(messageIds: List, expand: Boolean)
fun showDetails(details: String)
+ fun showMessageLinkAskDialog(uri: Uri)
fun requestDefaultSms()
fun requestStoragePermission()
fun requestSmsPermission()
@@ -68,7 +82,7 @@ interface ComposeView : QkView {
fun themeChanged()
fun showKeyboard()
fun requestCamera()
- fun requestGallery()
+ fun requestGallery(mimeType: String, requestCode: Int)
fun requestDatePicker()
fun requestContact()
fun setDraft(draft: String)
diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt
index bf65a224..a94558bd 100644
--- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt
+++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt
@@ -59,6 +59,7 @@ import dev.octoshrimpy.quik.util.Preferences
import dev.octoshrimpy.quik.util.tryOrNull
import com.uber.autodispose.android.lifecycle.scope
import com.uber.autodispose.autoDisposable
+import dev.octoshrimpy.quik.extensions.isSmil
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.rxkotlin.Observables
@@ -79,6 +80,7 @@ class ComposeViewModel @Inject constructor(
@Named("addresses") private val addresses: List,
@Named("text") private val sharedText: String,
@Named("attachments") private val sharedAttachments: Attachments,
+ @Named("mode") private val mode: String,
private val contactRepo: ContactRepository,
private val context: Context,
private val activeConversationManager: ActiveConversationManager,
@@ -242,6 +244,10 @@ class ComposeViewModel @Inject constructor(
val sub = if (subs.size > 1) subs.firstOrNull { it.subscriptionId == subId } ?: subs[0] else null
newState { copy(subscription = sub) }
}.subscribe()
+
+ // actions
+ if (mode == "scheduling")
+ newState { copy(scheduling = true) }
}
override fun bindView(view: ComposeView) {
@@ -378,8 +384,8 @@ class ComposeViewModel @Inject constructor(
.filter { it == R.id.forward }
.withLatestFrom(view.messagesSelectedIntent) { _, messages ->
messages?.firstOrNull()?.let { messageRepo.getMessage(it) }?.let { message ->
- val images = message.parts.filter { it.isImage() }.mapNotNull { it.getUri() }
- navigator.showCompose(message.getText(), images)
+ val attachments = message.parts.filter { !it.isSmil() }.mapNotNull { it.getUri() }
+ navigator.showCompose(message.getText(), attachments)
}
}
.autoDisposable(view.scope())
@@ -487,6 +493,31 @@ class ComposeViewModel @Inject constructor(
cancelMessage.execute(CancelDelayedMessage.Params(message.id, message.threadId))
}
+ // send a delayed message now
+ view.sendNowIntent
+ .mapNotNull(messageRepo::getMessage)
+ .autoDisposable(view.scope())
+ .subscribe { message ->
+ cancelMessage.execute(CancelDelayedMessage.Params(message.id, message.threadId))
+ val address = listOf(conversationRepo
+ .getConversation(threadId)?.recipients?.firstOrNull()?.address ?: message.address)
+ sendMessage.execute(
+ SendMessage.Params(
+ message.subId,
+ message.threadId,
+ address,
+ message.body,
+ listOf(), // sms with attachments (mms) can't be delayed so we can know attachments are empty for a 'send now' delayed sms
+ 0
+ )
+ )
+ }
+
+ // Show the message details
+ view.messageLinkAskIntent
+ .autoDisposable(view.scope())
+ .subscribe { view.showMessageLinkAskDialog(it) }
+
// Set the current conversation
Observables
.combineLatest(
@@ -528,19 +559,21 @@ class ComposeViewModel @Inject constructor(
view.cameraIntent
.autoDisposable(view.scope())
.subscribe {
- if (permissionManager.hasStorage()) {
- newState { copy(attaching = false) }
- view.requestCamera()
- } else {
- view.requestStoragePermission()
- }
+ newState { copy(attaching = false) }
+ view.requestCamera()
}
- // Attach a photo from gallery
- view.galleryIntent
- .doOnNext { newState { copy(attaching = false) } }
- .autoDisposable(view.scope())
- .subscribe { view.requestGallery() }
+ // pick a photo (specifically) from image provider apps
+ view.attachImageFileIntent
+ .doOnNext { newState { copy(attaching = false) } }
+ .autoDisposable(view.scope())
+ .subscribe { view.requestGallery("image/*", ComposeView.AttachAFileRequestCode) }
+
+ // pick any file from any provider apps
+ view.attachAnyFileIntent
+ .doOnNext { newState { copy(attaching = false) } }
+ .autoDisposable(view.scope())
+ .subscribe { view.requestGallery("*/*", ComposeView.AttachAFileRequestCode) }
// Choose a time to schedule the message
view.scheduleIntent
@@ -552,15 +585,21 @@ class ComposeViewModel @Inject constructor(
.autoDisposable(view.scope())
.subscribe { view.requestDatePicker() }
- // A photo was selected
- Observable.merge(
- view.attachmentSelectedIntent.map { uri -> Attachment.Image(uri) },
- view.inputContentIntent.map { inputContent -> Attachment.Image(inputContent = inputContent) })
- .withLatestFrom(attachments) { attachment, attachments -> attachments + attachment }
- .doOnNext(attachments::onNext)
- .autoDisposable(view.scope())
- .subscribe { newState { copy(attaching = false) } }
+ view.scheduleAction
+ .take(1)
+ .doOnNext{ newState { copy(scheduling = false) } }
+ .autoDisposable(view.scope())
+ .subscribe { view.requestDatePicker() }
+ // a file, photo or otherwise, was picked by the user
+ Observable.merge(
+ view.attachAnyFileSelectedIntent.map { uri -> Attachment(uri) },
+ view.inputContentIntent.map { inputContent -> Attachment(inputContent = inputContent) }
+ )
+ .withLatestFrom(attachments) { attachment, attachments -> attachments + attachment }
+ .doOnNext(attachments::onNext)
+ .autoDisposable(view.scope())
+ .subscribe { newState { copy(attaching = false) } }
// Set the scheduled time
view.scheduleSelectedIntent
.filter { scheduled ->
@@ -579,7 +618,7 @@ class ComposeViewModel @Inject constructor(
// Contact was selected for attachment
view.contactSelectedIntent
- .map { uri -> Attachment.Contact(getVCard(uri)!!) }
+ .map { uri -> Attachment(getFullVCardUri(uri)) }
.withLatestFrom(attachments) { attachment, attachments -> attachments + attachment }
.subscribeOn(Schedulers.io())
.autoDisposable(view.scope())
@@ -704,7 +743,6 @@ class ComposeViewModel @Inject constructor(
state.scheduled != 0L -> {
newState { copy(scheduled = 0) }
val uris = attachments
- .mapNotNull { it as? Attachment.Image }
.map { it.getUri() }
.map { it.toString() }
val params = AddScheduledMessage
@@ -784,17 +822,17 @@ class ComposeViewModel @Inject constructor(
}
- private fun getVCard(contactData: Uri): String? {
- val lookupKey = context.contentResolver.query(contactData, null, null, null, null)?.use { cursor ->
- cursor.moveToFirst()
- cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY))
+ private fun getFullVCardUri(contactData: Uri): Uri {
+ val lookupKey = context.contentResolver.query(contactData, null, null, null, null)?.use {
+ it.moveToFirst()
+ val index = it.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY)
+ if (index >= 0)
+ it.getString(index)
+ else
+ ""
}
- val vCardUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_VCARD_URI, lookupKey)
- return context.contentResolver.openAssetFileDescriptor(vCardUri, "r")
- ?.createInputStream()
- ?.readBytes()
- ?.let { bytes -> String(bytes) }
+ return Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_VCARD_URI, lookupKey)
}
}
\ No newline at end of file
diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/MessagesAdapter.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/MessagesAdapter.kt
index d8dd5061..dc397a65 100644
--- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/MessagesAdapter.kt
+++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/MessagesAdapter.kt
@@ -21,17 +21,23 @@ package dev.octoshrimpy.quik.feature.compose
import android.animation.ObjectAnimator
import android.content.Context
import android.graphics.Typeface
+import android.net.Uri
import android.text.Layout
import android.text.Spannable
import android.text.SpannableString
+import android.text.SpannableStringBuilder
+import android.text.method.LinkMovementMethod
+import android.text.style.ClickableSpan
import android.text.style.StyleSpan
+import android.text.style.URLSpan
+import android.text.util.Linkify
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.ProgressBar
-import androidx.recyclerview.widget.RecyclerView
import com.jakewharton.rxbinding2.view.clicks
+import com.moez.QKSMS.common.QkMediaPlayer
import dev.octoshrimpy.quik.R
import dev.octoshrimpy.quik.common.base.QkRealmAdapter
import dev.octoshrimpy.quik.common.base.QkViewHolder
@@ -55,6 +61,7 @@ import dev.octoshrimpy.quik.model.Message
import dev.octoshrimpy.quik.model.Recipient
import dev.octoshrimpy.quik.util.PhoneNumberUtils
import dev.octoshrimpy.quik.util.Preferences
+import io.reactivex.disposables.Disposable
import io.reactivex.subjects.PublishSubject
import io.reactivex.subjects.Subject
import io.realm.RealmResults
@@ -67,6 +74,7 @@ import kotlinx.android.synthetic.main.message_list_item_in.status
import kotlinx.android.synthetic.main.message_list_item_in.timestamp
import kotlinx.android.synthetic.main.message_list_item_in.view.*
import kotlinx.android.synthetic.main.message_list_item_out.*
+import kotlinx.android.synthetic.main.message_list_item_out.view.cancel
import java.util.*
import java.util.concurrent.TimeUnit
import javax.inject.Inject
@@ -83,6 +91,13 @@ class MessagesAdapter @Inject constructor(
private val textViewStyler: TextViewStyler
) : QkRealmAdapter() {
+ class AudioState(
+ var partId: Long = -1,
+ var state: QkMediaPlayer.PlayingState = QkMediaPlayer.PlayingState.Stopped,
+ var seekBarUpdater: Disposable? = null,
+ var viewHolder: QkViewHolder? = null
+ )
+
companion object {
private const val VIEW_TYPE_MESSAGE_IN = 0
private const val VIEW_TYPE_MESSAGE_OUT = 1
@@ -96,7 +111,9 @@ class MessagesAdapter @Inject constructor(
val clicks: Subject = PublishSubject.create()
val partClicks: Subject = PublishSubject.create()
+ val messageLinkClicks: Subject = PublishSubject.create()
val cancelSending: Subject = PublishSubject.create()
+ val sendNow: Subject = PublishSubject.create()
var data: Pair>? = null
set(value) {
@@ -127,11 +144,12 @@ class MessagesAdapter @Inject constructor(
private val contactCache = ContactCache()
private val expanded = HashMap()
- private val partsViewPool = RecyclerView.RecycledViewPool()
private val subs = subscriptionManager.activeSubscriptionInfoList
var theme: Colors.Theme = colors.theme()
+ private val audioState = AudioState()
+
/**
* If the viewType is negative, then the viewHolder has an attachment. We'll consider
* this a unique viewType even though it uses the same view, so that regular messages
@@ -147,6 +165,7 @@ class MessagesAdapter @Inject constructor(
view = layoutInflater.inflate(R.layout.message_list_item_out, parent, false)
view.findViewById(R.id.cancelIcon).setTint(theme.theme)
view.findViewById(R.id.cancel).setTint(theme.theme)
+ view.findViewById(R.id.sendNowIcon).setTint(theme.theme)
} else {
view = layoutInflater.inflate(R.layout.message_list_item_in, parent, false)
}
@@ -156,8 +175,6 @@ class MessagesAdapter @Inject constructor(
val partsAdapter = partsAdapterProvider.get()
partsAdapter.clicks.subscribe(partClicks)
view.attachments.adapter = partsAdapter
- view.attachments.setRecycledViewPool(partsViewPool)
- view.body.forwardTouches(view)
return QkViewHolder(view).apply {
view.setOnClickListener {
@@ -193,28 +210,42 @@ class MessagesAdapter @Inject constructor(
// Update the selected state
holder.containerView.isActivated = isSelected(message.id) || highlight == message.id
- // Bind the cancel view
- holder.cancel?.let { cancel ->
- val isCancellable = message.isSending() && message.date > System.currentTimeMillis()
- cancel.setVisible(isCancellable)
- cancel.clicks().subscribe { cancelSending.onNext(message.id) }
- cancel.progress = 2
+ // Bind the cancelFrame (cancel button) view
+ if (holder.cancelFrame != null) {
+ holder.cancelFrame.let { cancelFrame ->
+ val isCancellable = message.isSending() && message.date > System.currentTimeMillis()
+ cancelFrame.visibility = if (isCancellable) View.VISIBLE else View.GONE
+ cancelFrame.clicks().subscribe { cancelSending.onNext(message.id) }
+ cancelFrame.cancel.progress = 2
- if (isCancellable) {
- val delay = when (prefs.sendDelay.get()) {
- Preferences.SEND_DELAY_SHORT -> 3000
- Preferences.SEND_DELAY_MEDIUM -> 5000
- Preferences.SEND_DELAY_LONG -> 10000
- else -> 0
- }
- val progress = (1 - (message.date - System.currentTimeMillis()) / delay.toFloat()) * 100
+ if (isCancellable) {
+ val delay = when (prefs.sendDelay.get()) {
+ Preferences.SEND_DELAY_SHORT -> 3000
+ Preferences.SEND_DELAY_MEDIUM -> 5000
+ Preferences.SEND_DELAY_LONG -> 10000
+ else -> 0
+ }
+ val progress =
+ (1 - (message.date - System.currentTimeMillis()) / delay.toFloat()) * 100
- ObjectAnimator.ofInt(cancel, "progress", progress.toInt(), 100)
+ ObjectAnimator.ofInt(cancelFrame.cancel, "progress", progress.toInt(), 100)
.setDuration(message.date - System.currentTimeMillis())
.start()
+ }
}
}
+ // Bind the send now icon view
+ if (holder.sendNowIcon != null) {
+ holder.sendNowIcon.let { sendNowIcon ->
+ val isCancellable = message.isSending() && message.date > System.currentTimeMillis()
+ sendNowIcon.visibility = if (isCancellable) View.VISIBLE else View.GONE
+ sendNowIcon.clicks().subscribe { sendNow.onNext(message.id) }
+ }
+ }
+
+ val cancelableSimpleOnGestureListener = holder.body.forwardTouches(holder.containerView)
+
// Bind the message status
bindStatus(holder, message, next)
@@ -272,8 +303,48 @@ class MessagesAdapter @Inject constructor(
false -> TextViewStyler.SIZE_PRIMARY
})
- holder.body.text = messageText
- holder.body.setVisible(message.isSms() || messageText.isNotBlank())
+ val spanString = SpannableStringBuilder(messageText)
+
+ when (prefs.messageLinkHandling.get()) {
+ Preferences.MESSAGE_LINK_HANDLING_BLOCK -> holder.body.autoLinkMask = 0
+ Preferences.MESSAGE_LINK_HANDLING_ASK -> {
+ // manually handle link clicks if user has set to ask before opening links
+ holder.body.isClickable = false
+ holder.body.linksClickable = false
+ holder.body.movementMethod = LinkMovementMethod.getInstance()
+
+ Linkify.addLinks(spanString, holder.body.autoLinkMask)
+
+ for (span in spanString.getSpans(
+ 0,
+ spanString.length,
+ URLSpan::class.java)
+ ) {
+ // set handler for when user touches a link into new span
+ spanString.setSpan(
+ object : ClickableSpan() {
+ override fun onClick(widget: View) {
+ messageLinkClicks.onNext(Uri.parse(span.url))
+
+ // interrupt the upcoming click event on the body view
+ cancelableSimpleOnGestureListener.cancelCurrentClick()
+ }
+ },
+ spanString.getSpanStart(span),
+ spanString.getSpanEnd(span),
+ spanString.getSpanFlags(span)
+ )
+
+ // remove original span
+ spanString.removeSpan(span)
+ }
+ }
+ else -> holder.body.movementMethod = LinkMovementMethod.getInstance()
+ }
+
+ holder.body.text = spanString
+ holder.body.setVisible(message.isSms() || spanString.isNotBlank())
+
holder.body.setBackgroundResource(getBubble(
emojiOnly = emojiOnly,
canGroupWithPrevious = canGroup(message, previous) || media.isNotEmpty(),
@@ -283,7 +354,7 @@ class MessagesAdapter @Inject constructor(
// Bind the attachments
val partsAdapter = holder.attachments.adapter as PartsAdapter
partsAdapter.theme = theme
- partsAdapter.setData(message, previous, next, holder)
+ partsAdapter.setData(message, previous, next, holder, audioState)
}
private fun bindStatus(holder: QkViewHolder, message: Message, next: Message?) {
diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/part/AudioBinder.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/part/AudioBinder.kt
index c956deeb..b253185c 100644
--- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/part/AudioBinder.kt
+++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/part/AudioBinder.kt
@@ -33,16 +33,14 @@ import dev.octoshrimpy.quik.common.util.extensions.setBackgroundTint
import dev.octoshrimpy.quik.common.util.extensions.setTint
import dev.octoshrimpy.quik.common.widget.BubbleImageView
import dev.octoshrimpy.quik.extensions.isAudio
+import dev.octoshrimpy.quik.feature.compose.MessagesAdapter
import dev.octoshrimpy.quik.model.Message
import dev.octoshrimpy.quik.model.MmsPart
import dev.octoshrimpy.quik.util.GlideApp
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
-import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.mms_audio_preview_list_item.*
-import kotlinx.android.synthetic.main.mms_audio_preview_list_item.view.playPause
-import kotlinx.android.synthetic.main.mms_audio_preview_list_item.view.seekBar
import kotlinx.android.synthetic.main.mms_image_preview_list_item.thumbnail
import java.util.concurrent.TimeUnit
import javax.inject.Inject
@@ -53,91 +51,132 @@ class AudioBinder @Inject constructor(colors: Colors, private val context: Conte
override val partLayout = R.layout.mms_audio_preview_list_item
override var theme = colors.theme()
- private var thisPlayingState = QkMediaPlayer.PlayingState.Stopped
override fun canBindPart(part: MmsPart) = part.isAudio()
+ var audioState = MessagesAdapter.AudioState(-1, QkMediaPlayer.PlayingState.Stopped)
+
+ private fun startSeekBarUpdateTimer() {
+ audioState.apply {
+ seekBarUpdater?.dispose()
+ seekBarUpdater = Observable.interval(500, TimeUnit.MILLISECONDS)
+ .subscribeOn(Schedulers.single())
+ .observeOn(AndroidSchedulers.mainThread())
+ .doOnNext {
+ viewHolder?.seekBar?.progress = QkMediaPlayer.currentPosition
+ }
+ .subscribe()
+ }
+ }
+
+ private fun uiToPlaying(viewHolder: QkViewHolder) {
+ viewHolder.seekBar.max = QkMediaPlayer.duration
+ viewHolder.seekBar.isEnabled = true
+ viewHolder.seekBar.progress = QkMediaPlayer.currentPosition
+ viewHolder.playPause.setImageResource(R.drawable.exo_icon_pause)
+ viewHolder.playPause.tag = QkMediaPlayer.PlayingState.Playing
+ viewHolder.metadataTitle.isSelected = true // start marquee
+ }
+
+ private fun uiToPaused(viewHolder: QkViewHolder) {
+ viewHolder.playPause.setImageResource(R.drawable.exo_icon_play)
+ viewHolder.playPause.tag = QkMediaPlayer.PlayingState.Paused
+ }
+
+ private fun uiToStopped(viewHolder: QkViewHolder) {
+ viewHolder.seekBar.progress = 0
+ viewHolder.seekBar.max = 0
+ viewHolder.seekBar.isEnabled = false
+ viewHolder.playPause.setImageResource(R.drawable.exo_icon_play)
+ viewHolder.playPause.tag = QkMediaPlayer.PlayingState.Stopped
+ viewHolder.metadataTitle.isSelected = false // stop marquee
+ }
+
override fun bindPart(
holder: QkViewHolder,
part: MmsPart,
message: Message,
canGroupWithPrevious: Boolean,
- canGroupWithNext: Boolean
+ canGroupWithNext: Boolean,
) {
// play/pause button click handling
- holder.playPause.setOnClickListener { view ->
- var seekBarUpdater: Disposable? = null
+ holder.playPause.setOnClickListener {
+ when (holder.playPause.tag) {
+ QkMediaPlayer.PlayingState.Playing -> {
+ if (audioState.partId == part.id) {
+ QkMediaPlayer.pause()
+ uiToPaused(holder)
+ audioState.state = QkMediaPlayer.PlayingState.Paused
- when (thisPlayingState) {
- QkMediaPlayer.PlayingState.Stopped -> {
- QkMediaPlayer.apply {
- reset() // make sure reset before trying to (re-)use
-
- setAudioAttributes(
- AudioAttributes.Builder()
- .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC) // music, maybe?? could be voice. don't want to use CONTENT_TYPE_UNKNOWN though
- .setUsage(AudioAttributes.USAGE_MEDIA)
- .build()
- )
-
- setDataSource(context, part.getUri())
-
- setOnPreparedListener {
- // start timer to update seek bar
- seekBarUpdater = Observable.interval(500, TimeUnit.MILLISECONDS)
- .subscribeOn(Schedulers.single())
- .observeOn(AndroidSchedulers.mainThread())
- .map { System.nanoTime() }
- .doOnNext { holder.seekBar.progress = QkMediaPlayer.currentPosition }
- .subscribe()
-
- // set seek bar max value
- holder.seekBar.max = QkMediaPlayer.duration
-
- start()
-
- thisPlayingState = QkMediaPlayer.PlayingState.Playing
- view.playPause.setImageResource(R.drawable.exo_icon_pause)
- holder.containerView.seekBar.isEnabled = true
- holder.metadataTitle.isSelected = true
- }
-
- setOnCompletionListener { // also called on error because we don't have an onerrorlistener
- seekBarUpdater?.dispose() // stop timer
-
- thisPlayingState = QkMediaPlayer.PlayingState.Stopped
- holder.containerView.seekBar.seekBar.isEnabled = false
- holder.containerView.seekBar.seekBar.progress = 0
- view.playPause.setImageResource(R.drawable.exo_icon_play)
- holder.metadataTitle.isSelected = false
- }
-
- // prepare to play
- prepareAsync()
+ // stop progress bar update timer
+ audioState.seekBarUpdater?.dispose()
}
}
- QkMediaPlayer.PlayingState.Playing -> {
- QkMediaPlayer.pause()
- view.playPause.setImageResource(R.drawable.exo_icon_play)
- thisPlayingState = QkMediaPlayer.PlayingState.Paused
- }
QkMediaPlayer.PlayingState.Paused -> {
- QkMediaPlayer.start()
- view.playPause.setImageResource(R.drawable.exo_icon_pause)
- thisPlayingState = QkMediaPlayer.PlayingState.Playing
+ if (audioState.partId == part.id) {
+ QkMediaPlayer.start()
+ uiToPlaying(holder)
+ audioState.state = QkMediaPlayer.PlayingState.Playing
+
+ // start progress bar update timer
+ startSeekBarUpdateTimer()
+ }
+ }
+ else -> {
+ QkMediaPlayer.reset() // make sure reset before trying to (re-)use
+
+ QkMediaPlayer.setOnPreparedListener {
+ // start media playing
+ QkMediaPlayer.start()
+
+ uiToPlaying(holder)
+
+ // set current view holder and part as active
+ audioState.apply {
+ audioState.state = QkMediaPlayer.PlayingState.Playing
+ partId = part.id
+ viewHolder = holder
+ }
+
+ // start progress bar update timer
+ startSeekBarUpdateTimer()
+ }
+
+ QkMediaPlayer.setOnCompletionListener { // also called on error because we don't have an onerrorlistener
+ audioState.apply {
+ // if this part is currently active, set it to stopped and inactive
+ if ((partId == part.id) && (viewHolder != null))
+ uiToStopped(viewHolder!!)
+
+ state = QkMediaPlayer.PlayingState.Stopped
+ partId = -1
+ viewHolder = null
+ }
+ }
+
+ // start the media player play sequence
+ QkMediaPlayer.setAudioAttributes(
+ AudioAttributes.Builder()
+ .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC) // music, maybe?? could be voice. don't want to use CONTENT_TYPE_UNKNOWN though
+ .setUsage(AudioAttributes.USAGE_MEDIA)
+ .build()
+ )
+
+ QkMediaPlayer.setDataSource(context, part.getUri())
+
+ QkMediaPlayer.prepareAsync()
}
}
}
- holder.thumbnail.bubbleStyle = when {
- !canGroupWithPrevious && canGroupWithNext ->
- if (message.isMe()) BubbleImageView.Style.OUT_FIRST else BubbleImageView.Style.IN_FIRST
- canGroupWithPrevious && canGroupWithNext ->
- if (message.isMe()) BubbleImageView.Style.OUT_MIDDLE else BubbleImageView.Style.IN_MIDDLE
- canGroupWithPrevious && !canGroupWithNext ->
- if (message.isMe()) BubbleImageView.Style.OUT_LAST else BubbleImageView.Style.IN_LAST
- else -> BubbleImageView.Style.ONLY
- }
+ holder.containerView.setOnClickListener { clicks.onNext(part.id) }
+
+ // if this item is the active active audio item update the active view holder
+ if (audioState.partId == part.id)
+ audioState.viewHolder = holder
+ // else, this is not the active item so ensure the stored view holder is not this one
+ else if (audioState.viewHolder == holder)
+ audioState.viewHolder = null
// tint colours
val secondaryColor =
@@ -151,9 +190,6 @@ class AudioBinder @Inject constructor(colors: Colors, private val context: Conte
else
holder.containerView.context.resolveThemeColor(android.R.attr.textColorPrimary)
- val metaDataRetriever = MediaMetadataRetriever()
- metaDataRetriever.setDataSource(context, part.getUri())
-
// sound wave
holder.soundWave.setTint(primaryColor)
@@ -161,11 +197,11 @@ class AudioBinder @Inject constructor(colors: Colors, private val context: Conte
holder.seekBar.apply {
setTint(secondaryColor)
thumbTintList = ColorStateList.valueOf(secondaryColor)
- max = 0
- isEnabled = false
+
setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(p0: SeekBar?, progress: Int, fromUser: Boolean) {
- if ((thisPlayingState != QkMediaPlayer.PlayingState.Stopped) && fromUser)
+ // if seek was initiated by the user and this part is currently playing
+ if (fromUser)
QkMediaPlayer.seekTo(progress)
}
override fun onStartTrackingTouch(p0: SeekBar?) { /* nothing */ }
@@ -175,35 +211,65 @@ class AudioBinder @Inject constructor(colors: Colors, private val context: Conte
// playPause button
holder.playPause. apply {
+ if ((audioState.partId == part.id) &&
+ (audioState.state == QkMediaPlayer.PlayingState.Playing))
+ uiToPlaying(holder)
+ else if ((audioState.partId == part.id) &&
+ (audioState.state == QkMediaPlayer.PlayingState.Paused))
+ uiToPaused(holder)
+ else
+ uiToStopped(holder)
+
setTint(secondaryColor)
setBackgroundTint(primaryColor)
}
- holder.metadataTitle.apply {
- // metadata title
- text = metaDataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE) ?: ""
+ MediaMetadataRetriever().use {
+ it.setDataSource(context, part.getUri())
- if (text == "")
- visibility = View.GONE
- else {
- setTextColor(primaryColor)
- setBackgroundTint(0xccffffff.toInt() and secondaryColor) // hex value is alpha
+ // metadata title
+ holder.metadataTitle.apply {
+ text = it.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE)
+
+ if (text.isEmpty())
+ visibility = View.GONE
+ else {
+ visibility = View.VISIBLE
+ setTextColor(primaryColor)
+ setBackgroundTint(0xccffffff.toInt() and secondaryColor) // hex value is alpha
+ }
+ }
+
+ // bubble / embedded image
+ holder.thumbnail.apply {
+ bubbleStyle = when {
+ !canGroupWithPrevious && canGroupWithNext ->
+ if (message.isMe()) BubbleImageView.Style.OUT_FIRST else BubbleImageView.Style.IN_FIRST
+ canGroupWithPrevious && canGroupWithNext ->
+ if (message.isMe()) BubbleImageView.Style.OUT_MIDDLE else BubbleImageView.Style.IN_MIDDLE
+ canGroupWithPrevious && !canGroupWithNext ->
+ if (message.isMe()) BubbleImageView.Style.OUT_LAST else BubbleImageView.Style.IN_LAST
+ else -> BubbleImageView.Style.ONLY
+ }
+
+ val embeddedPicture = it.embeddedPicture
+ if (embeddedPicture == null) {
+ holder.frame.layoutParams.height = (holder.frame.layoutParams.width / 2)
+ setTint(secondaryColor)
+ setImageResource(R.drawable.rectangle)
+ } else {
+ holder.frame.layoutParams.height = holder.frame.layoutParams.width
+ setTint(null)
+ GlideApp.with(context)
+ .asBitmap()
+ .load(embeddedPicture)
+ .override(
+ holder.frame.layoutParams.width,
+ holder.frame.layoutParams.height
+ )
+ .into(this)
+ }
}
}
-
- // embedded image
- val embeddedPicture = metaDataRetriever.embeddedPicture
- if (embeddedPicture == null) {
- holder.thumbnail.setTint(secondaryColor)
- holder.frame.layoutParams.height /= 2
- holder.thumbnail.requestLayout()
- } else {
- GlideApp.with(context)
- .asBitmap()
- .load(embeddedPicture)
- .into(holder.thumbnail)
- }
-
- metaDataRetriever.close()
}
}
\ No newline at end of file
diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/part/PartsAdapter.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/part/PartsAdapter.kt
index 68d26a1c..7449616c 100644
--- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/part/PartsAdapter.kt
+++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/part/PartsAdapter.kt
@@ -28,6 +28,7 @@ import dev.octoshrimpy.quik.common.util.extensions.forwardTouches
import dev.octoshrimpy.quik.extensions.isSmil
import dev.octoshrimpy.quik.extensions.isText
import dev.octoshrimpy.quik.feature.compose.BubbleUtils.canGroup
+import dev.octoshrimpy.quik.feature.compose.MessagesAdapter
import dev.octoshrimpy.quik.model.Message
import dev.octoshrimpy.quik.model.MmsPart
import io.reactivex.Observable
@@ -39,7 +40,7 @@ class PartsAdapter @Inject constructor(
fileBinder: FileBinder,
imageBinder: ImageBinder,
audioBinder: AudioBinder,
- vCardBinder: VCardBinder
+ vCardBinder: VCardBinder,
) : QkAdapter() {
private val partBinders = listOf(audioBinder, imageBinder, vCardBinder, fileBinder)
@@ -57,14 +58,22 @@ class PartsAdapter @Inject constructor(
private var next: Message? = null
private var holder: QkViewHolder? = null
private var bodyVisible: Boolean = true
+ private var audioState: MessagesAdapter.AudioState? = null
- fun setData(message: Message, previous: Message?, next: Message?, holder: QkViewHolder) {
+ fun setData(
+ message: Message,
+ previous: Message?,
+ next: Message?,
+ holder: QkViewHolder,
+ audioState: MessagesAdapter.AudioState?
+ ) {
this.message = message
this.previous = previous
this.next = next
this.holder = holder
this.bodyVisible = holder.body.visibility == View.VISIBLE
this.data = message.parts.filter { !it.isSmil() && !it.isText() }
+ this.audioState = audioState
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
@@ -80,9 +89,13 @@ class PartsAdapter @Inject constructor(
val canGroupWithPrevious = canGroup(message, previous) || position > 0
val canGroupWithNext = canGroup(message, next) || position < itemCount - 1 || bodyVisible
- partBinders
- .firstOrNull { it.canBindPart(part) }
- ?.bindPart(holder, part, message, canGroupWithPrevious, canGroupWithNext)
+ val binder = partBinders.firstOrNull { it.canBindPart(part) }
+
+ // if audioState is set and binder is audio type, set audioState into it
+ if ((audioState != null) && (binder is AudioBinder))
+ binder.audioState = audioState!!
+
+ binder?.bindPart(holder, part, message, canGroupWithPrevious, canGroupWithNext)
}
override fun getItemViewType(position: Int): Int {
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/java/com/moez/QKSMS/feature/scheduled/ScheduledMessageAttachmentAdapter.kt b/presentation/src/main/java/com/moez/QKSMS/feature/scheduled/ScheduledMessageAttachmentAdapter.kt
index 96a10ffc..e5f3e1b4 100644
--- a/presentation/src/main/java/com/moez/QKSMS/feature/scheduled/ScheduledMessageAttachmentAdapter.kt
+++ b/presentation/src/main/java/com/moez/QKSMS/feature/scheduled/ScheduledMessageAttachmentAdapter.kt
@@ -19,32 +19,112 @@
package dev.octoshrimpy.quik.feature.scheduled
import android.content.Context
+import android.content.Intent
+import android.media.MediaMetadataRetriever
import android.net.Uri
+import android.provider.MediaStore.MATCH_DEFAULT
+import android.provider.OpenableColumns
import android.view.LayoutInflater
+import android.view.View
import android.view.ViewGroup
+import com.bumptech.glide.Glide
import dev.octoshrimpy.quik.R
import dev.octoshrimpy.quik.common.base.QkAdapter
import dev.octoshrimpy.quik.common.base.QkViewHolder
-import dev.octoshrimpy.quik.util.GlideApp
-import kotlinx.android.synthetic.main.attachment_image_list_item.view.*
-import kotlinx.android.synthetic.main.scheduled_message_image_list_item.*
+import dev.octoshrimpy.quik.extensions.resourceExists
+import kotlinx.android.synthetic.main.scheduled_message_image_list_item.fileName
+import kotlinx.android.synthetic.main.scheduled_message_image_list_item.thumbnail
import javax.inject.Inject
+
class ScheduledMessageAttachmentAdapter @Inject constructor(
private val context: Context
) : QkAdapter() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
- val view = LayoutInflater.from(parent.context).inflate(R.layout.scheduled_message_image_list_item, parent, false)
- view.thumbnail.clipToOutline = true
-
- return QkViewHolder(view)
+ return QkViewHolder(
+ LayoutInflater
+ .from(parent.context)
+ .inflate(R.layout.scheduled_message_image_list_item, parent, false)
+ )
}
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
- val attachment = getItem(position)
+ val uri = getItem(position)
- GlideApp.with(context).load(attachment).into(holder.thumbnail)
+ // if uri target doesn't exist anymore
+ if (!uri.resourceExists(context)) {
+ holder.thumbnail.setImageResource(android.R.drawable.ic_delete)
+ holder.fileName.text = context.getString(R.string.attachment_missing)
+ holder.fileName.visibility = View.VISIBLE
+ return
+ }
+
+ val mimeType = context.contentResolver.getType(uri)
+
+ // if attachment mime type is image/* or video/*, use image/video-frame
+ if ((mimeType?.startsWith("image/") == true) ||
+ (mimeType?.startsWith("video/") == true)
+ ) {
+ Glide
+ .with(context)
+ .load(uri)
+ .into(holder.thumbnail)
+ return
+ }
+
+ // if audio mime type, try and use embedded image if one exists
+ if (mimeType?.startsWith("audio/") == true) {
+ val metaDataRetriever = MediaMetadataRetriever()
+ metaDataRetriever.setDataSource(context, uri)
+ val embeddedPicture = metaDataRetriever.embeddedPicture
+ if (embeddedPicture != null) {
+ Glide
+ .with(context)
+ .load(embeddedPicture)
+ .into(holder.thumbnail)
+ return
+ }
+ }
+
+ // try and use icon from default app for type
+ val intent = Intent(Intent.ACTION_VIEW).setDataAndType(uri, mimeType)
+ val appIcon = context
+ .packageManager
+ .resolveActivity(intent, MATCH_DEFAULT)
+ ?.loadIcon(context.packageManager)
+ if (appIcon != null)
+ Glide
+ .with(context)
+ .load(appIcon)
+ .into(holder.thumbnail)
+ else if (mimeType?.startsWith("audio/") == true)
+ // else, if audio, use default local audio icon
+ Glide
+ .with(context)
+ .load(R.drawable.ic_round_volume_up_24)
+ .into(holder.thumbnail)
+ else
+ // else, use default attachment icon
+ Glide
+ .with(context)
+ .load(R.drawable.ic_attachment_black_24dp)
+ .into(holder.thumbnail)
+
+ // else, show file name
+ val cursor = context.contentResolver.query(
+ uri, arrayOf(OpenableColumns.DISPLAY_NAME), null, null, null
+ )
+ cursor?.use {
+ try {
+ cursor.moveToFirst()
+ holder.fileName.text = cursor.getString(
+ cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME) ?: 0
+ )
+ holder.fileName.visibility = View.VISIBLE
+ } catch (e: Exception) {
+ }
+ }
}
}
diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/scheduled/ScheduledViewModel.kt b/presentation/src/main/java/com/moez/QKSMS/feature/scheduled/ScheduledViewModel.kt
index 4324c6da..c2f1489b 100644
--- a/presentation/src/main/java/com/moez/QKSMS/feature/scheduled/ScheduledViewModel.kt
+++ b/presentation/src/main/java/com/moez/QKSMS/feature/scheduled/ScheduledViewModel.kt
@@ -70,7 +70,7 @@ class ScheduledViewModel @Inject constructor(
view.composeIntent
.autoDisposable(view.scope())
- .subscribe { navigator.showCompose() }
+ .subscribe { navigator.showCompose(mode = "scheduling") }
view.upgradeIntent
.autoDisposable(view.scope())
diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsController.kt b/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsController.kt
index ff03200f..4c302dfe 100644
--- a/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsController.kt
+++ b/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsController.kt
@@ -41,7 +41,6 @@ import dev.octoshrimpy.quik.common.util.extensions.animateLayoutChanges
import dev.octoshrimpy.quik.common.util.extensions.setBackgroundTint
import dev.octoshrimpy.quik.common.util.extensions.setVisible
import dev.octoshrimpy.quik.common.widget.PreferenceView
-import dev.octoshrimpy.quik.common.widget.QkSwitch
import dev.octoshrimpy.quik.common.widget.TextInputDialog
import dev.octoshrimpy.quik.feature.settings.about.AboutController
import dev.octoshrimpy.quik.feature.settings.autodelete.AutoDeleteDialog
@@ -73,6 +72,7 @@ class SettingsController : QkController = mmsSizeDialog.adapter.menuItemClicks
+ override fun messageLinkHandlingSelected(): Observable = messageLinkHandlingDialog.adapter.menuItemClicks
+
override fun render(state: SettingsState) {
themePreview.setBackgroundTint(state.theme)
night.summary = state.nightModeSummary
@@ -195,6 +198,9 @@ class SettingsController : QkController syncingProgress.isVisible = false
@@ -254,6 +260,8 @@ class SettingsController : QkController
+ val index = messageLinkHandlingIds.indexOf(messageLinkHandlingId)
+ newState {
+ copy(
+ messageLinkHandlingSummary = messageLinkHandlingLabels[index],
+ messageLinkHandlingId = messageLinkHandlingId
+ )
+ }
+ }
+
disposables += syncRepo.syncProgress
.sample(16, TimeUnit.MILLISECONDS)
.distinctUntilChanged()
@@ -204,6 +217,8 @@ class SettingsPresenter @Inject constructor(
R.id.mmsSize -> view.showMmsSizePicker()
+ R.id.messsageLinkHandling -> view.showMessageLinkHandlingDialogPicker()
+
R.id.sync -> syncMessages.execute(Unit)
R.id.about -> view.showAbout()
@@ -294,6 +309,10 @@ class SettingsPresenter @Inject constructor(
view.mmsSizeSelected()
.autoDisposable(view.scope())
.subscribe(prefs.mmsSize::set)
+
+ view.messageLinkHandlingSelected()
+ .autoDisposable(view.scope())
+ .subscribe(prefs.messageLinkHandling::set)
}
}
\ No newline at end of file
diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsState.kt b/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsState.kt
index ea90b728..c87522bc 100644
--- a/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsState.kt
+++ b/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsState.kt
@@ -46,5 +46,7 @@ data class SettingsState(
val longAsMms: Boolean = false,
val maxMmsSizeSummary: String = "100KB",
val maxMmsSizeId: Int = 100,
+ val messageLinkHandlingSummary: String = "Ask before opening",
+ val messageLinkHandlingId: Int = 2,
val syncProgress: SyncRepository.SyncProgress = SyncRepository.SyncProgress.Idle
)
\ No newline at end of file
diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsView.kt b/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsView.kt
index d97a0229..b3396b49 100644
--- a/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsView.kt
+++ b/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsView.kt
@@ -34,6 +34,7 @@ interface SettingsView : QkViewContract {
fun signatureChanged(): Observable
fun autoDeleteChanged(): Observable
fun mmsSizeSelected(): Observable
+ fun messageLinkHandlingSelected(): Observable
fun showQksmsPlusSnackbar()
fun showNightModeDialog()
@@ -45,6 +46,7 @@ interface SettingsView : QkViewContract {
fun showAutoDeleteDialog(days: Int)
suspend fun showAutoDeleteWarningDialog(messages: Int): Boolean
fun showMmsSizePicker()
+ fun showMessageLinkHandlingDialogPicker()
fun showSwipeActions()
fun showThemePicker()
fun showAbout()
diff --git a/presentation/src/main/res/drawable/audio_preview_foreground.png b/presentation/src/main/res/drawable/audio_preview_foreground.png
index bf87f59e..21a73548 100644
Binary files a/presentation/src/main/res/drawable/audio_preview_foreground.png and b/presentation/src/main/res/drawable/audio_preview_foreground.png differ
diff --git a/presentation/src/main/res/drawable/ic_round_volume_up_24.xml b/presentation/src/main/res/drawable/ic_round_volume_up_24.xml
new file mode 100644
index 00000000..cb631566
--- /dev/null
+++ b/presentation/src/main/res/drawable/ic_round_volume_up_24.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/presentation/src/main/res/layout/attachment_image_list_item.xml b/presentation/src/main/res/layout/attachment_file_list_item.xml
similarity index 82%
rename from presentation/src/main/res/layout/attachment_image_list_item.xml
rename to presentation/src/main/res/layout/attachment_file_list_item.xml
index ff757f03..b14e7827 100644
--- a/presentation/src/main/res/layout/attachment_image_list_item.xml
+++ b/presentation/src/main/res/layout/attachment_file_list_item.xml
@@ -37,7 +37,17 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
- tools:src="@tools:sample/avatars" />
+ tools:src="@tools:sample/backgrounds/scenic[0]" />
+
+
diff --git a/presentation/src/main/res/layout/compose_activity.xml b/presentation/src/main/res/layout/compose_activity.xml
index eac3add4..9da2deb6 100644
--- a/presentation/src/main/res/layout/compose_activity.xml
+++ b/presentation/src/main/res/layout/compose_activity.xml
@@ -32,8 +32,6 @@
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="12dp"
- android:clipChildren="false"
- android:clipToPadding="false"
android:paddingTop="8dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintBottom_toTopOf="@id/messageBackground"
@@ -204,7 +202,7 @@
android:layout_height="56dp"
android:padding="10dp"
android:src="@drawable/ic_cancel_black_24dp"
- android:tint="?android:attr/textColorSecondary"
+ app:tint="?android:attr/textColorSecondary"
app:layout_constraintBottom_toTopOf="@id/scheduledSeparator"
app:layout_constraintEnd_toEndOf="@id/messageBackground" />
@@ -230,7 +228,7 @@
app:layout_constraintBottom_toTopOf="@id/message"
app:layout_constraintEnd_toEndOf="@id/messageBackground"
app:layout_constraintStart_toStartOf="@id/messageBackground"
- tools:listitem="@layout/attachment_image_list_item" />
+ tools:listitem="@layout/attachment_file_list_item" />
@@ -304,7 +302,7 @@
android:contentDescription="@string/compose_send_cd"
android:padding="10dp"
android:src="@drawable/ic_send_black_24dp"
- android:tint="?android:textColorSecondary"
+ app:tint="?android:textColorSecondary"
app:layout_constraintBottom_toBottomOf="@id/messageBackground"
app:layout_constraintEnd_toEndOf="parent" />
@@ -371,7 +369,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
- app:constraint_referenced_ids="contact,contactLabel,schedule,scheduleLabel,gallery,galleryLabel,camera,cameraLabel,attachingBackground" />
+ app:constraint_referenced_ids="contact,contactLabel,schedule,scheduleLabel,gallery,galleryLabel,attachAFileIcon,attachAFileLabel,camera,cameraLabel,attachingBackground" />
@@ -452,6 +450,43 @@
app:layout_constraintStart_toEndOf="@id/schedule"
app:layout_constraintTop_toTopOf="@id/schedule" />
+
+
+
+
+
+
.
-->
-
-
+ android:layout_marginEnd="36dp"
+ android:orientation="vertical">
-
+
-
+
-
+
-
+
-
+
-
+
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/presentation/src/main/res/layout/message_list_item_out.xml b/presentation/src/main/res/layout/message_list_item_out.xml
index b2942b2d..020e1cb6 100644
--- a/presentation/src/main/res/layout/message_list_item_out.xml
+++ b/presentation/src/main/res/layout/message_list_item_out.xml
@@ -17,133 +17,180 @@
~ You should have received a copy of the GNU General Public License
~ along with QKSMS. If not, see .
-->
-
-
-
-
-
-
-
-
+ android:orientation="vertical">
-
-
+
-
+
-
+
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/presentation/src/main/res/layout/mms_audio_preview_list_item.xml b/presentation/src/main/res/layout/mms_audio_preview_list_item.xml
index bcf28071..97fc8839 100644
--- a/presentation/src/main/res/layout/mms_audio_preview_list_item.xml
+++ b/presentation/src/main/res/layout/mms_audio_preview_list_item.xml
@@ -22,7 +22,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/frame"
android:layout_width="280dp"
- android:layout_height="280dp"
+ android:layout_height="140dp"
android:layout_marginTop="2dp"
android:clipChildren="false">
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" />
+
+
+
+
\ No newline at end of file
diff --git a/presentation/src/main/res/layout/settings_controller.xml b/presentation/src/main/res/layout/settings_controller.xml
index 19c392ed..e2687537 100644
--- a/presentation/src/main/res/layout/settings_controller.xml
+++ b/presentation/src/main/res/layout/settings_controller.xml
@@ -212,6 +212,15 @@
app:title="@string/settings_mms_size_title"
tools:summary="100KB" />
+
+
Send long messages as MMS
If your longer text messages are failing to send, or sending in the wrong order, you can send them as MMS messages instead. Additional charges may apply
- Auto-compress MMS attachments
+ Auto-compress MMS image attachments
Συγχρονισμός μηνυμάτων
Επανασυγχρονισμός μηνυμάτων με τη βάση δεδομένων SMS του Android
Σχετικά με το QUIK
diff --git a/presentation/src/main/res/values-fr/strings.xml b/presentation/src/main/res/values-fr/strings.xml
index a008813c..8a67cbf6 100644
--- a/presentation/src/main/res/values-fr/strings.xml
+++ b/presentation/src/main/res/values-fr/strings.xml
@@ -68,9 +68,9 @@
Faire de QUIK votre application SMS par défaut
Changer
Autorisation requise
- QUIK a besoin de l\'autorisation d’envoyer et de consulter des messages SMS
+ QUIK a besoin de l\'autorisation d\’envoyer et de consulter les messages SMS
QUIK a besoin de l\'autorisation d\'accéder aux contacts
- QUIK needs permission to display notifications
+ QUIK a besoin de l\'autorisation d\'afficher des notifications
Autoriser
Boite de réception
@@ -86,14 +86,14 @@
Débloquer les nouvelles fonctions sensationnelles et soutenir le développement
Vous aimez QUIK?
- Partagez un peu d’amour et évaluez-nous sur le Play Store !
- OK !
+ Partagez un peu d\’amour et évaluez-nous sur le Play Store!
+ OK!
ANNULER
Supprimer
- - Êtes-vous sûr de vouloir supprimer cette conversation ?
- - Êtes-vous sûr de vouloir supprimer %d conversations ?
+ - Êtes-vous sûr de vouloir supprimer cette conversation?
+ - Êtes-vous sûr de vouloir supprimer %d conversations?
- Êtes-vous sûr de vouloir supprimer ce message?
@@ -114,10 +114,10 @@
%1$d sur %2$d résultats
Envoyer en tant que message groupé
Les destinataires et les réponses seront visibles par tout le monde
- C\'est le début de votre conversation. Dites quelque chose de sympa !
+ C\'est le début de votre conversation. Dites quelque chose de sympa!
Fiche du contact
Programmé pour
- Le moment choisi doit être dans le futur !
+ Le moment choisi doit être dans le futur!
Vous devez déverrouiller QUIK+ pour utiliser la programmation de message
Ajouté aux messages programmés
Écrire un message…
@@ -130,16 +130,16 @@
Suivant
Effacer
Détails du message
- Type : %s
- De : %s
- À : %s
- Objet : %s
- Priorité : %s
- Taille : %s
- Envoyé : %s
- Reçu : %s
- Délivré : %s
- Code erreur : %d
+ Type: %s
+ De: %s
+ À: %s
+ Objet: %s
+ Priorité: %s
+ Taille: %s
+ Envoyé: %s
+ Reçu: %s
+ Délivré: %s
+ Code erreur: %d
Ajouter une pièce jointe
Joindre une photo
Prendre une photo
@@ -174,8 +174,8 @@
Restaurer à partir d\'une sauvegarde
Chargement…
Jamais
- Backup location
- Set folder
+ Emplacement de sauvegarde
+ Définir le dossier
Restauration
Sélectionner une sauvegarde
Déverrouillez QUIK+ pour utiliser la sauvegarde et la restauration
@@ -184,8 +184,8 @@
Restaurer à partir d’une sauvegarde
Arrêter la restauration
Les messages qui ont déjà été restaurés resteront sur votre appareil
- Select backup location
- Please select a folder to save your backups to
+ Sélectionnez l\'emplacement de sauvegarde
+ Veuillez sélectionner un dossier dans lequel enregistrer vos sauvegardes
%1$s\n%2$d messages
Erreur
Impossible de lire le fichier de sauvegarde
@@ -193,7 +193,7 @@
Sauvegardes
/QUIK/Backups
Aucune sauvegarde trouvée
- Actuellement, seulement la sauvegarde et la restauration des SMS sont pris en charge. Les MMS et les sauvegardes planifiées arriveront bientôt !
+ Actuellement, seulement la sauvegarde et la restauration des SMS sont pris en charge. Les MMS et les sauvegardes planifiées arriveront bientôt!
Sauvegarder maintenant
Analyse de la sauvegarde…
%d/%d messages
@@ -204,9 +204,9 @@
Programmé
Envoyer automatiquement un message, au moment précis que vous souhaitez
- Hé ! Quand était votre anniversaire déjà ?
+ Hé! Quand était votre anniversaire déjà ?
C’est le 23 décembre
- Joyeux anniversaire ! Regarde le grand ami que je suis, je me souviens de ton anniversaire
+ Joyeux anniversaire! Regarde le grand ami que je suis, je me souviens de ton anniversaire
Envoyé le 23 décembre
Programmer un message
@@ -339,7 +339,7 @@
Liste des modifications
Contact
Licence
- Droits d’auteur
+ Droits d\’auteur
Soutenir le développement, tout déverrouiller
Vous pouvez sauver un développeur affamé pour seulement %s
@@ -350,7 +350,7 @@
One-time purchase of %1$s %2$s
Déverrouiller + faire un don pour %1$s %2$s
- Merci de soutenir QUIK !
+ Merci de soutenir QUIK!
Vous avez maintenant accès à toutes les fonctionnalités de QUIK+
Une erreur s\'est produite. Merci de réessayer.
QUIK + est gratuit pour les utilisateurs de F-Droid ! Si vous souhaitez soutenir le développement, n’hésitez pas à faire un don.
@@ -375,7 +375,7 @@
Réponse automatique
Répondre automatiquement aux messages entrants avec une réponse prédéfinie
Plus
- QUIK est en cours de développement actif, et votre achat comprendra toutes les futures fonctionnalités QUIK + !
+ QUIK est en cours de développement actif, et votre achat comprendra toutes les futures fonctionnalités QUIK +!
Chargement…
Afficher plus de conversations
@@ -500,7 +500,7 @@
- J\'arrive
- Merci
- Ça a l\'air bien
- - Quoi de neuf ?
+ - Quoi de neuf?
- D\'accord
- Non
- Je t\'aime
diff --git a/presentation/src/main/res/values-gd/strings.xml b/presentation/src/main/res/values-gd/strings.xml
index e9e43c73..8c790a8e 100644
--- a/presentation/src/main/res/values-gd/strings.xml
+++ b/presentation/src/main/res/values-gd/strings.xml
@@ -254,7 +254,7 @@
Send long messages as MMS
If your longer text messages are failing to send, or sending in the wrong order, you can send them as MMS messages instead. Additional charges may apply
- Auto-compress MMS attachments
+ Auto-compress MMS image attachments
Sync messages
Re-sync your messages with the native Android SMS database
About QUIK
diff --git a/presentation/src/main/res/values-lt/strings.xml b/presentation/src/main/res/values-lt/strings.xml
index 22e2c9a0..ab1559e0 100644
--- a/presentation/src/main/res/values-lt/strings.xml
+++ b/presentation/src/main/res/values-lt/strings.xml
@@ -254,7 +254,7 @@
Send long messages as MMS
If your longer text messages are failing to send, or sending in the wrong order, you can send them as MMS messages instead. Additional charges may apply
- Auto-compress MMS attachments
+ Auto-compress MMS image attachments
Sinchronizuoti pranešimus
Iš naujo sinchronizuoti Android pranešimų duomenų bazę
Apie QUIK
diff --git a/presentation/src/main/res/values-ne/strings.xml b/presentation/src/main/res/values-ne/strings.xml
index 5921fd84..cad960c0 100644
--- a/presentation/src/main/res/values-ne/strings.xml
+++ b/presentation/src/main/res/values-ne/strings.xml
@@ -250,7 +250,7 @@
Send long messages as MMS
If your longer text messages are failing to send, or sending in the wrong order, you can send them as MMS messages instead. Additional charges may apply
- Auto-compress MMS attachments
+ Auto-compress MMS image attachments
Sync messages
Re-sync your messages with the native Android SMS database
About QUIK
diff --git a/presentation/src/main/res/values-ta/strings.xml b/presentation/src/main/res/values-ta/strings.xml
index 1319f51c..75b60836 100644
--- a/presentation/src/main/res/values-ta/strings.xml
+++ b/presentation/src/main/res/values-ta/strings.xml
@@ -250,7 +250,7 @@
நீண்ட செய்திகளை எம்.எம்.எஸ் ஆக அனுப்பு
If your longer text messages are failing to send, or sending in the wrong order, you can send them as MMS messages instead. Additional charges may apply
- Auto-compress MMS attachments
+ Auto-compress MMS image attachments
தகவல்களை ஒத்திசை
Re-sync your messages with the native Android SMS database
QUIK பற்றி
diff --git a/presentation/src/main/res/values-tl/strings.xml b/presentation/src/main/res/values-tl/strings.xml
index 3940f2bc..c156eaff 100644
--- a/presentation/src/main/res/values-tl/strings.xml
+++ b/presentation/src/main/res/values-tl/strings.xml
@@ -250,7 +250,7 @@
Send long messages as MMS
If your longer text messages are failing to send, or sending in the wrong order, you can send them as MMS messages instead. Additional charges may apply
- Auto-compress MMS attachments
+ Auto-compress MMS image attachments
Sync messages
Re-sync your messages with the native Android SMS database
About QUIK
diff --git a/presentation/src/main/res/values-ur/strings.xml b/presentation/src/main/res/values-ur/strings.xml
index 731e6f6e..029c80cc 100644
--- a/presentation/src/main/res/values-ur/strings.xml
+++ b/presentation/src/main/res/values-ur/strings.xml
@@ -250,7 +250,7 @@
Send long messages as MMS
If your longer text messages are failing to send, or sending in the wrong order, you can send them as MMS messages instead. Additional charges may apply
- Auto-compress MMS attachments
+ Auto-compress MMS image attachments
Sync messages
Re-sync your messages with the native Android SMS database
About QUIK
diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml
index 99f8d9b6..db3e19c8 100644
--- a/presentation/src/main/res/values/strings.xml
+++ b/presentation/src/main/res/values/strings.xml
@@ -141,6 +141,7 @@
Delivered: %s
Error code: %d
Add an attachment
+ Attach any file
Attach a photo
Take a photo
Schedule message
@@ -151,6 +152,12 @@
%s selected, change SIM card
Send message
+ Cancel
+ Send now
+ SIM number
+ Message item
+ Attachment
+
Sending…
Delivered %s
Failed to send. Tap to try again
@@ -211,6 +218,7 @@
Sending on December 23rd
Schedule a message
Scheduled message
+ Missing
- Send now
- Copy text
@@ -237,7 +245,10 @@
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
@@ -284,7 +295,8 @@
Send long messages as MMS
If your longer text messages are failing to send, or sending in the wrong order, you can send them as MMS messages instead. Additional charges may apply
- Auto-compress MMS attachments
+ Auto-compress MMS image attachments
+ Link handling in messages
Sync messages
Re-sync your messages with the native Android SMS database
About QUIK
@@ -494,6 +506,18 @@
- 0
+
+ - Block
+ - Allow
+ - Ask before opening
+
+
+
+ - 0
+ - 1
+ - 2
+
+
- Okay
- Give me a moment
@@ -510,4 +534,8 @@
No Messages
Speak unseen messages
+ External Link Warning
+ Some links may be unsafe or redirect you unexpectedly. Review the link below before proceeding:\n\n%1$s\n\nDo you want to continue?
+ Yes, open the link
+ No