Bug 1958322 - onPictureInPictureModeChanged notifies GeckoSession of pip changes r=geckoview-reviewers,android-reviewers,ohall,007,owlish
Differential Revision: https://phabricator.services.mozilla.com/D244834
This commit is contained in:
@@ -608,6 +608,13 @@ class GeckoEngineSession(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* See [EngineSession.onPipModeChanged].
|
||||
*/
|
||||
override fun onPipModeChanged(enabled: Boolean) {
|
||||
geckoSession.compositorController.onPipModeChanged(enabled)
|
||||
}
|
||||
|
||||
/**
|
||||
* See [EngineSession.checkForFormData].
|
||||
*/
|
||||
|
||||
@@ -1888,6 +1888,19 @@ class GeckoEngineSessionTest {
|
||||
verify(geckoSession.compositorController).clearColor = Color.BLUE
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `onPipModeChanged sets same enabled value`() {
|
||||
whenever(geckoSession.compositorController).thenReturn(mock())
|
||||
val engineSession = GeckoEngineSession(
|
||||
mock(),
|
||||
geckoSessionProvider = geckoSessionProvider,
|
||||
)
|
||||
engineSession.onPipModeChanged(true)
|
||||
verify(geckoSession.compositorController).onPipModeChanged(true)
|
||||
engineSession.onPipModeChanged(false)
|
||||
verify(geckoSession.compositorController).onPipModeChanged(false)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun unsupportedSettings() {
|
||||
val settings = GeckoEngineSession(
|
||||
|
||||
@@ -1019,4 +1019,11 @@ abstract class EngineSession(
|
||||
* @param displayMode the display mode value for this session.
|
||||
*/
|
||||
open fun setDisplayMode(displayMode: WebAppManifest.DisplayMode) = Unit
|
||||
|
||||
/**
|
||||
* Should be called by PictureInPictureFeature on changes to and from picture-in-picture mode.
|
||||
*
|
||||
* @param enabled True if the activity is in picture-in-picture mode.
|
||||
*/
|
||||
open fun onPipModeChanged(enabled: Boolean) = Unit
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import android.os.Build.VERSION.SDK_INT
|
||||
import androidx.annotation.RequiresApi
|
||||
import mozilla.components.browser.state.action.ContentAction
|
||||
import mozilla.components.browser.state.selector.findTabOrCustomTabOrSelectedTab
|
||||
import mozilla.components.browser.state.selector.selectedTab
|
||||
import mozilla.components.browser.state.store.BrowserStore
|
||||
import mozilla.components.concept.base.crash.CrashReporting
|
||||
import mozilla.components.concept.engine.mediasession.MediaSession
|
||||
@@ -84,6 +85,7 @@ class PictureInPictureFeature(
|
||||
*/
|
||||
fun onPictureInPictureModeChanged(enabled: Boolean) {
|
||||
val sessionId = tabId ?: store.state.selectedTabId ?: return
|
||||
store.state.selectedTab?.engineState?.engineSession?.onPipModeChanged(enabled)
|
||||
store.dispatch(ContentAction.PictureInPictureChangedAction(sessionId, enabled))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import mozilla.components.browser.state.action.ContentAction
|
||||
import mozilla.components.browser.state.selector.selectedTab
|
||||
import mozilla.components.browser.state.state.BrowserState
|
||||
import mozilla.components.browser.state.state.MediaSessionState
|
||||
import mozilla.components.browser.state.state.SessionState
|
||||
@@ -286,6 +287,10 @@ class PictureInPictureFeatureTest {
|
||||
@Test
|
||||
fun `on pip mode changed`() {
|
||||
val store = mock<BrowserStore>()
|
||||
val browserState = mock<BrowserState>().apply {
|
||||
whenever(selectedTab).thenReturn(null)
|
||||
}
|
||||
whenever(store.state).thenReturn(browserState)
|
||||
val pipFeature = PictureInPictureFeature(
|
||||
store,
|
||||
activity,
|
||||
|
||||
@@ -407,6 +407,7 @@ package org.mozilla.geckoview {
|
||||
method public void addDrawCallback(@NonNull Runnable);
|
||||
method public int getClearColor();
|
||||
method @Nullable public Runnable getFirstPaintCallback();
|
||||
method public void onPipModeChanged(boolean);
|
||||
method public void removeDrawCallback(@NonNull Runnable);
|
||||
method public void setClearColor(int);
|
||||
method public void setFirstPaintCallback(@Nullable Runnable);
|
||||
|
||||
@@ -81,6 +81,15 @@ public final class CompositorController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be called when the system informs you of changes to and from picture-in-picture mode.
|
||||
*
|
||||
* @param enabled True if the activity is in picture-in-picture mode.
|
||||
*/
|
||||
public void onPipModeChanged(final boolean enabled) {
|
||||
mCompositor.onPipModeChanged(enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current clear color when drawing.
|
||||
*
|
||||
|
||||
@@ -15,6 +15,9 @@ exclude: true
|
||||
|
||||
## v139
|
||||
- ⚠️ Removed deprecated [`GeckoSession.requestAnalysis`][118.4], [`GeckoSession.requestCreateAnalysis`][122.2], [`GeckoSession.requestAnalysisStatus`][137.1], [`GeckoSession.sendPlacementAttributionEvent`][123.3], [`GeckoSession.pollForAnalysisCompleted`][137.2], [`GeckoSession.sendClickAttributionEvent`][121.4], [`GeckoSession.sendImpressionAttributionEvent`][121.5], [`GeckoSession.sendPlacementAttributionEvent`][123.3], [`GeckoSession.requestRecommendations`][118.5], [`GeckoSession.reportBackInStock`][122.1], `AnalysisStatusResponse`, [`ReviewAnalysis`][120.2] and [`Recommendation`][120.3].
|
||||
- Added [`CompositorController.onPipModeChanged`][139.1] to [`CompositorController`][65.1] to inform GeckoSession of changes to and from picture-in-picture mode.
|
||||
|
||||
[139.1]: {{javadoc_uri}}/CompositorController.html#onPipModeChanged
|
||||
|
||||
## v138
|
||||
- Added [`GeckoSession.Loader.originalInput`][138.1] option, which allows passing through the original user address bar input
|
||||
@@ -1702,4 +1705,4 @@ to allow adding gecko profiler markers.
|
||||
[65.24]: {{javadoc_uri}}/CrashReporter.html#sendCrashReport(android.content.Context,android.os.Bundle,java.lang.String)
|
||||
[65.25]: {{javadoc_uri}}/GeckoResult.html
|
||||
|
||||
[api-version]: 9fc471e63fc6d37006ad4c5bb5911b157dd2ba7a
|
||||
[api-version]: f538591c2dfeec76c798c4c1b77639ac544f8aff
|
||||
|
||||
Reference in New Issue
Block a user