For #6313 - Set session ClearColor through Engine DefaultSettings

upstream-sync
ekager 4 years ago
parent 4acf3c601d
commit e15f50712a

@ -26,11 +26,6 @@ object FeatureFlags {
*/
val showGridViewInTabsSettings = Config.channel.isNightlyOrDebug
/**
* Enables wait til first contentful paint
*/
val waitUntilPaintToDraw = Config.channel.isNightlyOrDebug
/**
* Enables downloads with external download managers.
*/

@ -247,9 +247,7 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
fragment = WeakReference(this),
engineView = WeakReference(engineView),
swipeRefresh = WeakReference(swipeRefresh),
viewLifecycleScope = WeakReference(viewLifecycleOwner.lifecycleScope),
settings = context.components.settings,
firstContentfulHappened = ::didFirstContentfulHappen
viewLifecycleScope = WeakReference(viewLifecycleOwner.lifecycleScope)
).apply {
beginAnimateInIfNecessary()
}
@ -659,28 +657,6 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
.collect { tab -> pipModeChanged(tab) }
}
if (context.settings().waitToShowPageUntilFirstPaint) {
store.flowScoped(viewLifecycleOwner) { flow ->
flow.mapNotNull { state ->
state.findTabOrCustomTabOrSelectedTab(
customTabSessionId
)
}
.ifChanged { it.content.firstContentfulPaint }
.collect {
val showEngineView =
it.content.firstContentfulPaint || it.content.progress == LOADING_PROGRESS_COMPLETE
if (showEngineView) {
engineView?.asView()?.isVisible = true
swipeRefresh?.alpha = 1f
} else {
engineView?.asView()?.isVisible = false
}
}
}
}
view.swipeRefresh.isEnabled =
FeatureFlags.pullToRefreshEnabled && context.settings().isPullToRefreshEnabledInBrowser
if (view.swipeRefresh.isEnabled) {
@ -1153,15 +1129,6 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
}
}
private fun didFirstContentfulHappen() =
if (components.settings.waitToShowPageUntilFirstPaint) {
val tab =
components.core.store.state.findTabOrCustomTabOrSelectedTab(customTabSessionId)
tab?.content?.firstContentfulPaint ?: false
} else {
true
}
/*
* Dereference these views when the fragment view is destroyed to prevent memory leaks
*/

@ -18,7 +18,6 @@ import mozilla.components.concept.engine.EngineView
import org.mozilla.fenix.R
import org.mozilla.fenix.components.toolbar.ToolbarPosition
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.utils.Settings
import java.lang.ref.WeakReference
/**
@ -29,9 +28,7 @@ class BrowserAnimator(
private val fragment: WeakReference<Fragment>,
private val engineView: WeakReference<EngineView>,
private val swipeRefresh: WeakReference<View>,
private val viewLifecycleScope: WeakReference<LifecycleCoroutineScope>,
private val settings: Settings,
private val firstContentfulHappened: () -> Boolean
private val viewLifecycleScope: WeakReference<LifecycleCoroutineScope>
) {
private val unwrappedEngineView: EngineView?
@ -41,17 +38,8 @@ class BrowserAnimator(
get() = swipeRefresh.get()
fun beginAnimateInIfNecessary() {
if (settings.waitToShowPageUntilFirstPaint) {
if (firstContentfulHappened()) {
viewLifecycleScope.get()?.launch {
delay(ANIMATION_DELAY)
unwrappedEngineView?.asView()?.visibility = View.VISIBLE
unwrappedSwipeRefresh?.background = null
unwrappedSwipeRefresh?.alpha = 1f
}
}
} else {
unwrappedSwipeRefresh?.alpha = 1f
viewLifecycleScope.get()?.launch {
delay(ANIMATION_DELAY)
unwrappedEngineView?.asView()?.visibility = View.VISIBLE
unwrappedSwipeRefresh?.background = null
}

@ -8,6 +8,7 @@ import GeckoProvider
import android.content.Context
import android.content.res.Configuration
import android.os.StrictMode
import androidx.core.content.ContextCompat
import io.sentry.Sentry
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
@ -21,8 +22,8 @@ import mozilla.components.browser.session.SessionManager
import mozilla.components.browser.session.engine.EngineMiddleware
import mozilla.components.browser.session.storage.SessionStorage
import mozilla.components.browser.session.undo.UndoMiddleware
import mozilla.components.browser.state.action.RestoreCompleteAction
import mozilla.components.browser.state.action.RecentlyClosedAction
import mozilla.components.browser.state.action.RestoreCompleteAction
import mozilla.components.browser.state.state.BrowserState
import mozilla.components.browser.state.store.BrowserStore
import mozilla.components.browser.storage.sync.PlacesBookmarksStorage
@ -101,7 +102,11 @@ class Core(
fontInflationEnabled = context.settings().shouldUseAutoSize,
suspendMediaWhenInactive = false,
forceUserScalableContent = context.settings().forceEnableZoom,
loginAutofillEnabled = context.settings().shouldAutofillLogins
loginAutofillEnabled = context.settings().shouldAutofillLogins,
clearColor = ContextCompat.getColor(
context,
R.color.foundation_normal_theme
)
)
GeckoEngine(
@ -230,7 +235,8 @@ class Core(
// Now that we have restored our previous state (if there's one) let's remove timed out tabs
if (!context.settings().manuallyCloseTabs) {
store.state.tabs.filter {
(System.currentTimeMillis() - it.lastAccess) > context.settings().getTabTimeout()
(System.currentTimeMillis() - it.lastAccess) > context.settings()
.getTabTimeout()
}.forEach {
val session = sessionManager.findSessionById(it.id)
if (session != null) {

@ -31,12 +31,6 @@ class SecretSettingsFragment : PreferenceFragmentCompat() {
onPreferenceChangeListener = SharedPreferenceUpdater()
}
requirePreference<SwitchPreference>(R.string.pref_key_wait_first_paint).apply {
isVisible = FeatureFlags.waitUntilPaintToDraw
isChecked = context.settings().waitToShowPageUntilFirstPaint
onPreferenceChangeListener = SharedPreferenceUpdater()
}
requirePreference<SwitchPreference>(R.string.pref_key_synced_tabs_tabs_tray).apply {
isVisible = FeatureFlags.syncedTabsInTabsTray
isChecked = context.settings().syncedTabsInTabsTray

@ -129,12 +129,6 @@ class Settings(private val appContext: Context) : PreferencesHolder {
featureFlag = FeatureFlags.showGridViewInTabsSettings
)
var waitToShowPageUntilFirstPaint by featureFlagPreference(
appContext.getPreferenceKey(R.string.pref_key_wait_first_paint),
default = false,
featureFlag = FeatureFlags.waitUntilPaintToDraw
)
var syncedTabsInTabsTray by featureFlagPreference(
appContext.getPreferenceKey(R.string.pref_key_synced_tabs_tabs_tray),
default = false,

@ -26,7 +26,6 @@
android:id="@+id/swipeRefresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<mozilla.components.concept.engine.EngineView

@ -202,8 +202,6 @@
<string name="pref_key_migrating_from_fenix_tip" translatable="false">pref_key_migrating_from_fenix_tip</string>
<string name="pref_key_master_password_tip" translatable="false">pref_key_master_password_tip</string>
<string name="pref_key_wait_first_paint" translatable="false">pref_key_wait_first_paint</string>
<string name="pref_key_synced_tabs_tabs_tray" translatable="false">pref_key_synced_tabs_tabs_tray</string>
<string name="pref_key_debug_settings" translatable="false">pref_key_debug_settings</string>

@ -34,8 +34,6 @@
<string name="preferences_debug_settings">Secret Settings</string>
<!-- Label for the show grid view in tabs setting preference -->
<string name="preferences_debug_settings_show_grid_view_tabs_settings">Show Grid View in Tabs Settings</string>
<!-- Label for the wait until first paint preference -->
<string name="preferences_debug_settings_wait_first_paint">Wait Until First Paint To Show Page Content</string>
<!-- Label for showing Synced Tabs in the tabs tray -->
<string name="preferences_debug_synced_tabs_tabs_tray">Show Synced Tabs in the tabs tray</string>

@ -9,11 +9,6 @@
android:key="@string/pref_key_show_grid_view_tabs_settings"
android:title="@string/preferences_debug_settings_show_grid_view_tabs_settings"
app:iconSpaceReserved="false" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/pref_key_wait_first_paint"
android:title="@string/preferences_debug_settings_wait_first_paint"
app:iconSpaceReserved="false" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/pref_key_synced_tabs_tabs_tray"

Loading…
Cancel
Save