Merge pull request #365 from h11128/h11128pull

书源基本属性增加“书源注释”,便于保存书源作者,书源详细信息
pull/366/head
kunfei 4 years ago committed by GitHub
commit 16e7da2b6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      app/build.gradle
  2. 5
      app/src/main/assets/web/index.html
  3. 2
      app/src/main/assets/web/index.js
  4. 10
      app/src/main/java/io/legado/app/data/AppDatabase.kt
  5. 3
      app/src/main/java/io/legado/app/data/entities/BookSource.kt
  6. 3
      app/src/main/java/io/legado/app/help/storage/OldRule.kt
  7. 2
      app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt
  8. 4
      app/src/main/res/values-night/strings.xml
  9. 3
      app/src/main/res/values-zh-rHK/strings.xml
  10. 3
      app/src/main/res/values-zh-rTW/strings.xml
  11. 3
      app/src/main/res/values-zh/strings.xml
  12. 3
      app/src/main/res/values/strings.xml

@ -135,6 +135,7 @@ dependencies {
implementation 'com.google.android.material:material:1.2.1' implementation 'com.google.android.material:material:1.2.1'
implementation 'com.google.android:flexbox:1.1.0' implementation 'com.google.android:flexbox:1.1.0'
implementation 'com.google.code.gson:gson:2.8.6' implementation 'com.google.code.gson:gson:2.8.6'
testImplementation "androidx.room:room-testing:2.2.5"
//lifecycle //lifecycle
def lifecycle_version = '2.2.0' def lifecycle_version = '2.2.0'
@ -145,6 +146,7 @@ dependencies {
def room_version = '2.2.5' def room_version = '2.2.5'
implementation "androidx.room:room-runtime:$room_version" implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version" kapt "androidx.room:room-compiler:$room_version"
testImplementation "androidx.room:room-testing:2.2.5"
//paging //paging
implementation 'androidx.paging:paging-runtime-ktx:2.1.2' implementation 'androidx.paging:paging-runtime-ktx:2.1.2'
@ -208,4 +210,5 @@ dependencies {
//implementation 'fadeapp.widgets:scrollless-recyclerView:1.0.2' //implementation 'fadeapp.widgets:scrollless-recyclerView:1.0.2'
} }
apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android-extensions'

@ -38,6 +38,11 @@
<textarea rows="1" id="loginUrl" class="base" title="loginUrl" <textarea rows="1" id="loginUrl" class="base" title="loginUrl"
placeholder="&lt;选填&gt;填写网站登录网址,仅在需要登录的书源有用"></textarea> placeholder="&lt;选填&gt;填写网站登录网址,仅在需要登录的书源有用"></textarea>
</div> </div>
<div>
<div>注释:</div>
<textarea rows="1" id="bookSourceComment" class="base" title="bookSourceComment"
placeholder="&lt;选填&gt;描述书源作者和状态"></textarea>
</div>
<div> <div>
<div>链接验证:</div> <div>链接验证:</div>
<textarea rows="1" id="bookUrlPattern" class="base" title="bookUrlPattern" <textarea rows="1" id="bookUrlPattern" class="base" title="bookUrlPattern"

@ -33,6 +33,7 @@ const RuleJSON = (() => {
ruleJson.weight = 0; ruleJson.weight = 0;
ruleJson.enabled = true; ruleJson.enabled = true;
ruleJson.enabledExplore = true; ruleJson.enabledExplore = true;
ruleJson.bookSourceComment = ""
// 搜索规则 // 搜索规则
$$('.rules .ruleSearch').forEach(item => searchJson[item.title] = ''); $$('.rules .ruleSearch').forEach(item => searchJson[item.title] = '');
@ -159,6 +160,7 @@ function rule2json() {
RuleJSON.ruleContent = contentJson; RuleJSON.ruleContent = contentJson;
RuleJSON.lastUpdateTime = RuleJSON.lastUpdateTime == '' ? 0 : parseInt(RuleJSON.lastUpdateTime); RuleJSON.lastUpdateTime = RuleJSON.lastUpdateTime == '' ? 0 : parseInt(RuleJSON.lastUpdateTime);
RuleJSON.bookSourceComment = RuleJSON.bookSourceComment == '' ? "" : String(RuleJSON.bookSourceComment);
RuleJSON.customOrder = RuleJSON.customOrder == '' ? 0 : parseInt(RuleJSON.customOrder); RuleJSON.customOrder = RuleJSON.customOrder == '' ? 0 : parseInt(RuleJSON.customOrder);
RuleJSON.weight = RuleJSON.weight == '' ? 0 : parseInt(RuleJSON.weight); RuleJSON.weight = RuleJSON.weight == '' ? 0 : parseInt(RuleJSON.weight);
RuleJSON.bookSourceType == RuleJSON.bookSourceType == '' ? 0 : parseInt(RuleJSON.weight); RuleJSON.bookSourceType == RuleJSON.bookSourceType == '' ? 0 : parseInt(RuleJSON.weight);

@ -16,7 +16,7 @@ import io.legado.app.data.entities.*
ReplaceRule::class, SearchBook::class, SearchKeyword::class, Cookie::class, ReplaceRule::class, SearchBook::class, SearchKeyword::class, Cookie::class,
RssSource::class, Bookmark::class, RssArticle::class, RssReadRecord::class, RssSource::class, Bookmark::class, RssArticle::class, RssReadRecord::class,
RssStar::class, TxtTocRule::class, ReadRecord::class, HttpTTS::class], RssStar::class, TxtTocRule::class, ReadRecord::class, HttpTTS::class],
version = 19, version = 20,
exportSchema = true exportSchema = true
) )
abstract class AppDatabase : RoomDatabase() { abstract class AppDatabase : RoomDatabase() {
@ -36,7 +36,8 @@ abstract class AppDatabase : RoomDatabase() {
migration_14_15, migration_14_15,
migration_15_17, migration_15_17,
migration_17_18, migration_17_18,
migration_18_19 migration_18_19,
migration_19_20
) )
.allowMainThreadQueries() .allowMainThreadQueries()
.build() .build()
@ -112,6 +113,11 @@ abstract class AppDatabase : RoomDatabase() {
database.execSQL("ALTER TABLE readRecordNew RENAME TO readRecord") database.execSQL("ALTER TABLE readRecordNew RENAME TO readRecord")
} }
} }
private val migration_19_20 = object : Migration(19,20) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("ALTER TABLE book_sources ADD bookSourceComment TEXT")
}
}
} }
abstract fun bookDao(): BookDao abstract fun bookDao(): BookDao

@ -32,6 +32,7 @@ data class BookSource(
var enabledExplore: Boolean = true, // 启用发现 var enabledExplore: Boolean = true, // 启用发现
var header: String? = null, // 请求头 var header: String? = null, // 请求头
var loginUrl: String? = null, // 登录地址 var loginUrl: String? = null, // 登录地址
var bookSourceComment: String? = "", // 注释
var lastUpdateTime: Long = 0, // 最后更新时间,用于排序 var lastUpdateTime: Long = 0, // 最后更新时间,用于排序
var weight: Int = 0, // 智能排序的权重 var weight: Int = 0, // 智能排序的权重
var exploreUrl: String? = null, // 发现url var exploreUrl: String? = null, // 发现url
@ -104,7 +105,7 @@ data class BookSource(
} }
fun removeGroup(group: String) { fun removeGroup(group: String) {
bookSourceGroup?.splitNotBlank("[,;]".toRegex())?.toHashSet()?.let { bookSourceGroup?.splitNotBlank("[,;,;]".toRegex())?.toHashSet()?.let {
it.remove(group) it.remove(group)
bookSourceGroup = TextUtils.join(",", it) bookSourceGroup = TextUtils.join(",", it)
} }

@ -28,6 +28,7 @@ object OldRule {
bookSourceName = jsonItem.readString("bookSourceName") ?: "" bookSourceName = jsonItem.readString("bookSourceName") ?: ""
bookSourceGroup = jsonItem.readString("bookSourceGroup") bookSourceGroup = jsonItem.readString("bookSourceGroup")
loginUrl = jsonItem.readString("loginUrl") loginUrl = jsonItem.readString("loginUrl")
bookSourceComment = jsonItem.readString("bookSourceComment") ?: ""
bookUrlPattern = jsonItem.readString("ruleBookUrlPattern") bookUrlPattern = jsonItem.readString("ruleBookUrlPattern")
customOrder = jsonItem.readInt("serialNumber") ?: 0 customOrder = jsonItem.readInt("serialNumber") ?: 0
header = uaToHeader(jsonItem.readString("httpUserAgent")) header = uaToHeader(jsonItem.readString("httpUserAgent"))
@ -96,6 +97,7 @@ object OldRule {
source.enabledExplore = sourceAny.enabledExplore source.enabledExplore = sourceAny.enabledExplore
source.header = sourceAny.header source.header = sourceAny.header
source.loginUrl = sourceAny.loginUrl source.loginUrl = sourceAny.loginUrl
source.bookSourceComment = sourceAny.bookSourceComment
source.lastUpdateTime = sourceAny.lastUpdateTime source.lastUpdateTime = sourceAny.lastUpdateTime
source.weight = sourceAny.weight source.weight = sourceAny.weight
source.exploreUrl = sourceAny.exploreUrl source.exploreUrl = sourceAny.exploreUrl
@ -144,6 +146,7 @@ object OldRule {
var enabledExplore: Boolean = true, // 启用发现 var enabledExplore: Boolean = true, // 启用发现
var header: String? = null, // 请求头 var header: String? = null, // 请求头
var loginUrl: String? = null, // 登录地址 var loginUrl: String? = null, // 登录地址
var bookSourceComment: String? = "", //书源注释
var lastUpdateTime: Long = 0, // 最后更新时间,用于排序 var lastUpdateTime: Long = 0, // 最后更新时间,用于排序
var weight: Int = 0, // 智能排序的权重 var weight: Int = 0, // 智能排序的权重
var exploreUrl: String? = null, // 发现url var exploreUrl: String? = null, // 发现url

@ -173,6 +173,7 @@ class BookSourceEditActivity :
add(EditEntity("loginUrl", source?.loginUrl, R.string.login_url)) add(EditEntity("loginUrl", source?.loginUrl, R.string.login_url))
add(EditEntity("bookUrlPattern", source?.bookUrlPattern, R.string.book_url_pattern)) add(EditEntity("bookUrlPattern", source?.bookUrlPattern, R.string.book_url_pattern))
add(EditEntity("header", source?.header, R.string.source_http_header)) add(EditEntity("header", source?.header, R.string.source_http_header))
add(EditEntity("bookSourceComment", source?.bookSourceComment, R.string.comment))
} }
//搜索 //搜索
val sr = source?.getSearchRule() val sr = source?.getSearchRule()
@ -262,6 +263,7 @@ class BookSourceEditActivity :
"loginUrl" -> source.loginUrl = it.value "loginUrl" -> source.loginUrl = it.value
"bookUrlPattern" -> source.bookUrlPattern = it.value "bookUrlPattern" -> source.bookUrlPattern = it.value
"header" -> source.header = it.value "header" -> source.header = it.value
"bookSourceComment" -> source.bookSourceComment = it.value ?: ""
} }
} }
searchEntities.forEach { searchEntities.forEach {

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
</resources>

@ -383,6 +383,7 @@
<string name="source_group">源分組 (sourceGroup)</string> <string name="source_group">源分組 (sourceGroup)</string>
<string name="sort_url">分類 Url</string> <string name="sort_url">分類 Url</string>
<string name="login_url">登錄 URL(loginUrl)</string> <string name="login_url">登錄 URL(loginUrl)</string>
<string name="comment">源注釋(sourceComment)</string>
<string name="r_search_url">搜索地址 (url)</string> <string name="r_search_url">搜索地址 (url)</string>
<string name="r_find_url">發現地址規則 (url)</string> <string name="r_find_url">發現地址規則 (url)</string>
<string name="r_book_list">書籍列表規則 (bookList)</string> <string name="r_book_list">書籍列表規則 (bookList)</string>
@ -757,4 +758,6 @@
<string name="save_night_theme_summary">保存夜间主题配置以共调用和分享</string> <string name="save_night_theme_summary">保存夜间主题配置以共调用和分享</string>
<string name="theme_list">主题列表</string> <string name="theme_list">主题列表</string>
<string name="theme_list_summary">使用保存主题,导入,分享主题</string> <string name="theme_list_summary">使用保存主题,导入,分享主题</string>
<string name="select_theme">切換默認主題</string>
</resources> </resources>

@ -386,6 +386,7 @@
<string name="login_url">登入URL(loginUrl)</string> <string name="login_url">登入URL(loginUrl)</string>
<string name="r_search_url">搜尋地址(url)</string> <string name="r_search_url">搜尋地址(url)</string>
<string name="r_find_url">發現地址規則(url)</string> <string name="r_find_url">發現地址規則(url)</string>
<string name="comment">源注釋(sourceComment)</string>
<string name="r_book_list">書籍列表規則(bookList)</string> <string name="r_book_list">書籍列表規則(bookList)</string>
<string name="r_book_name">書名規則(name)</string> <string name="r_book_name">書名規則(name)</string>
<string name="r_book_url">詳情頁url規則(bookUrl)</string> <string name="r_book_url">詳情頁url規則(bookUrl)</string>
@ -757,5 +758,7 @@
<string name="save_night_theme_summary">保存夜间主题配置以共调用和分享</string> <string name="save_night_theme_summary">保存夜间主题配置以共调用和分享</string>
<string name="theme_list">主题列表</string> <string name="theme_list">主题列表</string>
<string name="theme_list_summary">使用保存主题,导入,分享主题</string> <string name="theme_list_summary">使用保存主题,导入,分享主题</string>
<string name="select_theme">切換默認主題</string>
</resources> </resources>

@ -386,6 +386,7 @@
<string name="source_group">源分组(sourceGroup)</string> <string name="source_group">源分组(sourceGroup)</string>
<string name="sort_url">分类Url</string> <string name="sort_url">分类Url</string>
<string name="login_url">登录URL(loginUrl)</string> <string name="login_url">登录URL(loginUrl)</string>
<string name="comment">源注释(sourceComment)</string>
<string name="r_search_url">搜索地址(url)</string> <string name="r_search_url">搜索地址(url)</string>
<string name="r_find_url">发现地址规则(url)</string> <string name="r_find_url">发现地址规则(url)</string>
<string name="r_book_list">书籍列表规则(bookList)</string> <string name="r_book_list">书籍列表规则(bookList)</string>
@ -757,4 +758,6 @@
<string name="save_night_theme_summary">保存夜间主题配置以共调用和分享</string> <string name="save_night_theme_summary">保存夜间主题配置以共调用和分享</string>
<string name="theme_list">主题列表</string> <string name="theme_list">主题列表</string>
<string name="theme_list_summary">使用保存主题,导入,分享主题</string> <string name="theme_list_summary">使用保存主题,导入,分享主题</string>
<string name="select_theme">切换默认主题</string>
</resources> </resources>

@ -290,6 +290,7 @@
<string name="padding_right">Padding right</string> <string name="padding_right">Padding right</string>
<string name="check_book_source">Check book sources</string> <string name="check_book_source">Check book sources</string>
<string name="check_select_source">Check the selected source</string> <string name="check_select_source">Check the selected source</string>
<string name="debug_select_source">Debug the selected source</string>
<string name="progress_show">Progress %1$d/%2$d</string> <string name="progress_show">Progress %1$d/%2$d</string>
<string name="tts_fix">Please install and select Chinese TTS!</string> <string name="tts_fix">Please install and select Chinese TTS!</string>
<string name="tts_init_failed">TTS initialization failed!</string> <string name="tts_init_failed">TTS initialization failed!</string>
@ -386,6 +387,7 @@
<string name="source_group">源分组(sourceGroup)</string> <string name="source_group">源分组(sourceGroup)</string>
<string name="sort_url">分类Url</string> <string name="sort_url">分类Url</string>
<string name="login_url">登录URL(loginUrl)</string> <string name="login_url">登录URL(loginUrl)</string>
<string name="comment">源注释(sourceComment)</string>
<string name="r_search_url">搜索地址(url)</string> <string name="r_search_url">搜索地址(url)</string>
<string name="r_find_url">发现地址规则(url)</string> <string name="r_find_url">发现地址规则(url)</string>
<string name="r_book_list">书籍列表规则(bookList)</string> <string name="r_book_list">书籍列表规则(bookList)</string>
@ -759,4 +761,5 @@
<string name="save_night_theme_summary">Save night theme config</string> <string name="save_night_theme_summary">Save night theme config</string>
<string name="theme_list">Theme list</string> <string name="theme_list">Theme list</string>
<string name="theme_list_summary">Save, Import, Share theme</string> <string name="theme_list_summary">Save, Import, Share theme</string>
</resources> </resources>
Loading…
Cancel
Save