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

Handle new intent when a link is shared from another app using long press #629

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
23 changes: 18 additions & 5 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)
// Put it in the address bar if any
clue?.let { iWebBrowser.setAddressBarText(it) }

//Fix for #628 - Handle when a link is long pressed on another app and shared to Fulguris
if (clue != null && URLUtil.isNetworkUrl(clue.trim())) {
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 @@ -1135,9 +1150,7 @@ class TabsManager @Inject constructor(
lastTab()?.isNewTab = true
}
} else {
newTab(UrlInitializer(url), true)
shouldClose = true
lastTab()?.isNewTab = true
launchNewTabAndActivate(url)
}
}
}
Expand Down
Loading