Commit 5bd5f815 authored by mcarare's avatar mcarare Committed by Jeff Boek
Browse files

For #6980: Add onboarding Toolbar position picker card

parent e3370442
......@@ -37,6 +37,7 @@ import org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding.OnboardingPr
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.OnboardingToolbarPositionPickerViewHolder
import org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding.OnboardingTrackingProtectionViewHolder
import org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding.OnboardingWhatsNewViewHolder
......@@ -111,6 +112,7 @@ sealed class AdapterItem(@LayoutRes val viewType: Int) {
object OnboardingPrivateBrowsing : AdapterItem(OnboardingPrivateBrowsingViewHolder.LAYOUT_ID)
object OnboardingPrivacyNotice : AdapterItem(OnboardingPrivacyNoticeViewHolder.LAYOUT_ID)
object OnboardingFinish : AdapterItem(OnboardingFinishViewHolder.LAYOUT_ID)
object OnboardingToolbarPositionPicker : AdapterItem(OnboardingToolbarPositionPickerViewHolder.LAYOUT_ID)
object OnboardingWhatsNew : AdapterItem(OnboardingWhatsNewViewHolder.LAYOUT_ID)
/**
......@@ -172,6 +174,7 @@ class SessionControlAdapter(
OnboardingPrivacyNoticeViewHolder.LAYOUT_ID -> OnboardingPrivacyNoticeViewHolder(view)
OnboardingFinishViewHolder.LAYOUT_ID -> OnboardingFinishViewHolder(view, interactor)
OnboardingWhatsNewViewHolder.LAYOUT_ID -> OnboardingWhatsNewViewHolder(view)
OnboardingToolbarPositionPickerViewHolder.LAYOUT_ID -> OnboardingToolbarPositionPickerViewHolder(view)
else -> throw IllegalStateException()
}
}
......
......@@ -113,6 +113,7 @@ private fun onboardingAdapterItems(onboardingState: OnboardingState): List<Adapt
AdapterItem.OnboardingThemePicker,
AdapterItem.OnboardingTrackingProtection,
AdapterItem.OnboardingPrivateBrowsing,
AdapterItem.OnboardingToolbarPositionPicker,
AdapterItem.OnboardingPrivacyNotice,
AdapterItem.OnboardingFinish
))
......
/* 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_toolbar_position_picker.view.*
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.asActivity
import org.mozilla.fenix.ext.settings
class OnboardingToolbarPositionPickerViewHolder(view: View) : RecyclerView.ViewHolder(view) {
init {
val radioTopToolbar = view.toolbar_top_radio_button
val radioBottomToolbar = view.toolbar_bottom_radio_button
radioTopToolbar.addToRadioGroup(radioBottomToolbar)
radioBottomToolbar.addToRadioGroup(radioTopToolbar)
with(view.context.settings()) {
val radio = when {
this.shouldUseBottomToolbar -> radioBottomToolbar
else -> radioTopToolbar
}
radio.isChecked = true
}
radioBottomToolbar.onClickListener {
itemView.context.asActivity()?.recreate()
}
view.toolbar_bottom_image.setOnClickListener {
radioBottomToolbar.performClick()
}
radioTopToolbar.onClickListener {
itemView.context.asActivity()?.recreate()
}
view.toolbar_top_image.setOnClickListener {
radioTopToolbar.performClick()
}
}
companion object {
const val LAYOUT_ID = R.layout.onboarding_toolbar_position_picker
}
}
<?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"
android:id="@+id/onboarding_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:background="@drawable/onboarding_card_background_light"
android:paddingTop="16dp"
android:paddingBottom="16dp">
<TextView
android:id="@+id/header_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:paddingBottom="14dp"
android:text="@string/onboarding_toolbar_position_header"
android:textAppearance="@style/HeaderTextStyle"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/description_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:text="@string/onboarding_toolbar_position_description"
android:textAppearance="@style/Body14TextStyle"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/header_text" />
<TextView
android:id="@+id/toolbar_top_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/preference_top_toolbar"
android:textColor="?primaryText"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="@+id/toolbar_top_image"
app:layout_constraintStart_toStartOf="@id/toolbar_top_image"
app:layout_constraintTop_toBottomOf="@id/toolbar_top_image"
app:layout_constraintBottom_toBottomOf="parent"/>
<org.mozilla.fenix.onboarding.OnboardingRadioButton
android:id="@+id/toolbar_top_radio_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/preference_top_toolbar"
android:elevation="1dp"
app:layout_constraintBottom_toBottomOf="@+id/toolbar_top_image"
app:layout_constraintCircle="@id/toolbar_top_image"
app:layout_constraintCircleAngle="298"
app:layout_constraintCircleRadius="66dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/description_text"
app:onboardingKey="@string/pref_key_toolbar_top" />
<ImageButton
android:id="@+id/toolbar_top_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:background="@drawable/onboarding_light_theme"
android:contentDescription="@string/preference_top_toolbar"
android:foreground="@drawable/rounded_ripple"
app:layout_constraintEnd_toStartOf="@+id/toolbar_bottom_image"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/description_text" />
<org.mozilla.fenix.onboarding.OnboardingRadioButton
android:id="@+id/toolbar_bottom_radio_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/preference_bottom_toolbar"
android:elevation="1dp"
app:layout_constraintBottom_toBottomOf="@+id/toolbar_bottom_image"
app:layout_constraintCircle="@id/toolbar_bottom_image"
app:layout_constraintCircleAngle="298"
app:layout_constraintCircleRadius="66dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/description_text"
app:onboardingKey="@string/pref_key_toolbar_bottom" />
<ImageButton
android:id="@+id/toolbar_bottom_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:background="@drawable/onboarding_dark_theme"
android:contentDescription="@string/preference_bottom_toolbar"
android:foreground="@drawable/rounded_ripple"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/toolbar_top_image"
app:layout_constraintTop_toBottomOf="@+id/description_text" />
<TextView
android:id="@+id/toolbar_bottom_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/preference_bottom_toolbar"
android:textColor="?primaryText"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="@+id/toolbar_bottom_image"
app:layout_constraintStart_toStartOf="@id/toolbar_bottom_image"
app:layout_constraintTop_toBottomOf="@id/toolbar_bottom_image"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment