diff --git a/search/src/main/kotlin/com/alfresco/content/search/SearchChipCategory.kt b/search/src/main/kotlin/com/alfresco/content/search/SearchChipCategory.kt index 265e79fa3..5921b80cd 100644 --- a/search/src/main/kotlin/com/alfresco/content/search/SearchChipCategory.kt +++ b/search/src/main/kotlin/com/alfresco/content/search/SearchChipCategory.kt @@ -61,6 +61,8 @@ data class SearchChipCategory( fun resetData(searchChipCategory: SearchChipCategory): SearchChipCategory { return SearchChipCategory( category = searchChipCategory.category, + fieldsItem = searchChipCategory.fieldsItem, + intervalsItem = searchChipCategory.intervalsItem, isSelected = searchChipCategory.category?.component == null, selectedName = "", selectedQuery = "" @@ -89,7 +91,7 @@ data class SearchChipCategory( return SearchChipCategory( category = CategoriesItem( null, Component(null, ChipComponentType.FACET_FIELDS.component), - null, data.label, null + data.label, data.label, null ), fieldsItem = data, selectedName = "", @@ -104,7 +106,7 @@ data class SearchChipCategory( return SearchChipCategory( category = CategoriesItem( null, Component(null, ChipComponentType.FACET_INTERVALS.component), - null, data.label, null + data.label, data.label, null ), intervalsItem = data, selectedName = "", diff --git a/search/src/main/kotlin/com/alfresco/content/search/components/CreateComponentsSheet.kt b/search/src/main/kotlin/com/alfresco/content/search/components/CreateComponentsSheet.kt index 4a2f59c44..a5ad12b56 100644 --- a/search/src/main/kotlin/com/alfresco/content/search/components/CreateComponentsSheet.kt +++ b/search/src/main/kotlin/com/alfresco/content/search/components/CreateComponentsSheet.kt @@ -4,10 +4,13 @@ import android.annotation.SuppressLint import android.os.Bundle import android.text.Editable import android.text.TextWatcher +import android.util.TypedValue import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.view.WindowManager +import android.widget.LinearLayout +import android.widget.RelativeLayout import androidx.lifecycle.lifecycleScope import com.airbnb.epoxy.AsyncEpoxyController import com.airbnb.mvrx.MavericksView @@ -40,6 +43,7 @@ class CreateComponentsSheet : BottomSheetDialogFragment(), MavericksView { var onReset: ComponentResetCallback? = null var onCancel: ComponentCancelCallback? = null var executedPicker = false + private val minVisibleItem = 10 override fun onCreateView( inflater: LayoutInflater, @@ -56,7 +60,6 @@ class CreateComponentsSheet : BottomSheetDialogFragment(), MavericksView { dialog?.setOnCancelListener { onCancel?.invoke() } - setupComponents() setListeners() } @@ -69,8 +72,6 @@ class CreateComponentsSheet : BottomSheetDialogFragment(), MavericksView { bottomSheet?.let { BottomSheetBehavior.from(it).apply { val peekAmount = 1.0 - isHideable = false - skipCollapsed = false peekHeight = ((it.parent as View).height * peekAmount).toInt() } } @@ -79,7 +80,10 @@ class CreateComponentsSheet : BottomSheetDialogFragment(), MavericksView { private fun setupComponents() { withState(viewModel) { state -> - binding.title.text = state.parent.category?.name + binding.parentView.removeAllViews() + binding.parentView.addView(binding.topView) + binding.parentView.addView(binding.separator) + binding.title.text = requireContext().getLocalizedName(state.parent.category?.name ?: "") when (state.parent.category?.component?.selector) { ChipComponentType.TEXT.component -> setupTextComponent(state) ChipComponentType.CHECK_LIST.component -> setupCheckListComponent() @@ -88,7 +92,9 @@ class CreateComponentsSheet : BottomSheetDialogFragment(), MavericksView { ChipComponentType.SLIDER.component -> setupSliderComponent(state) ChipComponentType.DATE_RANGE.component -> setupDateRangeComponent(state) ChipComponentType.FACET_FIELDS.component, - ChipComponentType.FACET_INTERVALS.component -> setupFacetComponent() + ChipComponentType.FACET_INTERVALS.component -> { + setupFacetComponent(state) + } } } } @@ -130,6 +136,7 @@ class CreateComponentsSheet : BottomSheetDialogFragment(), MavericksView { } private fun setupTextComponent(state: ComponentCreateState) { + binding.parentView.addView(binding.frameText) binding.textComponent.componentParent.visibility = View.VISIBLE binding.textComponent.nameInput.isFocusableInTouchMode = true binding.textComponent.nameInput.requestFocus() @@ -152,12 +159,14 @@ class CreateComponentsSheet : BottomSheetDialogFragment(), MavericksView { } private fun setupCheckListComponent() { + binding.parentView.addView(binding.frameCheckList) viewModel.buildCheckListModel() binding.checkListComponent.componentParent.visibility = View.VISIBLE binding.checkListComponent.recyclerView.setController(epoxyCheckListController) } private fun setupRadioListComponent(state: ComponentCreateState) { + binding.parentView.addView(binding.frameRadio) viewModel.buildSingleDataModel() if (state.parent.selectedName.isEmpty()) viewModel.copyDefaultComponentData() @@ -166,6 +175,7 @@ class CreateComponentsSheet : BottomSheetDialogFragment(), MavericksView { } private fun setupNumberRangeComponent(state: ComponentCreateState) { + binding.parentView.addView(binding.frameNumberRange) viewModel.buildSingleDataModel() binding.numberRangeComponent.componentParent.visibility = View.VISIBLE binding.numberRangeComponent.fromInput.isFocusableInTouchMode = true @@ -222,6 +232,7 @@ class CreateComponentsSheet : BottomSheetDialogFragment(), MavericksView { } private fun setupSliderComponent(state: ComponentCreateState) { + binding.parentView.addView(binding.frameSlider) viewModel.fromValue = "0" viewModel.buildSingleDataModel() binding.sliderComponent.componentParent.visibility = View.VISIBLE @@ -250,6 +261,8 @@ class CreateComponentsSheet : BottomSheetDialogFragment(), MavericksView { } private fun setupDateRangeComponent(state: ComponentCreateState) { + + binding.parentView.addView(binding.frameDateRange) binding.dateRangeComponent.componentParent.visibility = View.VISIBLE binding.dateRangeComponent.fromInput.inputType = 0 @@ -331,8 +344,15 @@ class CreateComponentsSheet : BottomSheetDialogFragment(), MavericksView { } @SuppressLint("ClickableViewAccessibility") - private fun setupFacetComponent() { + private fun setupFacetComponent(state: ComponentCreateState) { viewModel.buildCheckListModel() + binding.parentView.addView(binding.frameFacet) + state.parent.fieldsItem?.buckets?.let { + if (it.size > minVisibleItem) { + binding.facetCheckListComponent.recyclerView.layoutParams = getRecyclerviewLayoutParams() + binding.facetCheckListComponent.searchInputLayout.visibility = View.VISIBLE + } + } binding.facetCheckListComponent.componentParent.visibility = View.VISIBLE binding.facetCheckListComponent.recyclerView.setController(epoxyCheckFacetListController) binding.facetCheckListComponent.searchInputLayout.editText?.addTextChangedListener(object : TextWatcher { @@ -468,4 +488,9 @@ class CreateComponentsSheet : BottomSheetDialogFragment(), MavericksView { } } } + + private fun getRecyclerviewLayoutParams(): LinearLayout.LayoutParams { + val calculatedHeight = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, minVisibleItem * 48f, resources.displayMetrics).toInt() + return LinearLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, calculatedHeight) + } } diff --git a/search/src/main/kotlin/com/alfresco/content/search/components/ListViewFacetCheckRow.kt b/search/src/main/kotlin/com/alfresco/content/search/components/ListViewFacetCheckRow.kt index 5d72e5dc7..a11eb9f8c 100644 --- a/search/src/main/kotlin/com/alfresco/content/search/components/ListViewFacetCheckRow.kt +++ b/search/src/main/kotlin/com/alfresco/content/search/components/ListViewFacetCheckRow.kt @@ -8,6 +8,7 @@ import com.airbnb.epoxy.CallbackProp import com.airbnb.epoxy.ModelProp import com.airbnb.epoxy.ModelView import com.alfresco.content.data.Buckets +import com.alfresco.content.search.R import com.alfresco.content.search.databinding.ViewCheckListRowBinding @ModelView(autoLayout = ModelView.Size.MATCH_WIDTH_WRAP_HEIGHT) @@ -21,9 +22,9 @@ internal class ListViewFacetCheckRow @JvmOverloads constructor( @ModelProp fun setData(options: Buckets) { if (options.metrics == null) { - binding.title.text = options.label + " (${options.count})" + binding.title.text = String.format(context.getString(R.string.label_count_format_integer), options.label, options.count) } else { - binding.title.text = options.label + " (${options.metrics?.get(0)?.value?.count})" + binding.title.text = String.format(context.getString(R.string.label_count_format_string), options.label, options.metrics?.get(0)?.value?.count) } } diff --git a/search/src/main/res/layout/sheet_component_create.xml b/search/src/main/res/layout/sheet_component_create.xml index 0922ebe83..d226ca8d6 100644 --- a/search/src/main/res/layout/sheet_component_create.xml +++ b/search/src/main/res/layout/sheet_component_create.xml @@ -3,85 +3,135 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="wrap_content" android:orientation="vertical" android:paddingTop="16dp" - android:paddingBottom="16dp"> + android:paddingBottom="16dp" + android:layout_height="match_parent"> - + android:orientation="vertical" + app:behavior_hideable="false"> - - - + android:layout_height="wrap_content"> + + + + + + + android:layout_marginTop="8dp"> + + + + + + layout="@layout/view_check_list_component" /> + + + + layout="@layout/view_number_range_component" /> + + + + layout="@layout/view_slider_component" /> + + + + layout="@layout/view_date_range_component" /> + + + + layout="@layout/view_facet_check_list_component" /> + - - + - - - - - - - + android:layout_marginEnd="@dimen/component_default_margin" + android:orientation="vertical"> + + + + + + + + + + diff --git a/search/src/main/res/layout/view_check_list_component.xml b/search/src/main/res/layout/view_check_list_component.xml index dfab27dce..a6c1f1740 100644 --- a/search/src/main/res/layout/view_check_list_component.xml +++ b/search/src/main/res/layout/view_check_list_component.xml @@ -2,9 +2,9 @@ + android:layout_height="wrap_content" + android:visibility="gone"> diff --git a/search/src/main/res/layout/view_radio_list_component.xml b/search/src/main/res/layout/view_radio_list_component.xml index e4ec7ce7c..7d87c6b97 100644 --- a/search/src/main/res/layout/view_radio_list_component.xml +++ b/search/src/main/res/layout/view_radio_list_component.xml @@ -1,16 +1,16 @@ + android:visibility="gone"> diff --git a/search/src/main/res/layout/view_text_component.xml b/search/src/main/res/layout/view_text_component.xml index aa0f883f0..f489e3d1d 100644 --- a/search/src/main/res/layout/view_text_component.xml +++ b/search/src/main/res/layout/view_text_component.xml @@ -1,6 +1,5 @@ To %1$s-%2$s-%3$s %1$s... + %1$s (%2$d) + %1$s (%2$s) Size Created