Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class LaunchersAdapter(
return getItem(position).getLauncherIdentifier().hashCode().toLong()
}

fun getLauncherId(position: Int): String {
return getItem(position).getLauncherIdentifier()
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val binding = ItemLauncherLabelBinding.inflate(
LayoutInflater.from(parent.context), parent, false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ package org.fossify.home.fragments
import android.annotation.SuppressLint
import android.content.Context
import android.util.AttributeSet
import android.view.KeyEvent
import android.view.MotionEvent
import android.view.inputmethod.EditorInfo
import android.widget.TextView
import android.widget.TextView.OnEditorActionListener
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.OnScrollListener
import org.fossify.commons.extensions.beGone
Expand All @@ -24,6 +28,7 @@ import org.fossify.home.interfaces.AllAppsListener
import org.fossify.home.models.AppLauncher
import org.fossify.home.models.HomeScreenGridItem


class AllAppsFragment(
context: Context,
attributeSet: AttributeSet
Expand Down Expand Up @@ -200,6 +205,21 @@ class AllAppsFragment(
binding.searchBar.onSearchTextChangedListener = {
submitList(launchers)
}

binding.searchBar.binding.topToolbarSearch.setOnEditorActionListener(object : OnEditorActionListener {
override fun onEditorAction(v: TextView?, actionId: Int, event: KeyEvent?): Boolean {
if (actionId == EditorInfo.IME_ACTION_DONE) {
val itemCount = getAdapter()?.itemCount
if (itemCount != null && itemCount > 0) {
val launcherId = getAdapter()?.getLauncherId(0)
val (packageName, activityName) = launcherId!!.split('/', ignoreCase = true, limit = 2)
activity?.launchApp(packageName, activityName)
return false
}
}
return true
}
})
}

private fun showNoResultsPlaceholderIfNeeded() {
Expand Down
Loading