Skip to content

Commit

Permalink
Fixed: Not able to open a ZIM file from Samsung's file explorer.
Browse files Browse the repository at this point in the history
  • Loading branch information
MohitMaliDeveloper committed Oct 8, 2024
1 parent 83899c6 commit bf613a0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
12 changes: 12 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@
<data android:mimeType="application/octet-stream" />

</intent-filter>
<intent-filter>
<!-- Intent filter for Samsung's "My Files" file manager.
This is necessary because it returns an empty mimeType for ZIM files,
preventing our application from appearing in the suggestion list. -->
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<!-- This will match any URI that starts with "content://0@media/external/file/" -->
<data android:scheme="content" />
<data android:host="media" />
<data android:pathPrefix="/external/file/" />
<data android:mimeType="*/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />

Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/org/kiwix/kiwixmobile/main/KiwixMainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import android.graphics.drawable.Icon
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import org.kiwix.kiwixmobile.core.utils.files.Log
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.view.ActionMode
import androidx.core.os.ConfigurationCompat
Expand Down Expand Up @@ -226,6 +227,15 @@ class KiwixMainActivity : CoreMainActivity() {
}

private fun handleZimFileIntent(intent: Intent?) {
Log.e(
"INTENT_URI",
"handleZimFileIntent: ${intent?.data}" +
"\n scheme ${intent?.scheme}" +
"\n mimeType ${intent?.type}" +
"\n host ${intent?.data?.host}" +
"\n other uri things ${intent?.data?.encodedUserInfo}" +
"\n intent = $intent"
)
intent?.data?.let {
when (it.scheme) {
"file",
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/res/layout/fragment_reader.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
android:id="@+id/donation_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible"
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
Expand Down

0 comments on commit bf613a0

Please sign in to comment.