Prevent app crash when trying to open a corrupted PDF sent/received by chat

This commit is contained in:
Sylvain Berfini 2025-09-17 13:36:15 +02:00
parent 808dc92cd7
commit 31e15ddfca
3 changed files with 10 additions and 3 deletions

View file

@ -291,7 +291,12 @@ class FileViewModel
Log.e("$TAG Can't open PDF, probably protected by a password: $se")
pdfCurrentPage.postValue("0")
pdfPages.postValue("0")
showRedToast(R.string.conversation_pdf_file_cant_be_opened_error_toast, R.drawable.warning_circle)
showRedToast(R.string.conversation_pdf_password_protected_file_cant_be_opened_error_toast, R.drawable.warning_circle)
} catch (e: Exception) {
Log.e("$TAG Can't open PDF, it may be corrupted: $e")
pdfCurrentPage.postValue("0")
pdfPages.postValue("0")
showRedToast(R.string.conversation_pdf_file_error_toast, R.drawable.warning_circle)
}
}
}

View file

@ -552,7 +552,8 @@
<string name="conversation_pick_file_from_gallery_label">Ouvrir la galerie</string>
<string name="conversation_pick_any_file_label">Choisir un fichier</string>
<string name="conversation_file_cant_be_opened_error_toast">Impossible d\'ouvrir le fichier !</string>
<string name="conversation_pdf_file_cant_be_opened_error_toast">Impossible d\'ouvrir un PDF protégé par mot de passe</string>
<string name="conversation_pdf_password_protected_file_cant_be_opened_error_toast">Impossible d\'ouvrir un PDF protégé par mot de passe</string>
<string name="conversation_pdf_file_error_toast">Impossible d\'ouvrir ce PDF, le fichier est peut-être corrompu</string>
<string name="conversation_editing_message_title">Modification du message</string>
<string name="conversation_message_edited_label">Modifié</string>
<string name="conversation_dialog_delete_chat_message_title">Supprimer le message ?</string>

View file

@ -595,7 +595,8 @@
<string name="conversation_pick_file_from_gallery_label">Open gallery</string>
<string name="conversation_pick_any_file_label">Pick file</string>
<string name="conversation_file_cant_be_opened_error_toast">File can\'t be opened!</string>
<string name="conversation_pdf_file_cant_be_opened_error_toast">Can\'t open password protected PDFs yet</string>
<string name="conversation_pdf_password_protected_file_cant_be_opened_error_toast">Can\'t open password protected PDFs yet</string>
<string name="conversation_pdf_file_error_toast">Can\'t open this PDF, file may be corrupted</string>
<string name="conversation_editing_message_title">Message being edited</string>
<string name="conversation_message_edited_label">Edited</string>
<string name="conversation_dialog_delete_chat_message_title">Delete this message?</string>