diff --git a/features/feature_change_record/src/main/java/com/example/util/simpletimetracker/feature_change_record/adapter/ChangeRecordCommentFieldAdapterDelegate.kt b/features/feature_change_record/src/main/java/com/example/util/simpletimetracker/feature_change_record/adapter/ChangeRecordCommentFieldAdapterDelegate.kt index b617603ff..10030ea65 100644 --- a/features/feature_change_record/src/main/java/com/example/util/simpletimetracker/feature_change_record/adapter/ChangeRecordCommentFieldAdapterDelegate.kt +++ b/features/feature_change_record/src/main/java/com/example/util/simpletimetracker/feature_change_record/adapter/ChangeRecordCommentFieldAdapterDelegate.kt @@ -1,6 +1,9 @@ package com.example.util.simpletimetracker.feature_change_record.adapter +import android.content.res.ColorStateList import android.text.TextWatcher +import androidx.annotation.ColorInt +import androidx.core.view.ViewCompat import androidx.core.widget.doAfterTextChanged import com.example.util.simpletimetracker.feature_base_adapter.ViewHolderType import com.example.util.simpletimetracker.feature_base_adapter.createRecyclerBindingAdapterDelegate @@ -10,7 +13,7 @@ import com.example.util.simpletimetracker.feature_change_record.databinding.Chan fun createChangeRecordCommentFieldAdapterDelegate( afterTextChange: (String) -> Unit, - onSearchClick: () -> Unit, + onFavouriteClick: () -> Unit, ) = createRecyclerBindingAdapterDelegate( Binding::inflate, ) { binding, item, _ -> @@ -20,8 +23,13 @@ fun createChangeRecordCommentFieldAdapterDelegate( if (item.text != etChangeRecordCommentField.text.toString()) { etChangeRecordCommentField.setText(item.text) + etChangeRecordCommentField.setSelection(item.text.length) } - btnChangeRecordSearchCommentField.setOnClick { onSearchClick() } + ViewCompat.setBackgroundTintList( + binding.ivChangeRecordFavouriteComment, + ColorStateList.valueOf(item.iconColor), + ) + btnChangeRecordCommentField.setOnClick { onFavouriteClick() } etChangeRecordCommentField.removeTextChangedListener(textWatcher) textWatcher = etChangeRecordCommentField.doAfterTextChanged { afterTextChange(it.toString()) } @@ -31,6 +39,7 @@ fun createChangeRecordCommentFieldAdapterDelegate( data class ChangeRecordCommentFieldViewData( val id: Long, val text: String, + @ColorInt val iconColor: Int, ) : ViewHolderType { override fun getUniqueId(): Long = id diff --git a/features/feature_change_record/src/main/java/com/example/util/simpletimetracker/feature_change_record/interactor/ChangeRecordViewDataInteractor.kt b/features/feature_change_record/src/main/java/com/example/util/simpletimetracker/feature_change_record/interactor/ChangeRecordViewDataInteractor.kt index f510b3064..6e7fefe8b 100644 --- a/features/feature_change_record/src/main/java/com/example/util/simpletimetracker/feature_change_record/interactor/ChangeRecordViewDataInteractor.kt +++ b/features/feature_change_record/src/main/java/com/example/util/simpletimetracker/feature_change_record/interactor/ChangeRecordViewDataInteractor.kt @@ -13,14 +13,11 @@ import com.example.util.simpletimetracker.domain.interactor.RunningRecordInterac import com.example.util.simpletimetracker.domain.model.Record import com.example.util.simpletimetracker.feature_base_adapter.ViewHolderType import com.example.util.simpletimetracker.feature_base_adapter.hint.HintViewData -import com.example.util.simpletimetracker.feature_base_adapter.loader.LoaderViewData import com.example.util.simpletimetracker.feature_change_record.R import com.example.util.simpletimetracker.feature_change_record.adapter.ChangeRecordCommentFieldViewData import com.example.util.simpletimetracker.feature_change_record.adapter.ChangeRecordCommentViewData import com.example.util.simpletimetracker.feature_change_record.mapper.ChangeRecordViewDataMapper import com.example.util.simpletimetracker.feature_change_record.model.ChangeRecordDateTimeFieldsState -import com.example.util.simpletimetracker.feature_change_record.viewData.ChangeRecordFavCommentState -import com.example.util.simpletimetracker.feature_change_record.viewData.ChangeRecordSearchCommentState import com.example.util.simpletimetracker.feature_change_record.viewData.ChangeRecordViewData import javax.inject.Inject @@ -61,11 +58,48 @@ class ChangeRecordViewDataInteractor @Inject constructor( ) } - suspend fun getLastCommentsViewData( + // TODO replace fav to text button? + // TODO add button to hide similar comments? + suspend fun getCommentsViewData( + comment: String, typeId: Long, ): List { data class Data(val timeStarted: Long, val comment: String) + val items = mutableListOf() + val isDarkTheme = prefsInteractor.getDarkMode() + val isFavourite = favouriteCommentInteractor.get(comment) != null + + ChangeRecordCommentFieldViewData( + id = 1L, // Only one at the time. + text = comment, + iconColor = if (isFavourite) { + resourceRepo.getColor(R.color.colorSecondary) + } else { + colorMapper.toInactiveColor(isDarkTheme) + } + ).let(items::add) + + val searchResults = if (comment.isNotEmpty()) { + recordInteractor.searchComment(comment) + .asSequence() + .sortedByDescending { it.timeStarted } + .map { it.comment } + .toSet() + .mapNotNull { + if (it == comment) return@mapNotNull null + ChangeRecordCommentViewData.Last(it) + } + .takeUnless { it.isEmpty() } + ?.let { + HintViewData( + text = resourceRepo.getString(R.string.change_record_similar_comments_hint) + ).let(::listOf) + it + }.orEmpty() + } else { + emptyList() + } + val favouriteComments = favouriteCommentInteractor.getAll() .map { ChangeRecordCommentViewData.Favourite(it.comment) } .takeUnless { it.isEmpty() } @@ -95,51 +129,11 @@ class ChangeRecordViewDataInteractor @Inject constructor( ).let(::listOf) + it }.orEmpty() - return favouriteComments + lastComments - } + items += searchResults + items += favouriteComments + items += lastComments - suspend fun getFavCommentViewData( - comment: String, - ): ChangeRecordFavCommentState { - val isDarkTheme = prefsInteractor.getDarkMode() - val isFavourite = favouriteCommentInteractor.get(comment) != null - - return ChangeRecordFavCommentState( - iconColor = if (isFavourite) { - resourceRepo.getColor(R.color.colorSecondary) - } else { - colorMapper.toInactiveColor(isDarkTheme) - }, - isVisible = comment.isNotEmpty(), - ) - } - - suspend fun getSearchCommentViewData( - isEnabled: Boolean, - isLoading: Boolean, - search: String, - ): ChangeRecordSearchCommentState { - val items = mutableListOf() - - ChangeRecordCommentFieldViewData( - id = 1L, // Only one at the time. - text = search, - ).let(items::add) - - when { - isLoading -> LoaderViewData().let(::listOf) - search.isEmpty() -> emptyList() - else -> { - recordInteractor.searchComment(search) - .sortedByDescending { it.timeStarted } - .map { ChangeRecordCommentViewData.Last(it.comment) } - } - }.let(items::addAll) - - return ChangeRecordSearchCommentState( - enabled = isEnabled, - items = items, - ) + return items } fun getTimeAdjustmentItems( diff --git a/features/feature_change_record/src/main/java/com/example/util/simpletimetracker/feature_change_record/view/ChangeRecordCore.kt b/features/feature_change_record/src/main/java/com/example/util/simpletimetracker/feature_change_record/view/ChangeRecordCore.kt index e9253da2d..421c815d2 100644 --- a/features/feature_change_record/src/main/java/com/example/util/simpletimetracker/feature_change_record/view/ChangeRecordCore.kt +++ b/features/feature_change_record/src/main/java/com/example/util/simpletimetracker/feature_change_record/view/ChangeRecordCore.kt @@ -1,13 +1,13 @@ package com.example.util.simpletimetracker.feature_change_record.view -import android.content.res.ColorStateList +import android.annotation.SuppressLint import android.view.View +import android.widget.EditText import androidx.appcompat.widget.AppCompatTextView import androidx.cardview.widget.CardView -import androidx.core.view.ViewCompat import androidx.core.view.isVisible import androidx.core.view.updatePadding -import androidx.core.widget.doAfterTextChanged +import androidx.fragment.app.Fragment import androidx.viewbinding.ViewBinding import com.example.util.simpletimetracker.core.base.BaseFragment import com.example.util.simpletimetracker.core.extension.addOnBackPressedListener @@ -28,8 +28,8 @@ import com.example.util.simpletimetracker.feature_base_adapter.hint.createHintAc import com.example.util.simpletimetracker.feature_base_adapter.hint.createHintAdapterDelegate import com.example.util.simpletimetracker.feature_base_adapter.hintBig.createHintBigAdapterDelegate import com.example.util.simpletimetracker.feature_base_adapter.info.createInfoAdapterDelegate -import com.example.util.simpletimetracker.feature_base_adapter.loader.createLoaderAdapterDelegate import com.example.util.simpletimetracker.feature_base_adapter.recordType.createRecordTypeAdapterDelegate +import com.example.util.simpletimetracker.feature_change_record.R import com.example.util.simpletimetracker.feature_change_record.adapter.createChangeRecordButtonAdapterDelegate import com.example.util.simpletimetracker.feature_change_record.adapter.createChangeRecordChangePreviewAdapterDelegate import com.example.util.simpletimetracker.feature_change_record.adapter.createChangeRecordCommentAdapterDelegate @@ -45,11 +45,10 @@ import com.example.util.simpletimetracker.feature_change_record.viewData.ChangeR import com.example.util.simpletimetracker.feature_change_record.viewData.ChangeRecordChooserState.State.Closed import com.example.util.simpletimetracker.feature_change_record.viewData.ChangeRecordChooserState.State.Comment import com.example.util.simpletimetracker.feature_change_record.viewData.ChangeRecordChooserState.State.Tag -import com.example.util.simpletimetracker.feature_change_record.viewData.ChangeRecordFavCommentState -import com.example.util.simpletimetracker.feature_change_record.viewData.ChangeRecordSearchCommentState import com.example.util.simpletimetracker.feature_change_record.viewData.ChangeRecordTagsViewData import com.example.util.simpletimetracker.feature_change_record.viewModel.ChangeRecordBaseViewModel import com.example.util.simpletimetracker.feature_views.extension.dpToPx +import com.example.util.simpletimetracker.feature_views.extension.postDelayed import com.example.util.simpletimetracker.feature_views.extension.rotateDown import com.example.util.simpletimetracker.feature_views.extension.rotateUp import com.example.util.simpletimetracker.feature_views.extension.setOnClick @@ -87,17 +86,13 @@ class ChangeRecordCore( private val commentsAdapter: BaseRecyclerAdapter by lazy { BaseRecyclerAdapter( createHintAdapterDelegate(), - createChangeRecordCommentAdapterDelegate(viewModel::onCommentClick), - ) - } - private val searchCommentsAdapter: BaseRecyclerAdapter by lazy { - BaseRecyclerAdapter( - createLoaderAdapterDelegate(), createChangeRecordCommentFieldAdapterDelegate( - afterTextChange = viewModel::onSearchCommentChange, - onSearchClick = viewModel::onSearchCommentClick, + afterTextChange = viewModel::onCommentChange, + onFavouriteClick = viewModel::onFavouriteCommentClick, + ), + createChangeRecordCommentAdapterDelegate( + onItemClick = viewModel::onCommentClick, ), - createChangeRecordCommentAdapterDelegate(viewModel::onCommentClick), ) } private val actionsAdapter: BaseRecyclerAdapter by lazy { @@ -140,7 +135,7 @@ class ChangeRecordCore( } adapter = categoriesAdapter } - rvChangeRecordLastComments.apply { + rvChangeRecordComments.apply { layoutManager = FlexboxLayoutManager(context).apply { flexDirection = FlexDirection.ROW justifyContent = JustifyContent.CENTER @@ -148,14 +143,6 @@ class ChangeRecordCore( } adapter = commentsAdapter } - rvChangeRecordSearchComments.apply { - layoutManager = FlexboxLayoutManager(context).apply { - flexDirection = FlexDirection.ROW - justifyContent = JustifyContent.CENTER - flexWrap = FlexWrap.WRAP - } - adapter = searchCommentsAdapter - } rvChangeRecordAction.apply { layoutManager = LinearLayoutManagerWithExtraLayoutSpace(context) adapter = actionsAdapter @@ -166,9 +153,6 @@ class ChangeRecordCore( fragment: BaseFragment, binding: ChangeRecordCoreLayoutBinding, ) = with(binding) { - etChangeRecordComment.doAfterTextChanged { viewModel.onCommentChange(it.toString()) } - btnChangeRecordFavouriteComment.setOnClick(viewModel::onFavouriteCommentClick) - btnChangeRecordSearchComment.setOnClick(viewModel::onSearchCommentClick) fieldChangeRecordType.setOnClick(viewModel::onTypeChooserClick) fieldChangeRecordCategory.setOnClick(viewModel::onCategoryChooserClick) fieldChangeRecordComment.setOnClick(viewModel::onCommentChooserClick) @@ -217,17 +201,8 @@ class ChangeRecordCore( timeStartedAdjustmentItems.observe(containerChangeRecordTimeStartedAdjust.adapter::replace) timeEndedAdjustmentItems.observe(containerChangeRecordTimeEndedAdjust.adapter::replace) chooserState.observe { updateChooserState(it, binding) } - keyboardVisibility.observe { visible -> - if (visible) { - showKeyboard(etChangeRecordComment) - } else { - hideKeyboard() - } - } - lastComments.observe(commentsAdapter::replace) - comment.observe { updateUi(binding, it) } - favCommentViewData.observe { setFavCommentState(it, binding) } - searchCommentViewData.observe { setSearchCommentState(it, binding) } + keyboardVisibility.observe { onKeyboardVisibility(binding, it) } + comments.observe(commentsAdapter::replace) actionsViewData.observe(::setActionsViewData) } } @@ -244,14 +219,6 @@ class ChangeRecordCore( } } - fun updateUi( - binding: ChangeRecordCoreLayoutBinding, - comment: String, - ) = with(binding) { - etChangeRecordComment.setText(comment) - etChangeRecordComment.setSelection(comment.length) - } - fun setDateTime( state: ChangeRecordDateTimeState, dateView: AppCompatTextView, @@ -292,7 +259,7 @@ class ChangeRecordCore( ) updateChooser( state = state, - chooserData = containerChangeRecordComment, + chooserData = rvChangeRecordComments, chooserView = fieldChangeRecordComment, chooserArrow = arrowChangeRecordComment, ) @@ -330,31 +297,6 @@ class ChangeRecordCore( actionsAdapter.replace(data) } - private fun setFavCommentState( - data: ChangeRecordFavCommentState, - binding: ChangeRecordCoreLayoutBinding, - ) { - ViewCompat.setBackgroundTintList( - binding.ivChangeRecordFavouriteComment, - ColorStateList.valueOf(data.iconColor), - ) - binding.btnChangeRecordFavouriteComment.visible = data.isVisible - } - - private fun setSearchCommentState( - data: ChangeRecordSearchCommentState, - binding: ChangeRecordCoreLayoutBinding, - ) { - if (data.enabled) { - binding.containerChangeRecordCommentField.visible = false - binding.rvChangeRecordSearchComments.visible = true - } else { - binding.containerChangeRecordCommentField.visible = true - binding.rvChangeRecordSearchComments.visible = false - } - searchCommentsAdapter.replaceAsNew(data.items) - } - private fun setTimeEndedVisibility( isVisible: Boolean, binding: ChangeRecordCoreLayoutBinding, @@ -364,6 +306,7 @@ class ChangeRecordCore( binding.btnChangeRecordTimeEndedAdjust.isVisible = isVisible } + @SuppressLint("SetTextI18n") private fun updateCategories( data: ChangeRecordTagsViewData, binding: ChangeRecordCoreLayoutBinding, @@ -373,6 +316,20 @@ class ChangeRecordCore( tvChangeRecordTagPreview.text = data.selectedCount.toString() } + private fun Fragment.onKeyboardVisibility( + binding: ChangeRecordCoreLayoutBinding, + visible: Boolean, + ) { + if (visible) { + binding.rvChangeRecordComments.postDelayed(500) { + findViewById(R.id.etChangeRecordCommentField) + ?.let(::showKeyboard) + } + } else { + hideKeyboard() + } + } + private inline fun updateChooser( state: ChangeRecordChooserState, chooserData: View, diff --git a/features/feature_change_record/src/main/java/com/example/util/simpletimetracker/feature_change_record/view/ChangeRecordFragment.kt b/features/feature_change_record/src/main/java/com/example/util/simpletimetracker/feature_change_record/view/ChangeRecordFragment.kt index 276bf2359..ba70a04c5 100644 --- a/features/feature_change_record/src/main/java/com/example/util/simpletimetracker/feature_change_record/view/ChangeRecordFragment.kt +++ b/features/feature_change_record/src/main/java/com/example/util/simpletimetracker/feature_change_record/view/ChangeRecordFragment.kt @@ -89,9 +89,6 @@ class ChangeRecordFragment : override fun initViewModel() = with(binding) { with(viewModel) { extra = this@ChangeRecordFragment.extra - record.observeOnce(viewLifecycleOwner) { - core.updateUi(layoutChangeRecordCore, it.comment) - } record.observe(::updatePreview) core.initViewModel(this@ChangeRecordFragment, layoutChangeRecordCore) } diff --git a/features/feature_change_record/src/main/java/com/example/util/simpletimetracker/feature_change_record/viewData/ChangeRecordFavCommentState.kt b/features/feature_change_record/src/main/java/com/example/util/simpletimetracker/feature_change_record/viewData/ChangeRecordFavCommentState.kt deleted file mode 100644 index 4bc2905d2..000000000 --- a/features/feature_change_record/src/main/java/com/example/util/simpletimetracker/feature_change_record/viewData/ChangeRecordFavCommentState.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.example.util.simpletimetracker.feature_change_record.viewData - -import androidx.annotation.ColorInt - -data class ChangeRecordFavCommentState( - @ColorInt val iconColor: Int, - val isVisible: Boolean, -) \ No newline at end of file diff --git a/features/feature_change_record/src/main/java/com/example/util/simpletimetracker/feature_change_record/viewData/ChangeRecordSearchCommentState.kt b/features/feature_change_record/src/main/java/com/example/util/simpletimetracker/feature_change_record/viewData/ChangeRecordSearchCommentState.kt deleted file mode 100644 index 95e85c775..000000000 --- a/features/feature_change_record/src/main/java/com/example/util/simpletimetracker/feature_change_record/viewData/ChangeRecordSearchCommentState.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.example.util.simpletimetracker.feature_change_record.viewData - -import com.example.util.simpletimetracker.feature_base_adapter.ViewHolderType - -data class ChangeRecordSearchCommentState( - val enabled: Boolean, - val items: List, -) \ No newline at end of file diff --git a/features/feature_change_record/src/main/java/com/example/util/simpletimetracker/feature_change_record/viewModel/ChangeRecordBaseViewModel.kt b/features/feature_change_record/src/main/java/com/example/util/simpletimetracker/feature_change_record/viewModel/ChangeRecordBaseViewModel.kt index 8bee47c33..6181fe55c 100644 --- a/features/feature_change_record/src/main/java/com/example/util/simpletimetracker/feature_change_record/viewModel/ChangeRecordBaseViewModel.kt +++ b/features/feature_change_record/src/main/java/com/example/util/simpletimetracker/feature_change_record/viewModel/ChangeRecordBaseViewModel.kt @@ -35,8 +35,6 @@ import com.example.util.simpletimetracker.feature_change_record.model.ChangeReco import com.example.util.simpletimetracker.feature_change_record.model.ChangeRecordDateTimeFieldsState import com.example.util.simpletimetracker.feature_change_record.model.TimeAdjustmentState import com.example.util.simpletimetracker.feature_change_record.viewData.ChangeRecordChooserState -import com.example.util.simpletimetracker.feature_change_record.viewData.ChangeRecordFavCommentState -import com.example.util.simpletimetracker.feature_change_record.viewData.ChangeRecordSearchCommentState import com.example.util.simpletimetracker.feature_change_record.viewData.ChangeRecordTagsViewData import com.example.util.simpletimetracker.navigation.Router import com.example.util.simpletimetracker.navigation.params.screen.ChangeRecordTagFromScreen @@ -78,11 +76,11 @@ abstract class ChangeRecordBaseViewModel( initial } } - val lastComments: LiveData> by lazy { + val comments: LiveData> by lazy { return@lazy MutableLiveData>().let { initial -> viewModelScope.launch { initializePreviewViewData() - initial.value = loadLastCommentsViewData() + initial.value = loadCommentsViewData() } initial } @@ -99,18 +97,8 @@ abstract class ChangeRecordBaseViewModel( previous = ChangeRecordChooserState.State.Closed, ), ) - val searchCommentViewData: LiveData by lazy { - return@lazy MutableLiveData().let { initial -> - viewModelScope.launch { - initial.value = loadSearchCommentViewData(isLoading = false, isEnabled = false) - } - initial - } - } val saveButtonEnabled: LiveData = MutableLiveData(true) val keyboardVisibility: LiveData = MutableLiveData(false) - val comment: LiveData = MutableLiveData() - val favCommentViewData: LiveData = MutableLiveData() val timeEndedVisibility: LiveData by lazy { MutableLiveData(isTimeEndedAvailable) } val deleteIconVisibility: LiveData by lazy { MutableLiveData(isDeleteButtonVisible) } val statsIconVisibility: LiveData by lazy { MutableLiveData(isStatisticsButtonVisible) } @@ -151,7 +139,6 @@ abstract class ChangeRecordBaseViewModel( protected abstract val isStatisticsButtonVisible: Boolean private var prevRecord: Record? = null - private var searchComment: String = "" private var searchLoadJob: Job? = null init { @@ -166,7 +153,6 @@ abstract class ChangeRecordBaseViewModel( protected open suspend fun initializePreviewViewData() { // Don't wait for the completion. viewModelScope.launch { initializeActions() } - viewModelScope.launch { updateFavCommentViewData() } } protected open suspend fun onTimeStartedChanged() { @@ -301,8 +287,8 @@ abstract class ChangeRecordBaseViewModel( viewModelScope.launch { updatePreview() updateCategoriesViewData() - updateLastCommentsViewData() } + updateCommentsViewData() updateActionsData() } @@ -361,8 +347,7 @@ abstract class ChangeRecordBaseViewModel( } fun onCommentClick(item: ChangeRecordCommentViewData) { - // View update through text change listener. - comment.set(item.text) + onCommentChange(item.text) } fun onCommentChange(comment: String) { @@ -370,20 +355,7 @@ abstract class ChangeRecordBaseViewModel( if (comment != newComment) { newComment = comment updatePreview() - updateFavCommentViewData() - } - } - } - - fun onSearchCommentChange(search: String) { - val isEnabled = searchCommentViewData.value?.enabled ?: return - - if (search != searchComment && isEnabled) { - searchComment = search - searchLoadJob?.cancel() - searchLoadJob = viewModelScope.launch { - updateSearchCommentViewData(isLoading = true, isEnabled = true) - updateSearchCommentViewData(isLoading = false, isEnabled = true) + updateCommentsViewData() } } } @@ -398,20 +370,7 @@ abstract class ChangeRecordBaseViewModel( val new = FavouriteComment(comment = newComment) favouriteCommentInteractor.add(new) } - updateLastCommentsViewData() - updateFavCommentViewData() - } - } - - fun onSearchCommentClick() { - val currentlyEnabled = searchCommentViewData.value?.enabled.orFalse() - - keyboardVisibility.set(false) - viewModelScope.launch { - updateSearchCommentViewData( - isEnabled = !currentlyEnabled, - isLoading = false, - ) + updateCommentsViewData() } } @@ -569,8 +528,7 @@ abstract class ChangeRecordBaseViewModel( } // Show keyboard on comment chooser opened, hide otherwise. - val showKeyboard = newState is ChangeRecordChooserState.State.Comment && - !searchCommentViewData.value?.enabled.orFalse() + val showKeyboard = newState is ChangeRecordChooserState.State.Comment keyboardVisibility.set(showKeyboard) chooserState.set( @@ -896,41 +854,17 @@ abstract class ChangeRecordBaseViewModel( ) } - private suspend fun updateLastCommentsViewData() { - lastComments.set(loadLastCommentsViewData()) - } - - private suspend fun loadLastCommentsViewData(): List { - return changeRecordViewDataInteractor.getLastCommentsViewData(newTypeId) - } - - private suspend fun updateFavCommentViewData() { - favCommentViewData.set(loadFavCommentViewData()) - } - - private suspend fun loadFavCommentViewData(): ChangeRecordFavCommentState { - return changeRecordViewDataInteractor.getFavCommentViewData(newComment) - } - - private suspend fun updateSearchCommentViewData( - isLoading: Boolean, - isEnabled: Boolean, - ) { - val data = loadSearchCommentViewData( - isLoading = isLoading, - isEnabled = isEnabled, - ) - searchCommentViewData.set(data) + private fun updateCommentsViewData() { + searchLoadJob?.cancel() + searchLoadJob = viewModelScope.launch { + comments.set(loadCommentsViewData()) + } } - private suspend fun loadSearchCommentViewData( - isLoading: Boolean, - isEnabled: Boolean, - ): ChangeRecordSearchCommentState { - return changeRecordViewDataInteractor.getSearchCommentViewData( - isEnabled = isEnabled, - isLoading = isLoading, - search = searchComment, + private suspend fun loadCommentsViewData(): List { + return changeRecordViewDataInteractor.getCommentsViewData( + comment = newComment, + typeId = newTypeId, ) } diff --git a/features/feature_change_record/src/main/res/layout/change_record_comment_field_item.xml b/features/feature_change_record/src/main/res/layout/change_record_comment_field_item.xml index ceee643bd..afe362ac1 100644 --- a/features/feature_change_record/src/main/res/layout/change_record_comment_field_item.xml +++ b/features/feature_change_record/src/main/res/layout/change_record_comment_field_item.xml @@ -11,7 +11,7 @@ android:layout_height="wrap_content" android:layout_marginStart="2dp" android:layout_marginEnd="2dp" - app:layout_constraintEnd_toStartOf="@id/btnChangeRecordSearchCommentField" + app:layout_constraintEnd_toStartOf="@id/btnChangeRecordCommentField" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> @@ -20,34 +20,46 @@ style="@style/EditTextMultiLine" android:layout_width="match_parent" android:layout_height="wrap_content" - android:hint="@string/records_all_search_comment" /> + android:hint="@string/change_record_comment_hint" /> + app:layout_constraintTop_toTopOf="@id/inputChangeRecordCommentField"> - + android:layout_height="match_parent"> - + + + + + diff --git a/features/feature_change_record/src/main/res/layout/change_record_core_layout.xml b/features/feature_change_record/src/main/res/layout/change_record_core_layout.xml index fadbcccae..17cef2b96 100644 --- a/features/feature_change_record/src/main/res/layout/change_record_core_layout.xml +++ b/features/feature_change_record/src/main/res/layout/change_record_core_layout.xml @@ -14,7 +14,7 @@ app:layout_constraintBottom_toTopOf="@id/dividerChangeRecordButton" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0" - tools:visibility="visible"> + tools:visibility="gone"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + tools:itemCount="1" + tools:listitem="@layout/change_record_comment_field_item" + tools:visibility="visible" /> T.postDelayed( + delayMillis: Long, + crossinline action: T.() -> Unit +) { + postDelayed( + { action() }, + delayMillis, + ) } \ No newline at end of file diff --git a/resources/src/main/res/values-ar/strings.xml b/resources/src/main/res/values-ar/strings.xml index 145409ee2..49e58a79f 100644 --- a/resources/src/main/res/values-ar/strings.xml +++ b/resources/src/main/res/values-ar/strings.xml @@ -111,6 +111,7 @@ آخر التعليقات المفضلة التعليقات المفضلة + تعليقات مماثلة لم تضاف وسوم متتبعة حفظ بدون وسم @@ -238,7 +239,6 @@ فرز التتبعات بدأ الوقت مدة - تعليق البحث لبدء التتبع ، أضف الأنشطة بالنقر فوق الزر %s أو استخدم الإعدادات المسبقة الافتراضية بالنقر فوق الزر %s diff --git a/resources/src/main/res/values-ca/strings.xml b/resources/src/main/res/values-ca/strings.xml index ec1abf285..dbc5f99c9 100644 --- a/resources/src/main/res/values-ca/strings.xml +++ b/resources/src/main/res/values-ca/strings.xml @@ -111,6 +111,7 @@ Últims comentaris Favorit Comentaris preferits + Comentaris semblants No s\'han afegit etiquetes Desa Sense etiquetar @@ -238,7 +239,6 @@ Endreça els enregistraments Temps d\'inici Durada - Cerca un comentari Per començar el seguiment, afegiu activitats fent clic al botó %s o utilitzeu els valors predeterminats fent clic al botó %s diff --git a/resources/src/main/res/values-de/strings.xml b/resources/src/main/res/values-de/strings.xml index 183714229..2881f5c03 100644 --- a/resources/src/main/res/values-de/strings.xml +++ b/resources/src/main/res/values-de/strings.xml @@ -111,6 +111,7 @@ Letzte Kommentare Favorit Lieblingskommentare + Ähnliche Kommentare Keine Datensatz-Tags hinzugefügt Speichern Nicht markiert @@ -238,7 +239,6 @@ Einträge sortieren Zeit gestartet Dauer - Kommentar suchen Um mit der Verfolgung zu beginnen, fügen Sie Aktivitäten hinzu, indem Sie auf die Schaltfläche %s klicken, oder verwenden Sie Standardvoreinstellungen, indem Sie auf die Schaltfläche %s klicken diff --git a/resources/src/main/res/values-es/strings.xml b/resources/src/main/res/values-es/strings.xml index 0d8dd4060..c854a5dde 100644 --- a/resources/src/main/res/values-es/strings.xml +++ b/resources/src/main/res/values-es/strings.xml @@ -111,6 +111,7 @@ Últimos comentarios Favorito Comentarios favoritos + Comentarios similares No se añadieron etiquetas Guardar Sin etiquetar @@ -238,7 +239,6 @@ Ordenar los registros Tiempo de inicio Duración - Buscar comentario Para comenzar a rastrear, agregue actividades haciendo clic en el botón %s o use los ajustes preestablecidos predeterminados haciendo clic en el botón %s diff --git a/resources/src/main/res/values-fa/strings.xml b/resources/src/main/res/values-fa/strings.xml index 501a2a818..8e60536ff 100644 --- a/resources/src/main/res/values-fa/strings.xml +++ b/resources/src/main/res/values-fa/strings.xml @@ -111,6 +111,7 @@ نظرهای قبلی مورد علاقه نظرات مورد علاقه + نظرات مشابه برچسب تاریخچه ای اضافه نشده ذخیره بدون برچسب @@ -238,7 +239,6 @@ مرتب کردن تاریخچه ها زمان شروع طول مدت - جستجوی نظر برای شروع ردیابی، با کلیک بر روی دکمه %s فعالیت ها را اضافه کنید یا با کلیک بر روی دکمه %s از تنظیمات پیش فرض استفاده کنید diff --git a/resources/src/main/res/values-fr/strings.xml b/resources/src/main/res/values-fr/strings.xml index 5903b3adb..c2fe744dd 100644 --- a/resources/src/main/res/values-fr/strings.xml +++ b/resources/src/main/res/values-fr/strings.xml @@ -111,6 +111,7 @@ Derniers commentaires Favoris Commentaires favoris + Commentaires similaires Aucune étiquette d\'enregistrement ajoutée Sauvegarder Non étiqueté @@ -238,7 +239,6 @@ Trier les enregistrements Heure de début Durée - Rechercher un commentaire Pour commencer le suivi, ajoutez des activités en cliquant sur le bouton %s ou utilisez les préréglages par défaut en cliquant sur le bouton %s diff --git a/resources/src/main/res/values-hi/strings.xml b/resources/src/main/res/values-hi/strings.xml index a1367e8bc..4e92b4c84 100644 --- a/resources/src/main/res/values-hi/strings.xml +++ b/resources/src/main/res/values-hi/strings.xml @@ -111,6 +111,7 @@ अंतिम टिप्पणियाँ पसंदीदा पसंदीदा टिप्पणियाँ + समान टिप्पणियाँ कोई रिकॉर्ड टैग नहीं जोड़ा गया बचाना टैग नहीं किए गए @@ -238,7 +239,6 @@ क्रमबद्ध अभिलेख समय शुरू हुआ अवधि - खोज टिप्पणी ट्रैकिंग शुरू करने के लिए, %s बटन पर क्लिक करके गतिविधियाँ जोड़ें या %s बटन पर क्लिक करके डिफ़ॉल्ट प्रीसेट का उपयोग करें diff --git a/resources/src/main/res/values-in/strings.xml b/resources/src/main/res/values-in/strings.xml index dc57256dd..3ffc1e2b8 100644 --- a/resources/src/main/res/values-in/strings.xml +++ b/resources/src/main/res/values-in/strings.xml @@ -111,6 +111,7 @@ Komentar terakhir Favorit Komentar favorit + Komentar serupa Tidak ada label rekaman yang ditambahkan Simpan Tidak berlabel @@ -238,7 +239,6 @@ Urutkan rekor Waktu dimulai Durasi - Cari komentar Untuk memulai pelacakan, tambahkan aktivitas dengan mengklik tombol %s atau gunakan preset default dengan mengklik tombol %s diff --git a/resources/src/main/res/values-it/strings.xml b/resources/src/main/res/values-it/strings.xml index 076c7eeb6..cdb8da8b7 100644 --- a/resources/src/main/res/values-it/strings.xml +++ b/resources/src/main/res/values-it/strings.xml @@ -111,6 +111,7 @@ Ultimi commenti Preferito Commenti preferiti + Commenti simili Nessuna etichetta aggiunta alla registrazione Salva Non etichettato @@ -238,7 +239,6 @@ Ordina le registrazioni Ora di inizio Durata - Cerca commento Per avviare il tracciamento, aggiungi attività facendo clic sul pulsante %s o utilizza i preset predefiniti facendo clic sul pulsante %s diff --git a/resources/src/main/res/values-iw/strings.xml b/resources/src/main/res/values-iw/strings.xml index 4fa3efc42..6e0df2a36 100644 --- a/resources/src/main/res/values-iw/strings.xml +++ b/resources/src/main/res/values-iw/strings.xml @@ -111,6 +111,7 @@ הערות אחרונות מועדף הערות אהובות + הערות דומות לא נוספו תגיות רשומה שמור לא מתויג @@ -238,7 +239,6 @@ מיין רשומות זמן התחלה משך - חפש הערה כדי להתחיל מעקב, הוסף פעילויות על ידי לחיצה על כפתור %s או השתמש בקביעות ברירת מחדל על ידי לחיצה על כפתור %s diff --git a/resources/src/main/res/values-ja/strings.xml b/resources/src/main/res/values-ja/strings.xml index 5c34bcf95..94fcd9c84 100644 --- a/resources/src/main/res/values-ja/strings.xml +++ b/resources/src/main/res/values-ja/strings.xml @@ -111,6 +111,7 @@ 最新コメント お気に入り お気に入りのコメント + 同様のコメント 計測タグがありません 保存 タグを外す @@ -238,7 +239,6 @@ 計測記録をソート 時間の開始 期間 - 検索コメント 追跡を開始するには、%s ボタンをクリックしてアクティビティを追加するか、%s ボタンをクリックしてデフォルトのプリセットを使用します。 diff --git a/resources/src/main/res/values-ko/strings.xml b/resources/src/main/res/values-ko/strings.xml index 5e530fe81..862e0df9e 100644 --- a/resources/src/main/res/values-ko/strings.xml +++ b/resources/src/main/res/values-ko/strings.xml @@ -111,6 +111,7 @@ 이전 코멘트 자주쓰는 코멘트 즐겨찾는 댓글 + 비슷한 댓글 기록 태그 없음 저장 태그 없음 @@ -238,7 +239,6 @@ 기록 정렬 시작한 시간 기간 - 코멘트 검색 기록을 시작하기 위해 %s 버튼을 눌러 활동을 추가하거나 %s 버튼을 눌러 기본 템플릿을 사용하세요 diff --git a/resources/src/main/res/values-nl/strings.xml b/resources/src/main/res/values-nl/strings.xml index b2505a668..cfec9fc47 100644 --- a/resources/src/main/res/values-nl/strings.xml +++ b/resources/src/main/res/values-nl/strings.xml @@ -111,6 +111,7 @@ Laatste opmerkingen Favoriet Favoriete opmerkingen + Soortgelijke opmerkingen Geen opname labels toegevoegd Opslaan Niet gelabeld @@ -238,7 +239,6 @@ Records sorteren Tijd begonnen Looptijd - Opmerking zoeken Om het volgen te starten, voegt u activiteiten toe door op de %s-knop te klikken of gebruikt u standaardinstellingen door op de %s-knop te klikken diff --git a/resources/src/main/res/values-pl/strings.xml b/resources/src/main/res/values-pl/strings.xml index f77f8137e..bdb370b2e 100644 --- a/resources/src/main/res/values-pl/strings.xml +++ b/resources/src/main/res/values-pl/strings.xml @@ -111,6 +111,7 @@ Ostatni komentarz Ulubione Ulubione komentarze + Podobne komentarze Brak dodanych tagów Zapisz Nieotagowane @@ -238,7 +239,6 @@ Posortuj rekordy Czas rozpoczęcia Czas trwania - Wyszukaj komentarz Aby rozpocząć śledzenie, dodaj aktywność, klikając przycisk %s lub użyj domyślnych, klikając przycisk %s diff --git a/resources/src/main/res/values-pt-rPT/strings.xml b/resources/src/main/res/values-pt-rPT/strings.xml index 7c915fd94..61d61adef 100644 --- a/resources/src/main/res/values-pt-rPT/strings.xml +++ b/resources/src/main/res/values-pt-rPT/strings.xml @@ -111,6 +111,7 @@ Últimos comentários Favorito Comentários favoritos + Comentários semelhantes Nenhuma etiqueta de registo adicionada Guardar Sem etiqueta @@ -238,7 +239,6 @@ Organizar registos Hora de início Duração - Pesquisar comentário Para iniciar o registo, adicionar atividades clicando no botão %s ou usar as definições padrão clicando no botão %s diff --git a/resources/src/main/res/values-pt/strings.xml b/resources/src/main/res/values-pt/strings.xml index 5a65f8725..e2ed4e56c 100644 --- a/resources/src/main/res/values-pt/strings.xml +++ b/resources/src/main/res/values-pt/strings.xml @@ -111,6 +111,7 @@ Últimos comentários Favorito Comentários favoritos + Comentários semelhantes Nenhuma tag de registro adicionada Salvar Sem tag @@ -238,7 +239,6 @@ Ordenar registros Hora de início Duração - Pesquisar comentário Para iniciar o rastreamento, adicione atividades clicando no botão %s ou use as predefinições padrão clicando no botão %s diff --git a/resources/src/main/res/values-ro/strings.xml b/resources/src/main/res/values-ro/strings.xml index bacc1fee4..82f0dbd12 100644 --- a/resources/src/main/res/values-ro/strings.xml +++ b/resources/src/main/res/values-ro/strings.xml @@ -111,6 +111,7 @@ Ultimele comentarii Favorite Comentarii preferate + Comentarii similare Nu au fost adăugate etichete Salvează Ne-etichetat @@ -238,7 +239,6 @@ Sortează înregistrările Ora de început Durata - Caută comentariu Pentru a începe urmărirea, adaugă activitatea prin apăsarea butonului %s sau folosește setările de bază apăsând butonul %s diff --git a/resources/src/main/res/values-ru/strings.xml b/resources/src/main/res/values-ru/strings.xml index 6a53543f2..268662089 100644 --- a/resources/src/main/res/values-ru/strings.xml +++ b/resources/src/main/res/values-ru/strings.xml @@ -111,6 +111,7 @@ Последние комментарии Избранные Избранные комментарии + Похожие комментарии Теги для записей не добавлены Сохранить Без тега @@ -238,7 +239,6 @@ Сортировка Дата Продолж. - Поиск комментария Чтобы начать отслеживание, добавьте активности нажав кнопку %s, или используйте предустановки по умолчанию нажав кнопку %s diff --git a/resources/src/main/res/values-sv/strings.xml b/resources/src/main/res/values-sv/strings.xml index 798893263..9c8e4d378 100644 --- a/resources/src/main/res/values-sv/strings.xml +++ b/resources/src/main/res/values-sv/strings.xml @@ -111,6 +111,7 @@ Tidigare kommentarer Favorit Favoritkommentarer + Liknande kommentarer Ingen händelsetagg vald Spara Ej taggad @@ -238,7 +239,6 @@ Sortera händelser Starttid Varaktighet - Sök kommentar För att börja spåra, lägg till aktiviteter genom att klicka på %s-knappen eller använd standardförinställningar genom att klicka på %s-knappen diff --git a/resources/src/main/res/values-tr/strings.xml b/resources/src/main/res/values-tr/strings.xml index 22b305eaf..bec45b9f2 100644 --- a/resources/src/main/res/values-tr/strings.xml +++ b/resources/src/main/res/values-tr/strings.xml @@ -111,6 +111,7 @@ Son yorumlar Favori Favori yorumlar + Benzer yorumlar Kayıt etiketi eklenmedi Kaydet Etiketsiz @@ -238,7 +239,6 @@ Kayıtları sırala Başlangıç zamanı Süre - Yorum ara İzlemeye başlamak için %s düğmesine tıklayarak etkinlikler ekleyin veya %s düğmesine tıklayarak varsayılan ön ayarları kullanın diff --git a/resources/src/main/res/values-uk/strings.xml b/resources/src/main/res/values-uk/strings.xml index 337813666..bd6a79e93 100644 --- a/resources/src/main/res/values-uk/strings.xml +++ b/resources/src/main/res/values-uk/strings.xml @@ -111,6 +111,7 @@ Останні коментарі Обрані Обрані коментарі + Подібні коментарі Теги для записів не додані Зберегти Без тегу @@ -238,7 +239,6 @@ Сортувати записи Початок Тривалість - Шукати коментар Щоб розпочати відстеження, додайте дії, натиснувши кнопку %s, або використайте стандартні налаштування, натиснувши кнопку %s diff --git a/resources/src/main/res/values-vi/strings.xml b/resources/src/main/res/values-vi/strings.xml index 277401f15..568743d7e 100644 --- a/resources/src/main/res/values-vi/strings.xml +++ b/resources/src/main/res/values-vi/strings.xml @@ -111,6 +111,7 @@ Nhận xét cuối cùng Yêu thích Bình luận yêu thích + Nhận xét tương tự Không có thẻ bản ghi nào được thêm vào Lưu Chưa gắn thẻ @@ -238,7 +239,6 @@ Sắp xếp bản ghi Thời gian bắt đầu Thời lượng - Tìm kiếm nhận xét Để bắt đầu theo dõi, hãy thêm hoạt động bằng cách nhấp vào nút %s hoặc sử dụng thiết đặt trước mặc định bằng cách nhấp vào nút %s diff --git a/resources/src/main/res/values-zh-rTW/strings.xml b/resources/src/main/res/values-zh-rTW/strings.xml index f9986ff5e..c1404ecb9 100644 --- a/resources/src/main/res/values-zh-rTW/strings.xml +++ b/resources/src/main/res/values-zh-rTW/strings.xml @@ -111,6 +111,7 @@ 最後註解 最喜歡的 收藏評論 + 類似評論 沒有新增紀錄標記 儲存 已取消標記 @@ -238,7 +239,6 @@ 排序紀錄 開始時間 期間 - 搜尋註解 要開始跟踪,請單擊 %s 按鈕添加活動,或單擊 %s 按鈕使用默認預設 diff --git a/resources/src/main/res/values-zh/strings.xml b/resources/src/main/res/values-zh/strings.xml index 1cb9bfba7..c67a49783 100644 --- a/resources/src/main/res/values-zh/strings.xml +++ b/resources/src/main/res/values-zh/strings.xml @@ -111,6 +111,7 @@ 最后评论 最喜欢的 收藏评论 + 类似评论 未添加记录标签 保存 无标签 @@ -238,7 +239,6 @@ 对记录排序 开始时间 持续时间 - 搜索评论 要开始跟踪,请单击 %s 按钮添加活动,或单击 %s 按钮使用默认预设 diff --git a/resources/src/main/res/values/strings.xml b/resources/src/main/res/values/strings.xml index bda720059..c0d93a103 100644 --- a/resources/src/main/res/values/strings.xml +++ b/resources/src/main/res/values/strings.xml @@ -111,6 +111,7 @@ Last comments Favourite Favourite comments + Similar comments No record tags added Save Untagged @@ -238,7 +239,6 @@ Sort records Time started Duration - Search comment To start tracking, add activities by clicking on %s button or use default presets by clicking on %s button