diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt index 3d689582a..463ba1621 100644 --- a/app/src/main/java/io/legado/app/App.kt +++ b/app/src/main/java/io/legado/app/App.kt @@ -79,7 +79,7 @@ class App : Application() { } } - fun applyDayNight(){ + fun applyDayNight() { upThemeStore() initNightTheme() } diff --git a/app/src/main/java/io/legado/app/base/BaseFragment.kt b/app/src/main/java/io/legado/app/base/BaseFragment.kt index 559631422..0a35d8a1f 100644 --- a/app/src/main/java/io/legado/app/base/BaseFragment.kt +++ b/app/src/main/java/io/legado/app/base/BaseFragment.kt @@ -6,11 +6,9 @@ import android.view.MenuItem import androidx.appcompat.view.SupportMenuInflater import androidx.appcompat.widget.Toolbar import androidx.fragment.app.Fragment -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.LifecycleRegistry import io.legado.app.utils.setIconColor -abstract class BaseFragment(contentLayoutId: Int = 0) : Fragment(contentLayoutId){ +abstract class BaseFragment(contentLayoutId: Int = 0) : Fragment(contentLayoutId) { var supportToolbar: Toolbar? = null private set diff --git a/app/src/main/java/io/legado/app/base/adapter/InfiniteScrollListener.kt b/app/src/main/java/io/legado/app/base/adapter/InfiniteScrollListener.kt index fc7c48bab..a679f3e08 100644 --- a/app/src/main/java/io/legado/app/base/adapter/InfiniteScrollListener.kt +++ b/app/src/main/java/io/legado/app/base/adapter/InfiniteScrollListener.kt @@ -14,7 +14,7 @@ abstract class InfiniteScrollListener() : RecyclerView.OnScrollListener() { override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { // if (dy < 0 || dataLoading.isDataLoading()) return - val layoutManager:LinearLayoutManager = recyclerView.layoutManager as LinearLayoutManager + val layoutManager: LinearLayoutManager = recyclerView.layoutManager as LinearLayoutManager val visibleItemCount = recyclerView.childCount val totalItemCount = layoutManager.itemCount val firstVisibleItem = layoutManager.findFirstVisibleItemPosition() diff --git a/app/src/main/java/io/legado/app/base/adapter/ItemAnimation.kt b/app/src/main/java/io/legado/app/base/adapter/ItemAnimation.kt index 6db4a7415..cf2f40305 100644 --- a/app/src/main/java/io/legado/app/base/adapter/ItemAnimation.kt +++ b/app/src/main/java/io/legado/app/base/adapter/ItemAnimation.kt @@ -2,12 +2,7 @@ package io.legado.app.base.adapter import android.view.animation.Interpolator import android.view.animation.LinearInterpolator -import io.legado.app.base.adapter.animations.AlphaInAnimation -import io.legado.app.base.adapter.animations.BaseAnimation -import io.legado.app.base.adapter.animations.ScaleInAnimation -import io.legado.app.base.adapter.animations.SlideInBottomAnimation -import io.legado.app.base.adapter.animations.SlideInLeftAnimation -import io.legado.app.base.adapter.animations.SlideInRightAnimation +import io.legado.app.base.adapter.animations.* /** * Created by Invincible on 2017/12/15. diff --git a/app/src/main/java/io/legado/app/base/adapter/ItemViewDelegate.kt b/app/src/main/java/io/legado/app/base/adapter/ItemViewDelegate.kt index e3ec89060..b4cd06a2f 100644 --- a/app/src/main/java/io/legado/app/base/adapter/ItemViewDelegate.kt +++ b/app/src/main/java/io/legado/app/base/adapter/ItemViewDelegate.kt @@ -7,7 +7,7 @@ import android.content.Context * * item代理, */ -abstract class ItemViewDelegate(protected val context: Context, val layoutId: Int) { +abstract class ItemViewDelegate(protected val context: Context, val layoutId: Int) { abstract fun convert(holder: ItemViewHolder, item: ITEM, payloads: MutableList) diff --git a/app/src/main/java/io/legado/app/base/adapter/animations/AlphaInAnimation.kt b/app/src/main/java/io/legado/app/base/adapter/animations/AlphaInAnimation.kt index b307300a3..e3a5b523a 100644 --- a/app/src/main/java/io/legado/app/base/adapter/animations/AlphaInAnimation.kt +++ b/app/src/main/java/io/legado/app/base/adapter/animations/AlphaInAnimation.kt @@ -8,7 +8,7 @@ import android.view.View class AlphaInAnimation @JvmOverloads constructor(private val mFrom: Float = DEFAULT_ALPHA_FROM) : BaseAnimation { override fun getAnimators(view: View): Array = - arrayOf(ObjectAnimator.ofFloat(view, "alpha", mFrom, 1f)) + arrayOf(ObjectAnimator.ofFloat(view, "alpha", mFrom, 1f)) companion object { diff --git a/app/src/main/java/io/legado/app/base/adapter/animations/SlideInBottomAnimation.kt b/app/src/main/java/io/legado/app/base/adapter/animations/SlideInBottomAnimation.kt index 0fd2bfde6..941562201 100644 --- a/app/src/main/java/io/legado/app/base/adapter/animations/SlideInBottomAnimation.kt +++ b/app/src/main/java/io/legado/app/base/adapter/animations/SlideInBottomAnimation.kt @@ -3,11 +3,10 @@ package io.legado.app.base.adapter.animations import android.animation.Animator import android.animation.ObjectAnimator import android.view.View -import io.legado.app.base.adapter.animations.BaseAnimation class SlideInBottomAnimation : BaseAnimation { override fun getAnimators(view: View): Array = - arrayOf(ObjectAnimator.ofFloat(view, "translationY", view.measuredHeight.toFloat(), 0f)) + arrayOf(ObjectAnimator.ofFloat(view, "translationY", view.measuredHeight.toFloat(), 0f)) } diff --git a/app/src/main/java/io/legado/app/base/adapter/animations/SlideInLeftAnimation.kt b/app/src/main/java/io/legado/app/base/adapter/animations/SlideInLeftAnimation.kt index daa6f17a1..8cfae170b 100644 --- a/app/src/main/java/io/legado/app/base/adapter/animations/SlideInLeftAnimation.kt +++ b/app/src/main/java/io/legado/app/base/adapter/animations/SlideInLeftAnimation.kt @@ -3,12 +3,11 @@ package io.legado.app.base.adapter.animations import android.animation.Animator import android.animation.ObjectAnimator import android.view.View -import io.legado.app.base.adapter.animations.BaseAnimation class SlideInLeftAnimation : BaseAnimation { override fun getAnimators(view: View): Array = - arrayOf(ObjectAnimator.ofFloat(view, "translationX", -view.rootView.width.toFloat(), 0f)) + arrayOf(ObjectAnimator.ofFloat(view, "translationX", -view.rootView.width.toFloat(), 0f)) } diff --git a/app/src/main/java/io/legado/app/base/adapter/animations/SlideInRightAnimation.kt b/app/src/main/java/io/legado/app/base/adapter/animations/SlideInRightAnimation.kt index 71c8feac7..e7f1c85e5 100644 --- a/app/src/main/java/io/legado/app/base/adapter/animations/SlideInRightAnimation.kt +++ b/app/src/main/java/io/legado/app/base/adapter/animations/SlideInRightAnimation.kt @@ -3,12 +3,11 @@ package io.legado.app.base.adapter.animations import android.animation.Animator import android.animation.ObjectAnimator import android.view.View -import io.legado.app.base.adapter.animations.BaseAnimation class SlideInRightAnimation : BaseAnimation { override fun getAnimators(view: View): Array = - arrayOf(ObjectAnimator.ofFloat(view, "translationX", view.rootView.width.toFloat(), 0f)) + arrayOf(ObjectAnimator.ofFloat(view, "translationX", view.rootView.width.toFloat(), 0f)) } diff --git a/app/src/main/java/io/legado/app/constant/AppUtils.kt b/app/src/main/java/io/legado/app/constant/AppUtils.kt index 836736ee5..4910553be 100644 --- a/app/src/main/java/io/legado/app/constant/AppUtils.kt +++ b/app/src/main/java/io/legado/app/constant/AppUtils.kt @@ -4,9 +4,9 @@ import com.google.gson.Gson import com.google.gson.GsonBuilder object AppUtils { - val GSON_CONVERTER: Gson = GsonBuilder() - .disableHtmlEscaping() - .setPrettyPrinting() - .setDateFormat("yyyy-MM-dd HH:mm:ssZ") - .create() + val GSON_CONVERTER: Gson = GsonBuilder() + .disableHtmlEscaping() + .setPrettyPrinting() + .setDateFormat("yyyy-MM-dd HH:mm:ssZ") + .create() } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/data/AppDatabase.kt b/app/src/main/java/io/legado/app/data/AppDatabase.kt index 81cd4db5d..60501adb2 100644 --- a/app/src/main/java/io/legado/app/data/AppDatabase.kt +++ b/app/src/main/java/io/legado/app/data/AppDatabase.kt @@ -7,15 +7,19 @@ import androidx.room.RoomDatabase import androidx.room.migration.Migration import androidx.sqlite.db.SupportSQLiteDatabase import io.legado.app.data.dao.BookDao -import io.legado.app.data.dao.ReplaceRuleDao import io.legado.app.data.dao.BookSourceDao +import io.legado.app.data.dao.ReplaceRuleDao import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.Chapter import io.legado.app.data.entities.ReplaceRule -@Database(entities = [Book::class, BookSource::class, Chapter::class, ReplaceRule::class], version = 1, exportSchema = true) +@Database( + entities = [Book::class, BookSource::class, Chapter::class, ReplaceRule::class], + version = 1, + exportSchema = true +) abstract class AppDatabase : RoomDatabase() { companion object { @@ -46,5 +50,5 @@ abstract class AppDatabase : RoomDatabase() { abstract fun bookDao(): BookDao abstract fun replaceRuleDao(): ReplaceRuleDao - abstract fun bookSourceDao() : BookSourceDao + abstract fun bookSourceDao(): BookSourceDao } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt b/app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt index 82fb01304..a60ed4dca 100644 --- a/app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt @@ -11,10 +11,10 @@ interface BookSourceDao { fun observeAll(): DataSource.Factory @Query("select * from book_sources where name like :searchKey or `group` like :searchKey or origin like :searchKey order by customOrder asc") - fun observeSearch(searchKey:String = ""): DataSource.Factory + fun observeSearch(searchKey: String = ""): DataSource.Factory @Query("select * from book_sources where origin = :key") - fun findByKey(key:String): BookSource? + fun findByKey(key: String): BookSource? @Query("select count(*) from book_sources") fun allCount(): Int diff --git a/app/src/main/java/io/legado/app/data/entities/Book.kt b/app/src/main/java/io/legado/app/data/entities/Book.kt index 78b3694e8..b1a18961f 100644 --- a/app/src/main/java/io/legado/app/data/entities/Book.kt +++ b/app/src/main/java/io/legado/app/data/entities/Book.kt @@ -1,42 +1,45 @@ package io.legado.app.data.entities import android.os.Parcelable -import androidx.room.* +import androidx.room.Entity +import androidx.room.Index +import androidx.room.PrimaryKey import io.legado.app.constant.AppConst.NOT_AVAILABLE import kotlinx.android.parcel.Parcelize @Parcelize @Entity(tableName = "books", indices = [(Index(value = ["descUrl"], unique = true))]) -data class Book(@PrimaryKey - var descUrl: String = "", // 详情页Url(本地书源存储完整文件路径) - var tocUrl: String = "", // 目录页Url (toc=table of Contents) - var sourceId: Int = -1, // 书源规则id(默认-1,表示本地书籍) - var name: String? = null, // 书籍名称(书源获取) - var customName: String? = null, // 书籍名称(用户修改) - var author: String? = null, // 作者名称(书源获取) - var customAuthor: String? = null, // 作者名称(用户修改) - var tag: String? = null, // 分类信息(书源获取) - var customTag: String? = null, // 分类信息(用户修改) - var coverUrl: String? = null, // 封面Url(书源获取) - var customCoverUrl: String? = null, // 封面Url(用户修改) - var description: String? = null, // 简介内容(书源获取) - var customDescription: String? = null, // 简介内容(用户修改) - var charset: String? = null, // 自定义字符集名称(仅适用于本地书籍) - var type: Int = 0, // 0: 文本读物, 1: 有声读物 - var group: Int = 0, // 自定义分组索引号 - var latestChapterTitle: String? = null, // 最新章节标题 - var latestChapterTime: Long = 0, // 最新章节标题更新时间 - var lastCheckTime: Long = 0, // 最近一次更新书籍信息的时间 - var lastCheckCount: Int = 0, // 最近一次发现新章节的数量 - var totalChapterNum: Int = 0, // 书籍目录总数 - var durChapterTitle: String? = null, // 当前章节名称 - var durChapterIndex: Int = 0, // 当前章节索引 - var durChapterPos: Int = 0, // 当前阅读的进度(首行字符的索引位置) - var durChapterTime: Long = 0, // 最近一次阅读书籍的时间(打开正文的时间) - var canUpdate: Boolean = true, // 刷新书架时更新书籍信息 - var order: Int = 0, // 手动排序 - var useReplaceRule: Boolean = true, // 正文使用净化替换规则 - var variable: String? = null // 自定义书籍变量信息(用于书源规则检索书籍信息) +data class Book( + @PrimaryKey + var descUrl: String = "", // 详情页Url(本地书源存储完整文件路径) + var tocUrl: String = "", // 目录页Url (toc=table of Contents) + var sourceId: Int = -1, // 书源规则id(默认-1,表示本地书籍) + var name: String? = null, // 书籍名称(书源获取) + var customName: String? = null, // 书籍名称(用户修改) + var author: String? = null, // 作者名称(书源获取) + var customAuthor: String? = null, // 作者名称(用户修改) + var tag: String? = null, // 分类信息(书源获取) + var customTag: String? = null, // 分类信息(用户修改) + var coverUrl: String? = null, // 封面Url(书源获取) + var customCoverUrl: String? = null, // 封面Url(用户修改) + var description: String? = null, // 简介内容(书源获取) + var customDescription: String? = null, // 简介内容(用户修改) + var charset: String? = null, // 自定义字符集名称(仅适用于本地书籍) + var type: Int = 0, // 0: 文本读物, 1: 有声读物 + var group: Int = 0, // 自定义分组索引号 + var latestChapterTitle: String? = null, // 最新章节标题 + var latestChapterTime: Long = 0, // 最新章节标题更新时间 + var lastCheckTime: Long = 0, // 最近一次更新书籍信息的时间 + var lastCheckCount: Int = 0, // 最近一次发现新章节的数量 + var totalChapterNum: Int = 0, // 书籍目录总数 + var durChapterTitle: String? = null, // 当前章节名称 + var durChapterIndex: Int = 0, // 当前章节索引 + var durChapterPos: Int = 0, // 当前阅读的进度(首行字符的索引位置) + var durChapterTime: Long = 0, // 最近一次阅读书籍的时间(打开正文的时间) + var canUpdate: Boolean = true, // 刷新书架时更新书籍信息 + var order: Int = 0, // 手动排序 + var useReplaceRule: Boolean = true, // 正文使用净化替换规则 + var variable: String? = null // 自定义书籍变量信息(用于书源规则检索书籍信息) ) : Parcelable { fun getUnreadChapterNum() = Math.max(totalChapterNum - durChapterIndex - 1, 0) diff --git a/app/src/main/java/io/legado/app/data/entities/BookSource.kt b/app/src/main/java/io/legado/app/data/entities/BookSource.kt index 40a975434..64d1ce1b2 100644 --- a/app/src/main/java/io/legado/app/data/entities/BookSource.kt +++ b/app/src/main/java/io/legado/app/data/entities/BookSource.kt @@ -1,7 +1,9 @@ package io.legado.app.data.entities import android.os.Parcelable -import androidx.room.* +import androidx.room.Entity +import androidx.room.Index +import androidx.room.PrimaryKey import io.legado.app.constant.AppUtils.GSON_CONVERTER import io.legado.app.data.entities.rule.* import kotlinx.android.parcel.IgnoredOnParcel @@ -12,7 +14,7 @@ import kotlinx.android.parcel.Parcelize tableName = "book_sources", indices = [(Index(value = ["origin"], unique = false))] ) -data class BookSource ( +data class BookSource( @PrimaryKey var origin: String = "", // 地址,包括 http/https var name: String = "", // 名称 diff --git a/app/src/main/java/io/legado/app/data/entities/Chapter.kt b/app/src/main/java/io/legado/app/data/entities/Chapter.kt index 3513143d3..288a1bd94 100644 --- a/app/src/main/java/io/legado/app/data/entities/Chapter.kt +++ b/app/src/main/java/io/legado/app/data/entities/Chapter.kt @@ -4,26 +4,29 @@ import android.os.Parcelable import androidx.room.Entity import androidx.room.ForeignKey import androidx.room.Index -import androidx.room.PrimaryKey import kotlinx.android.parcel.Parcelize @Parcelize -@Entity(tableName = "chapters", +@Entity( + tableName = "chapters", primaryKeys = ["url", "bookUrl"], indices = [(Index(value = ["url"], unique = true)), (Index(value = ["bookUrl", "index"], unique = true))], - foreignKeys = [(ForeignKey(entity = Book::class, + foreignKeys = [(ForeignKey( + entity = Book::class, parentColumns = ["descUrl"], childColumns = ["bookUrl"], - onDelete = ForeignKey.CASCADE))]) // 删除书籍时自动删除章节 + onDelete = ForeignKey.CASCADE + ))] +) // 删除书籍时自动删除章节 data class Chapter( - var url: String = "", // 章节地址 - var title: String = "", // 章节标题 - var bookUrl: String = "", // 书籍地址 - var index: Int = 0, // 章节序号 - var resourceUrl: String? = null, // 音频真实URL - var tag: String? = null, // - var start: Long? = null, // 章节起始位置 - var end: Long? = null // 章节终止位置 + var url: String = "", // 章节地址 + var title: String = "", // 章节标题 + var bookUrl: String = "", // 书籍地址 + var index: Int = 0, // 章节序号 + var resourceUrl: String? = null, // 音频真实URL + var tag: String? = null, // + var start: Long? = null, // 章节起始位置 + var end: Long? = null // 章节终止位置 ) : Parcelable diff --git a/app/src/main/java/io/legado/app/data/entities/ExploreSearchUrl.kt b/app/src/main/java/io/legado/app/data/entities/ExploreSearchUrl.kt index 97a4d2bfb..4b8c8cde2 100644 --- a/app/src/main/java/io/legado/app/data/entities/ExploreSearchUrl.kt +++ b/app/src/main/java/io/legado/app/data/entities/ExploreSearchUrl.kt @@ -8,13 +8,17 @@ import androidx.room.PrimaryKey import kotlinx.android.parcel.Parcelize @Parcelize -@Entity(tableName = "explore_search_urls", +@Entity( + tableName = "explore_search_urls", indices = [(Index(value = ["sourceId", "url"], unique = true))], - foreignKeys = [(ForeignKey(entity = BookSource::class, + foreignKeys = [(ForeignKey( + entity = BookSource::class, parentColumns = ["sourceId"], childColumns = ["sourceId"], - onDelete = ForeignKey.CASCADE))]) // 删除书源时自动删除章节 -data class ExploreSearchUrl ( + onDelete = ForeignKey.CASCADE + ))] +) // 删除书源时自动删除章节 +data class ExploreSearchUrl( @PrimaryKey(autoGenerate = true) var esId: Int = 0, // 编号 var sourceId: Int = 0, // 书源Id @@ -25,5 +29,5 @@ data class ExploreSearchUrl ( var defOrder: Int = 0, // 默认排序,是在编辑书源的时候的顺序 var usage: Int = 0, // 使用次数,用于按使用次数排序 var lastUseTime: Long = 0L // 最后一次使用的时间 - ) : Parcelable +) : Parcelable diff --git a/app/src/main/java/io/legado/app/data/entities/ReplaceRule.kt b/app/src/main/java/io/legado/app/data/entities/ReplaceRule.kt index 8b5a0fda6..e43699c36 100644 --- a/app/src/main/java/io/legado/app/data/entities/ReplaceRule.kt +++ b/app/src/main/java/io/legado/app/data/entities/ReplaceRule.kt @@ -8,19 +8,21 @@ import androidx.room.PrimaryKey import kotlinx.android.parcel.Parcelize @Parcelize -@Entity(tableName = "replace_rules", - indices = [(Index(value = ["id"]))]) +@Entity( + tableName = "replace_rules", + indices = [(Index(value = ["id"]))] +) data class ReplaceRule( - @PrimaryKey(autoGenerate = true) - var id: Int = 0, - var name: String? = null, - var pattern: String? = null, - var replacement: String? = null, - var scope: String? = null, - var isEnabled: Boolean = true, - var isRegex: Boolean = true, - @ColumnInfo(name = "sortOrder") - var order: Int = 0 + @PrimaryKey(autoGenerate = true) + var id: Int = 0, + var name: String? = null, + var pattern: String? = null, + var replacement: String? = null, + var scope: String? = null, + var isEnabled: Boolean = true, + var isRegex: Boolean = true, + @ColumnInfo(name = "sortOrder") + var order: Int = 0 ) : Parcelable diff --git a/app/src/main/java/io/legado/app/data/entities/SearchKeyword.kt b/app/src/main/java/io/legado/app/data/entities/SearchKeyword.kt index e8dce4fd9..1c1c5015b 100644 --- a/app/src/main/java/io/legado/app/data/entities/SearchKeyword.kt +++ b/app/src/main/java/io/legado/app/data/entities/SearchKeyword.kt @@ -9,9 +9,9 @@ import kotlinx.android.parcel.Parcelize @Parcelize @Entity(tableName = "search_keywords", indices = [(Index(value = ["word"], unique = true))]) -data class SearchKeyword ( +data class SearchKeyword( @PrimaryKey var word: String = "", // 搜索关键词 var usage: Int = 1, // 使用次数 var lastUseTime: Long = 0 // 最后一次使用时间 -): Parcelable +) : Parcelable diff --git a/app/src/main/java/io/legado/app/data/entities/rule/BookInfoRule.kt b/app/src/main/java/io/legado/app/data/entities/rule/BookInfoRule.kt index 3dea36204..230da5358 100644 --- a/app/src/main/java/io/legado/app/data/entities/rule/BookInfoRule.kt +++ b/app/src/main/java/io/legado/app/data/entities/rule/BookInfoRule.kt @@ -1,6 +1,6 @@ package io.legado.app.data.entities.rule -data class BookInfoRule ( +data class BookInfoRule( var name: Rule, var author: Rule, var desc: Rule, diff --git a/app/src/main/java/io/legado/app/data/entities/rule/ChapterRule.kt b/app/src/main/java/io/legado/app/data/entities/rule/ChapterRule.kt index 830d1295a..e3799d048 100644 --- a/app/src/main/java/io/legado/app/data/entities/rule/ChapterRule.kt +++ b/app/src/main/java/io/legado/app/data/entities/rule/ChapterRule.kt @@ -1,6 +1,6 @@ package io.legado.app.data.entities.rule -data class ChapterRule ( +data class ChapterRule( var chapterList: Rule, var isReversed: Boolean = false, var title: Rule, diff --git a/app/src/main/java/io/legado/app/data/entities/rule/ContentRule.kt b/app/src/main/java/io/legado/app/data/entities/rule/ContentRule.kt index 9b809c9a2..a301c114e 100644 --- a/app/src/main/java/io/legado/app/data/entities/rule/ContentRule.kt +++ b/app/src/main/java/io/legado/app/data/entities/rule/ContentRule.kt @@ -1,6 +1,6 @@ package io.legado.app.data.entities.rule -data class ContentRule ( +data class ContentRule( var fulltext: Rule, var resourceUrl: Rule, var nextUrl: Rule diff --git a/app/src/main/java/io/legado/app/data/entities/rule/ExploreRule.kt b/app/src/main/java/io/legado/app/data/entities/rule/ExploreRule.kt index dd444801f..f1fe3e425 100644 --- a/app/src/main/java/io/legado/app/data/entities/rule/ExploreRule.kt +++ b/app/src/main/java/io/legado/app/data/entities/rule/ExploreRule.kt @@ -1,6 +1,6 @@ package io.legado.app.data.entities.rule -data class ExploreRule ( +data class ExploreRule( var bookList: Rule, var name: Rule, var author: Rule, diff --git a/app/src/main/java/io/legado/app/data/entities/rule/PutRule.kt b/app/src/main/java/io/legado/app/data/entities/rule/PutRule.kt index f5e1824ba..2b315eccb 100644 --- a/app/src/main/java/io/legado/app/data/entities/rule/PutRule.kt +++ b/app/src/main/java/io/legado/app/data/entities/rule/PutRule.kt @@ -1,6 +1,6 @@ package io.legado.app.data.entities.rule -data class PutRule ( +data class PutRule( var selector: Rule, var key: String ) \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/data/entities/rule/Rule.kt b/app/src/main/java/io/legado/app/data/entities/rule/Rule.kt index 4caf219f0..8d43370d1 100644 --- a/app/src/main/java/io/legado/app/data/entities/rule/Rule.kt +++ b/app/src/main/java/io/legado/app/data/entities/rule/Rule.kt @@ -1,9 +1,9 @@ package io.legado.app.data.entities.rule -import io.legado.app.utils.splitNotBlank import io.legado.app.utils.safeTrim +import io.legado.app.utils.splitNotBlank -data class Rule ( +data class Rule( var selectors: List, var regex: String?, var replacement: String?, diff --git a/app/src/main/java/io/legado/app/data/entities/rule/SearchRule.kt b/app/src/main/java/io/legado/app/data/entities/rule/SearchRule.kt index fbcb77da9..def4cfee0 100644 --- a/app/src/main/java/io/legado/app/data/entities/rule/SearchRule.kt +++ b/app/src/main/java/io/legado/app/data/entities/rule/SearchRule.kt @@ -1,6 +1,6 @@ package io.legado.app.data.entities.rule -data class SearchRule ( +data class SearchRule( var bookList: Rule, var name: Rule, var author: Rule, diff --git a/app/src/main/java/io/legado/app/help/permission/RequestSource.kt b/app/src/main/java/io/legado/app/help/permission/RequestSource.kt index 73c89df43..a822ff5ad 100644 --- a/app/src/main/java/io/legado/app/help/permission/RequestSource.kt +++ b/app/src/main/java/io/legado/app/help/permission/RequestSource.kt @@ -2,7 +2,6 @@ package io.legado.app.help.permission import android.content.Context import android.content.Intent -import androidx.fragment.app.FragmentManager interface RequestSource { diff --git a/app/src/main/java/io/legado/app/lib/theme/view/ATESwitch.kt b/app/src/main/java/io/legado/app/lib/theme/view/ATESwitch.kt index a27798055..8009d817a 100644 --- a/app/src/main/java/io/legado/app/lib/theme/view/ATESwitch.kt +++ b/app/src/main/java/io/legado/app/lib/theme/view/ATESwitch.kt @@ -3,7 +3,6 @@ package io.legado.app.lib.theme.view import android.content.Context import android.util.AttributeSet import android.view.View -import android.widget.Switch import androidx.appcompat.widget.SwitchCompat import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ThemeStore diff --git a/app/src/main/java/io/legado/app/lib/webdav/WebDav.kt b/app/src/main/java/io/legado/app/lib/webdav/WebDav.kt index d06630002..452f07c15 100644 --- a/app/src/main/java/io/legado/app/lib/webdav/WebDav.kt +++ b/app/src/main/java/io/legado/app/lib/webdav/WebDav.kt @@ -3,29 +3,16 @@ package io.legado.app.lib.webdav import io.legado.app.lib.webdav.http.Handler import io.legado.app.lib.webdav.http.HttpAuth import io.legado.app.lib.webdav.http.OkHttp - +import okhttp3.* import org.jsoup.Jsoup -import org.jsoup.nodes.Document -import org.jsoup.nodes.Element -import org.jsoup.select.Elements - import java.io.File -import java.io.FileOutputStream import java.io.IOException import java.io.InputStream import java.io.UnsupportedEncodingException -import java.lang.reflect.Field import java.net.MalformedURLException import java.net.URL import java.net.URLEncoder -import java.util.ArrayList - -import okhttp3.Credentials -import okhttp3.MediaType -import okhttp3.OkHttpClient -import okhttp3.Request -import okhttp3.RequestBody -import okhttp3.Response +import java.util.* class WebDav @Throws(MalformedURLException::class) constructor(url: String) { @@ -50,9 +37,9 @@ constructor(url: String) { get() = url.toString() private val inputStream: InputStream? - get() = getUrl()?.let {url -> + get() = getUrl()?.let { url -> val request = Request.Builder().url(url) - HttpAuth.auth?.let {request.header("Authorization", Credentials.basic(it.user, it.pass)) } + HttpAuth.auth?.let { request.header("Authorization", Credentials.basic(it.user, it.pass)) } try { return okHttpClient.newCall(request.build()).execute().body()?.byteStream() @@ -113,9 +100,9 @@ constructor(url: String) { @Throws(IOException::class) @JvmOverloads fun listFiles(propsList: ArrayList = ArrayList()): List { - propFindResponse(propsList)?.let {response-> + propFindResponse(propsList)?.let { response -> if (response.isSuccessful) { - response.body()?.let {body-> + response.body()?.let { body -> return parseDir(body.string()) } } @@ -136,14 +123,14 @@ constructor(url: String) { } else { String.format(DIR, requestProps.toString() + "\n") } - getUrl()?.let {url-> + getUrl()?.let { url -> val request = Request.Builder() .url(url) // 添加RequestBody对象,可以只返回的属性。如果设为null,则会返回全部属性 // 注意:尽量手动指定需要返回的属性。若返回全部属性,可能后由于Prop.java里没有该属性名,而崩溃。 .method("PROPFIND", RequestBody.create(MediaType.parse("text/plain"), requestPropsStr)) - HttpAuth.auth?.let {request.header("Authorization", Credentials.basic(it.user, it.pass)) } + HttpAuth.auth?.let { request.header("Authorization", Credentials.basic(it.user, it.pass)) } request.header("Depth", if (depth < 0) "infinity" else Integer.toString(depth)) @@ -156,7 +143,7 @@ constructor(url: String) { val list = ArrayList() val document = Jsoup.parse(s) val elements = document.getElementsByTag("d:response") - getUrl()?.let { url-> + getUrl()?.let { url -> val baseUrl = if (url.endsWith("/")) url else "$url/" for (element in elements) { val href = element.getElementsByTag("d:href")[0].text() @@ -184,7 +171,7 @@ constructor(url: String) { */ @Throws(IOException::class) fun makeAsDir(): Boolean { - getUrl()?.let { url-> + getUrl()?.let { url -> val request = Request.Builder() .url(url) .method("MKCOL", null) diff --git a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt index 30b29b7dc..8f9ded816 100644 --- a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt @@ -3,7 +3,6 @@ package io.legado.app.ui.config import android.content.SharedPreferences import android.os.Bundle import android.os.Handler -import android.os.Looper import androidx.appcompat.app.AlertDialog import androidx.preference.PreferenceFragmentCompat import com.jeremyliao.liveeventbus.LiveEventBus @@ -87,7 +86,7 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar if (App.INSTANCE.getPrefBoolean("isNightTheme", false) == isNightTheme) { App.INSTANCE.upThemeStore() LiveEventBus.get().with(Bus.recreate).post("") - Handler().postDelayed({activity?.recreate()}, 100) + Handler().postDelayed({ activity?.recreate() }, 100) } } diff --git a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt index b7ebfc759..973380645 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt @@ -1,7 +1,6 @@ package io.legado.app.ui.main import android.os.Bundle -import android.view.Menu import android.view.MenuItem import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager diff --git a/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt b/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt index 671f1c660..82a9146c5 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt @@ -6,5 +6,4 @@ import androidx.lifecycle.AndroidViewModel class MainViewModel(application: Application) : AndroidViewModel(application) { - } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/main/booksource/BookSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/main/booksource/BookSourceAdapter.kt index 92581f4e1..7e0a40998 100644 --- a/app/src/main/java/io/legado/app/ui/main/booksource/BookSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/main/booksource/BookSourceAdapter.kt @@ -4,20 +4,16 @@ import android.view.LayoutInflater import android.view.Menu import android.view.View import android.view.ViewGroup -import android.widget.CompoundButton import android.widget.PopupMenu import androidx.paging.PagedListAdapter import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView import io.legado.app.R import io.legado.app.data.entities.BookSource -import io.legado.app.help.ItemTouchCallback import io.legado.app.help.ItemTouchCallback.OnItemTouchCallbackListener import io.legado.app.lib.theme.ThemeStore import kotlinx.android.synthetic.main.item_book_source.view.* import org.jetbrains.anko.sdk27.listeners.onClick -import java.util.* -import kotlin.collections.HashSet class BookSourceAdapter : PagedListAdapter(DIFF_CALLBACK) { @@ -48,8 +44,8 @@ class BookSourceAdapter : PagedListAdapter - targetSource?.let { b-> + srcSource?.let { a -> + targetSource?.let { b -> a.customOrder = targetPosition b.customOrder = srcPosition callBack?.update(a, b) @@ -86,25 +82,31 @@ class BookSourceAdapter : PagedListAdapter{ + R.id.menu_edit -> { callBack?.edit(bookSource) - true} - R.id.menu_del ->{ + true + } + R.id.menu_del -> { callBack?.del(bookSource) - true} - R.id.menu_top ->{ true} - else -> {false} + true + } + R.id.menu_top -> { + true + } + else -> { + false + } } } popupMenu.show() diff --git a/app/src/main/java/io/legado/app/ui/main/booksource/BookSourceFragment.kt b/app/src/main/java/io/legado/app/ui/main/booksource/BookSourceFragment.kt index 88ae2af00..de7e9e7e6 100644 --- a/app/src/main/java/io/legado/app/ui/main/booksource/BookSourceFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/booksource/BookSourceFragment.kt @@ -24,7 +24,8 @@ import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import org.jetbrains.anko.startActivity -class BookSourceFragment : BaseFragment(R.layout.fragment_book_source), BookSourceAdapter.CallBack, SearchView.OnQueryTextListener { +class BookSourceFragment : BaseFragment(R.layout.fragment_book_source), BookSourceAdapter.CallBack, + SearchView.OnQueryTextListener { private lateinit var adapter: BookSourceAdapter private var bookSourceLiveDate: LiveData>? = null @@ -68,9 +69,12 @@ class BookSourceFragment : BaseFragment(R.layout.fragment_book_source), BookSour search_view.setOnQueryTextListener(this) } - private fun initDataObservers(searchKey:String = "") { + private fun initDataObservers(searchKey: String = "") { bookSourceLiveDate?.removeObservers(viewLifecycleOwner) - val dataFactory = if (searchKey.isEmpty()) App.db.bookSourceDao().observeAll() else App.db.bookSourceDao().observeSearch(searchKey) + val dataFactory = + if (searchKey.isEmpty()) App.db.bookSourceDao().observeAll() else App.db.bookSourceDao().observeSearch( + searchKey + ) bookSourceLiveDate = LivePagedListBuilder(dataFactory, 30).build() bookSourceLiveDate?.observe(viewLifecycleOwner, Observer { adapter.submitList(it) }) } diff --git a/app/src/main/java/io/legado/app/ui/main/findbook/FindBookFragment.kt b/app/src/main/java/io/legado/app/ui/main/findbook/FindBookFragment.kt index 9a6c1e1ea..7a1804151 100644 --- a/app/src/main/java/io/legado/app/ui/main/findbook/FindBookFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/findbook/FindBookFragment.kt @@ -2,7 +2,6 @@ package io.legado.app.ui.main.findbook import android.os.Bundle import android.view.Menu -import android.view.MenuItem import android.view.View import io.legado.app.R import io.legado.app.base.BaseFragment diff --git a/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt b/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt index 22d27b639..c78d2cf73 100644 --- a/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt +++ b/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt @@ -40,19 +40,21 @@ class ReplaceRuleActivity : BaseActivity() { private fun initRecyclerView() { rv_replace_rule.layoutManager = LinearLayoutManager(this) adapter = ReplaceRuleAdapter(this) - adapter.onClickListener = object: ReplaceRuleAdapter.OnClickListener { + adapter.onClickListener = object : ReplaceRuleAdapter.OnClickListener { override fun update(rule: ReplaceRule) { doAsync { App.db.replaceRuleDao().update(rule) updateEnableAll() } } + override fun delete(rule: ReplaceRule) { doAsync { App.db.replaceRuleDao().delete(rule) updateEnableAll() } } + override fun edit(rule: ReplaceRule) { doAsync { App.db.replaceRuleDao().enableAll(!allEnabled) @@ -67,7 +69,8 @@ class ReplaceRuleActivity : BaseActivity() { DividerItemDecoration(this, DividerItemDecoration.VERTICAL).apply { ContextCompat.getDrawable(baseContext, R.drawable.ic_divider)?.let { Log.e(APP_TAG, it.toString()) - this.setDrawable(it) } + this.setDrawable(it) + } }) } diff --git a/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleAdapter.kt b/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleAdapter.kt index d9befdd97..80cc79cce 100644 --- a/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleAdapter.kt @@ -1,7 +1,6 @@ package io.legado.app.ui.replacerule import android.content.Context -import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -10,7 +9,6 @@ import androidx.paging.PagedListAdapter import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView import io.legado.app.R -import io.legado.app.constant.AppConst.APP_TAG import io.legado.app.data.entities.ReplaceRule import kotlinx.android.synthetic.main.item_relace_rule.view.* import org.jetbrains.anko.sdk27.listeners.onClick @@ -52,11 +50,11 @@ class ReplaceRuleAdapter(context: Context) : class MyViewHolder(view: View) : RecyclerView.ViewHolder(view) { fun bind(rule: ReplaceRule, listener: OnClickListener?) = with(itemView) { - tv_name.text = rule.name - swt_enabled.isChecked = rule.isEnabled + tv_name.text = rule.name + swt_enabled.isChecked = rule.isEnabled // divider.isGone = hideDivider - iv_delete.isGone = true - iv_edit.isGone = true + iv_delete.isGone = true + iv_edit.isGone = true // iv_delete.onClick { listener?.delete(rule) } // iv_edit.onClick { listener?.edit(rule) } swt_enabled.onClick { diff --git a/app/src/main/java/io/legado/app/ui/search/SearchActivity.kt b/app/src/main/java/io/legado/app/ui/search/SearchActivity.kt index d11694683..6a6a02fb0 100644 --- a/app/src/main/java/io/legado/app/ui/search/SearchActivity.kt +++ b/app/src/main/java/io/legado/app/ui/search/SearchActivity.kt @@ -4,7 +4,6 @@ import android.os.Bundle import io.legado.app.R import io.legado.app.base.BaseActivity import io.legado.app.utils.getViewModel -import org.jetbrains.anko.startActivity class SearchActivity : BaseActivity() { diff --git a/app/src/main/java/io/legado/app/ui/sourceedit/SourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/sourceedit/SourceEditActivity.kt index 178f0fc68..68a0d71df 100644 --- a/app/src/main/java/io/legado/app/ui/sourceedit/SourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/sourceedit/SourceEditActivity.kt @@ -5,14 +5,14 @@ import android.view.Menu import android.view.MenuItem import androidx.lifecycle.Observer import androidx.recyclerview.widget.LinearLayoutManager -import io.legado.app.App import io.legado.app.R import io.legado.app.base.BaseActivity import io.legado.app.data.entities.BookSource import io.legado.app.utils.getViewModel import kotlinx.android.synthetic.main.activity_source_edit.* -import kotlinx.coroutines.* -import org.jetbrains.anko.UI +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch import org.jetbrains.anko.toast class SourceEditActivity : BaseActivity() { diff --git a/app/src/main/java/io/legado/app/ui/sourceedit/SourceEditAdapter.kt b/app/src/main/java/io/legado/app/ui/sourceedit/SourceEditAdapter.kt index be301e4c1..8b54223fe 100644 --- a/app/src/main/java/io/legado/app/ui/sourceedit/SourceEditAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/sourceedit/SourceEditAdapter.kt @@ -11,7 +11,7 @@ import kotlinx.android.synthetic.main.item_source_edit.view.* class SourceEditAdapter : RecyclerView.Adapter() { - var sourceEditEntities:ArrayList = ArrayList() + var sourceEditEntities: ArrayList = ArrayList() override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder { return MyViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.item_source_edit, parent, false)) @@ -60,7 +60,7 @@ class SourceEditAdapter : RecyclerView.Adapter() } override fun afterTextChanged(s: Editable?) { - sourceEditEntity.value=(s?.toString()) + sourceEditEntity.value = (s?.toString()) } } editText.addTextChangedListener(textWatcher) diff --git a/app/src/main/java/io/legado/app/ui/sourceedit/SourceEditViewModel.kt b/app/src/main/java/io/legado/app/ui/sourceedit/SourceEditViewModel.kt index ed90408f9..b1af68e88 100644 --- a/app/src/main/java/io/legado/app/ui/sourceedit/SourceEditViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/sourceedit/SourceEditViewModel.kt @@ -4,14 +4,13 @@ import android.app.Application import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.MutableLiveData import io.legado.app.App -import io.legado.app.data.dao.BookSourceDao import io.legado.app.data.entities.BookSource import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch class SourceEditViewModel(application: Application) : AndroidViewModel(application) { - val sourceLiveData:MutableLiveData = MutableLiveData() + val sourceLiveData: MutableLiveData = MutableLiveData() fun setBookSource(key: String) { GlobalScope.launch { diff --git a/app/src/main/java/io/legado/app/ui/widget/RotateLoading.kt b/app/src/main/java/io/legado/app/ui/widget/RotateLoading.kt index c17bc7b5d..441efc6e0 100644 --- a/app/src/main/java/io/legado/app/ui/widget/RotateLoading.kt +++ b/app/src/main/java/io/legado/app/ui/widget/RotateLoading.kt @@ -89,7 +89,12 @@ class RotateLoading : View { arc = 10f loadingRectF = - RectF((2 * thisWidth).toFloat(), (2 * thisWidth).toFloat(), (w - 2 * thisWidth).toFloat(), (h - 2 * thisWidth).toFloat()) + RectF( + (2 * thisWidth).toFloat(), + (2 * thisWidth).toFloat(), + (w - 2 * thisWidth).toFloat(), + (h - 2 * thisWidth).toFloat() + ) shadowRectF = RectF( (2 * thisWidth + shadowPosition).toFloat(), (2 * thisWidth + shadowPosition).toFloat(), diff --git a/app/src/main/java/io/legado/app/ui/widget/dynamiclayout/ViewSwitcher.kt b/app/src/main/java/io/legado/app/ui/widget/dynamiclayout/ViewSwitcher.kt index b985d79f8..dbcc0f132 100644 --- a/app/src/main/java/io/legado/app/ui/widget/dynamiclayout/ViewSwitcher.kt +++ b/app/src/main/java/io/legado/app/ui/widget/dynamiclayout/ViewSwitcher.kt @@ -5,12 +5,12 @@ import androidx.annotation.StringRes interface ViewSwitcher { - companion object{ - const val SHOW_CONTENT_VIEW = 0 - const val SHOW_ERROR_VIEW = 1 - const val SHOW_EMPTY_VIEW = 2 - const val SHOW_PROGRESS_VIEW = 3 - } + companion object { + const val SHOW_CONTENT_VIEW = 0 + const val SHOW_ERROR_VIEW = 1 + const val SHOW_EMPTY_VIEW = 2 + const val SHOW_PROGRESS_VIEW = 3 + } @Retention(AnnotationRetention.SOURCE) @IntDef(SHOW_CONTENT_VIEW, SHOW_ERROR_VIEW, SHOW_EMPTY_VIEW, SHOW_PROGRESS_VIEW) diff --git a/app/src/main/java/io/legado/app/utils/AnkoExtensions.kt b/app/src/main/java/io/legado/app/utils/AnkoExtensions.kt index 591bd4ade..44bdf4f15 100644 --- a/app/src/main/java/io/legado/app/utils/AnkoExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/AnkoExtensions.kt @@ -1,10 +1,8 @@ package io.legado.app.utils -import android.app.Activity import android.content.res.ColorStateList import android.graphics.drawable.Drawable import android.view.View -import android.view.WindowManager import androidx.annotation.ColorRes import androidx.annotation.DrawableRes import androidx.annotation.StringRes diff --git a/app/src/main/java/io/legado/app/utils/MenuExtensions.kt b/app/src/main/java/io/legado/app/utils/MenuExtensions.kt index 787f083dd..f573804c4 100644 --- a/app/src/main/java/io/legado/app/utils/MenuExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/MenuExtensions.kt @@ -6,7 +6,9 @@ import androidx.appcompat.view.menu.MenuBuilder import androidx.appcompat.view.menu.MenuItemImpl import androidx.core.view.forEach import io.legado.app.R -import io.legado.app.lib.theme.* +import io.legado.app.lib.theme.DrawableUtils +import io.legado.app.lib.theme.getPrimaryTextColor +import io.legado.app.lib.theme.isDarkTheme fun Menu.setIconColor(context: Context): Menu = this.let { menu -> if (menu is MenuBuilder) { diff --git a/app/src/main/java/io/legado/app/utils/StringExtensions.kt b/app/src/main/java/io/legado/app/utils/StringExtensions.kt index 477ff0d19..92f2801de 100644 --- a/app/src/main/java/io/legado/app/utils/StringExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/StringExtensions.kt @@ -1,4 +1,5 @@ package io.legado.app.utils + // import org.apache.commons.text.StringEscapeUtils fun String?.safeTrim() = if (this.isNullOrBlank()) null else this.trim() @@ -7,6 +8,6 @@ fun String.isAbsUrl() = this.startsWith("http://", true) || this.startsWith("https://", true) fun String.splitNotBlank(delim: String) = if (!this.contains(delim)) sequenceOf(this) else - this.split(delim).asSequence().map { it.trim() }.filterNot { it.isBlank() } + this.split(delim).asSequence().map { it.trim() }.filterNot { it.isBlank() } // fun String.unescapeJson() = StringEscapeUtils.unescapeJson(this) \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/utils/ViewModelKt.kt b/app/src/main/java/io/legado/app/utils/ViewModelKt.kt index 2d66826c1..c2ef64e53 100644 --- a/app/src/main/java/io/legado/app/utils/ViewModelKt.kt +++ b/app/src/main/java/io/legado/app/utils/ViewModelKt.kt @@ -9,4 +9,5 @@ fun AppCompatActivity.getViewModel(clazz: Class) = ViewModelP fun Fragment.getViewModel(clazz: Class) = ViewModelProviders.of(this).get(clazz) -fun Fragment.getViewModelOfActivity(clazz: Class) = ViewModelProviders.of(requireActivity()).get(clazz) \ No newline at end of file +fun Fragment.getViewModelOfActivity(clazz: Class) = + ViewModelProviders.of(requireActivity()).get(clazz) \ No newline at end of file diff --git a/app/src/main/res/layout/item_bookshelf_list.xml b/app/src/main/res/layout/item_bookshelf_list.xml index 03845fa18..71a7d9c3e 100644 --- a/app/src/main/res/layout/item_bookshelf_list.xml +++ b/app/src/main/res/layout/item_bookshelf_list.xml @@ -1,175 +1,175 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/cv_content" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:clickable="true" + android:focusable="true" + android:foreground="?android:attr/selectableItemBackground" + tools:ignore="UnusedAttribute"> + android:id="@+id/iv_cover" + android:layout_width="60dp" + android:layout_height="80dp" + android:layout_margin="8dp" + android:contentDescription="@string/img_cover" + android:scaleType="centerCrop" + android:src="@drawable/img_cover_default" + android:transitionName="img_cover" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintTop_toTopOf="parent" + tools:ignore="UnusedAttribute"/> - - + app:layout_constraintRight_toRightOf="parent" + app:layout_constraintTop_toTopOf="@id/tv_name"> + + + android:id="@+id/rl_loading" + android:layout_width="26dp" + android:layout_height="26dp" + android:layout_gravity="right" + android:visibility="invisible" + app:loading_color="@color/colorAccent" + app:loading_width="2dp" + tools:ignore="RtlHardcoded"/> + android:id="@+id/tv_name" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginLeft="8dp" + android:layout_marginTop="8dp" + android:includeFontPadding="false" + android:paddingLeft="4dp" + android:singleLine="true" + android:text="@string/book_name" + android:textColor="@color/tv_text_default" + android:textSize="16sp" + app:layout_constraintBottom_toTopOf="@+id/tv_author" + app:layout_constraintLeft_toRightOf="@+id/iv_cover" + app:layout_constraintRight_toLeftOf="@id/fl_has_new" + app:layout_constraintTop_toTopOf="parent" + tools:ignore="RtlHardcoded,RtlSymmetry"/> + android:id="@+id/iv_author" + android:layout_width="@dimen/desc_icon_size" + android:layout_height="@dimen/desc_icon_size" + android:layout_marginLeft="8dp" + android:contentDescription="@string/author" + android:paddingStart="2dp" + android:paddingEnd="2dp" + android:src="@drawable/ic_author" + app:layout_constraintBottom_toBottomOf="@+id/tv_author" + app:layout_constraintLeft_toRightOf="@+id/iv_cover" + app:layout_constraintTop_toTopOf="@+id/tv_author" + app:tint="@color/tv_text_secondary" + tools:ignore="RtlHardcoded,RtlSymmetry"/> + android:id="@+id/tv_author" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:includeFontPadding="false" + android:maxLines="1" + android:paddingEnd="6dp" + android:text="@string/author" + android:textColor="@color/tv_text_secondary" + android:textSize="13sp" + app:layout_constraintBottom_toTopOf="@+id/tv_read" + app:layout_constraintLeft_toRightOf="@+id/iv_author" + app:layout_constraintRight_toLeftOf="@id/fl_has_new" + app:layout_constraintTop_toBottomOf="@+id/tv_name" + tools:ignore="RtlSymmetry"/> + android:id="@+id/iv_read" + android:layout_width="@dimen/desc_icon_size" + android:layout_height="@dimen/desc_icon_size" + android:layout_marginLeft="8dp" + android:contentDescription="@string/read_dur_progress" + android:paddingStart="2dp" + android:paddingEnd="2dp" + android:src="@drawable/ic_history" + app:layout_constraintBottom_toBottomOf="@+id/tv_read" + app:layout_constraintLeft_toRightOf="@+id/iv_cover" + app:layout_constraintTop_toTopOf="@+id/tv_read" + app:tint="@color/tv_text_secondary" + tools:ignore="RtlHardcoded,RtlSymmetry"/> + android:id="@+id/tv_read" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:includeFontPadding="false" + android:singleLine="true" + android:text="@string/read_dur_progress" + android:textColor="@color/tv_text_secondary" + android:textSize="13sp" + app:layout_constraintBottom_toTopOf="@id/tv_last" + app:layout_constraintLeft_toRightOf="@+id/iv_read" + app:layout_constraintRight_toLeftOf="@id/fl_has_new" + app:layout_constraintTop_toBottomOf="@+id/tv_author"/> + android:id="@+id/iv_last" + android:layout_width="@dimen/desc_icon_size" + android:layout_height="@dimen/desc_icon_size" + android:layout_marginLeft="8dp" + android:contentDescription="@string/book_search_last" + android:paddingStart="2dp" + android:paddingEnd="2dp" + android:src="@drawable/ic_book_last" + app:layout_constraintBottom_toBottomOf="@+id/tv_last" + app:layout_constraintLeft_toRightOf="@+id/iv_cover" + app:layout_constraintTop_toTopOf="@+id/tv_last" + app:tint="@color/tv_text_secondary" + tools:ignore="RtlHardcoded,RtlSymmetry"/> + android:id="@+id/tv_last" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginBottom="8dp" + android:singleLine="true" + android:text="@string/book_search_last" + android:textColor="@color/tv_text_secondary" + android:textSize="13sp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintLeft_toRightOf="@+id/iv_last" + app:layout_constraintRight_toLeftOf="@id/fl_has_new" + app:layout_constraintTop_toBottomOf="@+id/tv_read"/> + android:id="@+id/vw_select" + android:layout_width="match_parent" + android:layout_height="0dp" + android:visibility="gone" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent"/> + android:layout_width="match_parent" + android:layout_height="0.5dp" + android:background="@color/btn_bg_press" + app:layout_constraintBottom_toBottomOf="parent"/> \ No newline at end of file diff --git a/app/src/main/res/layout/item_relace_rule.xml b/app/src/main/res/layout/item_relace_rule.xml index 34e28b5c9..af08d245e 100644 --- a/app/src/main/res/layout/item_relace_rule.xml +++ b/app/src/main/res/layout/item_relace_rule.xml @@ -2,7 +2,6 @@ @@ -46,7 +45,7 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toStartOf="@+id/tv_name" app:layout_constraintTop_toTopOf="parent" - app:layout_constraintBottom_toBottomOf="parent" /> + app:layout_constraintBottom_toBottomOf="parent"/> + android:id="@+id/textInputLayout" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + android:id="@+id/editText" + android:layout_width="match_parent" + android:layout_height="wrap_content"/> \ No newline at end of file diff --git a/app/src/main/res/layout/view_dynamic.xml b/app/src/main/res/layout/view_dynamic.xml index e94e2eaca..0531c97d3 100644 --- a/app/src/main/res/layout/view_dynamic.xml +++ b/app/src/main/res/layout/view_dynamic.xml @@ -1,20 +1,20 @@ + android:layout_width="match_parent" + android:layout_height="match_parent"> + android:id="@+id/errorViewStub" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:layout="@layout/view_error"/> + android:id="@+id/progressViewStub" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:layout="@layout/view_loading"/> \ No newline at end of file diff --git a/app/src/main/res/layout/view_error.xml b/app/src/main/res/layout/view_error.xml index 844a5a969..f104e00c3 100644 --- a/app/src/main/res/layout/view_error.xml +++ b/app/src/main/res/layout/view_error.xml @@ -1,27 +1,27 @@ + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="center_horizontal" + android:orientation="vertical"> + android:id="@+id/iv_error_image" + android:layout_width="wrap_content" + android:layout_height="wrap_content"/> + android:id="@+id/tv_error_message" + style="@style/Style.Text.Primary.Normal" + android:paddingTop="16dp" + android:paddingBottom="16dp"/> + android:id="@+id/btn_error_retry" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:backgroundTint="@color/colorAccent" + android:minWidth="96dp" + android:text="@string/dynamic_click_retry"/> \ No newline at end of file