mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-09 19:10:42 +00:00
* For #7254: Replace anko applyConstraintSet * Anko has been deprecated and will not be continued * Refactor ConstraintSet changes * Replace applyConstraintSet in SearchLayouts * Refactor HomeFragment ConstraintSet * Define anonymous ConstraintSet * Remove ConstraintSet prefix from PARENT_ID
This commit is contained in:
parent
c5a142aa14
commit
a40af5b134
@ -18,7 +18,12 @@ import android.widget.LinearLayout
|
||||
import android.widget.PopupWindow
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.constraintlayout.widget.ConstraintLayout.LayoutParams.PARENT_ID
|
||||
import androidx.constraintlayout.widget.ConstraintSet
|
||||
import androidx.constraintlayout.widget.ConstraintSet.BOTTOM
|
||||
import androidx.constraintlayout.widget.ConstraintSet.TOP
|
||||
import androidx.constraintlayout.widget.ConstraintSet.START
|
||||
import androidx.constraintlayout.widget.ConstraintSet.END
|
||||
import androidx.constraintlayout.widget.ConstraintSet.PARENT_ID
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.lifecycle.Lifecycle
|
||||
@ -53,11 +58,6 @@ import mozilla.components.feature.media.ext.getSession
|
||||
import mozilla.components.feature.media.state.MediaState
|
||||
import mozilla.components.feature.media.state.MediaStateMachine
|
||||
import mozilla.components.feature.tab.collections.TabCollection
|
||||
import org.jetbrains.anko.constraint.layout.ConstraintSetBuilder.Side.BOTTOM
|
||||
import org.jetbrains.anko.constraint.layout.ConstraintSetBuilder.Side.END
|
||||
import org.jetbrains.anko.constraint.layout.ConstraintSetBuilder.Side.START
|
||||
import org.jetbrains.anko.constraint.layout.ConstraintSetBuilder.Side.TOP
|
||||
import org.jetbrains.anko.constraint.layout.applyConstraintSet
|
||||
import org.mozilla.fenix.BrowserDirection
|
||||
import org.mozilla.fenix.HomeActivity
|
||||
import org.mozilla.fenix.R
|
||||
@ -197,15 +197,13 @@ class HomeFragment : Fragment() {
|
||||
|
||||
sessionControlView = SessionControlView(homeFragmentStore, view.homeLayout, sessionControlInteractor)
|
||||
|
||||
view.homeLayout.applyConstraintSet {
|
||||
sessionControlView.view {
|
||||
connect(
|
||||
TOP to BOTTOM of view.wordmark_spacer,
|
||||
START to START of PARENT_ID,
|
||||
END to END of PARENT_ID,
|
||||
BOTTOM to TOP of view.bottom_bar
|
||||
)
|
||||
}
|
||||
ConstraintSet().apply {
|
||||
clone(view.homeLayout)
|
||||
connect(sessionControlView.view.id, TOP, view.wordmark_spacer.id, BOTTOM)
|
||||
connect(sessionControlView.view.id, START, PARENT_ID, START)
|
||||
connect(sessionControlView.view.id, END, PARENT_ID, END)
|
||||
connect(sessionControlView.view.id, BOTTOM, view.bottom_bar.id, TOP)
|
||||
applyTo(view.homeLayout)
|
||||
}
|
||||
|
||||
activity.themeManager.applyStatusBarTheme(activity)
|
||||
|
@ -6,14 +6,13 @@ package org.mozilla.fenix.search
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.constraintlayout.widget.ConstraintLayout.LayoutParams.PARENT_ID
|
||||
import androidx.constraintlayout.widget.ConstraintLayout.LayoutParams.UNSET
|
||||
import androidx.constraintlayout.widget.ConstraintLayout.LayoutParams.TOP
|
||||
import androidx.constraintlayout.widget.ConstraintLayout.LayoutParams.BOTTOM
|
||||
import androidx.constraintlayout.widget.ConstraintSet
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import kotlinx.android.synthetic.main.component_awesomebar.*
|
||||
import kotlinx.android.synthetic.main.fragment_search.*
|
||||
import mozilla.components.support.base.log.logger.Logger
|
||||
import org.jetbrains.anko.constraint.layout.ConstraintSetBuilder.Side.BOTTOM
|
||||
import org.jetbrains.anko.constraint.layout.ConstraintSetBuilder.Side.TOP
|
||||
import org.jetbrains.anko.constraint.layout.applyConstraintSet
|
||||
import org.mozilla.fenix.Experiments.AATestDescriptor
|
||||
import org.mozilla.fenix.isInExperiment
|
||||
|
||||
@ -32,54 +31,43 @@ internal fun SearchFragment.layoutComponents(layout: ConstraintLayout) {
|
||||
|
||||
internal fun SearchFragment.setInExperimentConstraints(layout: ConstraintLayout) {
|
||||
Logger.debug("Loading in experiment constraints")
|
||||
layout.applyConstraintSet {
|
||||
toolbar_wrapper {
|
||||
connect(
|
||||
TOP to TOP of UNSET,
|
||||
BOTTOM to TOP of pillWrapper
|
||||
)
|
||||
}
|
||||
awesomeBar {
|
||||
connect(
|
||||
TOP to TOP of PARENT_ID,
|
||||
BOTTOM to TOP of toolbar_wrapper
|
||||
)
|
||||
}
|
||||
|
||||
ConstraintSet().apply {
|
||||
clone(layout)
|
||||
|
||||
// Move the search bar to the bottom of the layout
|
||||
clear(toolbar_wrapper.id, TOP)
|
||||
connect(toolbar_wrapper.id, BOTTOM, pillWrapper.id, TOP)
|
||||
|
||||
connect(awesomeBar.id, TOP, PARENT_ID, TOP)
|
||||
connect(awesomeBar.id, BOTTOM, toolbar_wrapper.id, TOP)
|
||||
(awesomeBar.layoutManager as? LinearLayoutManager)?.reverseLayout = true
|
||||
pillWrapper {
|
||||
connect(
|
||||
BOTTOM to BOTTOM of PARENT_ID
|
||||
)
|
||||
}
|
||||
|
||||
connect(pillWrapper.id, BOTTOM, PARENT_ID, BOTTOM)
|
||||
|
||||
applyTo(layout)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun SearchFragment.setOutOfExperimentConstraints(layout: ConstraintLayout) {
|
||||
Logger.debug("Loading out of experiment constraints")
|
||||
layout.applyConstraintSet {
|
||||
toolbar_wrapper {
|
||||
connect(
|
||||
TOP to TOP of PARENT_ID,
|
||||
BOTTOM to TOP of UNSET
|
||||
)
|
||||
}
|
||||
fill_link_from_clipboard {
|
||||
connect(
|
||||
TOP to BOTTOM of toolbar_wrapper
|
||||
)
|
||||
}
|
||||
awesomeBar {
|
||||
connect(
|
||||
TOP to TOP of UNSET,
|
||||
TOP to BOTTOM of search_with_shortcuts,
|
||||
BOTTOM to TOP of pillWrapper
|
||||
)
|
||||
}
|
||||
|
||||
ConstraintSet().apply {
|
||||
clone(layout)
|
||||
|
||||
// Move the search bar to the top of the layout
|
||||
connect(toolbar_wrapper.id, TOP, PARENT_ID, TOP)
|
||||
clear(toolbar_wrapper.id, BOTTOM)
|
||||
|
||||
connect(fill_link_from_clipboard.id, TOP, toolbar_wrapper.id, BOTTOM)
|
||||
|
||||
clear(awesomeBar.id, TOP)
|
||||
connect(awesomeBar.id, TOP, search_with_shortcuts.id, BOTTOM)
|
||||
connect(awesomeBar.id, BOTTOM, pillWrapper.id, TOP)
|
||||
(awesomeBar.layoutManager as? LinearLayoutManager)?.reverseLayout = false
|
||||
pillWrapper {
|
||||
connect(
|
||||
BOTTOM to BOTTOM of PARENT_ID
|
||||
)
|
||||
}
|
||||
|
||||
connect(pillWrapper.id, BOTTOM, PARENT_ID, BOTTOM)
|
||||
|
||||
applyTo(layout)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user