2019-01-29 20:20:29 +01:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2019-07-12 20:38:15 +02:00
|
|
|
* 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/. */
|
2019-01-29 20:20:29 +01:00
|
|
|
|
|
|
|
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.recyclerview.widget.LinearLayoutManager
|
2019-01-31 00:51:49 +01:00
|
|
|
import kotlinx.android.synthetic.main.component_awesomebar.*
|
2019-01-29 20:20:29 +01:00
|
|
|
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
|
|
|
|
|
|
|
|
internal fun SearchFragment.layoutComponents(layout: ConstraintLayout) {
|
|
|
|
context?.let {
|
|
|
|
when {
|
|
|
|
it.isInExperiment(AATestDescriptor) -> {
|
|
|
|
setInExperimentConstraints(layout)
|
|
|
|
}
|
|
|
|
else -> {
|
|
|
|
setOutOfExperimentConstraints(layout)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // we're unattached if context is null
|
|
|
|
}
|
|
|
|
|
|
|
|
internal fun SearchFragment.setInExperimentConstraints(layout: ConstraintLayout) {
|
|
|
|
Logger.debug("Loading in experiment constraints")
|
|
|
|
layout.applyConstraintSet {
|
|
|
|
toolbar_wrapper {
|
|
|
|
connect(
|
|
|
|
TOP to TOP of UNSET,
|
2019-08-03 10:14:35 +02:00
|
|
|
BOTTOM to TOP of pillWrapper
|
2019-01-29 20:20:29 +01:00
|
|
|
)
|
|
|
|
}
|
|
|
|
awesomeBar {
|
|
|
|
connect(
|
|
|
|
TOP to TOP of PARENT_ID,
|
|
|
|
BOTTOM to TOP of toolbar_wrapper
|
|
|
|
)
|
|
|
|
}
|
|
|
|
(awesomeBar.layoutManager as? LinearLayoutManager)?.reverseLayout = true
|
2019-08-03 10:14:35 +02:00
|
|
|
pillWrapper {
|
2019-01-29 20:20:29 +01:00
|
|
|
connect(
|
|
|
|
BOTTOM to BOTTOM of PARENT_ID
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
)
|
|
|
|
}
|
2019-09-16 17:58:19 +02:00
|
|
|
fill_link_from_clipboard {
|
2019-03-29 21:49:50 +01:00
|
|
|
connect(
|
|
|
|
TOP to BOTTOM of toolbar_wrapper
|
|
|
|
)
|
|
|
|
}
|
2019-01-29 20:20:29 +01:00
|
|
|
awesomeBar {
|
|
|
|
connect(
|
|
|
|
TOP to TOP of UNSET,
|
2019-09-16 17:58:19 +02:00
|
|
|
TOP to BOTTOM of search_with_shortcuts,
|
2019-08-03 10:14:35 +02:00
|
|
|
BOTTOM to TOP of pillWrapper
|
2019-01-29 20:20:29 +01:00
|
|
|
)
|
|
|
|
}
|
|
|
|
(awesomeBar.layoutManager as? LinearLayoutManager)?.reverseLayout = false
|
2019-08-03 10:14:35 +02:00
|
|
|
pillWrapper {
|
2019-01-29 20:20:29 +01:00
|
|
|
connect(
|
|
|
|
BOTTOM to BOTTOM of PARENT_ID
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|