mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-11 13:11:01 +00:00
parent
3fbfdac129
commit
24396d174f
@ -38,6 +38,8 @@ import org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding.OnboardingPr
|
|||||||
import org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding.OnboardingSectionHeaderViewHolder
|
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.OnboardingThemePickerViewHolder
|
||||||
import org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding.OnboardingTrackingProtectionViewHolder
|
import org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding.OnboardingTrackingProtectionViewHolder
|
||||||
|
import org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding.OnboardingWhatsNewViewHolder
|
||||||
|
|
||||||
import mozilla.components.feature.tab.collections.Tab as ComponentTab
|
import mozilla.components.feature.tab.collections.Tab as ComponentTab
|
||||||
|
|
||||||
sealed class AdapterItem(@LayoutRes val viewType: Int) {
|
sealed class AdapterItem(@LayoutRes val viewType: Int) {
|
||||||
@ -109,6 +111,7 @@ sealed class AdapterItem(@LayoutRes val viewType: Int) {
|
|||||||
object OnboardingPrivateBrowsing : AdapterItem(OnboardingPrivateBrowsingViewHolder.LAYOUT_ID)
|
object OnboardingPrivateBrowsing : AdapterItem(OnboardingPrivateBrowsingViewHolder.LAYOUT_ID)
|
||||||
object OnboardingPrivacyNotice : AdapterItem(OnboardingPrivacyNoticeViewHolder.LAYOUT_ID)
|
object OnboardingPrivacyNotice : AdapterItem(OnboardingPrivacyNoticeViewHolder.LAYOUT_ID)
|
||||||
object OnboardingFinish : AdapterItem(OnboardingFinishViewHolder.LAYOUT_ID)
|
object OnboardingFinish : AdapterItem(OnboardingFinishViewHolder.LAYOUT_ID)
|
||||||
|
object OnboardingWhatsNew : AdapterItem(OnboardingWhatsNewViewHolder.LAYOUT_ID)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if this item represents the same value as other. Used by [AdapterItemDiffCallback].
|
* True if this item represents the same value as other. Used by [AdapterItemDiffCallback].
|
||||||
@ -168,6 +171,7 @@ class SessionControlAdapter(
|
|||||||
OnboardingPrivateBrowsingViewHolder.LAYOUT_ID -> OnboardingPrivateBrowsingViewHolder(view)
|
OnboardingPrivateBrowsingViewHolder.LAYOUT_ID -> OnboardingPrivateBrowsingViewHolder(view)
|
||||||
OnboardingPrivacyNoticeViewHolder.LAYOUT_ID -> OnboardingPrivacyNoticeViewHolder(view)
|
OnboardingPrivacyNoticeViewHolder.LAYOUT_ID -> OnboardingPrivacyNoticeViewHolder(view)
|
||||||
OnboardingFinishViewHolder.LAYOUT_ID -> OnboardingFinishViewHolder(view, interactor)
|
OnboardingFinishViewHolder.LAYOUT_ID -> OnboardingFinishViewHolder(view, interactor)
|
||||||
|
OnboardingWhatsNewViewHolder.LAYOUT_ID -> OnboardingWhatsNewViewHolder(view)
|
||||||
else -> throw IllegalStateException()
|
else -> throw IllegalStateException()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,6 +111,7 @@ private fun onboardingAdapterItems(onboardingState: OnboardingState): List<Adapt
|
|||||||
val appName = it.getString(R.string.app_name)
|
val appName = it.getString(R.string.app_name)
|
||||||
it.getString(R.string.onboarding_feature_section_header, appName)
|
it.getString(R.string.onboarding_feature_section_header, appName)
|
||||||
},
|
},
|
||||||
|
AdapterItem.OnboardingWhatsNew,
|
||||||
AdapterItem.OnboardingThemePicker,
|
AdapterItem.OnboardingThemePicker,
|
||||||
AdapterItem.OnboardingTrackingProtection,
|
AdapterItem.OnboardingTrackingProtection,
|
||||||
AdapterItem.OnboardingPrivateBrowsing,
|
AdapterItem.OnboardingPrivateBrowsing,
|
||||||
|
@ -5,8 +5,10 @@
|
|||||||
package org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding
|
package org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding
|
||||||
|
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import androidx.annotation.ColorRes
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import androidx.appcompat.content.res.AppCompatResources
|
import androidx.appcompat.content.res.AppCompatResources
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import mozilla.components.support.ktx.android.view.putCompoundDrawablesRelative
|
import mozilla.components.support.ktx.android.view.putCompoundDrawablesRelative
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.ext.setBounds
|
import org.mozilla.fenix.ext.setBounds
|
||||||
@ -14,10 +16,12 @@ import org.mozilla.fenix.ext.setBounds
|
|||||||
/**
|
/**
|
||||||
* Sets the drawableStart of a header in an onboarding card.
|
* Sets the drawableStart of a header in an onboarding card.
|
||||||
*/
|
*/
|
||||||
fun TextView.setOnboardingIcon(@DrawableRes id: Int) {
|
fun TextView.setOnboardingIcon(@DrawableRes id: Int, @ColorRes tint: Int? = null) {
|
||||||
val icon = AppCompatResources.getDrawable(context, id)
|
val icon = AppCompatResources.getDrawable(context, id)
|
||||||
val size = context.resources.getDimensionPixelSize(R.dimen.onboarding_header_icon_height_width)
|
val size = context.resources.getDimensionPixelSize(R.dimen.onboarding_header_icon_height_width)
|
||||||
icon?.setBounds(size)
|
icon?.setBounds(size)
|
||||||
|
tint?.let {
|
||||||
|
icon?.setTint(ContextCompat.getColor(context, tint))
|
||||||
|
}
|
||||||
putCompoundDrawablesRelative(start = icon)
|
putCompoundDrawablesRelative(start = icon)
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
/* 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.style.UnderlineSpan
|
||||||
|
import android.view.View
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import kotlinx.android.synthetic.main.onboarding_tracking_protection.view.header_text
|
||||||
|
import kotlinx.android.synthetic.main.onboarding_whats_new.view.*
|
||||||
|
import kotlinx.android.synthetic.main.onboarding_whats_new.view.description_text
|
||||||
|
import org.mozilla.fenix.R
|
||||||
|
import org.mozilla.fenix.settings.SupportUtils
|
||||||
|
|
||||||
|
class OnboardingWhatsNewViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
view.header_text.setOnboardingIcon(R.drawable.ic_whats_new, R.color.accent_bright_dark_theme)
|
||||||
|
|
||||||
|
val appName = view.context.getString(R.string.app_name)
|
||||||
|
view.description_text.text = view.context.getString(R.string.onboarding_whats_new_description, appName)
|
||||||
|
|
||||||
|
val getAnswersText = view.get_answers.text.toString()
|
||||||
|
val textWithLink = SpannableString(getAnswersText).apply {
|
||||||
|
setSpan(UnderlineSpan(), 0, getAnswersText.length, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
view.get_answers.text = textWithLink
|
||||||
|
view.get_answers.setOnClickListener {
|
||||||
|
val intent = SupportUtils.createCustomTabIntent(view.context, SupportUtils.getWhatsNewUrl(view.context))
|
||||||
|
view.context.startActivity(intent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val LAYOUT_ID = R.layout.onboarding_whats_new
|
||||||
|
}
|
||||||
|
}
|
50
app/src/main/res/layout/onboarding_whats_new.xml
Normal file
50
app/src/main/res/layout/onboarding_whats_new.xml
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?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/. -->
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/onboarding_card"
|
||||||
|
style="@style/OnboardingCardLight"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/header_text"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/onboarding_whats_new_header1"
|
||||||
|
tools:drawableStart="@drawable/ic_whats_new"
|
||||||
|
android:drawablePadding="12dp"
|
||||||
|
android:textAppearance="@style/HeaderTextStyle"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:lines="1"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/description_text"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="@style/Body14TextStyle"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
tools:text="@string/onboarding_whats_new_description"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/header_text"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintBottom_toTopOf="@id/get_answers"/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/get_answers"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="@style/Body14TextStyle"
|
||||||
|
android:paddingTop="12dp"
|
||||||
|
android:paddingBottom="12dp"
|
||||||
|
android:text="@string/onboarding_whats_new_description_linktext"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/description_text"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue
Block a user