2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-03 23:15:31 +00:00

For #2393 - SearchTermsTapped even on URL should search (#2398)

This commit is contained in:
Emily Kager 2019-05-09 14:21:33 -07:00 committed by Colin Lee
parent 60fe8de3ec
commit e4b4934f53
2 changed files with 8 additions and 5 deletions

View File

@ -147,15 +147,17 @@ open class HomeActivity : AppCompatActivity() {
openToBrowser(BrowserDirection.FromGlobal, customTabSessionId)
}
@Suppress("LongParameterList")
fun openToBrowserAndLoad(
searchTermOrURL: String,
newTab: Boolean,
from: BrowserDirection,
customTabSessionId: String? = null,
engine: SearchEngine? = null
engine: SearchEngine? = null,
forceSearch: Boolean = false
) {
openToBrowser(from, customTabSessionId)
load(searchTermOrURL, newTab, engine)
load(searchTermOrURL, newTab, engine, forceSearch)
}
fun openToBrowser(from: BrowserDirection, customTabSessionId: String? = null) {
@ -180,7 +182,7 @@ open class HomeActivity : AppCompatActivity() {
navHost.navController.navigate(directions)
}
private fun load(searchTermOrURL: String, newTab: Boolean, engine: SearchEngine?) {
private fun load(searchTermOrURL: String, newTab: Boolean, engine: SearchEngine?, forceSearch: Boolean) {
val isPrivate = this.browsingModeManager.isPrivate
val loadUrlUseCase = if (newTab) {
@ -198,7 +200,7 @@ open class HomeActivity : AppCompatActivity() {
} else components.useCases.searchUseCases.defaultSearch.invoke(searchTerms, engine)
}
if (searchTermOrURL.isUrl()) {
if (!forceSearch && searchTermOrURL.isUrl()) {
loadUrlUseCase.invoke(searchTermOrURL.toNormalizedUrl())
} else {
searchUseCase.invoke(searchTermOrURL)

View File

@ -228,7 +228,8 @@ class SearchFragment : Fragment(), BackHandler {
searchTermOrURL = it.searchTerms,
newTab = sessionId == null,
from = BrowserDirection.FromSearch,
engine = it.engine
engine = it.engine,
forceSearch = true
)
val engine = it.engine ?: requireComponents