master v2.2.6
fengyuecanzhu 3 years ago
parent c28786f88a
commit 4ea1172716
  1. 2
      app/build.gradle
  2. 5
      app/release.md
  3. 4
      app/src/main/AndroidManifest.xml
  4. 7
      app/src/main/assets/updatelog.fy
  5. 2
      app/src/main/java/xyz/fycz/myreader/greendao/convert/ContentRuleConvert.java
  6. 3
      app/src/main/java/xyz/fycz/myreader/greendao/convert/FindRuleConvert.java
  7. 2
      app/src/main/java/xyz/fycz/myreader/greendao/convert/InfoRuleConvert.java
  8. 2
      app/src/main/java/xyz/fycz/myreader/greendao/convert/SearchRuleConvert.java
  9. 20
      app/src/main/java/xyz/fycz/myreader/greendao/convert/SearchWord1Convert.kt
  10. 2
      app/src/main/java/xyz/fycz/myreader/greendao/convert/TocRuleConvert.java
  11. 11
      app/src/main/java/xyz/fycz/myreader/greendao/entity/rule/BookSource.java
  12. 60
      app/src/main/java/xyz/fycz/myreader/greendao/entity/search/SearchWord.java
  13. 2
      app/src/main/java/xyz/fycz/myreader/greendao/entity/search/SearchWord1.kt
  14. 2
      app/src/main/java/xyz/fycz/myreader/greendao/entity/search/SearchWord2.kt
  15. 4
      app/src/main/java/xyz/fycz/myreader/greendao/service/BookService.java
  16. 4
      app/src/main/java/xyz/fycz/myreader/greendao/util/MySQLiteOpenHelper.java
  17. 12
      app/src/main/java/xyz/fycz/myreader/model/SearchWordEngine.kt
  18. 8
      app/src/main/java/xyz/fycz/myreader/model/storage/Backup.kt
  19. 10
      app/src/main/java/xyz/fycz/myreader/model/storage/Restore.kt
  20. 2
      app/src/main/java/xyz/fycz/myreader/ui/activity/SearchBookActivity.java
  21. 50
      app/src/main/java/xyz/fycz/myreader/ui/activity/SearchWordActivity.kt
  22. 6
      app/src/main/java/xyz/fycz/myreader/ui/adapter/holder/SearchWord1Holder.kt
  23. 2
      app/src/main/java/xyz/fycz/myreader/ui/adapter/holder/SearchWord2Holder.kt
  24. 1
      app/src/main/res/layout/activity_search_word.xml
  25. 1
      app/src/main/res/layout/item_search_word1.xml
  26. 2
      app/version_code.properties

@ -243,7 +243,7 @@ dependencies {
}
greendao {
schemaVersion 30
schemaVersion 32
daoPackage 'xyz.fycz.myreader.greendao.gen'
// targetGenDir 'src/main/java'
}

@ -1,2 +1,3 @@
* 1、优化内容搜索结果显示
* 2、修复v2.2.4版本json格式书源无法导入的bug
* 1、优化搜索键盘自动弹出体验
* 2、新增书籍内容搜索结果自动保存
* 3、新增书籍内容搜索结果备份与恢复

@ -75,9 +75,7 @@
android:name=".ui.activity.MainActivity"
android:alwaysRetainTaskState="true"
android:launchMode="singleTask" />
<activity
android:name=".ui.activity.SearchBookActivity"
android:windowSoftInputMode="stateVisible" />
<activity android:name=".ui.activity.SearchBookActivity" />
<activity android:name=".ui.activity.BookDetailedActivity" />
<activity

@ -1,3 +1,10 @@
2021.12.07
风月读书v2.2.6
更新内容:
1、优化搜索键盘自动弹出体验
2、新增书籍内容搜索结果自动保存
3、新增书籍内容搜索结果备份与恢复
2021.12.06
风月读书v2.2.5
更新内容:

@ -1,4 +1,4 @@
package xyz.fycz.myreader.greendao.entity.rule.convert;
package xyz.fycz.myreader.greendao.convert;
import org.greenrobot.greendao.converter.PropertyConverter;

@ -1,9 +1,8 @@
package xyz.fycz.myreader.greendao.entity.rule.convert;
package xyz.fycz.myreader.greendao.convert;
import org.greenrobot.greendao.converter.PropertyConverter;
import xyz.fycz.myreader.greendao.entity.rule.FindRule;
import xyz.fycz.myreader.greendao.entity.rule.TocRule;
import xyz.fycz.myreader.util.utils.GsonExtensionsKt;
/**

@ -1,4 +1,4 @@
package xyz.fycz.myreader.greendao.entity.rule.convert;
package xyz.fycz.myreader.greendao.convert;
import org.greenrobot.greendao.converter.PropertyConverter;

@ -1,4 +1,4 @@
package xyz.fycz.myreader.greendao.entity.rule.convert;
package xyz.fycz.myreader.greendao.convert;
import org.greenrobot.greendao.converter.PropertyConverter;

@ -0,0 +1,20 @@
package xyz.fycz.myreader.greendao.convert
import org.greenrobot.greendao.converter.PropertyConverter
import xyz.fycz.myreader.greendao.entity.search.SearchWord1
import xyz.fycz.myreader.util.utils.GSON
import xyz.fycz.myreader.util.utils.fromJsonArray
/**
* @author fengyue
* @date 2021/12/7 8:14
*/
class SearchWord1Convert: PropertyConverter<List<SearchWord1>, String> {
override fun convertToEntityProperty(databaseValue: String?): List<SearchWord1>? {
return GSON.fromJsonArray(databaseValue)
}
override fun convertToDatabaseValue(entityProperty: List<SearchWord1>?): String {
return GSON.toJson(entityProperty)
}
}

@ -1,4 +1,4 @@
package xyz.fycz.myreader.greendao.entity.rule.convert;
package xyz.fycz.myreader.greendao.convert;
import org.greenrobot.greendao.converter.PropertyConverter;

@ -15,16 +15,15 @@ import org.greenrobot.greendao.annotation.NotNull;
import org.greenrobot.greendao.annotation.OrderBy;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Transient;
import org.greenrobot.greendao.annotation.Unique;
import java.util.ArrayList;
import java.util.Objects;
import xyz.fycz.myreader.greendao.entity.rule.convert.ContentRuleConvert;
import xyz.fycz.myreader.greendao.entity.rule.convert.FindRuleConvert;
import xyz.fycz.myreader.greendao.entity.rule.convert.InfoRuleConvert;
import xyz.fycz.myreader.greendao.entity.rule.convert.SearchRuleConvert;
import xyz.fycz.myreader.greendao.entity.rule.convert.TocRuleConvert;
import xyz.fycz.myreader.greendao.convert.ContentRuleConvert;
import xyz.fycz.myreader.greendao.convert.FindRuleConvert;
import xyz.fycz.myreader.greendao.convert.InfoRuleConvert;
import xyz.fycz.myreader.greendao.convert.SearchRuleConvert;
import xyz.fycz.myreader.greendao.convert.TocRuleConvert;
import static xyz.fycz.myreader.util.utils.StringUtils.stringEquals;

@ -0,0 +1,60 @@
package xyz.fycz.myreader.greendao.entity.search;
import org.greenrobot.greendao.annotation.Convert;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import java.util.List;
import xyz.fycz.myreader.greendao.convert.SearchWord1Convert;
import org.greenrobot.greendao.annotation.Generated;
/**
* @author fengyue
* @date 2021/12/7 8:31
*/
@Entity
public class SearchWord {
@Id
private String bookId;
private String keyword;
@Convert(columnType = String.class, converter = SearchWord1Convert.class)
private List<SearchWord1> searchWords;
@Generated(hash = 2054974399)
public SearchWord(String bookId, String keyword,
List<SearchWord1> searchWords) {
this.bookId = bookId;
this.keyword = keyword;
this.searchWords = searchWords;
}
@Generated(hash = 407254878)
public SearchWord() {
}
public String getBookId() {
return this.bookId;
}
public void setBookId(String bookId) {
this.bookId = bookId;
}
public List<SearchWord1> getSearchWords() {
return this.searchWords;
}
public void setSearchWords(List<SearchWord1> searchWords) {
this.searchWords = searchWords;
}
public String getKeyword() {
return this.keyword;
}
public void setKeyword(String keyword) {
this.keyword = keyword;
}
}

@ -1,4 +1,4 @@
package xyz.fycz.myreader.entity
package xyz.fycz.myreader.greendao.entity.search
/**
* @author fengyue

@ -1,4 +1,4 @@
package xyz.fycz.myreader.entity
package xyz.fycz.myreader.greendao.entity.search
/**
* @author fengyue

@ -189,10 +189,11 @@ public class BookService extends BaseService {
* @param id
*/
public void deleteBookById(String id) {
BookDao bookDao = DbManager.getInstance().getSession().getBookDao();
BookDao bookDao = DbManager.getDaoSession().getBookDao();
bookDao.deleteByKey(id);
mChapterService.deleteBookALLChapterById(id);
mBookMarkService.deleteBookALLBookMarkById(id);
DbManager.getDaoSession().getSearchWordDao().deleteByKey(id);
}
/**
@ -205,6 +206,7 @@ public class BookService extends BaseService {
deleteEntity(book);
mChapterService.deleteBookALLChapterById(book.getId());
mBookMarkService.deleteBookALLBookMarkById(book.getId());
DbManager.getDaoSession().getSearchWordDao().deleteByKey(book.getId());
}catch (Exception ignored){}
}

@ -38,10 +38,10 @@ public class MySQLiteOpenHelper extends DaoMaster.OpenHelper {
},
BookDao.class, ChapterDao.class, SearchHistoryDao.class,
BookMarkDao.class, BookGroupDao.class, ReplaceRuleBeanDao.class,
BookSourceDao.class, CookieBeanDao.class, ReadRecordDao.class
BookSourceDao.class, CookieBeanDao.class, ReadRecordDao.class,
SearchWordDao.class
);
}
}

@ -7,8 +7,8 @@ import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import xyz.fycz.myreader.R
import xyz.fycz.myreader.application.App
import xyz.fycz.myreader.entity.SearchWord1
import xyz.fycz.myreader.entity.SearchWord2
import xyz.fycz.myreader.greendao.entity.search.SearchWord1
import xyz.fycz.myreader.greendao.entity.search.SearchWord2
import xyz.fycz.myreader.greendao.entity.Book
import xyz.fycz.myreader.greendao.entity.Chapter
import xyz.fycz.myreader.greendao.service.ChapterService
@ -102,8 +102,12 @@ class SearchWordEngine(
val chapterNum = searchSiteIndex
val chapter = chapters[chapterNum]
Observable.create(ObservableOnSubscribe<SearchWord1> { emitter ->
val searchWord1 =
SearchWord1(book.id, chapterNum, chapter.title, mutableListOf())
val searchWord1 = SearchWord1(
bookId = book.id,
chapterNum = chapterNum,
chapterTitle = chapter.title,
searchWord2List = mutableListOf()
)
if (!isLocalBook && !ChapterService.isChapterCached(book.id, chapter.title)) {
emitter.onNext(searchWord1)
return@ObservableOnSubscribe

@ -42,6 +42,7 @@ object Backup {
"replaceRule.json",
"bookSource.json",
"readRecord.json",
"searchWord.json",
"config.xml"
)
}
@ -110,6 +111,13 @@ object Backup {
.writeText(json)
}
}
DbManager.getDaoSession().searchWordDao.queryBuilder().list().let {
if (it.isNotEmpty()) {
val json = GSON.toJson(it)
FileUtils.getFile(backupPath + File.separator + "searchWord.json")
.writeText(json)
}
}
try {
val setting = SysManager.getNewSetting()
val readStyles = setting.readStyles

@ -15,6 +15,7 @@ import xyz.fycz.myreader.entity.Setting
import xyz.fycz.myreader.greendao.DbManager
import xyz.fycz.myreader.greendao.entity.*
import xyz.fycz.myreader.greendao.entity.rule.BookSource
import xyz.fycz.myreader.greendao.entity.search.SearchWord
import xyz.fycz.myreader.util.SharedPreUtils
import xyz.fycz.myreader.util.utils.*
import java.io.File
@ -129,6 +130,15 @@ object Restore {
} catch (e: Exception) {
e.printStackTrace()
}
try {
val file = FileUtils.getFile(path + File.separator + "searchWord.json")
val json = file.readText()
GSON.fromJsonArray<SearchWord>(json)?.let {
DbManager.getInstance().session.searchWordDao.insertOrReplaceInTx(it)
}
} catch (e: Exception) {
e.printStackTrace()
}
try {
val settingFile = FileUtils.getFile(path + File.separator + "setting.json")
val settingJson = settingFile.readText()

@ -120,7 +120,7 @@ public class SearchBookActivity extends BaseActivity {
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus){
if (hasFocus && binding.etSearchKey.getText().length() == 0){
App.getHandler().postDelayed(() -> {
binding.etSearchKey.requestFocus();
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);

@ -7,7 +7,6 @@ import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager
import androidx.appcompat.widget.Toolbar
import androidx.recyclerview.widget.LinearLayoutManager
import org.jetbrains.anko.contentView
import xyz.fycz.myreader.R
import xyz.fycz.myreader.application.App
import xyz.fycz.myreader.base.BaseActivity
@ -17,15 +16,14 @@ import xyz.fycz.myreader.base.adapter.IViewHolder
import xyz.fycz.myreader.base.adapter2.onClick
import xyz.fycz.myreader.common.APPCONST
import xyz.fycz.myreader.databinding.ActivitySearchWordBinding
import xyz.fycz.myreader.entity.SearchWord1
import xyz.fycz.myreader.greendao.DbManager
import xyz.fycz.myreader.greendao.entity.search.SearchWord1
import xyz.fycz.myreader.greendao.entity.Book
import xyz.fycz.myreader.greendao.entity.Chapter
import xyz.fycz.myreader.greendao.entity.search.SearchWord
import xyz.fycz.myreader.model.SearchWordEngine
import xyz.fycz.myreader.ui.adapter.holder.SearchWord1Holder
import xyz.fycz.myreader.ui.adapter.holder.SearchWord2Holder
import xyz.fycz.myreader.util.ToastUtils
import xyz.fycz.myreader.widget.page.PageLoader
import xyz.fycz.myreader.widget.page.PageView
/**
* @author fengyue
@ -39,6 +37,8 @@ class SearchWordActivity : BaseActivity() {
private lateinit var pageLoader: PageLoader
private lateinit var searchWordEngine: SearchWordEngine
private lateinit var adapter: BaseListAdapter<SearchWord1>
private var searchWord: SearchWord? = null
private var keyword: String? = null
override fun bindView() {
binding = ActivitySearchWordBinding.inflate(layoutInflater)
@ -48,7 +48,21 @@ class SearchWordActivity : BaseActivity() {
override fun setUpToolbar(toolbar: Toolbar?) {
super.setUpToolbar(toolbar)
setStatusBarColor(R.color.colorPrimary, true)
supportActionBar?.title = getString(R.string.search_word)
setUpToolbarTitle()
}
private fun setUpToolbarTitle() {
if (searchWord == null) {
supportActionBar?.title = getString(R.string.search_word)
} else {
var sum = 0
searchWord?.searchWords?.forEach {
sum += it.searchWord2List.size
}
supportActionBar?.title =
getString(R.string.search_word) + "(共" + searchWord?.searchWords?.size +
"个章节," + sum + "条结果)"
}
}
override fun onSaveInstanceState(outState: Bundle) {
@ -60,7 +74,7 @@ class SearchWordActivity : BaseActivity() {
override fun onWindowFocusChanged(hasFocus: Boolean) {
super.onWindowFocusChanged(hasFocus)
if (hasFocus) {
if (hasFocus && binding.etSearchKey.text?.isEmpty() == true) {
App.getHandler().postDelayed({
binding.etSearchKey.requestFocus()
val imm =
@ -81,6 +95,7 @@ class SearchWordActivity : BaseActivity() {
pageLoader =
BitIntentDataManager.getInstance().getData(APPCONST.PAGE_LOADER_KEY) as PageLoader
searchWordEngine = SearchWordEngine(book, chapters, pageLoader)
searchWord = DbManager.getDaoSession().searchWordDao.load(book.id)
}
override fun initWidget() {
@ -96,12 +111,11 @@ class SearchWordActivity : BaseActivity() {
override fun loadFinish(isEmpty: Boolean) {
binding.fabSearchStop.visibility = View.GONE
binding.rpb.isAutoLoading = false
var sum = 0
adapter.items.forEach {
sum += it.searchWord2List.size
if (adapter.itemSize > 0) {
searchWord = SearchWord(book.id, keyword, adapter.items)
setUpToolbarTitle()
DbManager.getDaoSession().searchWordDao.insertOrReplace(searchWord)
}
supportActionBar?.title = getString(R.string.search_word) + "(共" + adapter.itemSize +
"个章节," + sum + "条结果)"
}
@Synchronized
@ -135,6 +149,11 @@ class SearchWordActivity : BaseActivity() {
}
binding.rvSearchWord1.layoutManager = LinearLayoutManager(this)
binding.rvSearchWord1.adapter = adapter
searchWord?.let {
binding.etSearchKey.setText(it.keyword)
keyword = it.keyword
adapter.refreshItems(it.searchWords)
}
}
override fun initClick() {
@ -144,8 +163,8 @@ class SearchWordActivity : BaseActivity() {
private fun search() {
val keyword = binding.etSearchKey.text.toString()
if (keyword.isNotEmpty()) {
supportActionBar?.title = getString(R.string.search_word)
if (keyword.isNotEmpty() && this.keyword != keyword) {
this.keyword = keyword
adapter.clear()
binding.fabSearchStop.visibility = View.VISIBLE
binding.rpb.isAutoLoading = true
@ -156,6 +175,9 @@ class SearchWordActivity : BaseActivity() {
binding.etSearchKey.windowToken,
InputMethodManager.HIDE_NOT_ALWAYS
)
DbManager.getDaoSession().searchWordDao.deleteByKey(book.id)
searchWord = null
setUpToolbarTitle()
}
}

@ -1,9 +1,7 @@
package xyz.fycz.myreader.ui.adapter.holder
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Intent
import android.view.View
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
@ -12,8 +10,8 @@ import xyz.fycz.myreader.R
import xyz.fycz.myreader.base.adapter.BaseListAdapter
import xyz.fycz.myreader.base.adapter.IViewHolder
import xyz.fycz.myreader.base.adapter.ViewHolderImpl
import xyz.fycz.myreader.entity.SearchWord1
import xyz.fycz.myreader.entity.SearchWord2
import xyz.fycz.myreader.greendao.entity.search.SearchWord1
import xyz.fycz.myreader.greendao.entity.search.SearchWord2
/**
* @author fengyue

@ -8,7 +8,7 @@ import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import xyz.fycz.myreader.R
import xyz.fycz.myreader.base.adapter.ViewHolderImpl
import xyz.fycz.myreader.entity.SearchWord2
import xyz.fycz.myreader.greendao.entity.search.SearchWord2
/**
* @author fengyue

@ -56,7 +56,6 @@
android:id="@+id/rv_search_word1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingHorizontal="10dp"
tools:ignore="SpeakableTextPresentCheck" />
<com.google.android.material.floatingactionbutton.FloatingActionButton

@ -2,6 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="10dp"
android:paddingBottom="10dp"
android:orientation="vertical">

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

Loading…
Cancel
Save