Skip to content
This repository has been archived by the owner on Jul 5, 2021. It is now read-only.

Commit

Permalink
Fixes Bugzilla issue 1681103
Browse files Browse the repository at this point in the history
  • Loading branch information
st3fan committed Apr 6, 2021
1 parent a428021 commit 18bfd62
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
25 changes: 16 additions & 9 deletions app/src/main/java/org/mozilla/focus/fragment/BrowserFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import android.util.DisplayMetrics
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.View.GONE
import android.view.ViewGroup
import android.view.ViewGroup.MarginLayoutParams
import android.view.ViewStub
Expand Down Expand Up @@ -946,7 +947,7 @@ class BrowserFragment : LocaleAwareFragment(), BrowserScreen, LifecycleOwner, Ba
isFromExternal: Boolean,
onViewReadyCallback: Runnable?
) {
updateURL(url)
loadedUrl = url
if (SupportUtils.isUrl(url)) {
if (openNewTab) {
sessionManager.addTab(url, TabUtil.argument(null, isFromExternal, true))
Expand Down Expand Up @@ -1150,7 +1151,13 @@ class BrowserFragment : LocaleAwareFragment(), BrowserScreen, LifecycleOwner, Ba
if (!isForegroundSession(session)) {
return
}
updateURL(url)
// Prevent updateURL when directly entering URL in the address bar.
if (chromeViewModel.openUrl.value?.url ?: "" != url) {
updateURL(url)
} else if (chromeViewModel.openUrl.value?.url ?: "" != "") {
chromeViewModel.openUrl.value!!.url = ""
}

shoppingSearchPromptMessageViewModel.checkShoppingSearchPromptVisibility(url)
}

Expand Down Expand Up @@ -1231,12 +1238,6 @@ class BrowserFragment : LocaleAwareFragment(), BrowserScreen, LifecycleOwner, Ba

override fun onTitleChanged(session: Session, title: String?) {
chromeViewModel.onFocusedTitleChanged(title)
if (!isForegroundSession(session)) {
return
}
if (url != session.url) {
updateURL(session.url)
}
}

override fun onReceivedIcon(icon: Bitmap?) {}
Expand Down Expand Up @@ -1433,7 +1434,13 @@ class BrowserFragment : LocaleAwareFragment(), BrowserScreen, LifecycleOwner, Ba
dismissGeoDialog()
updateURL(tab.url)
shoppingSearchPromptMessageViewModel.checkShoppingSearchPromptVisibility(tab.url)
progress_bar.progress = 0

if (tab.progress == 0 || tab.progress == 100) {
progress_bar.visibility = GONE
} else {
progress_bar.progress = tab.progress
}

val identity = if (tab.securityInfo.secure) SITE_LOCK else SITE_GLOBE
site_identity.setImageLevel(identity)
hideFindInPage()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,9 @@ class ChromeViewModel(
)

data class OpenUrlAction(
val url: String,
val withNewTab: Boolean,
val isFromExternal: Boolean
var url: String,
var withNewTab: Boolean,
var isFromExternal: Boolean
)

data class ScreenCaptureTelemetryData(val mode: String, val position: Int) : Parcelable {
Expand Down
2 changes: 0 additions & 2 deletions app/src/webkit/java/org/mozilla/focus/webkit/WebkitView.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,6 @@ public void loadUrl(String url) {
if (!webViewClient.shouldOverrideUrlLoading(this, url)) {
super.loadUrl(url);
}

webViewClient.notifyCurrentURL(url);
}

public void reload() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ class TabViewEngineSession constructor(

class ViewClient(private val es: TabViewEngineSession) : TabViewClient() {
override fun onPageStarted(url: String?) {
es.notifyObservers { onLoadingStateChange(true) }
url?.let { es.notifyObservers { onLocationChange(it) } }
es.notifyObservers { onLoadingStateChange(true) }

es.tabView?.let {
es.notifyObservers {
Expand Down Expand Up @@ -196,7 +196,6 @@ class TabViewEngineSession constructor(
}
// This is a hack, Webview often doesn't give us the latest url even in OnPageLoaded
// We utilize this callback which usually returns later as the last chance.
view.url?.let { es.notifyObservers { onLocationChange(it) } }
es.notifyObservers {
onNavigationStateChange(view.canGoBack(), view.canGoForward())
}
Expand Down

0 comments on commit 18bfd62

Please sign in to comment.