@ -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 )
}
}