Issue #17174: Remove usage of old media APIs.

upstream-sync
Sebastian Kaspari 3 years ago
parent ffc89c539a
commit f4f5e4b663

@ -232,9 +232,6 @@
<activity android:name=".settings.account.AuthIntentReceiverActivity"
android:exported="false" />
<service android:name=".media.MediaService"
android:exported="false" />
<service android:name=".media.MediaSessionService"
android:exported="false" />

@ -124,7 +124,6 @@ import org.mozilla.fenix.theme.ThemeManager
import org.mozilla.fenix.utils.allowUndo
import org.mozilla.fenix.wifi.SitePermissionsWifiIntegration
import java.lang.ref.WeakReference
import mozilla.components.feature.media.fullscreen.MediaFullscreenOrientationFeature
import mozilla.components.feature.session.behavior.EngineViewBrowserToolbarBehavior
import mozilla.components.feature.webauthn.WebAuthnFeature
import mozilla.components.support.base.feature.ActivityResultHandler
@ -172,8 +171,6 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Activit
private val sitePermissionWifiIntegration =
ViewBoundFeatureWrapper<SitePermissionsWifiIntegration>()
private val secureWindowFeature = ViewBoundFeatureWrapper<SecureWindowFeature>()
private var fullScreenMediaFeature =
ViewBoundFeatureWrapper<MediaFullscreenOrientationFeature>()
private var fullScreenMediaSessionFeature =
ViewBoundFeatureWrapper<MediaSessionFullscreenFeature>()
private val searchFeature = ViewBoundFeatureWrapper<SearchFeature>()

@ -15,7 +15,6 @@ import mozilla.components.lib.state.State
import mozilla.components.lib.state.Store
import org.mozilla.fenix.collections.CollectionCreationAction.StepChanged
import org.mozilla.fenix.components.TabCollectionStorage
import org.mozilla.fenix.ext.getMediaStateForSession
import org.mozilla.fenix.ext.toShortUrl
import org.mozilla.fenix.home.Tab
@ -87,12 +86,11 @@ internal fun BrowserState.getTabs(
): List<Tab> {
return tabIds
?.mapNotNull { id -> findTab(id) }
?.map { it.toTab(this, publicSuffixList) }
?.map { it.toTab(publicSuffixList) }
.orEmpty()
}
private fun TabSessionState.toTab(
state: BrowserState,
publicSuffixList: PublicSuffixList
): Tab {
val url = readerState.activeUrl ?: content.url
@ -102,8 +100,7 @@ private fun TabSessionState.toTab(
hostname = url.toShortUrl(publicSuffixList),
title = content.title,
selected = null,
icon = content.icon,
mediaState = state.getMediaStateForSession(this.id)
icon = content.icon
)
}

@ -19,7 +19,6 @@ import androidx.transition.Transition
import androidx.transition.TransitionManager
import kotlinx.android.extensions.LayoutContainer
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.support.ktx.android.view.hideKeyboard
import mozilla.components.support.ktx.android.view.showKeyboard
@ -197,8 +196,7 @@ class CollectionCreationView(
sessionId = tab.id.toString(),
url = tab.url,
hostname = tab.url.toShortUrl(publicSuffixList),
title = tab.title,
mediaState = MediaState.State.NONE
title = tab.title
)
}.let { tabs ->
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
import android.graphics.Bitmap
import mozilla.components.browser.state.state.MediaState
import mozilla.components.feature.tab.collections.TabCollection
import mozilla.components.feature.top.sites.TopSite
import mozilla.components.lib.state.Action
@ -28,8 +27,7 @@ data class Tab(
val hostname: String,
val title: String,
val selected: Boolean? = null,
val icon: Bitmap? = null,
val mediaState: MediaState.State
val icon: Bitmap? = null
)
/**

@ -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.runBlockingTest
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.store.BrowserStore
import mozilla.components.feature.tab.collections.TabCollection
@ -80,8 +79,8 @@ class DefaultCollectionCreationControllerTest {
).joinBlocking()
val tabs = listOf(
Tab("session-1", "", "", "", mediaState = MediaState.State.NONE),
Tab("null-session", "", "", "", mediaState = MediaState.State.NONE)
Tab("session-1", "", "", ""),
Tab("null-session", "", "", "")
)
controller.saveCollectionName(tabs, "name")
@ -173,7 +172,7 @@ class DefaultCollectionCreationControllerTest {
).joinBlocking()
val tabs = listOf(
Tab("session-1", "", "", "", mediaState = MediaState.State.NONE)
Tab("session-1", "", "", "")
)
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…
Cancel
Save