From d84a2b8f253744c4ccf4e27f2807b2e98cfac391 Mon Sep 17 00:00:00 2001 From: MinhDV Date: Wed, 18 Oct 2023 15:54:03 +0700 Subject: [PATCH] TW-789 Fix open apk --- .../model/preview_file/supported_preview_file_types.dart | 2 ++ lib/pages/chat/chat.dart | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/lib/domain/model/preview_file/supported_preview_file_types.dart b/lib/domain/model/preview_file/supported_preview_file_types.dart index 18d280c924..4609d91c2d 100644 --- a/lib/domain/model/preview_file/supported_preview_file_types.dart +++ b/lib/domain/model/preview_file/supported_preview_file_types.dart @@ -29,6 +29,8 @@ class SupportedPreviewFileTypes { static const pdfMimeTypes = ['application/pdf', 'application/rtf']; + static const apkMimeTypes = ['application/vnd.android.package-archive']; + static const xlsMimeTypes = [ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.oasis.opendocument.spreadsheet', diff --git a/lib/pages/chat/chat.dart b/lib/pages/chat/chat.dart index d259222981..cf068d335c 100644 --- a/lib/pages/chat/chat.dart +++ b/lib/pages/chat/chat.dart @@ -620,6 +620,11 @@ class ChatController extends State required DownloadFileForPreviewResponse downloadFileForPreviewResponse, }) async { final mimeType = downloadFileForPreviewResponse.mimeType; + if (Platform.isAndroid && + SupportedPreviewFileTypes.apkMimeTypes.contains(mimeType)) { + await Share.shareXFiles([XFile(downloadFileForPreviewResponse.filePath)]); + return; + } final openResults = await OpenFile.open( downloadFileForPreviewResponse.filePath, type: mimeType,