2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-15 18:12:54 +00:00

[fenix] For https://github.com/mozilla-mobile/fenix/issues/6980: Add onboarding Toolbar position picker card

This commit is contained in:
mcarare 2020-01-29 17:39:05 +02:00 committed by Jeff Boek
parent 31c5947a85
commit d52a5f1fad
8 changed files with 177 additions and 0 deletions

View File

@ -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.OnboardingPrivateBrowsingViewHolder
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.OnboardingToolbarPositionPickerViewHolder
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 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 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 OnboardingToolbarPositionPicker : AdapterItem(OnboardingToolbarPositionPickerViewHolder.LAYOUT_ID)
object OnboardingWhatsNew : AdapterItem(OnboardingWhatsNewViewHolder.LAYOUT_ID) object OnboardingWhatsNew : AdapterItem(OnboardingWhatsNewViewHolder.LAYOUT_ID)
/** /**
@ -172,6 +174,7 @@ class SessionControlAdapter(
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) OnboardingWhatsNewViewHolder.LAYOUT_ID -> OnboardingWhatsNewViewHolder(view)
OnboardingToolbarPositionPickerViewHolder.LAYOUT_ID -> OnboardingToolbarPositionPickerViewHolder(view)
else -> throw IllegalStateException() else -> throw IllegalStateException()
} }
} }

View File

@ -113,6 +113,7 @@ private fun onboardingAdapterItems(onboardingState: OnboardingState): List<Adapt
AdapterItem.OnboardingThemePicker, AdapterItem.OnboardingThemePicker,
AdapterItem.OnboardingTrackingProtection, AdapterItem.OnboardingTrackingProtection,
AdapterItem.OnboardingPrivateBrowsing, AdapterItem.OnboardingPrivateBrowsing,
AdapterItem.OnboardingToolbarPositionPicker,
AdapterItem.OnboardingPrivacyNotice, AdapterItem.OnboardingPrivacyNotice,
AdapterItem.OnboardingFinish AdapterItem.OnboardingFinish
)) ))

View File

@ -0,0 +1,51 @@
/* 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
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -0,0 +1,122 @@
<?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>