[fenix] Update Android Components version (https://github.com/mozilla-mobile/fenix/pull/21109)

* Update Android Components version to 93.0.20210901143120.

* For https://github.com/mozilla-mobile/fenix/issues/21043 - Integrate AC changes

* Fix breaking API changes of RestoreAction

Co-authored-by: Mugurell <Mugurell@users.noreply.github.com>
Co-authored-by: Christian Sadilek <christian.sadilek@gmail.com>
pull/600/head
Mickey Moz 3 years ago committed by GitHub
parent cda4440bad
commit dccc1133b1

@ -367,26 +367,6 @@ android.applicationVariants.all { variant ->
println("--") println("--")
} }
// -------------------------------------------------------------------------------------------------
// Pocket recommendations: Read token from local file if it exists (Only debug builds)
// -------------------------------------------------------------------------------------------------
print("Pocket recommendations token: ")
if (isDebug) {
if (gradle.hasProperty("localProperties.pocketConsumerKey")) {
def token = gradle.getProperty("localProperties.pocketConsumerKey")
buildConfigField 'String', 'POCKET_TOKEN', '"' + token + '"'
println "Added from local.properties file"
} else {
buildConfigField 'String', 'POCKET_TOKEN', '""'
println "Not found in local.properties file"
}
} else {
buildConfigField 'String', 'POCKET_TOKEN', '""'
println "Is to be only used in debug"
}
// ------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------
// BuildConfig: Set flag for official builds; similar to MOZILLA_OFFICIAL in mozilla-central. // BuildConfig: Set flag for official builds; similar to MOZILLA_OFFICIAL in mozilla-central.
// ------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------

@ -324,9 +324,7 @@ class Core(
@Suppress("MagicNumber") @Suppress("MagicNumber")
val pocketStoriesConfig by lazyMonitored { val pocketStoriesConfig by lazyMonitored {
PocketStoriesConfig( PocketStoriesConfig(client, Frequency(4, TimeUnit.HOURS))
BuildConfig.POCKET_TOKEN, client, Frequency(4, TimeUnit.HOURS), 7
)
} }
val pocketStoriesService by lazyMonitored { PocketStoriesService(context, pocketStoriesConfig) } val pocketStoriesService by lazyMonitored { PocketStoriesService(context, pocketStoriesConfig) }

@ -69,7 +69,6 @@ import mozilla.components.feature.top.sites.TopSitesConfig
import mozilla.components.feature.top.sites.TopSitesFeature import mozilla.components.feature.top.sites.TopSitesFeature
import mozilla.components.lib.state.ext.consumeFlow import mozilla.components.lib.state.ext.consumeFlow
import mozilla.components.lib.state.ext.consumeFrom import mozilla.components.lib.state.ext.consumeFrom
import mozilla.components.service.pocket.stories.PocketStoriesUseCases
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
import mozilla.components.support.ktx.android.content.res.resolveAttribute import mozilla.components.support.ktx.android.content.res.resolveAttribute
import mozilla.components.support.ktx.kotlinx.coroutines.flow.ifChanged import mozilla.components.support.ktx.kotlinx.coroutines.flow.ifChanged
@ -243,7 +242,7 @@ class HomeFragment : Fragment() {
if (requireContext().settings().pocketRecommendations) { if (requireContext().settings().pocketRecommendations) {
lifecycleScope.async(IO) { lifecycleScope.async(IO) {
val stories = PocketStoriesUseCases().GetPocketStories(requireContext()).invoke() val stories = components.core.pocketStoriesService.getStories()
homeFragmentStore.dispatch(HomeFragmentAction.PocketArticlesChange(stories)) homeFragmentStore.dispatch(HomeFragmentAction.PocketArticlesChange(stories))
} }
} }

@ -90,7 +90,7 @@ fun PocketStory(
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) { CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
Text( Text(
modifier = Modifier.padding(bottom = 2.dp), modifier = Modifier.padding(bottom = 2.dp),
text = story.domain, text = story.publisher,
style = MaterialTheme.typography.caption, style = MaterialTheme.typography.caption,
maxLines = 1, maxLines = 1,
overflow = TextOverflow.Ellipsis overflow = TextOverflow.Ellipsis
@ -170,13 +170,6 @@ fun PocketRecommendations(
) { ) {
content() content()
// Don't yet have the bottom image from designs as a proper Android SVG.
Box(
Modifier
.background(Color.Red)
.size(64.dp, 27.dp)
.padding(top = 16.dp)
)
// Image( // Image(
// painterResource(R.drawable.ic_firefox_pocket), // painterResource(R.drawable.ic_firefox_pocket),
// "Firefox and Pocket logos", // "Firefox and Pocket logos",
@ -269,15 +262,12 @@ private fun getFakePocketStories(limit: Int = 1): List<PocketRecommendedStory> {
add( add(
PocketRecommendedStory( PocketRecommendedStory(
id = randomNumber.toLong(),
url = "https://story$randomNumber.com",
title = "This is a ${"very ".repeat(randomNumber)} long title", title = "This is a ${"very ".repeat(randomNumber)} long title",
domain = "Website no #$randomNumber", publisher = "Publisher",
excerpt = "FOO", url = "https://story$randomNumber.com",
dedupeUrl = "BAR", imageUrl = "",
imageSrc = "", timeToRead = randomNumber,
sortId = randomNumber, category = "Category #$randomNumber"
publishedTimestamp = randomNumber.toString()
) )
) )
} }

@ -13,6 +13,8 @@ import mozilla.components.lib.state.ext.observeAsComposableState
import mozilla.components.service.pocket.PocketRecommendedStory import mozilla.components.service.pocket.PocketRecommendedStory
import org.mozilla.fenix.home.HomeFragmentStore import org.mozilla.fenix.home.HomeFragmentStore
private const val STORIES_TO_SHOW_COUNT = 7
/** /**
* [RecyclerView.ViewHolder] that will display a list of [PocketRecommendedStory]es * [RecyclerView.ViewHolder] that will display a list of [PocketRecommendedStory]es
* which is to be provided in the [bind] method. * which is to be provided in the [bind] method.
@ -41,11 +43,13 @@ class PocketStoriesViewHolder(
@Composable @Composable
fun PocketStories(store: HomeFragmentStore) { fun PocketStories(store: HomeFragmentStore) {
val stories = store.observeAsComposableState { state -> state.pocketArticles } val stories = store
.observeAsComposableState { state -> state.pocketArticles }.value
?.take(STORIES_TO_SHOW_COUNT)
ExpandableCard { ExpandableCard {
PocketRecommendations { PocketRecommendations {
PocketStories(stories.value ?: emptyList()) PocketStories(stories ?: emptyList())
} }
} }
} }

@ -15,6 +15,7 @@ import mozilla.components.browser.state.action.EngineAction
import mozilla.components.browser.state.action.TabListAction import mozilla.components.browser.state.action.TabListAction
import mozilla.components.browser.state.state.BrowserState import mozilla.components.browser.state.state.BrowserState
import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.state.createTab
import mozilla.components.browser.state.state.recover.RecoverableTab
import mozilla.components.browser.state.store.BrowserStore import mozilla.components.browser.state.store.BrowserStore
import mozilla.components.service.glean.testing.GleanTestRule import mozilla.components.service.glean.testing.GleanTestRule
import mozilla.components.support.base.android.Clock import mozilla.components.support.base.android.Clock
@ -168,11 +169,16 @@ class TelemetryMiddlewareTest {
fun `WHEN tabs are restored THEN the open tab count is updated`() { fun `WHEN tabs are restored THEN the open tab count is updated`() {
assertEquals(0, settings.openTabsCount) assertEquals(0, settings.openTabsCount)
val tabsToRestore = listOf( val tabsToRestore = listOf(
createTab("https://mozilla.org"), RecoverableTab(url = "https://mozilla.org", id = "1"),
createTab("https://firefox.com") RecoverableTab(url = "https://firefox.com", id = "2")
) )
store.dispatch(TabListAction.RestoreAction(tabsToRestore)).joinBlocking() store.dispatch(
TabListAction.RestoreAction(
tabs = tabsToRestore,
restoreLocation = TabListAction.RestoreAction.RestoreLocation.BEGINNING
)
).joinBlocking()
assertEquals(2, settings.openTabsCount) assertEquals(2, settings.openTabsCount)
verify(exactly = 1) { metrics.track(Event.HaveOpenTabs) } verify(exactly = 1) { metrics.track(Event.HaveOpenTabs) }
} }
@ -204,11 +210,12 @@ class TelemetryMiddlewareTest {
store.dispatch( store.dispatch(
TabListAction.RestoreAction( TabListAction.RestoreAction(
listOf( listOf(
createTab("https://www.mozilla.org", id = "foreground"), RecoverableTab(url = "https://www.mozilla.org", id = "foreground"),
createTab("https://getpocket.com", id = "background_pocket"), RecoverableTab(url = "https://getpocket.com", id = "background_pocket"),
createTab("https://theverge.com", id = "background_verge") RecoverableTab(url = "https://theverge.com", id = "background_verge")
), ),
selectedTabId = "foreground" selectedTabId = "foreground",
restoreLocation = TabListAction.RestoreAction.RestoreLocation.BEGINNING
) )
).joinBlocking() ).joinBlocking()
@ -227,11 +234,12 @@ class TelemetryMiddlewareTest {
store.dispatch( store.dispatch(
TabListAction.RestoreAction( TabListAction.RestoreAction(
listOf( listOf(
createTab("https://www.mozilla.org", id = "foreground"), RecoverableTab(url = "https://www.mozilla.org", id = "foreground"),
createTab("https://getpocket.com", id = "background_pocket"), RecoverableTab(url = "https://getpocket.com", id = "background_pocket"),
createTab("https://theverge.com", id = "background_verge") RecoverableTab(url = "https://theverge.com", id = "background_verge")
), ),
selectedTabId = "foreground" selectedTabId = "foreground",
restoreLocation = TabListAction.RestoreAction.RestoreLocation.BEGINNING
) )
).joinBlocking() ).joinBlocking()
@ -260,11 +268,12 @@ class TelemetryMiddlewareTest {
store.dispatch( store.dispatch(
TabListAction.RestoreAction( TabListAction.RestoreAction(
listOf( listOf(
createTab("https://www.mozilla.org", id = "foreground"), RecoverableTab(url = "https://www.mozilla.org", id = "foreground"),
createTab("https://getpocket.com", id = "background_pocket"), RecoverableTab(url = "https://getpocket.com", id = "background_pocket"),
createTab("https://theverge.com", id = "background_verge") RecoverableTab(url = "https://theverge.com", id = "background_verge")
), ),
selectedTabId = "foreground" selectedTabId = "foreground",
restoreLocation = TabListAction.RestoreAction.RestoreLocation.BEGINNING
) )
).joinBlocking() ).joinBlocking()
@ -296,11 +305,12 @@ class TelemetryMiddlewareTest {
store.dispatch( store.dispatch(
TabListAction.RestoreAction( TabListAction.RestoreAction(
listOf( listOf(
createTab("https://www.mozilla.org", id = "foreground"), RecoverableTab(url = "https://www.mozilla.org", id = "foreground"),
createTab("https://getpocket.com", id = "background_pocket"), RecoverableTab(url = "https://getpocket.com", id = "background_pocket"),
createTab("https://theverge.com", id = "background_verge") RecoverableTab(url = "https://theverge.com", id = "background_verge")
), ),
selectedTabId = "foreground" selectedTabId = "foreground",
restoreLocation = TabListAction.RestoreAction.RestoreLocation.BEGINNING
) )
).joinBlocking() ).joinBlocking()

@ -3,5 +3,5 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
object AndroidComponents { object AndroidComponents {
const val VERSION = "93.0.20210830220733" const val VERSION = "93.0.20210901143120"
} }

Loading…
Cancel
Save