Skip to content

Commit

Permalink
Disable APK install
Browse files Browse the repository at this point in the history
  • Loading branch information
yostyle committed Dec 11, 2023
1 parent 781ef3e commit c8ca742
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<!-- tchap scan media -->
<string name="tchap_scan_media_untrusted_content_message">Le document (%s) a été filtré par la politique de sécurité</string>
<string name="tchap_scan_media_error_file_is_infected">Le fichier est infecté, impossible de le télécharger.</string>
<string name="tchap_scan_media_warning_apk">Pour des raisons de sécurité l’installation d’application à partir de ${app_name} n’est pas autorisée.</string>

<!-- tchap room settings -->
<string name="tchap_room_settings_convert_to_private">Convertir en salon privé (irréversible)</string>
Expand Down
1 change: 1 addition & 0 deletions library/ui-strings/src/main/res/values/strings_tchap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<!-- tchap scan media -->
<string name="tchap_scan_media_untrusted_content_message">The file (%s) has been blocked</string>
<string name="tchap_scan_media_error_file_is_infected">We have detected that this file is infected, so it cannot be downloaded.</string>
<string name="tchap_scan_media_warning_apk">For security reasons, installing applications from ${app_name} is not allowed.</string>

<!-- tchap room settings -->
<string name="tchap_room_settings_convert_to_private">Convert to private room (irreversible)</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -628,13 +628,23 @@ class TimelineFragment :
}

private fun startOpenFileIntent(action: RoomDetailViewEvents.OpenFile) {
if (action.mimeType == MimeTypes.Apk) {
installApk(action)
// Tchap: Remove the ability to install an app from Tchap (https://github.com/tchapgouv/tchap-android/issues/832)
if (action.mimeType in listOf(MimeTypes.Apk, "application/x-authorware-bin")) {
showApkAlert()
} else {
openFile(action)
}
}

private fun showApkAlert() {
MaterialAlertDialogBuilder(requireContext())
.setTitle(getString(R.string.dialog_title_warning))
.setMessage(getString(R.string.tchap_scan_media_warning_apk))
.setCancelable(false)
.setPositiveButton(R.string.ok, null)
.show()
}

private fun openFile(action: RoomDetailViewEvents.OpenFile) {
val intent = Intent(Intent.ACTION_VIEW).apply {
setDataAndTypeAndNormalize(action.uri, action.mimeType)
Expand Down

0 comments on commit c8ca742

Please sign in to comment.