Improve error handling and remove backup file

Co-authored-by: adbenitez <24558636+adbenitez@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-14 02:11:23 +00:00
parent cf9a263b42
commit e8cf9b8dec
2 changed files with 4 additions and 27 deletions
@@ -563,7 +563,7 @@ public class ConversationFragment extends MessageSelectorFragment
File stickerFile = message.getFileAsFile();
if (stickerFile == null || !stickerFile.exists()) {
Toast.makeText(getContext(), R.string.cannot_save_file, Toast.LENGTH_SHORT).show();
Toast.makeText(getContext(), R.string.error, Toast.LENGTH_SHORT).show();
return;
}
@@ -577,21 +577,17 @@ public class ConversationFragment extends MessageSelectorFragment
String fileName = System.currentTimeMillis() + "_" + stickerFile.getName();
File destFile = new File(stickersDir, fileName);
try {
java.io.FileInputStream in = new java.io.FileInputStream(stickerFile);
java.io.FileOutputStream out = new java.io.FileOutputStream(destFile);
try (java.io.FileInputStream in = new java.io.FileInputStream(stickerFile);
java.io.FileOutputStream out = new java.io.FileOutputStream(destFile)) {
byte[] buffer = new byte[1024];
int read;
while ((read = in.read(buffer)) != -1) {
out.write(buffer, 0, read);
}
in.close();
out.close();
Toast.makeText(getContext(), R.string.add_to_sticker_collection, Toast.LENGTH_SHORT).show();
} catch (Exception e) {
Log.e(TAG, "Error saving sticker", e);
Toast.makeText(getContext(), R.string.cannot_save_file, Toast.LENGTH_SHORT).show();
Toast.makeText(getContext(), R.string.error, Toast.LENGTH_SHORT).show();
}
}
@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- WARNING: on modifications also update the layout-land folder. -->
<org.thoughtcrime.securesms.components.emoji.MediaKeyboard
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/emoji_drawer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<androidx.emoji2.emojipicker.EmojiPickerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/emoji_picker"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?emoji_drawer_background"
app:emojiGridColumns="9"/>
</org.thoughtcrime.securesms.components.emoji.MediaKeyboard>