commit f9494bc5f6050fa075f3c248110aef6bc44d7e22
Author: JabJab <noreply@xmpp.tel>
Date: Tue Aug 25 17:02:36 2026 +0300
Fixed a crash when previewing a voice recording before sending
---
build.gradle | 2 +-
.../tel/xmpp/jabjab/persistance/FileBackend.java | 22 ----------------------
.../xmpp/jabjab/services/NotificationService.java | 6 ++----
src/main/res/xml/file_paths.xml | 9 +++++----
4 files changed, 8 insertions(+), 31 deletions(-)
diff --git a/build.gradle b/build.gradle
index 5974681..162695a 100644
--- a/build.gradle
+++ b/build.gradle
@@ -113,7 +113,7 @@ android {
defaultConfig {
minSdkVersion 23
- versionCode 42311
+ versionCode 42312
versionName "1.0.7"
applicationId "tel.xmpp.jabjab"
resValue "string", "applicationId", applicationId
diff --git a/src/main/java/tel/xmpp/jabjab/persistance/FileBackend.java b/src/main/java/tel/xmpp/jabjab/persistance/FileBackend.java
index b98ca8f..93b2e97 100644
--- a/src/main/java/tel/xmpp/jabjab/persistance/FileBackend.java
+++ b/src/main/java/tel/xmpp/jabjab/persistance/FileBackend.java
@@ -394,28 +394,6 @@ public class FileBackend {
}
}
- public static Uri getMediaUri(Context context, File file) {
- final String filePath = file.getAbsolutePath();
- try (final Cursor cursor =
- context.getContentResolver()
- .query(
- MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
- new String[] {MediaStore.Images.Media._ID},
- MediaStore.Images.Media.DATA + "=? ",
- new String[] {filePath},
- null)) {
- if (cursor != null && cursor.moveToFirst()) {
- final int id =
- cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.MediaColumns._ID));
- return Uri.withAppendedPath(
- MediaStore.Images.Media.EXTERNAL_CONTENT_URI, String.valueOf(id));
- } else {
- return null;
- }
- } catch (final Exception e) {
- return null;
- }
- }
public static void updateFileParams(Message message, String url, long size) {
message.setBody(url + '|' + size);
diff --git a/src/main/java/tel/xmpp/jabjab/services/NotificationService.java b/src/main/java/tel/xmpp/jabjab/services/NotificationService.java
index e14689f..78bf6b2 100644
--- a/src/main/java/tel/xmpp/jabjab/services/NotificationService.java
+++ b/src/main/java/tel/xmpp/jabjab/services/NotificationService.java
@@ -1612,7 +1612,7 @@ public class NotificationService {
sender);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && isImageMessage(message)) {
final Uri dataUri =
- FileBackend.getMediaUri(
+ FileBackend.getUriForFile(
mXmppConnectionService,
mXmppConnectionService.getFileBackend().getFile(message));
NotificationCompat.MessagingStyle.Message imageMessage =
@@ -1621,9 +1621,7 @@ public class NotificationService {
.first,
message.getTimeSent(),
sender);
- if (dataUri != null) {
- imageMessage.setData(message.getMimeType(), dataUri);
- }
+ imageMessage.setData(message.getMimeType(), dataUri);
messagingStyle.addMessage(imageMessage);
} else {
messagingStyle.addMessage(
diff --git a/src/main/res/xml/file_paths.xml b/src/main/res/xml/file_paths.xml
index 99d5bf3..0dcb81f 100644
--- a/src/main/res/xml/file_paths.xml
+++ b/src/main/res/xml/file_paths.xml
@@ -18,10 +18,11 @@
<cache-path
name="camera"
path="Camera/" />
- <!-- Voice recordings will initially be stored in this cache directory.
- When sending it will be copied over.
- Exposing this path via file provider is only necessary for playing the preview. -->
- <cache-path
+ <!-- Voice recordings are staged here before sending (see FileBackend.Cache.recording()) —
+ getFilesDir(), not getCacheDir(), since Android can otherwise wipe an unsent recording
+ under storage pressure with no warning. Exposing this path via file provider is necessary
+ for the compose-bar preview player (MediaPreviewAdapter calls getUriForUri() on it). -->
+ <files-path
name="recordings"
path="Recordings" />
<cache-path
Built with passion for open-source software, XMPP, privacy, and security —
the belief that people deserve communication tools that serve them, not surveil them.
Dedicated to every brave man and woman who stands up against tyranny and oppression across the world.
And in memory of those who were silenced before they could speak freely.