mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-09 19:10:42 +00:00
For #2390 - Adds the onboarding welcome message
This commit is contained in:
parent
b14d0fa80c
commit
dfe14e1751
@ -58,7 +58,6 @@ import org.mozilla.fenix.mvi.ActionBusFactory
|
|||||||
import org.mozilla.fenix.mvi.getAutoDisposeObservable
|
import org.mozilla.fenix.mvi.getAutoDisposeObservable
|
||||||
import org.mozilla.fenix.mvi.getManagedEmitter
|
import org.mozilla.fenix.mvi.getManagedEmitter
|
||||||
import org.mozilla.fenix.onboarding.FenixOnboarding
|
import org.mozilla.fenix.onboarding.FenixOnboarding
|
||||||
import org.mozilla.fenix.onboarding.Onboarding
|
|
||||||
import org.mozilla.fenix.settings.SupportUtils
|
import org.mozilla.fenix.settings.SupportUtils
|
||||||
import org.mozilla.fenix.utils.ItsNotBrokenSnack
|
import org.mozilla.fenix.utils.ItsNotBrokenSnack
|
||||||
import kotlin.coroutines.CoroutineContext
|
import kotlin.coroutines.CoroutineContext
|
||||||
|
@ -19,6 +19,7 @@ import org.mozilla.fenix.home.sessioncontrol.viewholders.CollectionHeaderViewHol
|
|||||||
import org.mozilla.fenix.home.sessioncontrol.viewholders.NoCollectionMessageViewHolder
|
import org.mozilla.fenix.home.sessioncontrol.viewholders.NoCollectionMessageViewHolder
|
||||||
import org.mozilla.fenix.home.sessioncontrol.viewholders.CollectionViewHolder
|
import org.mozilla.fenix.home.sessioncontrol.viewholders.CollectionViewHolder
|
||||||
import org.mozilla.fenix.home.sessioncontrol.viewholders.TabInCollectionViewHolder
|
import org.mozilla.fenix.home.sessioncontrol.viewholders.TabInCollectionViewHolder
|
||||||
|
import org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding.OnboardingHeaderViewHolder
|
||||||
import java.lang.IllegalStateException
|
import java.lang.IllegalStateException
|
||||||
|
|
||||||
sealed class AdapterItem {
|
sealed class AdapterItem {
|
||||||
@ -33,6 +34,8 @@ sealed class AdapterItem {
|
|||||||
data class CollectionItem(val collection: TabCollection) : AdapterItem()
|
data class CollectionItem(val collection: TabCollection) : AdapterItem()
|
||||||
data class TabInCollectionItem(val collection: TabCollection, val tab: Tab, val isLastTab: Boolean) : AdapterItem()
|
data class TabInCollectionItem(val collection: TabCollection, val tab: Tab, val isLastTab: Boolean) : AdapterItem()
|
||||||
|
|
||||||
|
object OnboardingHeader : AdapterItem()
|
||||||
|
|
||||||
val viewType: Int
|
val viewType: Int
|
||||||
get() = when (this) {
|
get() = when (this) {
|
||||||
is TabHeader -> TabHeaderViewHolder.LAYOUT_ID
|
is TabHeader -> TabHeaderViewHolder.LAYOUT_ID
|
||||||
@ -45,6 +48,7 @@ sealed class AdapterItem {
|
|||||||
NoCollectionMessage -> NoCollectionMessageViewHolder.LAYOUT_ID
|
NoCollectionMessage -> NoCollectionMessageViewHolder.LAYOUT_ID
|
||||||
is CollectionItem -> CollectionViewHolder.LAYOUT_ID
|
is CollectionItem -> CollectionViewHolder.LAYOUT_ID
|
||||||
is TabInCollectionItem -> TabInCollectionViewHolder.LAYOUT_ID
|
is TabInCollectionItem -> TabInCollectionViewHolder.LAYOUT_ID
|
||||||
|
OnboardingHeader -> OnboardingHeaderViewHolder.LAYOUT_ID
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,6 +79,7 @@ class SessionControlAdapter(
|
|||||||
NoCollectionMessageViewHolder.LAYOUT_ID -> NoCollectionMessageViewHolder(view)
|
NoCollectionMessageViewHolder.LAYOUT_ID -> NoCollectionMessageViewHolder(view)
|
||||||
CollectionViewHolder.LAYOUT_ID -> CollectionViewHolder(view, actionEmitter, job)
|
CollectionViewHolder.LAYOUT_ID -> CollectionViewHolder(view, actionEmitter, job)
|
||||||
TabInCollectionViewHolder.LAYOUT_ID -> TabInCollectionViewHolder(view, actionEmitter, job)
|
TabInCollectionViewHolder.LAYOUT_ID -> TabInCollectionViewHolder(view, actionEmitter, job)
|
||||||
|
OnboardingHeaderViewHolder.LAYOUT_ID -> OnboardingHeaderViewHolder(view)
|
||||||
else -> throw IllegalStateException()
|
else -> throw IllegalStateException()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,10 +60,14 @@ private fun privateModeAdapterItems(tabs: List<Tab>): List<AdapterItem> {
|
|||||||
return items
|
return items
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun onboardingAdapterItems(): List<AdapterItem> = listOf(
|
||||||
|
AdapterItem.OnboardingHeader
|
||||||
|
)
|
||||||
|
|
||||||
private fun SessionControlState.toAdapterList(): List<AdapterItem> = when (mode) {
|
private fun SessionControlState.toAdapterList(): List<AdapterItem> = when (mode) {
|
||||||
is Mode.Normal -> normalModeAdapterItems(tabs, collections)
|
is Mode.Normal -> normalModeAdapterItems(tabs, collections)
|
||||||
is Mode.Private -> privateModeAdapterItems(tabs)
|
is Mode.Private -> privateModeAdapterItems(tabs)
|
||||||
is Mode.Onboarding -> listOf()
|
is Mode.Onboarding -> onboardingAdapterItems()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun collectionTabItems(collection: TabCollection) = collection.tabs.mapIndexed { index, tab ->
|
private fun collectionTabItems(collection: TabCollection) = collection.tabs.mapIndexed { index, tab ->
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
/* 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.home.sessioncontrol.viewholders.onboarding
|
||||||
|
|
||||||
|
import android.view.View
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import org.mozilla.fenix.R
|
||||||
|
|
||||||
|
class OnboardingHeaderViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||||
|
companion object {
|
||||||
|
const val LAYOUT_ID = R.layout.onboarding_header
|
||||||
|
}
|
||||||
|
}
|
17
app/src/main/res/layout/onboarding_header.xml
Normal file
17
app/src/main/res/layout/onboarding_header.xml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- 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/. -->
|
||||||
|
<FrameLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/onboarding_header"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/header_text"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/onboarding_header"
|
||||||
|
android:textAppearance="@style/HeaderTextStyle"
|
||||||
|
android:textSize="22sp" />
|
||||||
|
</FrameLayout>
|
@ -485,4 +485,8 @@
|
|||||||
<string name="full_screen_notification">Entering full screen mode</string>
|
<string name="full_screen_notification">Entering full screen mode</string>
|
||||||
<!-- Message for copying the URL via long press on the toolbar -->
|
<!-- Message for copying the URL via long press on the toolbar -->
|
||||||
<string name="url_copied">URL copied</string>
|
<string name="url_copied">URL copied</string>
|
||||||
|
|
||||||
|
<!-- Onboarding -->
|
||||||
|
<!-- Header text for onboarding -->
|
||||||
|
<string name="onboarding_header">Welcome to Firefox!</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user