This repository has been archived by the owner on Nov 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 475
Fix "flashes" by using coverUntilFirstPaint() #8752
Labels
Comments
Since the paste link may expire, this is the code: diff --git a/components/browser/engine-gecko-nightly/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngine.kt b/components/browser/engine-gecko-nightly/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngine.kt
index 61e683fb5..d3fe115b5 100644
--- a/components/browser/engine-gecko-nightly/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngine.kt
+++ b/components/browser/engine-gecko-nightly/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngine.kt
@@ -143,7 +143,7 @@ class GeckoEngine(
* Creates a new Gecko-based EngineView.
*/
override fun createView(context: Context, attrs: AttributeSet?): EngineView {
- return GeckoEngineView(context, attrs)
+ return GeckoEngineView(context, attrs, preferredColorScheme=settings.preferredColorScheme)
}
/**
diff --git a/components/browser/engine-gecko-nightly/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngineView.kt b/components/browser/engine-gecko-nightly/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngineView.kt
index e1857f827..50e4d2ac9 100644
--- a/components/browser/engine-gecko-nightly/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngineView.kt
+++ b/components/browser/engine-gecko-nightly/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngineView.kt
@@ -5,7 +5,9 @@
package mozilla.components.browser.engine.gecko
import android.content.Context
+import android.content.res.Configuration
import android.graphics.Bitmap
+import android.graphics.Color
import android.util.AttributeSet
import android.widget.FrameLayout
import androidx.annotation.VisibleForTesting
@@ -13,6 +15,7 @@ import androidx.core.view.ViewCompat
import mozilla.components.browser.engine.gecko.selection.GeckoSelectionActionDelegate
import mozilla.components.concept.engine.EngineSession
import mozilla.components.concept.engine.EngineView
+import mozilla.components.concept.engine.mediaquery.PreferredColorScheme
import mozilla.components.concept.engine.selection.SelectionActionDelegate
import org.mozilla.geckoview.BasicSelectionActionDelegate
import org.mozilla.geckoview.GeckoResult
@@ -25,8 +28,10 @@ import org.mozilla.geckoview.GeckoSession
class GeckoEngineView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
- defStyleAttr: Int = 0
+ defStyleAttr: Int = 0,
+ preferredColorScheme: PreferredColorScheme? = null
) : FrameLayout(context, attrs, defStyleAttr), EngineView {
+
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
internal var geckoView = object : NestedGeckoView(context) {
@@ -59,6 +64,22 @@ class GeckoEngineView @JvmOverloads constructor(
// autofill behavior for us here.
@Suppress("WrongConstant")
ViewCompat.setImportantForAutofill(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES)
+
+ var colorScheme = preferredColorScheme
+ if (preferredColorScheme == PreferredColorScheme.System) {
+ colorScheme = if (context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
+ == Configuration.UI_MODE_NIGHT_YES) {
+ PreferredColorScheme.Dark
+ } else {
+ PreferredColorScheme.Light
+ }
+ }
+
+ if (colorScheme == PreferredColorScheme.Dark) {
+ coverUntilFirstPaint(0xFF2A2A2E.toInt())
+ } else {
+ coverUntilFirstPaint(Color.WHITE)
+ }
}
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) |
With that we should be able to get rid of the code that shows/hides |
Feel free to close #8747 as dupe since it's basically the same thing as this one. |
ekager
added a commit
to ekager/android-components
that referenced
this issue
Oct 26, 2020
ekager
added a commit
to ekager/android-components
that referenced
this issue
Oct 26, 2020
ekager
added a commit
to ekager/android-components
that referenced
this issue
Oct 27, 2020
ekager
added a commit
to ekager/android-components
that referenced
this issue
Oct 28, 2020
ekager
added a commit
to ekager/android-components
that referenced
this issue
Oct 29, 2020
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
GeckoView:
https://bugzilla.mozilla.org/show_bug.cgi?id=1665068
Example:
https://paste.mozilla.org/hOTy9OsU
┆Issue is synchronized with this Jira Task
The text was updated successfully, but these errors were encountered: