Skip to content

Commit 7cc267c

Browse files
zerox80guruz
authored andcommitted
Fix PDF opening with external viewers
1 parent c2a1128 commit 7cc267c

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

  • opencloudApp/src/main/java/eu/opencloud/android/extensions

opencloudApp/src/main/java/eu/opencloud/android/extensions/ActivityExt.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import android.net.Uri
3333
import android.text.method.LinkMovementMethod
3434
import android.util.TypedValue
3535
import android.view.inputmethod.InputMethodManager
36+
import android.webkit.MimeTypeMap
3637
import android.widget.LinearLayout
3738
import android.widget.TextView
3839
import android.widget.Toast
@@ -164,8 +165,8 @@ private fun getIntentForSavedMimeType(data: Uri, type: String): Intent {
164165
private fun getIntentForGuessedMimeType(storagePath: String, type: String, data: Uri): Intent? {
165166
var intentForGuessedMimeType: Intent? = null
166167
if (storagePath.lastIndexOf('.') >= 0) {
167-
val guessedMimeType = MimetypeIconUtil.getBestMimeTypeForOpen(type, storagePath)
168-
if (guessedMimeType != type) {
168+
val guessedMimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(storagePath.substring(storagePath.lastIndexOf('.') + 1))
169+
if (guessedMimeType != null && guessedMimeType != type) {
169170
intentForGuessedMimeType = Intent(Intent.ACTION_VIEW)
170171
intentForGuessedMimeType.setDataAndType(data, guessedMimeType)
171172
intentForGuessedMimeType.flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION

0 commit comments

Comments
 (0)