mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-20 12:48:53 +01:00
Test stt rebase (#11)
* Update build-on-pull.yml Update's versions. * Update build-on-pull.yml Update Versions and add code to add the signing keys to the build. * Update build-on-pull.yml * Fixes the size of the icon.png. * Update build-on-pull.yml Fixes the formatting of the keystore injections. * Update build-on-pull.yml Changes it to only set up a NoAnalyticsDebug. * Update build-on-pull.yml Remove --stacktrace. * attachment context menu for save, share, forward and open externally remove share icons from audio and file attachment types add forward and open externally to gallery menu so it matches attachment context menu new icon/button for resend message * Update build-and-release.yml * Update build-on-pull.yml * Update PR-deploy.yml * Update build-and-release.yml * Update PR-deploy.yml * fix npe when setting out icons in messagesadapter when in message * Update strings.xml Change to "Leave A Star". * new setting to show/hide new stt button - defaults to 'show' to enable discovery by user. move compose stt feature from double-tap compose entry box to new button on compose activity * change tools view to 'on' for messageList * changes to ingest all attachments in a standard manner. does not change user-facing functionality * changes to make the speed-to-text button drag-and-dropable * rebased to latest master * changes to fix non-reset media player re-use crash * manual update to fix my rebase merge * changes to record audio for audio message from bluetooth sco device (ie bluetooth headset or earbuds) if connected at time of record * changes to fix a bug that appeared to be a race condition between deleting mms parts (attachments) and removing the message data from the realm db when deleting a message. there could be attempts to access part data that no longer exists. protected where the access was being attempted. * Update compose.xml Fixed showing the copy text details, rather than message details. * changes to enable a delete/clear menu icon on compose screen when there is message contents to clear - ie a schedule set, text input or attachments added * changed to reset all necessary state, regardless of editingMode, in clearCurrentMessageIntent handler * changes to make scheduled messages activity ui compliant with the rest of the app message listing activities. now allows sending and deleting multiple scheduled messages at once * fixed title of send now confirm dialog --------- Co-authored-by: octoshrimpy <octoshrimpy@users.noreply.github.com> Co-authored-by: gavine99 <github@xymail.tk>
This commit is contained in:
@@ -53,6 +53,9 @@ class SendMessage @Inject constructor(
|
||||
}
|
||||
messageRepo.sendMessage(params.subId, threadId, params.addresses, params.body, params.attachments,
|
||||
params.delay)
|
||||
|
||||
// delete attachment local files, if any, because they're saved to mms db by now
|
||||
params.attachments.forEach { it.removeCacheFile() }
|
||||
}
|
||||
.mapNotNull {
|
||||
// If the threadId wasn't provided, then it's probably because it doesn't exist in Realm.
|
||||
|
||||
@@ -47,11 +47,11 @@ class SendScheduledMessage @Inject constructor(
|
||||
}
|
||||
.map { message ->
|
||||
val threadId = TelephonyCompat.getOrCreateThreadId(context, message.recipients)
|
||||
val attachments = message.attachments.mapNotNull(Uri::parse).map { Attachment(it) }
|
||||
val attachments = message.attachments.mapNotNull(Uri::parse).map { Attachment(context, it) }
|
||||
SendMessage.Params(message.subId, threadId, message.recipients, message.body, attachments)
|
||||
}
|
||||
.flatMap(sendMessage::buildObservable)
|
||||
.doOnNext { scheduledMessageRepo.deleteScheduledMessage(params) }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@ interface PermissionManager {
|
||||
|
||||
fun hasStorage(): Boolean
|
||||
|
||||
fun hasRecordAudio(): Boolean
|
||||
|
||||
fun hasExactAlarms(): Boolean
|
||||
|
||||
}
|
||||
|
||||
@@ -18,51 +18,79 @@
|
||||
*/
|
||||
package dev.octoshrimpy.quik.model
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.ContentResolver
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.provider.ContactsContract
|
||||
import android.provider.OpenableColumns
|
||||
import android.webkit.MimeTypeMap
|
||||
import androidx.core.net.toFile
|
||||
import androidx.core.view.inputmethod.InputContentInfoCompat
|
||||
|
||||
|
||||
class Attachment(
|
||||
private val uri: Uri? = null,
|
||||
private val inputContent: InputContentInfoCompat? = null
|
||||
@SuppressLint("Range")
|
||||
class Attachment (
|
||||
context: Context,
|
||||
var uri: Uri = Uri.EMPTY,
|
||||
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 ?: Uri.EMPTY
|
||||
else uri ?: Uri.EMPTY
|
||||
)
|
||||
init {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1)
|
||||
uri = inputContent?.contentUri ?: uri
|
||||
|
||||
// if constructed with a uri to a contact, convert uri to associated vcard uri
|
||||
if (context.contentResolver.getType(uri)?.lowercase() ==
|
||||
ContactsContract.Contacts.CONTENT_ITEM_TYPE
|
||||
) {
|
||||
uri = try {
|
||||
Uri.withAppendedPath(
|
||||
ContactsContract.Contacts.CONTENT_VCARD_URI,
|
||||
context.contentResolver.query(
|
||||
uri, null, null, null, null
|
||||
)?.use {
|
||||
it.moveToFirst()
|
||||
it.getString(it.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY)) ?: ""
|
||||
}
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
Uri.EMPTY
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getType(context: Context): String {
|
||||
return context.contentResolver.getType(getUri()) ?: "application/octect-stream"
|
||||
var retVal: String? = null
|
||||
when (uri.scheme) {
|
||||
ContentResolver.SCHEME_CONTENT -> retVal = context.contentResolver.getType(uri)
|
||||
ContentResolver.SCHEME_FILE -> retVal =
|
||||
MimeTypeMap.getSingleton().getMimeTypeFromExtension(uri.toFile().extension)
|
||||
}
|
||||
return retVal ?: "application/octect-stream"
|
||||
}
|
||||
|
||||
fun getName(context: Context): String {
|
||||
var retVal: String? = null
|
||||
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*/ }
|
||||
when (uri.scheme) {
|
||||
ContentResolver.SCHEME_CONTENT -> {
|
||||
context.contentResolver.query(
|
||||
uri, arrayOf(OpenableColumns.DISPLAY_NAME), null, null, null
|
||||
)?.use {
|
||||
it.moveToFirst()
|
||||
retVal = it.getString(it.getColumnIndex(OpenableColumns.DISPLAY_NAME))
|
||||
}
|
||||
}
|
||||
|
||||
return "unknown"
|
||||
ContentResolver.SCHEME_FILE -> retVal = uri.toFile().name
|
||||
}
|
||||
} catch (e: Exception) { /* nothing */
|
||||
}
|
||||
|
||||
return retVal ?: "unknown"
|
||||
}
|
||||
|
||||
fun isVCard(context: Context): Boolean {
|
||||
@@ -75,53 +103,60 @@ class Attachment(
|
||||
}
|
||||
|
||||
fun isAudio(context: Context): Boolean {
|
||||
val mimeType = getType(context)
|
||||
return (mimeType.startsWith("audio/"))
|
||||
return (getType(context).startsWith("audio/"))
|
||||
}
|
||||
|
||||
fun isImage(context: Context): Boolean {
|
||||
val mimeType = getType(context)
|
||||
return (mimeType.startsWith("image/"))
|
||||
return (getType(context).startsWith("image/"))
|
||||
}
|
||||
|
||||
fun getSize(context: Context): Long {
|
||||
var retVal: Long? = null
|
||||
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 */ }
|
||||
when (uri.scheme) {
|
||||
ContentResolver.SCHEME_CONTENT -> {
|
||||
context.contentResolver.query(
|
||||
uri, arrayOf(OpenableColumns.SIZE), null, null, null
|
||||
)?.use {
|
||||
it.moveToFirst()
|
||||
retVal = it.getLong(it.getColumnIndex(OpenableColumns.SIZE))
|
||||
}
|
||||
}
|
||||
|
||||
return -1
|
||||
ContentResolver.SCHEME_FILE -> retVal = uri.toFile().length()
|
||||
}
|
||||
} catch (e: Exception) { /* nothing */
|
||||
}
|
||||
|
||||
return retVal ?: -1
|
||||
}
|
||||
|
||||
fun getResourceBytes(context: Context): ByteArray {
|
||||
if (resourceBytes != null)
|
||||
return resourceBytes!!
|
||||
|
||||
resourceBytes = ByteArray(0)
|
||||
|
||||
try {
|
||||
context.contentResolver.openInputStream(getUri())?.use {
|
||||
context.contentResolver.openInputStream(uri)?.use {
|
||||
resourceBytes = it.readBytes()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
|
||||
return resourceBytes!!
|
||||
return resourceBytes ?: ByteArray(0)
|
||||
}
|
||||
|
||||
fun releaseResourceBytes() {
|
||||
resourceBytes = null
|
||||
}
|
||||
|
||||
fun removeCacheFile(): Boolean {
|
||||
// all file:// scheme files are local to the app cache dir, so can be deleted
|
||||
if (uri.scheme == ContentResolver.SCHEME_FILE) {
|
||||
return try { uri.toFile().delete() }
|
||||
catch (e: Exception) { false }
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
class Attachments(attachments: List<Attachment>) : List<Attachment> by attachments
|
||||
|
||||
@@ -50,4 +50,7 @@ interface ScheduledMessageRepository {
|
||||
*/
|
||||
fun deleteScheduledMessage(id: Long)
|
||||
|
||||
// delete multiple scheduled messages by id list
|
||||
fun deleteScheduledMessages(ids: List<Long>)
|
||||
|
||||
}
|
||||
@@ -108,6 +108,9 @@ class Preferences @Inject constructor(
|
||||
val black = rxPrefs.getBoolean("black", false)
|
||||
val autoColor = rxPrefs.getBoolean("autoColor", true)
|
||||
val systemFont = rxPrefs.getBoolean("systemFont", false)
|
||||
val showStt = rxPrefs.getBoolean("showStt", true)
|
||||
val showSttOffsetX = rxPrefs.getFloat("showSttOffsetX", Float.MIN_VALUE)
|
||||
val showSttOffsetY = rxPrefs.getFloat("showSttOffsetY", Float.MIN_VALUE)
|
||||
val textSize = rxPrefs.getInteger("textSize", TEXT_SIZE_NORMAL)
|
||||
val blockingManager = rxPrefs.getInteger("blockingManager", BLOCKING_MANAGER_QKSMS)
|
||||
val drop = rxPrefs.getBoolean("drop", false)
|
||||
|
||||
Reference in New Issue
Block a user