Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
Revert "For #6313 - On first load, hides engineView until firstConten…
Browse files Browse the repository at this point in the history
…tfulPaint"

This reverts commit d667629.
  • Loading branch information
ekager committed May 18, 2020
1 parent 9b16017 commit 32e74aa
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ import org.mozilla.fenix.helpers.click
import org.mozilla.fenix.helpers.ext.waitNotNull

class BrowserRobot {

fun verifyBrowserScreen() {
onView(ViewMatchers.withResourceName("browserLayout"))
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
}

fun verifyCurrentPrivateSession(context: Context) {
val session = context.components.core.sessionManager.selectedSession
assertTrue("Current session is private", session?.private!!)
Expand Down Expand Up @@ -73,7 +79,6 @@ class BrowserRobot {
*/
fun verifyPageContent(expectedText: String) {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
mDevice.waitNotNull(Until.findObject(By.res("org.mozilla.fenix.debug:id/engineView")), waitingTime)
mDevice.waitNotNull(Until.findObject(text(expectedText)), waitingTime)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
engineView = WeakReference(engineView),
swipeRefresh = WeakReference(swipeRefresh),
viewLifecycleScope = viewLifecycleOwner.lifecycleScope,
arguments = requireArguments(),
firstContentfulHappened = ::didFirstContentfulHappen
arguments = requireArguments()
).apply {
beginAnimateInIfNecessary()
}
Expand Down Expand Up @@ -863,15 +862,6 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
}
}

private fun didFirstContentfulHappen(): Boolean {
val store = context?.components?.core?.store
val tabState = store?.state?.tabs?.find {
it.id == (customTabSessionId
?: context?.components?.core?.sessionManager?.selectedSession?.id)
}
return tabState?.content?.firstContentfulPaint == true
}

/*
* Dereference these views when the fragment view is destroyed to prevent memory leaks
*/
Expand Down
26 changes: 18 additions & 8 deletions app/src/main/java/org/mozilla/fenix/browser/BrowserAnimator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ class BrowserAnimator(
private val engineView: WeakReference<EngineView>,
private val swipeRefresh: WeakReference<View>,
private val viewLifecycleScope: LifecycleCoroutineScope,
private val arguments: Bundle,
private val firstContentfulHappened: () -> Boolean
private val arguments: Bundle
) {

private val unwrappedEngineView: EngineView?
Expand All @@ -53,9 +52,22 @@ class BrowserAnimator(
}

doOnEnd {
if (firstContentfulHappened()) {
unwrappedEngineView?.asView()?.visibility = View.VISIBLE
}
unwrappedEngineView?.asView()?.visibility = View.VISIBLE
unwrappedSwipeRefresh?.background = null
arguments.putBoolean(SHOULD_ANIMATE_FLAG, false)
}

interpolator = DecelerateInterpolator()
duration = ANIMATION_DURATION
}

private val browserFadeInValueAnimator = ValueAnimator.ofFloat(0f, END_ANIMATOR_VALUE).apply {
addUpdateListener {
unwrappedSwipeRefresh?.alpha = it.animatedFraction
}

doOnEnd {
unwrappedEngineView?.asView()?.visibility = View.VISIBLE
unwrappedSwipeRefresh?.background = null
arguments.putBoolean(SHOULD_ANIMATE_FLAG, false)
}
Expand All @@ -80,9 +92,7 @@ class BrowserAnimator(
}
} else {
unwrappedSwipeRefresh?.alpha = 1f
if (firstContentfulHappened()) {
unwrappedEngineView?.asView()?.visibility = View.VISIBLE
}
unwrappedEngineView?.asView()?.visibility = View.VISIBLE
unwrappedSwipeRefresh?.background = null
}
}
Expand Down

0 comments on commit 32e74aa

Please sign in to comment.