소스 검색

GlobalSearchController: Auto focus search view when initial query is empty (#8073)

Ivan Iskandar 2 년 전
부모
커밋
0fabe4bd01
1개의 변경된 파일14개의 추가작업 그리고 0개의 파일을 삭제
  1. 14 0
      app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchController.kt

+ 14 - 0
app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchController.kt

@@ -95,6 +95,20 @@ open class GlobalSearchController(
         )
 
         optionsMenuSearchItem = menu.findItem(R.id.action_search)
+
+        // Focus search on launch from browse screen
+        if (initialQuery.isNullOrEmpty()) {
+            optionsMenuSearchItem?.expandActionView()
+        }
+    }
+
+    override fun onSearchMenuItemActionCollapse(item: MenuItem?) {
+        super.onSearchMenuItemActionCollapse(item)
+        // Close this screen if query is empty
+        // i.e. launch from browse screen and clicking the back button icon without making any search
+        if (presenter.query.isEmpty()) {
+            router.popCurrentController()
+        }
     }
 
     override fun onSearchMenuItemActionExpand(item: MenuItem?) {