mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Prevent crash & show error toast when trying to open a password protected PDF
This commit is contained in:
parent
985a304df9
commit
616b7bb70f
3 changed files with 19 additions and 9 deletions
|
|
@ -278,13 +278,21 @@ class FileViewModel
|
|||
File(filePath),
|
||||
ParcelFileDescriptor.MODE_READ_ONLY
|
||||
)
|
||||
pdfRenderer = PdfRenderer(input)
|
||||
val count = pdfRenderer.pageCount
|
||||
Log.i("$TAG $count pages in file $filePath")
|
||||
pdfPages.postValue(count.toString())
|
||||
pdfCurrentPage.postValue("1")
|
||||
pdfRendererReadyEvent.postValue(Event(true))
|
||||
fileReadyEvent.postValue(Event(true))
|
||||
try {
|
||||
pdfRenderer = PdfRenderer(input)
|
||||
val count = pdfRenderer.pageCount
|
||||
Log.i("$TAG $count pages in file $filePath")
|
||||
pdfPages.postValue(count.toString())
|
||||
pdfCurrentPage.postValue("1")
|
||||
pdfRendererReadyEvent.postValue(Event(true))
|
||||
fileReadyEvent.postValue(Event(true))
|
||||
} catch (se: SecurityException) {
|
||||
// TODO FIXME: add support for password protected PDFs
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -513,7 +513,8 @@
|
|||
<string name="conversation_take_picture_label">Prendre une photo</string>
|
||||
<string name="conversation_pick_file_from_gallery_label">Ouvrir la gallerie</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_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_info_participants_list_title">Participants (%s)</string>
|
||||
<string name="conversation_info_add_participants_label">Ajouter des participants</string>
|
||||
|
|
@ -524,7 +525,7 @@
|
|||
<string name="conversation_info_admin_menu_unset_participant_admin">Retirer les droits admin</string>
|
||||
<string name="conversation_info_menu_go_to_contact">Voir le contact</string>
|
||||
<string name="conversation_info_menu_add_to_contacts">Ajouter aux contacts</string>
|
||||
<string name="conversation_info_dialog_delete_all_call_logs_title">Supprimer l\'historique ? </string>
|
||||
<string name="conversation_info_dialog_delete_all_call_logs_title">Supprimer l\'historique ?</string>
|
||||
<string name="conversation_info_dialog_delete_all_message">Tout les messages de cette conversation seront supprimés.</string>
|
||||
<string name="conversation_info_history_deleted_toast">Historique supprimé</string>
|
||||
<string name="conversation_info_participant_added_to_conversation_toast">%s a rejoint la conversation</string>
|
||||
|
|
|
|||
|
|
@ -555,6 +555,7 @@
|
|||
<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_info_participants_list_title">Group members (%s)</string>
|
||||
<string name="conversation_info_add_participants_label">Add participants</string>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue