Skip to content

Commit

Permalink
feat(drawer): Start first app by pressing Enter in search field (jkue…
Browse files Browse the repository at this point in the history
  • Loading branch information
khwolf committed Dec 22, 2023
1 parent ed81730 commit fbc2e6c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class AppDrawerAdapter(
}
}

fun getFirstApp(): UnlauncherApp {
return filteredApps.first()
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.add_app_fragment_list_item, parent, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import android.view.LayoutInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager
import android.widget.PopupMenu
import android.widget.Toast
Expand Down Expand Up @@ -204,6 +205,17 @@ class HomeFragment : BaseFragment(), OnLaunchAppListener {

app_drawer_edit_text.addTextChangedListener(appDrawerAdapter.searchBoxListener)

app_drawer_edit_text.setOnEditorActionListener { _, actionId, _ ->
if(actionId == EditorInfo.IME_ACTION_DONE && appDrawerAdapter.itemCount > 0) {
val firstApp = appDrawerAdapter.getFirstApp()
launchApp(firstApp.packageName, firstApp.className, firstApp.userSerial)
home_fragment.transitionToStart()
true
} else {
false
}
}

home_fragment.setTransitionListener(object : TransitionListener {
override fun onTransitionCompleted(motionLayout: MotionLayout?, currentId: Int) {
val inputMethodManager = requireContext().getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
Expand Down

0 comments on commit fbc2e6c

Please sign in to comment.