From 98e8fdbb331a72cfaf74d057a54a407951e72035 Mon Sep 17 00:00:00 2001 From: fengyuecanzhu <1021300691@qq.com> Date: Tue, 7 Dec 2021 12:36:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=85=E5=AE=B9=E6=90=9C=E7=B4=A2=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=B8=85=E9=99=A4=E6=90=9C=E7=B4=A2=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/misc.xml | 3 +++ .../fycz/myreader/model/SearchWordEngine.kt | 2 +- .../myreader/ui/activity/SearchWordActivity.kt | 18 ++++++++++++++++++ app/src/main/res/menu/menu_search_word.xml | 10 ++++++++++ app/src/main/res/values/strings.xml | 1 + app/version_code.properties | 2 +- 6 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 app/src/main/res/menu/menu_search_word.xml diff --git a/.idea/misc.xml b/.idea/misc.xml index 5241332..f539713 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,6 +3,7 @@ diff --git a/app/src/main/java/xyz/fycz/myreader/model/SearchWordEngine.kt b/app/src/main/java/xyz/fycz/myreader/model/SearchWordEngine.kt index 79502c6..a3fd4ca 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/SearchWordEngine.kt +++ b/app/src/main/java/xyz/fycz/myreader/model/SearchWordEngine.kt @@ -112,7 +112,7 @@ class SearchWordEngine( emitter.onNext(searchWord1) return@ObservableOnSubscribe } - var content = pageLoader.getChapterReader(chapter) + var content = chapter.title + "\n" + pageLoader.getChapterReader(chapter) content = pageLoader.contentHelper.replaceContent( book.name + "-" + book.author, book.source, diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/SearchWordActivity.kt b/app/src/main/java/xyz/fycz/myreader/ui/activity/SearchWordActivity.kt index 7ca570f..735aefc 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/SearchWordActivity.kt +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/SearchWordActivity.kt @@ -2,6 +2,8 @@ package xyz.fycz.myreader.ui.activity import android.os.Bundle import android.view.KeyEvent +import android.view.Menu +import android.view.MenuItem import android.view.View import android.view.inputmethod.EditorInfo import android.view.inputmethod.InputMethodManager @@ -192,4 +194,20 @@ class SearchWordActivity : BaseActivity() { searchWordEngine.stopSearch() searchWordEngine.closeSearchEngine() } + + override fun onCreateOptionsMenu(menu: Menu?): Boolean { + menuInflater.inflate(R.menu.menu_search_word, menu) + return super.onCreateOptionsMenu(menu) + } + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + if (item.itemId == R.id.action_clear) { + adapter.clear() + searchWord = null + setUpToolbarTitle() + DbManager.getDaoSession().searchWordDao.deleteByKey(book.id) + return true + } + return super.onOptionsItemSelected(item) + } } \ No newline at end of file diff --git a/app/src/main/res/menu/menu_search_word.xml b/app/src/main/res/menu/menu_search_word.xml new file mode 100644 index 0000000..867b220 --- /dev/null +++ b/app/src/main/res/menu/menu_search_word.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b41b097..15eef49 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -514,6 +514,7 @@ 输入关键词 内容搜索 搜索书籍已缓存的内容 + 清除搜索结果 diff --git a/app/version_code.properties b/app/version_code.properties index b9904de..44f55a5 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,3 +1,3 @@ #Fri Jun 18 21:45:31 CST 2021 VERSION_CODE=226 -NEED_CREATE_RELEASE=true +NEED_CREATE_RELEASE=false