diff --git a/app/src/main/java/com/amaze/filemanager/adapters/SearchRecyclerViewAdapter.kt b/app/src/main/java/com/amaze/filemanager/adapters/SearchRecyclerViewAdapter.kt index 02ad78f390..7859f68a06 100644 --- a/app/src/main/java/com/amaze/filemanager/adapters/SearchRecyclerViewAdapter.kt +++ b/app/src/main/java/com/amaze/filemanager/adapters/SearchRecyclerViewAdapter.kt @@ -21,6 +21,9 @@ package com.amaze.filemanager.adapters import android.content.Context +import android.text.Spannable +import android.text.SpannableString +import android.text.style.ForegroundColorSpan import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -67,14 +70,22 @@ class SearchRecyclerViewAdapter : override fun onBindViewHolder(holder: SearchRecyclerViewAdapter.ViewHolder, position: Int) { val (file, matchResult) = getItem(position) - holder.fileNameTV.text = file.name + val colorPreference = + (AppConfig.getInstance().mainActivityContext as MainActivity).currentColorPreference + + val fileName = SpannableString(file.name) + fileName.setSpan( + ForegroundColorSpan(colorPreference.accent), + matchResult.first, + matchResult.last + 1, + Spannable.SPAN_EXCLUSIVE_EXCLUSIVE + ) + + holder.fileNameTV.text = fileName holder.filePathTV.text = file.path.substring(0, file.path.lastIndexOf("/")) holder.colorView.setBackgroundColor(getRandomColor(holder.colorView.context)) - val colorPreference = - (AppConfig.getInstance().mainActivityContext as MainActivity).currentColorPreference - if (file.isDirectory) { holder.colorView.setBackgroundColor(colorPreference.primaryFirstTab) } else {