Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deeplink capability to manifest #109

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Alkitab/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@
<activity
android:name="yuku.alkitab.base.IsiActivity"
android:exported="true">

<!-- deeplink for opening bible reading page -->
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:scheme="https"
android:host="alkitab.app"
android:pathPrefix="/a" />
</intent-filter>

<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
20 changes: 16 additions & 4 deletions Alkitab/src/main/java/yuku/alkitab/base/IsiActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1361,15 +1361,27 @@ class IsiActivity : BaseLeftDrawerActivity(), LeftDrawer.Text.Listener {
private fun extractIntent(intent: Intent): IntentResult? {
dumpIntent(intent, "IsiActivity#onCreate")

return tryGetIntentResultFromView(intent)
return when (intent.action) {
"yuku.alkitab.action.VIEW" -> tryGetIntentResultFromCustomViewAction(intent)
Intent.ACTION_VIEW -> tryGetIntentResultFromViewAction(intent)
else -> null
}
}

private fun tryGetIntentResultFromViewAction(intent: Intent): IntentResult? {
val data = intent.data ?: return null
val pathSegments = data.pathSegments
if (pathSegments.size >= 2 && pathSegments[0] == "a") {
// TODO JS navigate content
IntentResult(0, false, 1)
}
return null
}

/**
* did we get here from VIEW intent?
*/
private fun tryGetIntentResultFromView(intent: Intent): IntentResult? {
if (intent.action != "yuku.alkitab.action.VIEW") return null

private fun tryGetIntentResultFromCustomViewAction(intent: Intent): IntentResult? {
val selectVerse = intent.getBooleanExtra("selectVerse", false)
val selectVerseCount = intent.getIntExtra("selectVerseCount", 1)

Expand Down