limit bubble display of text to 5000 chars.

add instruction status message when bubble char limit exceeded.
add share text feature.
make copy and share text menu options only available when there is text in selected messages.
new FileProvider to share messages text files out of app's cache dir.
add message subject to copy messages text feature.
a lot of refactoring of MessagesAdapter class.
add new FileUtils class.
convert file logging to use new FileUtils class.
change MediaRecorder to use new FileUtils class.
housekeeping worker now cleans messages text cache files.
housekeeping worker now checks cache files older than 2 hours before deleting.
This commit is contained in:
gavine99
2025-03-26 17:28:34 +11:00
parent 669932ef0e
commit 8356008b88
18 changed files with 707 additions and 340 deletions
@@ -23,8 +23,8 @@ import android.media.AudioDeviceInfo
import android.media.MediaRecorder
import android.net.Uri
import android.os.Build
import androidx.core.net.toUri
import java.io.File
import androidx.core.net.toFile
import dev.octoshrimpy.quik.util.FileUtils
import java.util.UUID
object MediaRecorderManager : MediaRecorder() {
@@ -63,10 +63,16 @@ object MediaRecorderManager : MediaRecorder() {
fun startRecording(context: Context, preferredAudioDevice: AudioDeviceInfo? = null): Uri {
return try {
val file = File(
context.cacheDir,
AUDIO_FILE_PREFIX + UUID.randomUUID() + AUDIO_FILE_SUFFIX
val (newUri, e) = FileUtils.create(
FileUtils.Companion.Location.Cache,
context,
"$AUDIO_FILE_PREFIX${UUID.randomUUID()}$AUDIO_FILE_SUFFIX",
""
)
if (e is Exception)
throw e
uri = newUri
// ensure stopped before using again
stopRecording()
@@ -76,13 +82,12 @@ object MediaRecorderManager : MediaRecorder() {
setOutputFormat(OutputFormat.THREE_GPP)
setAudioEncoder(AudioEncoder.AMR_WB)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
preferredDevice = preferredAudioDevice
}
recordingState = RecordingState.DataSourceConfigured
setOutputFile(file.path)
setOutputFile(uri.toFile().path)
prepare()
recordingState = RecordingState.Prepared
@@ -90,8 +95,6 @@ object MediaRecorderManager : MediaRecorder() {
start()
recordingState = RecordingState.Recording
uri = file.toUri()
uri
}
catch (e: Exception) {