For #2390 - Adds views for every onboarding card
parent
8928b19079
commit
b2e6b59e91
|
@ -20,9 +20,13 @@ import org.mozilla.fenix.home.sessioncontrol.viewholders.CollectionHeaderViewHol
|
|||
import org.mozilla.fenix.home.sessioncontrol.viewholders.NoCollectionMessageViewHolder
|
||||
import org.mozilla.fenix.home.sessioncontrol.viewholders.CollectionViewHolder
|
||||
import org.mozilla.fenix.home.sessioncontrol.viewholders.TabInCollectionViewHolder
|
||||
import org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding.OnboardingFirefoxAccountViewHolder
|
||||
import org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding.OnboardingHeaderViewHolder
|
||||
import org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding.OnboardingPrivacyNoticeViewHolder
|
||||
import org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding.OnboardingPrivateBrowsingViewHolder
|
||||
import org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding.OnboardingSectionHeaderViewHolder
|
||||
import org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding.OnboardingThemePickerViewHolder
|
||||
import org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding.OnboardingTrackingProtectionViewHolder
|
||||
import java.lang.IllegalStateException
|
||||
|
||||
sealed class AdapterItem {
|
||||
|
@ -41,7 +45,11 @@ sealed class AdapterItem {
|
|||
|
||||
object OnboardingHeader : AdapterItem()
|
||||
data class OnboardingSectionHeader(val labelBuilder: (Context) -> String) : AdapterItem()
|
||||
object OnboardingFirefoxAccount : AdapterItem()
|
||||
object OnboardingThemePicker : AdapterItem()
|
||||
object OnboardingTrackingProtection : AdapterItem()
|
||||
object OnboardingPrivateBrowsing : AdapterItem()
|
||||
object OnboardingPrivacyNotice : AdapterItem()
|
||||
|
||||
val viewType: Int
|
||||
get() = when (this) {
|
||||
|
@ -57,7 +65,11 @@ sealed class AdapterItem {
|
|||
is TabInCollectionItem -> TabInCollectionViewHolder.LAYOUT_ID
|
||||
OnboardingHeader -> OnboardingHeaderViewHolder.LAYOUT_ID
|
||||
is OnboardingSectionHeader -> OnboardingSectionHeaderViewHolder.LAYOUT_ID
|
||||
OnboardingFirefoxAccount -> OnboardingFirefoxAccountViewHolder.LAYOUT_ID
|
||||
OnboardingThemePicker -> OnboardingThemePickerViewHolder.LAYOUT_ID
|
||||
OnboardingTrackingProtection -> OnboardingTrackingProtectionViewHolder.LAYOUT_ID
|
||||
OnboardingPrivateBrowsing -> OnboardingPrivateBrowsingViewHolder.LAYOUT_ID
|
||||
OnboardingPrivacyNotice -> OnboardingPrivacyNoticeViewHolder.LAYOUT_ID
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,7 +102,11 @@ class SessionControlAdapter(
|
|||
TabInCollectionViewHolder.LAYOUT_ID -> TabInCollectionViewHolder(view, actionEmitter, job)
|
||||
OnboardingHeaderViewHolder.LAYOUT_ID -> OnboardingHeaderViewHolder(view)
|
||||
OnboardingSectionHeaderViewHolder.LAYOUT_ID -> OnboardingSectionHeaderViewHolder(view)
|
||||
OnboardingFirefoxAccountViewHolder.LAYOUT_ID -> OnboardingFirefoxAccountViewHolder(view)
|
||||
OnboardingThemePickerViewHolder.LAYOUT_ID -> OnboardingThemePickerViewHolder(view)
|
||||
OnboardingTrackingProtectionViewHolder.LAYOUT_ID -> OnboardingTrackingProtectionViewHolder(view)
|
||||
OnboardingPrivateBrowsingViewHolder.LAYOUT_ID -> OnboardingPrivateBrowsingViewHolder(view)
|
||||
OnboardingPrivacyNoticeViewHolder.LAYOUT_ID -> OnboardingPrivacyNoticeViewHolder(view)
|
||||
else -> throw IllegalStateException()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,11 +63,15 @@ private fun privateModeAdapterItems(tabs: List<Tab>): List<AdapterItem> {
|
|||
private fun onboardingAdapterItems(): List<AdapterItem> = listOf(
|
||||
AdapterItem.OnboardingHeader,
|
||||
AdapterItem.OnboardingSectionHeader() { it.getString(R.string.onboarding_fxa_section_header) },
|
||||
AdapterItem.OnboardingFirefoxAccount,
|
||||
AdapterItem.OnboardingSectionHeader() {
|
||||
val appName = it.getString(R.string.app_name)
|
||||
it.getString(R.string.onboarding_feature_section_header, appName)
|
||||
},
|
||||
AdapterItem.OnboardingThemePicker
|
||||
AdapterItem.OnboardingThemePicker,
|
||||
AdapterItem.OnboardingTrackingProtection,
|
||||
AdapterItem.OnboardingPrivateBrowsing,
|
||||
AdapterItem.OnboardingPrivacyNotice
|
||||
)
|
||||
|
||||
private fun SessionControlState.toAdapterList(): List<AdapterItem> = when (mode) {
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
/* 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 kotlinx.android.synthetic.main.onboarding_firefox_account.view.*
|
||||
import org.mozilla.fenix.R
|
||||
|
||||
class OnboardingFirefoxAccountViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
|
||||
init {
|
||||
val appName = view.context.getString(R.string.app_name)
|
||||
view.header_text.text = view.context.getString(R.string.onboarding_firefox_account_header, appName)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val LAYOUT_ID = R.layout.onboarding_firefox_account
|
||||
}
|
||||
}
|
|
@ -6,9 +6,16 @@ package org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding
|
|||
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kotlinx.android.synthetic.main.onboarding_header.view.*
|
||||
import org.mozilla.fenix.R
|
||||
|
||||
class OnboardingHeaderViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
|
||||
init {
|
||||
val appName = view.context.getString(R.string.app_name)
|
||||
view.header_text.text = view.context.getString(R.string.onboarding_header, appName)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val LAYOUT_ID = R.layout.onboarding_header
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
/* 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 kotlinx.android.synthetic.main.onboarding_theme_picker.view.*
|
||||
import org.mozilla.fenix.R
|
||||
|
||||
class OnboardingPrivacyNoticeViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
|
||||
init {
|
||||
val appName = view.context.getString(R.string.app_name)
|
||||
view.description_text.text = view.context.getString(R.string.onboarding_privacy_notice_description, appName)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val LAYOUT_ID = R.layout.onboarding_privacy_notice
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/* 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.text.SpannableString
|
||||
import android.text.Spanned
|
||||
import android.text.style.ImageSpan
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kotlinx.android.synthetic.main.onboarding_private_browsing.view.*
|
||||
import org.mozilla.fenix.R
|
||||
|
||||
class OnboardingPrivateBrowsingViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
|
||||
init {
|
||||
val icon = ImageSpan(view.context, R.drawable.ic_private_browsing)
|
||||
val text = SpannableString(view.context.getString(R.string.onboarding_private_browsing_description))
|
||||
|
||||
val spanStartIndex = text.indexOf(IMAGE_PLACEHOLDER)
|
||||
text.setSpan(
|
||||
icon,
|
||||
spanStartIndex,
|
||||
spanStartIndex + IMAGE_PLACEHOLDER.length,
|
||||
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
)
|
||||
|
||||
view.description_text.text = text
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val IMAGE_PLACEHOLDER = "%s"
|
||||
const val LAYOUT_ID = R.layout.onboarding_private_browsing
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
/* 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 kotlinx.android.synthetic.main.onboarding_tracking_protection.view.*
|
||||
import org.mozilla.fenix.R
|
||||
|
||||
class OnboardingTrackingProtectionViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
|
||||
init {
|
||||
val appName = view.context.getString(R.string.app_name)
|
||||
view.description_text.text = view.context.getString(
|
||||
R.string.onboarding_tracking_protection_description,
|
||||
appName
|
||||
)
|
||||
}
|
||||
companion object {
|
||||
const val LAYOUT_ID = R.layout.onboarding_tracking_protection
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?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/. -->
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/onboarding_card"
|
||||
style="@style/OnboardingCardLight"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:id="@+id/header_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="14dp"
|
||||
android:text="@string/onboarding_firefox_account_header"
|
||||
android:textAppearance="@style/HeaderTextStyle" />
|
||||
</LinearLayout>
|
|
@ -0,0 +1,25 @@
|
|||
<?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/. -->
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/onboarding_card"
|
||||
style="@style/OnboardingCardLight"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:id="@+id/header_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="14dp"
|
||||
android:text="@string/onboarding_privacy_notice_header"
|
||||
android:textAppearance="@style/HeaderTextStyle" />
|
||||
<TextView
|
||||
android:id="@+id/description_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/onboarding_privacy_notice_description"
|
||||
android:textAppearance="@style/Body14TextStyle" />
|
||||
</LinearLayout>
|
|
@ -0,0 +1,25 @@
|
|||
<?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/. -->
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/onboarding_card"
|
||||
style="@style/OnboardingCardLight"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:id="@+id/header_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="14dp"
|
||||
android:text="@string/onboarding_private_browsing_header"
|
||||
android:textAppearance="@style/HeaderTextStyle" />
|
||||
<TextView
|
||||
android:id="@+id/description_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/onboarding_private_browsing_description"
|
||||
android:textAppearance="@style/Body14TextStyle" />
|
||||
</LinearLayout>
|
|
@ -4,20 +4,20 @@
|
|||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/onboarding_header"
|
||||
android:id="@+id/onboarding_card"
|
||||
style="@style/OnboardingCardLight"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:id="@+id/theme_picker_header"
|
||||
android:id="@+id/header_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="14dp"
|
||||
android:text="@string/onboarding_theme_picker_header"
|
||||
android:textAppearance="@style/HeaderTextStyle" />
|
||||
<TextView
|
||||
android:id="@+id/theme_picker_description"
|
||||
android:id="@+id/description_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/onboarding_theme_picker_description"
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
<?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/. -->
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/onboarding_card"
|
||||
style="@style/OnboardingCardLight"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:id="@+id/header_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="14dp"
|
||||
android:text="@string/onboarding_tracking_protection_header"
|
||||
android:textAppearance="@style/HeaderTextStyle" />
|
||||
<TextView
|
||||
android:id="@+id/description_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/onboarding_tracking_protection_description"
|
||||
android:textAppearance="@style/Body14TextStyle" />
|
||||
</LinearLayout>
|
|
@ -487,8 +487,9 @@
|
|||
<string name="url_copied">URL copied</string>
|
||||
|
||||
<!-- Onboarding -->
|
||||
<!-- Text for onboarding welcome message-->
|
||||
<string name="onboarding_header">Welcome to Firefox!</string>
|
||||
<!-- Text for onboarding welcome message
|
||||
The first parameter is the name of the app defined in app_name (for example: Firefox Preview) -->
|
||||
<string name="onboarding_header">Welcome to %s!</string>
|
||||
<!-- text for the Firefox Accounts section header -->
|
||||
<string name="onboarding_fxa_section_header">Already have an account?</string>
|
||||
<!-- text for the Firefox Preview feature section header
|
||||
|
@ -498,4 +499,28 @@
|
|||
<string name="onboarding_theme_picker_header">Choose your theme</string>
|
||||
<!-- text for the theme picker onboarding card description -->
|
||||
<string name="onboarding_theme_picker_description">Save some battery and your eyesight by enabling dark mode.</string>
|
||||
<!-- text for the firefox account onboarding card header
|
||||
The first parameter is the name of the app defined in app_name (for example: Firefox Preview) -->
|
||||
<string name="onboarding_firefox_account_header">Get the most out of %s</string>
|
||||
<!-- text for the tracking protection onboarding card header -->
|
||||
<string name="onboarding_tracking_protection_header">Protect yourself</string>
|
||||
<!-- text for the tracking protection card description
|
||||
The first parameter is the name of the app defined in app_name (for example: Firefox Preview) -->
|
||||
<string name="onboarding_tracking_protection_description">%s helps stop websites from tracking you online, making it
|
||||
harder for ads to follow you around the web
|
||||
</string>
|
||||
<!-- text for the private browsing onboarding card header -->
|
||||
<string name="onboarding_private_browsing_header">Browse Privately</string>
|
||||
<!-- text for the private browsing onboarding card description
|
||||
The first parameter is an icon that represents private browsing -->
|
||||
<string name="onboarding_private_browsing_description">Private Browsing is always just a tap or two away, just look
|
||||
for the private browsing icon (%s)
|
||||
</string>
|
||||
<!-- text for the privacy notice onboarding card header -->
|
||||
<string name="onboarding_privacy_notice_header">Your Privacy</string>
|
||||
<!-- text for the privacy notice onboarding card description
|
||||
The first parameter is the name of the app defined in app_name (for example: Firefox Preview) -->
|
||||
<string name="onboarding_privacy_notice_description">We\'ve designed %s to give you control over what you share
|
||||
online and what you share with us.
|
||||
</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue