Skip to content

Commit

Permalink
Handle new intent when a link is shared from another app using long p…
Browse files Browse the repository at this point in the history
…ress - Fixes Slion#628
  • Loading branch information
gkrishnaks committed Apr 9, 2024
1 parent a25a034 commit 2d4d502
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions app/src/main/java/fulguris/browser/TabsManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,15 @@ class TabsManager @Inject constructor(
}
}

/**
*
*/
private fun launchNewTabAndActivate(url: String) {
newTab(UrlInitializer(url), true)
shouldClose = true
lastTab()?.isNewTab = true
}

/**
* Initialize the state of the [TabsManager] based on previous state of the browser.
*
Expand Down Expand Up @@ -1114,8 +1123,14 @@ class TabsManager @Inject constructor(
if ("text/plain" == intent.type) {
// Get shared text
val clue = intent.getStringExtra(Intent.EXTRA_TEXT)

//Fix for #628 - Handle when a link is long pressed on another app and shared to Fulguris
if (clue != null && URLUtil.isNetworkUrl(clue)) {
launchNewTabAndActivate(clue)
} else{
// Put it in the address bar if any
clue?.let { iWebBrowser.setAddressBarText(it) }
}
}
// Cancel other operation as we won't open a tab here
null
Expand All @@ -1130,14 +1145,10 @@ class TabsManager @Inject constructor(
} else if (url != null) {
if (URLUtil.isFileUrl(url)) {
iWebBrowser.showBlockedLocalFileDialog {
newTab(UrlInitializer(url), true)
shouldClose = true
lastTab()?.isNewTab = true
launchNewTabAndActivate(url)
}
} else {
newTab(UrlInitializer(url), true)
shouldClose = true
lastTab()?.isNewTab = true
launchNewTabAndActivate(url)
}
}
}
Expand Down

0 comments on commit 2d4d502

Please sign in to comment.