|
|
@ -6,29 +6,36 @@ package org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding
|
|
|
|
|
|
|
|
|
|
|
|
import android.view.View
|
|
|
|
import android.view.View
|
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
|
|
import kotlinx.android.synthetic.main.onboarding_toolbar_position_picker.view.*
|
|
|
|
import kotlinx.android.synthetic.main.onboarding_toolbar_position_picker.view.toolbar_bottom_image
|
|
|
|
|
|
|
|
import kotlinx.android.synthetic.main.onboarding_toolbar_position_picker.view.toolbar_bottom_radio_button
|
|
|
|
|
|
|
|
import kotlinx.android.synthetic.main.onboarding_toolbar_position_picker.view.toolbar_top_image
|
|
|
|
|
|
|
|
import kotlinx.android.synthetic.main.onboarding_toolbar_position_picker.view.toolbar_top_radio_button
|
|
|
|
import org.mozilla.fenix.R
|
|
|
|
import org.mozilla.fenix.R
|
|
|
|
import org.mozilla.fenix.ext.asActivity
|
|
|
|
import org.mozilla.fenix.ext.asActivity
|
|
|
|
import org.mozilla.fenix.ext.settings
|
|
|
|
import org.mozilla.fenix.ext.settings
|
|
|
|
|
|
|
|
import org.mozilla.fenix.onboarding.OnboardingRadioButton
|
|
|
|
|
|
|
|
|
|
|
|
class OnboardingToolbarPositionPickerViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
|
|
|
class OnboardingToolbarPositionPickerViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
|
|
|
|
|
|
|
|
|
|
|
init {
|
|
|
|
init {
|
|
|
|
val radioTopToolbar = view.toolbar_top_radio_button
|
|
|
|
val radioTopToolbar = view.toolbar_top_radio_button
|
|
|
|
val radioBottomToolbar = view.toolbar_bottom_radio_button
|
|
|
|
val radioBottomToolbar = view.toolbar_bottom_radio_button
|
|
|
|
|
|
|
|
val radio: OnboardingRadioButton
|
|
|
|
|
|
|
|
|
|
|
|
radioTopToolbar.addToRadioGroup(radioBottomToolbar)
|
|
|
|
radioTopToolbar.addToRadioGroup(radioBottomToolbar)
|
|
|
|
radioBottomToolbar.addToRadioGroup(radioTopToolbar)
|
|
|
|
radioBottomToolbar.addToRadioGroup(radioTopToolbar)
|
|
|
|
|
|
|
|
|
|
|
|
with(view.context.settings()) {
|
|
|
|
if (view.context.settings().shouldUseBottomToolbar) {
|
|
|
|
val radio = when {
|
|
|
|
radio = radioBottomToolbar
|
|
|
|
this.shouldUseBottomToolbar -> radioBottomToolbar
|
|
|
|
setBottomIllustrationSelected()
|
|
|
|
else -> radioTopToolbar
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
radio = radioTopToolbar
|
|
|
|
radio.isChecked = true
|
|
|
|
setTopIllustrationSelected()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
radio.isChecked = true
|
|
|
|
|
|
|
|
|
|
|
|
radioBottomToolbar.onClickListener {
|
|
|
|
radioBottomToolbar.onClickListener {
|
|
|
|
|
|
|
|
setBottomIllustrationSelected()
|
|
|
|
itemView.context.asActivity()?.recreate()
|
|
|
|
itemView.context.asActivity()?.recreate()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -37,6 +44,7 @@ class OnboardingToolbarPositionPickerViewHolder(view: View) : RecyclerView.ViewH
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
radioTopToolbar.onClickListener {
|
|
|
|
radioTopToolbar.onClickListener {
|
|
|
|
|
|
|
|
setTopIllustrationSelected()
|
|
|
|
itemView.context.asActivity()?.recreate()
|
|
|
|
itemView.context.asActivity()?.recreate()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -45,6 +53,16 @@ class OnboardingToolbarPositionPickerViewHolder(view: View) : RecyclerView.ViewH
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun setTopIllustrationSelected() {
|
|
|
|
|
|
|
|
itemView.toolbar_top_image.isSelected = true
|
|
|
|
|
|
|
|
itemView.toolbar_bottom_image.isSelected = false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun setBottomIllustrationSelected() {
|
|
|
|
|
|
|
|
itemView.toolbar_top_image.isSelected = false
|
|
|
|
|
|
|
|
itemView.toolbar_bottom_image.isSelected = true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
companion object {
|
|
|
|
companion object {
|
|
|
|
const val LAYOUT_ID = R.layout.onboarding_toolbar_position_picker
|
|
|
|
const val LAYOUT_ID = R.layout.onboarding_toolbar_position_picker
|
|
|
|
}
|
|
|
|
}
|
|
|
|