内容搜索新增清除搜索结果

master
fengyuecanzhu 3 years ago
parent 4ea1172716
commit 98e8fdbb33
  1. 3
      .idea/misc.xml
  2. 2
      app/src/main/java/xyz/fycz/myreader/model/SearchWordEngine.kt
  3. 18
      app/src/main/java/xyz/fycz/myreader/ui/activity/SearchWordActivity.kt
  4. 10
      app/src/main/res/menu/menu_search_word.xml
  5. 1
      app/src/main/res/values/strings.xml
  6. 2
      app/version_code.properties

@ -3,6 +3,7 @@
<component name="DesignSurface"> <component name="DesignSurface">
<option name="filePathToZoomLevelMap"> <option name="filePathToZoomLevelMap">
<map> <map>
<entry key="..\:/android/FYReader/app/src/main/res/drawable/ic_delete.xml" value="0.18518518518518517" />
<entry key="..\:/android/FYReader/app/src/main/res/drawable/ic_re_seg.xml" value="0.1962962962962963" /> <entry key="..\:/android/FYReader/app/src/main/res/drawable/ic_re_seg.xml" value="0.1962962962962963" />
<entry key="..\:/android/FYReader/app/src/main/res/drawable/ic_search_word.xml" value="0.21944444444444444" /> <entry key="..\:/android/FYReader/app/src/main/res/drawable/ic_search_word.xml" value="0.21944444444444444" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_about.xml" value="0.12132725430597771" /> <entry key="..\:/android/FYReader/app/src/main/res/layout/activity_about.xml" value="0.12132725430597771" />
@ -40,6 +41,8 @@
<entry key="..\:/android/FYReader/app/src/main/res/menu/menu_book_detail.xml" value="0.24947916666666667" /> <entry key="..\:/android/FYReader/app/src/main/res/menu/menu_book_detail.xml" value="0.24947916666666667" />
<entry key="..\:/android/FYReader/app/src/main/res/menu/menu_book_detail_local.xml" value="0.24947916666666667" /> <entry key="..\:/android/FYReader/app/src/main/res/menu/menu_book_detail_local.xml" value="0.24947916666666667" />
<entry key="..\:/android/FYReader/app/src/main/res/menu/menu_read.xml" value="0.24947916666666667" /> <entry key="..\:/android/FYReader/app/src/main/res/menu/menu_read.xml" value="0.24947916666666667" />
<entry key="..\:/android/FYReader/app/src/main/res/menu/menu_rule.xml" value="0.24947916666666667" />
<entry key="..\:/android/FYReader/app/src/main/res/menu/menu_search_word.xml" value="0.1425925925925926" />
</map> </map>
</option> </option>
</component> </component>

@ -112,7 +112,7 @@ class SearchWordEngine(
emitter.onNext(searchWord1) emitter.onNext(searchWord1)
return@ObservableOnSubscribe return@ObservableOnSubscribe
} }
var content = pageLoader.getChapterReader(chapter) var content = chapter.title + "\n" + pageLoader.getChapterReader(chapter)
content = pageLoader.contentHelper.replaceContent( content = pageLoader.contentHelper.replaceContent(
book.name + "-" + book.author, book.name + "-" + book.author,
book.source, book.source,

@ -2,6 +2,8 @@ package xyz.fycz.myreader.ui.activity
import android.os.Bundle import android.os.Bundle
import android.view.KeyEvent import android.view.KeyEvent
import android.view.Menu
import android.view.MenuItem
import android.view.View import android.view.View
import android.view.inputmethod.EditorInfo import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodManager
@ -192,4 +194,20 @@ class SearchWordActivity : BaseActivity() {
searchWordEngine.stopSearch() searchWordEngine.stopSearch()
searchWordEngine.closeSearchEngine() 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)
}
} }

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_clear"
android:icon="@drawable/ic_delete"
android:title="@string/clear_result"
app:showAsAction="never"/>
</menu>

@ -514,6 +514,7 @@
<string name="input_keyword">输入关键词</string> <string name="input_keyword">输入关键词</string>
<string name="search_word">内容搜索</string> <string name="search_word">内容搜索</string>
<string name="search_word_tip">搜索书籍已缓存的内容</string> <string name="search_word_tip">搜索书籍已缓存的内容</string>
<string name="clear_result">清除搜索结果</string>
<string-array name="reset_screen_time"> <string-array name="reset_screen_time">

@ -1,3 +1,3 @@
#Fri Jun 18 21:45:31 CST 2021 #Fri Jun 18 21:45:31 CST 2021
VERSION_CODE=226 VERSION_CODE=226
NEED_CREATE_RELEASE=true NEED_CREATE_RELEASE=false

Loading…
Cancel
Save