mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-15 18:12:54 +00:00
[fenix] Issue https://github.com/mozilla-mobile/fenix/issues/17174: Remove usage of old media APIs.
This commit is contained in:
parent
186570c1ba
commit
ac67fc9de6
@ -232,9 +232,6 @@
|
|||||||
<activity android:name=".settings.account.AuthIntentReceiverActivity"
|
<activity android:name=".settings.account.AuthIntentReceiverActivity"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|
||||||
<service android:name=".media.MediaService"
|
|
||||||
android:exported="false" />
|
|
||||||
|
|
||||||
<service android:name=".media.MediaSessionService"
|
<service android:name=".media.MediaSessionService"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|
||||||
|
@ -124,7 +124,6 @@ import org.mozilla.fenix.theme.ThemeManager
|
|||||||
import org.mozilla.fenix.utils.allowUndo
|
import org.mozilla.fenix.utils.allowUndo
|
||||||
import org.mozilla.fenix.wifi.SitePermissionsWifiIntegration
|
import org.mozilla.fenix.wifi.SitePermissionsWifiIntegration
|
||||||
import java.lang.ref.WeakReference
|
import java.lang.ref.WeakReference
|
||||||
import mozilla.components.feature.media.fullscreen.MediaFullscreenOrientationFeature
|
|
||||||
import mozilla.components.feature.session.behavior.EngineViewBrowserToolbarBehavior
|
import mozilla.components.feature.session.behavior.EngineViewBrowserToolbarBehavior
|
||||||
import mozilla.components.feature.webauthn.WebAuthnFeature
|
import mozilla.components.feature.webauthn.WebAuthnFeature
|
||||||
import mozilla.components.support.base.feature.ActivityResultHandler
|
import mozilla.components.support.base.feature.ActivityResultHandler
|
||||||
@ -172,8 +171,6 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Activit
|
|||||||
private val sitePermissionWifiIntegration =
|
private val sitePermissionWifiIntegration =
|
||||||
ViewBoundFeatureWrapper<SitePermissionsWifiIntegration>()
|
ViewBoundFeatureWrapper<SitePermissionsWifiIntegration>()
|
||||||
private val secureWindowFeature = ViewBoundFeatureWrapper<SecureWindowFeature>()
|
private val secureWindowFeature = ViewBoundFeatureWrapper<SecureWindowFeature>()
|
||||||
private var fullScreenMediaFeature =
|
|
||||||
ViewBoundFeatureWrapper<MediaFullscreenOrientationFeature>()
|
|
||||||
private var fullScreenMediaSessionFeature =
|
private var fullScreenMediaSessionFeature =
|
||||||
ViewBoundFeatureWrapper<MediaSessionFullscreenFeature>()
|
ViewBoundFeatureWrapper<MediaSessionFullscreenFeature>()
|
||||||
private val searchFeature = ViewBoundFeatureWrapper<SearchFeature>()
|
private val searchFeature = ViewBoundFeatureWrapper<SearchFeature>()
|
||||||
|
@ -15,7 +15,6 @@ import mozilla.components.lib.state.State
|
|||||||
import mozilla.components.lib.state.Store
|
import mozilla.components.lib.state.Store
|
||||||
import org.mozilla.fenix.collections.CollectionCreationAction.StepChanged
|
import org.mozilla.fenix.collections.CollectionCreationAction.StepChanged
|
||||||
import org.mozilla.fenix.components.TabCollectionStorage
|
import org.mozilla.fenix.components.TabCollectionStorage
|
||||||
import org.mozilla.fenix.ext.getMediaStateForSession
|
|
||||||
import org.mozilla.fenix.ext.toShortUrl
|
import org.mozilla.fenix.ext.toShortUrl
|
||||||
import org.mozilla.fenix.home.Tab
|
import org.mozilla.fenix.home.Tab
|
||||||
|
|
||||||
@ -87,12 +86,11 @@ internal fun BrowserState.getTabs(
|
|||||||
): List<Tab> {
|
): List<Tab> {
|
||||||
return tabIds
|
return tabIds
|
||||||
?.mapNotNull { id -> findTab(id) }
|
?.mapNotNull { id -> findTab(id) }
|
||||||
?.map { it.toTab(this, publicSuffixList) }
|
?.map { it.toTab(publicSuffixList) }
|
||||||
.orEmpty()
|
.orEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun TabSessionState.toTab(
|
private fun TabSessionState.toTab(
|
||||||
state: BrowserState,
|
|
||||||
publicSuffixList: PublicSuffixList
|
publicSuffixList: PublicSuffixList
|
||||||
): Tab {
|
): Tab {
|
||||||
val url = readerState.activeUrl ?: content.url
|
val url = readerState.activeUrl ?: content.url
|
||||||
@ -102,8 +100,7 @@ private fun TabSessionState.toTab(
|
|||||||
hostname = url.toShortUrl(publicSuffixList),
|
hostname = url.toShortUrl(publicSuffixList),
|
||||||
title = content.title,
|
title = content.title,
|
||||||
selected = null,
|
selected = null,
|
||||||
icon = content.icon,
|
icon = content.icon
|
||||||
mediaState = state.getMediaStateForSession(this.id)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ import androidx.transition.Transition
|
|||||||
import androidx.transition.TransitionManager
|
import androidx.transition.TransitionManager
|
||||||
import kotlinx.android.extensions.LayoutContainer
|
import kotlinx.android.extensions.LayoutContainer
|
||||||
import kotlinx.android.synthetic.main.component_collection_creation.*
|
import kotlinx.android.synthetic.main.component_collection_creation.*
|
||||||
import mozilla.components.browser.state.state.MediaState
|
|
||||||
import mozilla.components.feature.tab.collections.TabCollection
|
import mozilla.components.feature.tab.collections.TabCollection
|
||||||
import mozilla.components.support.ktx.android.view.hideKeyboard
|
import mozilla.components.support.ktx.android.view.hideKeyboard
|
||||||
import mozilla.components.support.ktx.android.view.showKeyboard
|
import mozilla.components.support.ktx.android.view.showKeyboard
|
||||||
@ -197,8 +196,7 @@ class CollectionCreationView(
|
|||||||
sessionId = tab.id.toString(),
|
sessionId = tab.id.toString(),
|
||||||
url = tab.url,
|
url = tab.url,
|
||||||
hostname = tab.url.toShortUrl(publicSuffixList),
|
hostname = tab.url.toShortUrl(publicSuffixList),
|
||||||
title = tab.title,
|
title = tab.title
|
||||||
mediaState = MediaState.State.NONE
|
|
||||||
)
|
)
|
||||||
}.let { tabs ->
|
}.let { tabs ->
|
||||||
collectionCreationTabListAdapter.updateData(tabs, tabs.toSet(), true)
|
collectionCreationTabListAdapter.updateData(tabs, tabs.toSet(), true)
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
package org.mozilla.fenix.ext
|
|
||||||
|
|
||||||
import mozilla.components.browser.state.state.BrowserState
|
|
||||||
import mozilla.components.browser.state.state.MediaState
|
|
||||||
|
|
||||||
fun BrowserState.getMediaStateForSession(sessionId: String): MediaState.State {
|
|
||||||
return if (media.aggregate.activeTabId == sessionId) {
|
|
||||||
media.aggregate.state
|
|
||||||
} else {
|
|
||||||
MediaState.State.NONE
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,7 +5,6 @@
|
|||||||
package org.mozilla.fenix.home
|
package org.mozilla.fenix.home
|
||||||
|
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import mozilla.components.browser.state.state.MediaState
|
|
||||||
import mozilla.components.feature.tab.collections.TabCollection
|
import mozilla.components.feature.tab.collections.TabCollection
|
||||||
import mozilla.components.feature.top.sites.TopSite
|
import mozilla.components.feature.top.sites.TopSite
|
||||||
import mozilla.components.lib.state.Action
|
import mozilla.components.lib.state.Action
|
||||||
@ -28,8 +27,7 @@ data class Tab(
|
|||||||
val hostname: String,
|
val hostname: String,
|
||||||
val title: String,
|
val title: String,
|
||||||
val selected: Boolean? = null,
|
val selected: Boolean? = null,
|
||||||
val icon: Bitmap? = null,
|
val icon: Bitmap? = null
|
||||||
val mediaState: MediaState.State
|
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
package org.mozilla.fenix.media
|
|
||||||
|
|
||||||
import mozilla.components.browser.state.store.BrowserStore
|
|
||||||
import mozilla.components.feature.media.service.AbstractMediaService
|
|
||||||
import org.mozilla.fenix.ext.components
|
|
||||||
|
|
||||||
/**
|
|
||||||
* [AbstractMediaService] implementation for injecting [BrowserStore] singleton.
|
|
||||||
*/
|
|
||||||
class MediaService : AbstractMediaService() {
|
|
||||||
override val store: BrowserStore by lazy { components.core.store }
|
|
||||||
}
|
|
@ -15,7 +15,6 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
|
|||||||
import kotlinx.coroutines.test.TestCoroutineScope
|
import kotlinx.coroutines.test.TestCoroutineScope
|
||||||
import kotlinx.coroutines.test.runBlockingTest
|
import kotlinx.coroutines.test.runBlockingTest
|
||||||
import mozilla.components.browser.state.action.TabListAction
|
import mozilla.components.browser.state.action.TabListAction
|
||||||
import mozilla.components.browser.state.state.MediaState
|
|
||||||
import mozilla.components.browser.state.state.createTab
|
import mozilla.components.browser.state.state.createTab
|
||||||
import mozilla.components.browser.state.store.BrowserStore
|
import mozilla.components.browser.state.store.BrowserStore
|
||||||
import mozilla.components.feature.tab.collections.TabCollection
|
import mozilla.components.feature.tab.collections.TabCollection
|
||||||
@ -80,8 +79,8 @@ class DefaultCollectionCreationControllerTest {
|
|||||||
).joinBlocking()
|
).joinBlocking()
|
||||||
|
|
||||||
val tabs = listOf(
|
val tabs = listOf(
|
||||||
Tab("session-1", "", "", "", mediaState = MediaState.State.NONE),
|
Tab("session-1", "", "", ""),
|
||||||
Tab("null-session", "", "", "", mediaState = MediaState.State.NONE)
|
Tab("null-session", "", "", "")
|
||||||
)
|
)
|
||||||
|
|
||||||
controller.saveCollectionName(tabs, "name")
|
controller.saveCollectionName(tabs, "name")
|
||||||
@ -173,7 +172,7 @@ class DefaultCollectionCreationControllerTest {
|
|||||||
).joinBlocking()
|
).joinBlocking()
|
||||||
|
|
||||||
val tabs = listOf(
|
val tabs = listOf(
|
||||||
Tab("session-1", "", "", "", mediaState = MediaState.State.NONE)
|
Tab("session-1", "", "", "")
|
||||||
)
|
)
|
||||||
val collection = mockk<TabCollection>()
|
val collection = mockk<TabCollection>()
|
||||||
|
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
package org.mozilla.fenix.ext
|
|
||||||
|
|
||||||
import mozilla.components.browser.state.state.BrowserState
|
|
||||||
import mozilla.components.browser.state.state.MediaState
|
|
||||||
import mozilla.components.browser.state.state.createTab
|
|
||||||
import org.junit.Assert.assertEquals
|
|
||||||
import org.junit.Test
|
|
||||||
|
|
||||||
private const val SESSION_ID_MOZILLA = "0"
|
|
||||||
private const val SESSION_ID_BCC = "1"
|
|
||||||
private const val SESSION_ID_BAD = "not a real session id"
|
|
||||||
|
|
||||||
class BrowserStateTest {
|
|
||||||
|
|
||||||
private val sessionMozilla = createTab(url = "www.mozilla.org", id = SESSION_ID_MOZILLA)
|
|
||||||
private val sessionBcc = createTab(url = "www.bcc.co.uk", id = SESSION_ID_BCC)
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `return media state if it matches tab id`() {
|
|
||||||
val state = BrowserState(
|
|
||||||
tabs = listOf(sessionBcc, sessionMozilla),
|
|
||||||
media = MediaState(
|
|
||||||
MediaState.Aggregate(
|
|
||||||
state = MediaState.State.PLAYING,
|
|
||||||
activeTabId = SESSION_ID_MOZILLA
|
|
||||||
))
|
|
||||||
)
|
|
||||||
|
|
||||||
assertEquals(MediaState.State.PLAYING, state.getMediaStateForSession(SESSION_ID_MOZILLA))
|
|
||||||
assertEquals(MediaState.State.NONE, state.getMediaStateForSession(SESSION_ID_BCC))
|
|
||||||
assertEquals(MediaState.State.NONE, state.getMediaStateForSession(SESSION_ID_BAD))
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user