diff --git a/app/src/main/assets/defaultData/txtTocRule.json b/app/src/main/assets/defaultData/txtTocRule.json index 58e9e8644..57cb4bfdb 100644 --- a/app/src/main/assets/defaultData/txtTocRule.json +++ b/app/src/main/assets/defaultData/txtTocRule.json @@ -24,7 +24,7 @@ "id": -4, "enable": false, "name": "目录(古典、轻小说备用)", - "rule": "^[  \\t]{0,4}(?:序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?![分赛游])|回(?![合来事去])|场(?![和合比电是])|篇(?!张))).{0,30}$", + "rule": "^[  \\t]{0,4}(?:序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?![分赛游])|回(?![合来事去])|场(?![和合比电是])|话|篇(?!张))).{0,30}$", "serialNumber": 3 }, { @@ -125,4 +125,4 @@ "rule": "^.{1,20}[((][\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}[))][  \t]{0,4}$", "serialNumber": 17 } -] +] \ No newline at end of file diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 5ad10ab4f..011689a1b 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,8 +3,15 @@ * 关注合作公众号 **[小说拾遗]()** 获取好看的小说。 * 旧版数据导入教程:先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。 -**2020/10/20** +**2020/10/23** +* 修复选择错误的bug +* 修复长图最后一张不能滚动的bug +* js添加java.getCookie(sourceUrl)来获取登录后的cookie by [AndyBernie](https://github.com/AndyBernie) +* 修复简繁转换没有处理标题 + +**2020/10/21** * 默认分组无书籍时自动隐藏 +* 自定义翻页按键支持多个按键 **2020/10/19** * 优化分组管理 diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt index 64f037fa4..02dd32dae 100644 --- a/app/src/main/java/io/legado/app/App.kt +++ b/app/src/main/java/io/legado/app/App.kt @@ -4,10 +4,8 @@ import android.app.NotificationChannel import android.app.NotificationManager import android.content.Context import android.content.res.Configuration -import android.graphics.Color import android.os.Build import android.provider.Settings -import android.util.Log import androidx.annotation.RequiresApi import androidx.appcompat.app.AppCompatDelegate import androidx.multidex.MultiDexApplication @@ -16,14 +14,10 @@ import io.legado.app.constant.AppConst.channelIdDownload import io.legado.app.constant.AppConst.channelIdReadAloud import io.legado.app.constant.AppConst.channelIdWeb import io.legado.app.constant.EventBus -import io.legado.app.constant.PreferKey import io.legado.app.data.AppDatabase -import io.legado.app.help.ActivityHelp -import io.legado.app.help.AppConfig -import io.legado.app.help.CrashHandler -import io.legado.app.help.ReadBookConfig -import io.legado.app.lib.theme.ThemeStore -import io.legado.app.utils.* +import io.legado.app.help.* +import io.legado.app.utils.LanguageUtils +import io.legado.app.utils.postEvent @Suppress("DEPRECATION") class App : MultiDexApplication() { @@ -72,68 +66,9 @@ class App : MultiDexApplication() { } } - /** - * 更新主题 - */ - fun applyTheme() { - when { - AppConfig.isEInkMode -> { - ThemeStore.editTheme(this) - .coloredNavigationBar(true) - .primaryColor(Color.WHITE) - .accentColor(Color.BLACK) - .backgroundColor(Color.WHITE) - .bottomBackground(Color.WHITE) - .apply() - } - AppConfig.isNightTheme -> { - val primary = - getPrefInt(PreferKey.cNPrimary, getCompatColor(R.color.md_blue_grey_600)) - val accent = - getPrefInt(PreferKey.cNAccent, getCompatColor(R.color.md_deep_orange_800)) - var background = - getPrefInt(PreferKey.cNBackground, getCompatColor(R.color.md_grey_900)) - if (ColorUtils.isColorLight(background)) { - background = getCompatColor(R.color.md_grey_900) - putPrefInt(PreferKey.cNBackground, background) - } - val bBackground = - getPrefInt(PreferKey.cNBBackground, getCompatColor(R.color.md_grey_850)) - ThemeStore.editTheme(this) - .coloredNavigationBar(true) - .primaryColor(ColorUtils.withAlpha(primary, 1f)) - .accentColor(ColorUtils.withAlpha(accent, 1f)) - .backgroundColor(ColorUtils.withAlpha(background, 1f)) - .bottomBackground(ColorUtils.withAlpha(bBackground, 1f)) - .apply() - } - else -> { - val primary = - getPrefInt(PreferKey.cPrimary, getCompatColor(R.color.md_brown_500)) - val accent = - getPrefInt(PreferKey.cAccent, getCompatColor(R.color.md_red_600)) - var background = - getPrefInt(PreferKey.cBackground, getCompatColor(R.color.md_grey_100)) - if (!ColorUtils.isColorLight(background)) { - background = getCompatColor(R.color.md_grey_100) - putPrefInt(PreferKey.cBackground, background) - } - val bBackground = - getPrefInt(PreferKey.cBBackground, getCompatColor(R.color.md_grey_200)) - ThemeStore.editTheme(this) - .coloredNavigationBar(true) - .primaryColor(ColorUtils.withAlpha(primary, 1f)) - .accentColor(ColorUtils.withAlpha(accent, 1f)) - .backgroundColor(ColorUtils.withAlpha(background, 1f)) - .bottomBackground(ColorUtils.withAlpha(bBackground, 1f)) - .apply() - } - } - } - fun applyDayNight() { ReadBookConfig.upBg() - applyTheme() + ThemeConfig.applyTheme(this) initNightMode() postEvent(EventBus.RECREATE, "") } diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt index 0dbd518af..b55f35d57 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -12,8 +12,8 @@ object PreferKey { const val speakEngine = "speakEngine" const val readAloudByPage = "readAloudByPage" const val ttsSpeechRate = "ttsSpeechRate" - const val prevKey = "prevKeyCode" - const val nextKey = "nextKeyCode" + const val prevKeys = "prevKeyCodes" + const val nextKeys = "nextKeyCodes" const val showRss = "showRss" const val bookshelfLayout = "bookshelfLayout" const val bookshelfSort = "bookshelfSort" diff --git a/app/src/main/java/io/legado/app/help/BookHelp.kt b/app/src/main/java/io/legado/app/help/BookHelp.kt index 537737c3f..18222d870 100644 --- a/app/src/main/java/io/legado/app/help/BookHelp.kt +++ b/app/src/main/java/io/legado/app/help/BookHelp.kt @@ -101,7 +101,7 @@ object BookHelp { downloadImages.add(src) val analyzeUrl = AnalyzeUrl(src) try { - analyzeUrl.getImageBytes(book.origin)?.let { + analyzeUrl.getResponseBytes(book.origin)?.let { FileUtils.createFileIfNotExist( downloadDir, cacheFolderName, @@ -324,7 +324,8 @@ object BookHelp { content: String, enableReplace: Boolean, ): List { - var c = content + var title1 = title + var content1 = content if (enableReplace) { synchronized(this) { if (bookName != name || bookOrigin != origin) { @@ -341,10 +342,10 @@ object BookHelp { item.pattern.let { if (it.isNotEmpty()) { try { - c = if (item.isRegex) { - c.replace(it.toRegex(), item.replacement) + content1 = if (item.isRegex) { + content1.replace(it.toRegex(), item.replacement) } else { - c.replace(it, item.replacement) + content1.replace(it, item.replacement) } } catch (e: Exception) { withContext(Main) { @@ -357,8 +358,14 @@ object BookHelp { } try { when (AppConfig.chineseConverterType) { - 1 -> c = HanLP.convertToSimplifiedChinese(c) - 2 -> c = HanLP.convertToTraditionalChinese(c) + 1 -> { + title1 = HanLP.convertToSimplifiedChinese(title1) + content1 = HanLP.convertToSimplifiedChinese(content1) + } + 2 -> { + title1 = HanLP.convertToTraditionalChinese(title1) + content1 = HanLP.convertToTraditionalChinese(content1) + } } } catch (e: Exception) { withContext(Main) { @@ -366,11 +373,11 @@ object BookHelp { } } val contents = arrayListOf() - c.split("\n").forEach { + content1.split("\n").forEach { val str = it.replace("^[\\n\\s\\r]+".toRegex(), "") if (contents.isEmpty()) { - contents.add(title) - if (str != title && str.isNotEmpty()) { + contents.add(title1) + if (str != title1 && str.isNotEmpty()) { contents.add("${ReadBookConfig.paragraphIndent}$str") } } else if (str.isNotEmpty()) { diff --git a/app/src/main/java/io/legado/app/help/JsExtensions.kt b/app/src/main/java/io/legado/app/help/JsExtensions.kt index 7ba245bcd..ff7357ad4 100644 --- a/app/src/main/java/io/legado/app/help/JsExtensions.kt +++ b/app/src/main/java/io/legado/app/help/JsExtensions.kt @@ -4,6 +4,7 @@ import android.util.Base64 import androidx.annotation.Keep import io.legado.app.constant.AppConst.dateFormat import io.legado.app.help.http.SSLHelper +import io.legado.app.help.http.CookieStore import io.legado.app.model.analyzeRule.AnalyzeUrl import io.legado.app.utils.* import org.jsoup.Connection @@ -119,6 +120,13 @@ interface JsExtensions { .execute() } + /** + *js实现读取cookie + */ + fun getCookie(tag: String): String { + return CookieStore.getCookie(tag) + } + /** * js实现解码,不能删 */ diff --git a/app/src/main/java/io/legado/app/help/ThemeConfig.kt b/app/src/main/java/io/legado/app/help/ThemeConfig.kt index 44948e17c..4f92a039a 100644 --- a/app/src/main/java/io/legado/app/help/ThemeConfig.kt +++ b/app/src/main/java/io/legado/app/help/ThemeConfig.kt @@ -7,6 +7,7 @@ import io.legado.app.App import io.legado.app.R import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey +import io.legado.app.lib.theme.ThemeStore import io.legado.app.utils.* import java.io.File @@ -14,16 +15,16 @@ object ThemeConfig { const val configFileName = "themeConfig.json" val configFilePath = FileUtils.getPath(App.INSTANCE.filesDir, configFileName) - val configList = arrayListOf() - - init { - upConfig() + val configList: ArrayList by lazy { + val cList = getConfigs() ?: DefaultData.defaultThemeConfigs + ArrayList(cList) } fun upConfig() { - (getConfigs() ?: DefaultData.defaultThemeConfigs).let { - configList.clear() - configList.addAll(it) + getConfigs()?.let { + it.forEach { config -> + addConfig(config) + } } } @@ -137,6 +138,65 @@ object ThemeConfig { addConfig(config) } + /** + * 更新主题 + */ + fun applyTheme(context: Context) = with(context) { + when { + AppConfig.isEInkMode -> { + ThemeStore.editTheme(this) + .coloredNavigationBar(true) + .primaryColor(Color.WHITE) + .accentColor(Color.BLACK) + .backgroundColor(Color.WHITE) + .bottomBackground(Color.WHITE) + .apply() + } + AppConfig.isNightTheme -> { + val primary = + getPrefInt(PreferKey.cNPrimary, getCompatColor(R.color.md_blue_grey_600)) + val accent = + getPrefInt(PreferKey.cNAccent, getCompatColor(R.color.md_deep_orange_800)) + var background = + getPrefInt(PreferKey.cNBackground, getCompatColor(R.color.md_grey_900)) + if (ColorUtils.isColorLight(background)) { + background = getCompatColor(R.color.md_grey_900) + putPrefInt(PreferKey.cNBackground, background) + } + val bBackground = + getPrefInt(PreferKey.cNBBackground, getCompatColor(R.color.md_grey_850)) + ThemeStore.editTheme(this) + .coloredNavigationBar(true) + .primaryColor(ColorUtils.withAlpha(primary, 1f)) + .accentColor(ColorUtils.withAlpha(accent, 1f)) + .backgroundColor(ColorUtils.withAlpha(background, 1f)) + .bottomBackground(ColorUtils.withAlpha(bBackground, 1f)) + .apply() + } + else -> { + val primary = + getPrefInt(PreferKey.cPrimary, getCompatColor(R.color.md_brown_500)) + val accent = + getPrefInt(PreferKey.cAccent, getCompatColor(R.color.md_red_600)) + var background = + getPrefInt(PreferKey.cBackground, getCompatColor(R.color.md_grey_100)) + if (!ColorUtils.isColorLight(background)) { + background = getCompatColor(R.color.md_grey_100) + putPrefInt(PreferKey.cBackground, background) + } + val bBackground = + getPrefInt(PreferKey.cBBackground, getCompatColor(R.color.md_grey_200)) + ThemeStore.editTheme(this) + .coloredNavigationBar(true) + .primaryColor(ColorUtils.withAlpha(primary, 1f)) + .accentColor(ColorUtils.withAlpha(accent, 1f)) + .backgroundColor(ColorUtils.withAlpha(background, 1f)) + .bottomBackground(ColorUtils.withAlpha(bBackground, 1f)) + .apply() + } + } + } + @Keep class Config( var themeName: String, diff --git a/app/src/main/java/io/legado/app/help/http/HttpHelper.kt b/app/src/main/java/io/legado/app/help/http/HttpHelper.kt index 3728f4819..a226b46d6 100644 --- a/app/src/main/java/io/legado/app/help/http/HttpHelper.kt +++ b/app/src/main/java/io/legado/app/help/http/HttpHelper.kt @@ -48,21 +48,6 @@ object HttpHelper { return null } - fun getBytes( - url: String, - queryMap: Map, - headers: Map - ): ByteArray? { - NetworkUtils.getBaseUrl(url)?.let { baseUrl -> - return getByteRetrofit(baseUrl) - .create(HttpGetApi::class.java) - .getMapByte(url, queryMap, headers) - .execute() - .body() - } - return null - } - suspend fun simpleGetAsync(url: String, encode: String? = null): String? { NetworkUtils.getBaseUrl(url)?.let { baseUrl -> val response = getApiService(baseUrl, encode) diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt index 8fb5e2c0f..11dcbab2c 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt @@ -649,16 +649,12 @@ class AnalyzeRule(var book: BaseBook? = null) : JsExtensions { * 章节数转数字 */ fun toNumChapter(s: String?): String? { - if (s == null) { - return null - } - val pattern = Pattern.compile("(第)(.+?)(章)") - val matcher = pattern.matcher(s) - return if (matcher.find()) { - matcher.group(1)!! + StringUtils.stringToInt(matcher.group(2)) + matcher.group(3) - } else { - s + s ?: return null + val matcher = titleNumPattern.matcher(s) + if (matcher.find()) { + return "${matcher.group(1)}${StringUtils.stringToInt(matcher.group(2))}${matcher.group(3)}" } + return s } companion object { @@ -667,6 +663,7 @@ class AnalyzeRule(var book: BaseBook? = null) : JsExtensions { private val evalPattern = Pattern.compile("@get:\\{[^}]+?\\}|\\{\\{[\\w\\W]*?\\}\\}", Pattern.CASE_INSENSITIVE) private val regexPattern = Pattern.compile("\\$\\d{1,2}") + private val titleNumPattern = Pattern.compile("(第)(.+?)(章)") } } diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt index 3680e5322..160c0debf 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt @@ -188,9 +188,9 @@ class AnalyzeUrl( GSON.fromJsonObject>(headers) ?.let { headerMap.putAll(it) } } - headerMap[UA_NAME] ?: let { - headerMap[UA_NAME] = userAgent - } + } + headerMap[UA_NAME] ?: let { + headerMap[UA_NAME] = userAgent } option.charset?.let { charset = it } option.body?.let { @@ -281,7 +281,7 @@ class AnalyzeUrl( fun getResponse(tag: String): Call { val cookie = CookieStore.getCookie(tag) if (cookie.isNotEmpty()) { - headerMap["Cookie"] = cookie + headerMap["Cookie"] += ";${cookie}" } return when { method == RequestMethod.POST -> { @@ -324,7 +324,7 @@ class AnalyzeUrl( } val cookie = CookieStore.getCookie(tag) if (cookie.isNotEmpty()) { - headerMap["Cookie"] = cookie + headerMap["Cookie"] += ";${cookie}" } val res = when { method == RequestMethod.POST -> { @@ -352,23 +352,11 @@ class AnalyzeUrl( return Res(NetworkUtils.getUrl(res), res.body()) } - fun getImageBytes(tag: String): ByteArray? { - val cookie = CookieStore.getCookie(tag) - if (cookie.isNotEmpty()) { - headerMap["Cookie"] += cookie - } - return if (fieldMap.isEmpty()) { - HttpHelper.getBytes(url, mapOf(), headerMap) - } else { - HttpHelper.getBytes(url, fieldMap, headerMap) - } - } - suspend fun getResponseBytes(tag: String? = null): ByteArray? { if (tag != null) { val cookie = CookieStore.getCookie(tag) if (cookie.isNotEmpty()) { - headerMap["Cookie"] = cookie + headerMap["Cookie"] += ";${cookie}" } } val response = when { diff --git a/app/src/main/java/io/legado/app/ui/about/AboutFragment.kt b/app/src/main/java/io/legado/app/ui/about/AboutFragment.kt index eea2feba4..d6c7df52a 100644 --- a/app/src/main/java/io/legado/app/ui/about/AboutFragment.kt +++ b/app/src/main/java/io/legado/app/ui/about/AboutFragment.kt @@ -29,7 +29,8 @@ class AboutFragment : PreferenceFragmentCompat() { Pair("(QQ群3)981838750", "g_Sgmp2nQPKqcZQ5qPcKLHziwX_mpps9"), Pair("(QQ群4)256929088", "czEJPLDnT4Pd9SKQ6RoRVzKhDxLchZrO"), Pair("(QQ群5)811843556", "zKZ2UYGZ7o5CzcA6ylxzlqi21si_iqaX"), - Pair("(QQ群6)870270970", "FeCF8iSxfQbe90HPvGsvcqs5P5oSeY5n") + Pair("(QQ群6)870270970", "FeCF8iSxfQbe90HPvGsvcqs5P5oSeY5n"), + Pair("(QQ群7)15987187", "S2g2TMD0LGd3sefUADd1AbyPEW2o2XfC") ) override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { diff --git a/app/src/main/java/io/legado/app/ui/book/explore/ExploreShowActivity.kt b/app/src/main/java/io/legado/app/ui/book/explore/ExploreShowActivity.kt index a447bb9e1..270e7e703 100644 --- a/app/src/main/java/io/legado/app/ui/book/explore/ExploreShowActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/explore/ExploreShowActivity.kt @@ -38,6 +38,13 @@ class ExploreShowActivity : VMBaseActivity(R.layout.activi loadMoreView = LoadMoreView(this) adapter.addFooterView(loadMoreView) loadMoreView.startLoad() + loadMoreView.setOnClickListener { + if (!isLoading) { + loadMoreView.hasMore() + scrollToBottom() + isLoading = true + } + } recycler_view.addOnScrollListener(object : RecyclerView.OnScrollListener() { override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { super.onScrolled(recyclerView, dx, dy) @@ -75,4 +82,4 @@ class ExploreShowActivity : VMBaseActivity(R.layout.activi Pair("author", book.author) ) } -} \ No newline at end of file +} diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index c7f860697..fc73a041c 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -313,30 +313,30 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo * 按键事件 */ override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { - when (keyCode) { - getPrefInt(PreferKey.prevKey) -> { + when { + ReadBookActivityHelp.isPrevKey(this, keyCode) -> { if (keyCode != KeyEvent.KEYCODE_UNKNOWN) { page_view.pageDelegate?.keyTurnPage(PageDelegate.Direction.PREV) return true } } - getPrefInt(PreferKey.nextKey) -> { + ReadBookActivityHelp.isNextKey(this, keyCode) -> { if (keyCode != KeyEvent.KEYCODE_UNKNOWN) { page_view.pageDelegate?.keyTurnPage(PageDelegate.Direction.NEXT) return true } } - KeyEvent.KEYCODE_VOLUME_UP -> { + keyCode == KeyEvent.KEYCODE_VOLUME_UP -> { if (volumeKeyPage(PageDelegate.Direction.PREV)) { return true } } - KeyEvent.KEYCODE_VOLUME_DOWN -> { + keyCode == KeyEvent.KEYCODE_VOLUME_DOWN -> { if (volumeKeyPage(PageDelegate.Direction.NEXT)) { return true } } - KeyEvent.KEYCODE_SPACE -> { + keyCode == KeyEvent.KEYCODE_SPACE -> { page_view.pageDelegate?.keyTurnPage(PageDelegate.Direction.NEXT) return true } diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivityHelp.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivityHelp.kt index adb8909e1..78195ad05 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivityHelp.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivityHelp.kt @@ -13,6 +13,7 @@ import android.view.WindowManager import android.widget.EditText import io.legado.app.App import io.legado.app.R +import io.legado.app.constant.PreferKey import io.legado.app.data.entities.Bookmark import io.legado.app.help.AppConfig import io.legado.app.help.ReadBookConfig @@ -24,6 +25,7 @@ import io.legado.app.service.help.CacheBook import io.legado.app.service.help.ReadBook import io.legado.app.ui.widget.text.AutoCompleteTextView import io.legado.app.utils.applyTint +import io.legado.app.utils.getPrefString import io.legado.app.utils.requestInputMethod import kotlinx.android.synthetic.main.dialog_download_choice.view.* import kotlinx.android.synthetic.main.dialog_edit_text.view.* @@ -186,4 +188,14 @@ object ReadBookActivityHelp { cancelButton() }.show().applyTint() } + + fun isPrevKey(context: Context, keyCode: Int): Boolean { + val prevKeysStr = context.getPrefString(PreferKey.prevKeys) + return prevKeysStr?.split(",")?.contains(keyCode.toString()) ?: false + } + + fun isNextKey(context: Context, keyCode: Int): Boolean { + val nextKeysStr = context.getPrefString(PreferKey.nextKeys) + return nextKeysStr?.split(",")?.contains(keyCode.toString()) ?: false + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt index 40af2c32d..d1480ac81 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt @@ -26,9 +26,8 @@ import org.jetbrains.anko.sdk27.listeners.onLongClick */ class ReadMenu @JvmOverloads constructor( context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = 0 -) : FrameLayout(context, attrs, defStyleAttr) { + attrs: AttributeSet? = null +) : FrameLayout(context, attrs) { var cnaShowMenu: Boolean = false private val callBack: CallBack? get() = activity as? CallBack private lateinit var menuTopIn: Animation diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/PageKeyDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/PageKeyDialog.kt index cfd632453..ce479caba 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/PageKeyDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/PageKeyDialog.kt @@ -6,10 +6,9 @@ import android.view.KeyEvent import io.legado.app.R import io.legado.app.constant.PreferKey import io.legado.app.lib.theme.backgroundColor -import io.legado.app.utils.getPrefInt +import io.legado.app.utils.getPrefString import io.legado.app.utils.hideSoftInput -import io.legado.app.utils.putPrefInt -import io.legado.app.utils.removePref +import io.legado.app.utils.putPrefString import kotlinx.android.synthetic.main.dialog_page_key.* import org.jetbrains.anko.sdk27.listeners.onClick @@ -19,33 +18,34 @@ class PageKeyDialog(context: Context) : Dialog(context, R.style.AppTheme_AlertDi init { setContentView(R.layout.dialog_page_key) content_view.setBackgroundColor(context.backgroundColor) - et_prev.setText(context.getPrefInt(PreferKey.prevKey).toString()) - et_next.setText(context.getPrefInt(PreferKey.nextKey).toString()) + et_prev.setText(context.getPrefString(PreferKey.prevKeys)) + et_next.setText(context.getPrefString(PreferKey.nextKeys)) tv_ok.onClick { - val prevKey = et_prev.text?.toString() - if (prevKey.isNullOrEmpty()) { - context.removePref(PreferKey.prevKey) - } else { - context.putPrefInt(PreferKey.prevKey, prevKey.toInt()) - } - val nextKey = et_next.text?.toString() - if (nextKey.isNullOrEmpty()) { - context.removePref(PreferKey.nextKey) - } else { - context.putPrefInt(PreferKey.nextKey, nextKey.toInt()) - } + context.putPrefString(PreferKey.prevKeys, et_prev.text?.toString()) + context.putPrefString(PreferKey.nextKeys, et_next.text?.toString()) dismiss() } } override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean { - if (keyCode != KeyEvent.KEYCODE_BACK) { + if (keyCode != KeyEvent.KEYCODE_BACK && keyCode != KeyEvent.KEYCODE_DEL) { if (et_prev.hasFocus()) { - et_prev.setText(keyCode.toString()) + val editableText = et_prev.editableText + if (editableText.isEmpty() or editableText.endsWith(",")) { + editableText.append(keyCode.toString()) + } else { + editableText.append(",").append(keyCode.toString()) + } + return true } else if (et_next.hasFocus()) { - et_next.setText(keyCode.toString()) + val editableText = et_next.editableText + if (editableText.isEmpty() or editableText.endsWith(",")) { + editableText.append(keyCode.toString()) + } else { + editableText.append(",").append(keyCode.toString()) + } + return true } - return true } return super.onKeyDown(keyCode, event) } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt index 295ccb0ef..575279a1c 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt @@ -23,7 +23,9 @@ import io.legado.app.utils.getCompatColor import io.legado.app.utils.getPrefBoolean import kotlinx.coroutines.CoroutineScope - +/** + * 阅读内容界面 + */ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, attrs) { var selectAble = context.getPrefBoolean(PreferKey.textSelectAble) var upView: ((TextPage) -> Unit)? = null @@ -41,7 +43,6 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at //滚动参数 private val pageFactory: TextPageFactory get() = callBack.pageFactory - private val maxScrollOffset = 100f private var pageOffset = 0f init { @@ -173,17 +174,13 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at */ fun onScroll(mOffset: Float) { if (mOffset == 0f) return - var offset = mOffset - if (offset > maxScrollOffset) { - offset = maxScrollOffset - } else if (offset < -maxScrollOffset) { - offset = -maxScrollOffset - } - - pageOffset += offset + pageOffset += mOffset if (!pageFactory.hasPrev() && pageOffset > 0) { pageOffset = 0f - } else if (!pageFactory.hasNext() && pageOffset < 0) { + } else if (!pageFactory.hasNext() + && pageOffset < 0 + && pageOffset + textPage.height < ChapterProvider.visibleHeight + ) { pageOffset = 0f } else if (pageOffset > 0) { pageFactory.moveToPrev(false) @@ -263,7 +260,10 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at for ((charIndex, textChar) in textLine.textChars.withIndex()) { if (x > textChar.start && x < textChar.end) { if (selectStart[0] != relativePos || selectStart[1] != lineIndex || selectStart[2] != charIndex) { - if (selectToInt(relativePos, lineIndex, charIndex) > selectToInt(selectEnd)) { + if (selectToInt(relativePos, lineIndex, charIndex) > selectToInt( + selectEnd + ) + ) { return } selectStart[0] = relativePos @@ -306,7 +306,10 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at if (x > textChar.start && x < textChar.end) { Log.e("char", "$relativePos $lineIndex $charIndex") if (selectEnd[0] != relativePos || selectEnd[1] != lineIndex || selectEnd[2] != charIndex) { - if (selectToInt(relativePos, lineIndex, charIndex) < selectToInt(selectStart)) { + if (selectToInt(relativePos, lineIndex, charIndex) < selectToInt( + selectStart + ) + ) { return } selectEnd[0] = relativePos diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt index 166a9b731..2b9d034e8 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt @@ -33,9 +33,11 @@ class ContentView(context: Context) : FrameLayout(context) { private var tvBookName: BatteryView? = null val headerHeight: Int - get() = if (ReadBookConfig.hideStatusBar) { - if (ll_header.isGone) 0 else ll_header.height - } else context.statusBarHeight + get() { + val h1 = if (ReadBookConfig.hideStatusBar) 0 else context.statusBarHeight + val h2 = if (ll_header.isGone) 0 else ll_header.height + return h1 + h2 + } init { //设置背景防止切换背景时文字重叠 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 4b76ebc3e..9b5d38e30 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 @@ -177,7 +177,7 @@ class ThemeConfigFragment : BasePreferenceFragment(), @SuppressLint("InflateParams") private fun saveThemeAlert(key: String) { - alert("主题名称") { + alert(R.string.theme_name) { var editText: AutoCompleteTextView? = null customView { layoutInflater.inflate(R.layout.dialog_edit_text, null).apply { @@ -203,7 +203,7 @@ class ThemeConfigFragment : BasePreferenceFragment(), private fun upTheme(isNightTheme: Boolean) { if (AppConfig.isNightTheme == isNightTheme) { listView.post { - App.INSTANCE.applyTheme() + ThemeConfig.applyTheme(requireContext()) recreateActivities() } } diff --git a/app/src/main/java/io/legado/app/ui/widget/ArcView.kt b/app/src/main/java/io/legado/app/ui/widget/ArcView.kt index 6338c6638..b92d552af 100644 --- a/app/src/main/java/io/legado/app/ui/widget/ArcView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/ArcView.kt @@ -8,9 +8,8 @@ import io.legado.app.R class ArcView @JvmOverloads constructor( context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = 0 -) : View(context, attrs, defStyleAttr) { + attrs: AttributeSet? = null +) : View(context, attrs) { private var mWidth = 0 private var mHeight = 0 diff --git a/app/src/main/java/io/legado/app/ui/widget/BatteryView.kt b/app/src/main/java/io/legado/app/ui/widget/BatteryView.kt index 1711a650e..3c3c1d7c3 100644 --- a/app/src/main/java/io/legado/app/ui/widget/BatteryView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/BatteryView.kt @@ -12,7 +12,10 @@ import androidx.appcompat.widget.AppCompatTextView import io.legado.app.utils.dp import java.io.File -class BatteryView(context: Context, attrs: AttributeSet?) : AppCompatTextView(context, attrs) { +class BatteryView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null +) : AppCompatTextView(context, attrs) { private val batteryPaint = Paint() private val outFrame = Rect() private val polar = Rect() diff --git a/app/src/main/java/io/legado/app/ui/widget/DetailSeekBar.kt b/app/src/main/java/io/legado/app/ui/widget/DetailSeekBar.kt index 5198599e4..010ebba78 100644 --- a/app/src/main/java/io/legado/app/ui/widget/DetailSeekBar.kt +++ b/app/src/main/java/io/legado/app/ui/widget/DetailSeekBar.kt @@ -13,7 +13,10 @@ import io.legado.app.utils.progressAdd import kotlinx.android.synthetic.main.view_detail_seek_bar.view.* import org.jetbrains.anko.sdk27.listeners.onClick -class DetailSeekBar(context: Context, attrs: AttributeSet?) : FrameLayout(context, attrs), +class DetailSeekBar @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null +) : FrameLayout(context, attrs), SeekBar.OnSeekBarChangeListener { private val isBottomBackground: Boolean var valueFormat: ((progress: Int) -> String)? = null diff --git a/app/src/main/java/io/legado/app/ui/widget/LabelsBar.kt b/app/src/main/java/io/legado/app/ui/widget/LabelsBar.kt index 4d51c5b80..01c4957db 100644 --- a/app/src/main/java/io/legado/app/ui/widget/LabelsBar.kt +++ b/app/src/main/java/io/legado/app/ui/widget/LabelsBar.kt @@ -8,7 +8,10 @@ import io.legado.app.ui.widget.text.AccentBgTextView import io.legado.app.utils.dp @Suppress("unused", "MemberVisibilityCanBePrivate") -class LabelsBar(context: Context, attrs: AttributeSet?) : LinearLayout(context, attrs) { +class LabelsBar @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null +) : LinearLayout(context, attrs) { private val unUsedViews = arrayListOf() private val usedViews = arrayListOf() diff --git a/app/src/main/java/io/legado/app/ui/widget/SearchView.kt b/app/src/main/java/io/legado/app/ui/widget/SearchView.kt index 82d24c671..975fe9d57 100644 --- a/app/src/main/java/io/legado/app/ui/widget/SearchView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/SearchView.kt @@ -18,9 +18,8 @@ import io.legado.app.R class SearchView @JvmOverloads constructor( context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = 0 -) : SearchView(context, attrs, defStyleAttr) { + attrs: AttributeSet? = null +) : SearchView(context, attrs) { private var mSearchHintIcon: Drawable? = null private var textView: TextView? = null diff --git a/app/src/main/java/io/legado/app/ui/widget/SelectActionBar.kt b/app/src/main/java/io/legado/app/ui/widget/SelectActionBar.kt index fd478ae42..3fc481e8b 100644 --- a/app/src/main/java/io/legado/app/ui/widget/SelectActionBar.kt +++ b/app/src/main/java/io/legado/app/ui/widget/SelectActionBar.kt @@ -17,7 +17,10 @@ import kotlinx.android.synthetic.main.view_select_action_bar.view.* import org.jetbrains.anko.sdk27.listeners.onClick @Suppress("unused") -class SelectActionBar(context: Context, attrs: AttributeSet?) : FrameLayout(context, attrs) { +class SelectActionBar @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null +) : FrameLayout(context, attrs) { private var callBack: CallBack? = null private var selMenu: PopupMenu? = null diff --git a/app/src/main/java/io/legado/app/ui/widget/ShadowLayout.kt b/app/src/main/java/io/legado/app/ui/widget/ShadowLayout.kt index 76668e772..95e54ac63 100644 --- a/app/src/main/java/io/legado/app/ui/widget/ShadowLayout.kt +++ b/app/src/main/java/io/legado/app/ui/widget/ShadowLayout.kt @@ -14,11 +14,10 @@ import io.legado.app.utils.getCompatColor /** * ShadowLayout.java * - * * Created by lijiankun on 17/8/11. */ @Suppress("unused") -class ShadowLayout( +class ShadowLayout @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null ) : RelativeLayout(context, attrs) { diff --git a/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt b/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt index a30873671..51a04f97d 100644 --- a/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt +++ b/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt @@ -22,7 +22,10 @@ import org.jetbrains.anko.bottomPadding import org.jetbrains.anko.topPadding @Suppress("unused") -class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, attrs) { +class TitleBar @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null +) : AppBarLayout(context, attrs) { val toolbar: Toolbar val menu: Menu diff --git a/app/src/main/java/io/legado/app/ui/widget/anima/RefreshProgressBar.kt b/app/src/main/java/io/legado/app/ui/widget/anima/RefreshProgressBar.kt index 1791b3be7..3a0af5b03 100644 --- a/app/src/main/java/io/legado/app/ui/widget/anima/RefreshProgressBar.kt +++ b/app/src/main/java/io/legado/app/ui/widget/anima/RefreshProgressBar.kt @@ -14,9 +14,8 @@ import io.legado.app.R @Suppress("unused", "MemberVisibilityCanBePrivate") class RefreshProgressBar @JvmOverloads constructor( context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = 0 -) : View(context, attrs, defStyleAttr) { + attrs: AttributeSet? = null +) : View(context, attrs) { private var a = 1 private var durProgress = 0 private var secondDurProgress = 0 diff --git a/app/src/main/java/io/legado/app/ui/widget/anima/RotateLoading.kt b/app/src/main/java/io/legado/app/ui/widget/anima/RotateLoading.kt index 13c4f346d..634f9689e 100644 --- a/app/src/main/java/io/legado/app/ui/widget/anima/RotateLoading.kt +++ b/app/src/main/java/io/legado/app/ui/widget/anima/RotateLoading.kt @@ -18,9 +18,12 @@ import io.legado.app.utils.dp * Created by Victor on 2015/4/28. */ @Suppress("MemberVisibilityCanBePrivate") -class RotateLoading : View { +class RotateLoading @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null +) : View(context, attrs) { - private lateinit var mPaint: Paint + private var mPaint: Paint private var loadingRectF: RectF? = null private var shadowRectF: RectF? = null @@ -55,19 +58,7 @@ class RotateLoading : View { private val hidden = Runnable { this.stopInternal() } - constructor(context: Context) : super(context) { - initView(context, null) - } - - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - initView(context, attrs) - } - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - initView(context, attrs) - } - - private fun initView(context: Context, attrs: AttributeSet?) { + init { loadingColor = context.accentColor thisWidth = DEFAULT_WIDTH.dp shadowPosition = DEFAULT_SHADOW_POSITION.dp diff --git a/app/src/main/java/io/legado/app/ui/widget/anima/explosion_field/ExplosionView.kt b/app/src/main/java/io/legado/app/ui/widget/anima/explosion_field/ExplosionView.kt index 9eef530f2..7345e7ed9 100644 --- a/app/src/main/java/io/legado/app/ui/widget/anima/explosion_field/ExplosionView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/anima/explosion_field/ExplosionView.kt @@ -30,7 +30,8 @@ import java.util.* @Suppress("unused") -class ExplosionView : View { +class ExplosionView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : + View(context, attrs) { private var customDuration = ExplosionAnimator.DEFAULT_DURATION private var idPlayAnimationEffect = 0 @@ -40,24 +41,7 @@ class ExplosionView : View { private val mExplosions = ArrayList() private val mExpandInset = IntArray(2) - constructor(context: Context) : super(context) { - init() - } - - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init() - } - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super( - context, - attrs, - defStyleAttr - ) { - init() - } - - private fun init() { - + init { Arrays.fill(mExpandInset, Utils.dp2Px(32)) } diff --git a/app/src/main/java/io/legado/app/ui/widget/dynamiclayout/DynamicFrameLayout.kt b/app/src/main/java/io/legado/app/ui/widget/dynamiclayout/DynamicFrameLayout.kt index 683cbc5d9..d3115bdc9 100644 --- a/app/src/main/java/io/legado/app/ui/widget/dynamiclayout/DynamicFrameLayout.kt +++ b/app/src/main/java/io/legado/app/ui/widget/dynamiclayout/DynamicFrameLayout.kt @@ -13,7 +13,10 @@ import io.legado.app.R import kotlinx.android.synthetic.main.view_dynamic.view.* @Suppress("unused") -class DynamicFrameLayout(context: Context, attrs: AttributeSet?) : FrameLayout(context, attrs), ViewSwitcher { +class DynamicFrameLayout @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null +) : FrameLayout(context, attrs), ViewSwitcher { private var errorView: View? = null private var errorImage: AppCompatImageView? = null diff --git a/app/src/main/java/io/legado/app/ui/widget/image/CircleImageView.kt b/app/src/main/java/io/legado/app/ui/widget/image/CircleImageView.kt index 2364deab7..f5781183e 100644 --- a/app/src/main/java/io/legado/app/ui/widget/image/CircleImageView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/image/CircleImageView.kt @@ -25,8 +25,10 @@ import kotlin.math.min import kotlin.math.pow @Suppress("unused", "MemberVisibilityCanBePrivate") -class CircleImageView(context: Context, attrs: AttributeSet) : - AppCompatImageView(context, attrs) { +class CircleImageView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null +) : AppCompatImageView(context, attrs) { private val mDrawableRect = RectF() private val mBorderRect = RectF() diff --git a/app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt b/app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt index 5a85a0573..d09eae0dd 100644 --- a/app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt @@ -22,12 +22,10 @@ import io.legado.app.utils.getPrefString @Suppress("unused") class CoverImageView @JvmOverloads constructor( context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = 0 + attrs: AttributeSet? = null ) : androidx.appcompat.widget.AppCompatImageView( context, - attrs, - defStyleAttr + attrs ) { internal var width: Float = 0.toFloat() internal var height: Float = 0.toFloat() diff --git a/app/src/main/java/io/legado/app/ui/widget/image/FilletImageView.kt b/app/src/main/java/io/legado/app/ui/widget/image/FilletImageView.kt index 57428fe47..eefcdafc8 100644 --- a/app/src/main/java/io/legado/app/ui/widget/image/FilletImageView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/image/FilletImageView.kt @@ -12,9 +12,8 @@ import kotlin.math.max class FilletImageView @JvmOverloads constructor( context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = 0 -) : AppCompatImageView(context, attrs, defStyleAttr) { + attrs: AttributeSet? = null +) : AppCompatImageView(context, attrs) { internal var width: Float = 0.toFloat() internal var height: Float = 0.toFloat() private var leftTopRadius: Int = 0 diff --git a/app/src/main/java/io/legado/app/ui/widget/image/PhotoView.kt b/app/src/main/java/io/legado/app/ui/widget/image/PhotoView.kt index 08cc63e3a..5d80f087e 100644 --- a/app/src/main/java/io/legado/app/ui/widget/image/PhotoView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/image/PhotoView.kt @@ -27,9 +27,8 @@ import kotlin.math.roundToInt @Suppress("UNUSED_PARAMETER", "unused", "MemberVisibilityCanBePrivate", "PropertyName") class PhotoView @JvmOverloads constructor( context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = 0 -) : AppCompatImageView(context, attrs, defStyleAttr) { + attrs: AttributeSet? = null +) : AppCompatImageView(context, attrs) { val MIN_ROTATE = 35 val ANIMA_DURING = 340 val MAX_SCALE = 2.5f diff --git a/app/src/main/java/io/legado/app/ui/widget/recycler/LoadMoreView.kt b/app/src/main/java/io/legado/app/ui/widget/recycler/LoadMoreView.kt index 01cb906cb..ed62431e1 100644 --- a/app/src/main/java/io/legado/app/ui/widget/recycler/LoadMoreView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/recycler/LoadMoreView.kt @@ -1,6 +1,7 @@ package io.legado.app.ui.widget.recycler import android.content.Context +import android.util.AttributeSet import android.view.View import android.view.ViewGroup import android.widget.FrameLayout @@ -10,7 +11,7 @@ import io.legado.app.utils.visible import kotlinx.android.synthetic.main.view_load_more.view.* @Suppress("unused") -class LoadMoreView(context: Context) : FrameLayout(context) { +class LoadMoreView(context: Context, attrs: AttributeSet? = null) : FrameLayout(context, attrs) { var hasMore = true private set @@ -32,7 +33,13 @@ class LoadMoreView(context: Context) : FrameLayout(context) { fun stopLoad() { rotate_loading.hide() } - + + fun hasMore() { + hasMore = true + tv_text.invisible() + rotate_loading.show() + } + fun noMore(msg: String? = null) { hasMore = false rotate_loading.hide() @@ -44,4 +51,4 @@ class LoadMoreView(context: Context) : FrameLayout(context) { tv_text.visible() } -} \ No newline at end of file +} diff --git a/app/src/main/java/io/legado/app/ui/widget/seekbar/VerticalSeekBar.kt b/app/src/main/java/io/legado/app/ui/widget/seekbar/VerticalSeekBar.kt index ab4509954..736b9eb3a 100644 --- a/app/src/main/java/io/legado/app/ui/widget/seekbar/VerticalSeekBar.kt +++ b/app/src/main/java/io/legado/app/ui/widget/seekbar/VerticalSeekBar.kt @@ -17,7 +17,8 @@ import java.lang.reflect.InvocationTargetException import java.lang.reflect.Method @Suppress("SameParameterValue") -class VerticalSeekBar : AppCompatSeekBar { +class VerticalSeekBar @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : + AppCompatSeekBar(context, attrs) { private var mIsDragging: Boolean = false private var mThumb: Drawable? = null @@ -54,38 +55,12 @@ class VerticalSeekBar : AppCompatSeekBar { } } - constructor(context: Context) : super(context) { - initialize(context, null, 0, 0) - } - - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - initialize(context, attrs, 0, 0) - } - - constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super( - context, - attrs, - defStyle - ) { - initialize(context, attrs, defStyle, 0) - } - - private fun initialize( - context: Context, - attrs: AttributeSet?, - defStyleAttr: Int, - defStyleRes: Int - ) { + init { ATH.setTint(this, ThemeStore.accentColor(context)) ViewCompat.setLayoutDirection(this, ViewCompat.LAYOUT_DIRECTION_LTR) if (attrs != null) { - val a = context.obtainStyledAttributes( - attrs, - R.styleable.VerticalSeekBar, - defStyleAttr, - defStyleRes - ) + val a = context.obtainStyledAttributes(attrs, R.styleable.VerticalSeekBar) val rotationAngle = a.getInteger(R.styleable.VerticalSeekBar_seekBarRotation, 0) if (isValidRotationAngle(rotationAngle)) { mRotationAngle = rotationAngle diff --git a/app/src/main/java/io/legado/app/ui/widget/seekbar/VerticalSeekBarWrapper.kt b/app/src/main/java/io/legado/app/ui/widget/seekbar/VerticalSeekBarWrapper.kt index da69c33ab..683953f1a 100644 --- a/app/src/main/java/io/legado/app/ui/widget/seekbar/VerticalSeekBarWrapper.kt +++ b/app/src/main/java/io/legado/app/ui/widget/seekbar/VerticalSeekBarWrapper.kt @@ -13,9 +13,8 @@ import kotlin.math.max class VerticalSeekBarWrapper @JvmOverloads constructor( context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = 0 -) : FrameLayout(context, attrs, defStyleAttr) { + attrs: AttributeSet? = null +) : FrameLayout(context, attrs) { private val childSeekBar: VerticalSeekBar? get() { diff --git a/app/src/main/java/io/legado/app/ui/widget/text/AccentBgTextView.kt b/app/src/main/java/io/legado/app/ui/widget/text/AccentBgTextView.kt index 3d9df36f0..ccaffaf79 100644 --- a/app/src/main/java/io/legado/app/ui/widget/text/AccentBgTextView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/text/AccentBgTextView.kt @@ -11,8 +11,10 @@ import io.legado.app.utils.ColorUtils import io.legado.app.utils.dp import io.legado.app.utils.getCompatColor -class AccentBgTextView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : - AppCompatTextView(context, attrs) { +class AccentBgTextView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null +) : AppCompatTextView(context, attrs) { private var radius = 0 diff --git a/app/src/main/java/io/legado/app/ui/widget/text/AutoCompleteTextView.kt b/app/src/main/java/io/legado/app/ui/widget/text/AutoCompleteTextView.kt index c7eb18ee4..cff5714f4 100644 --- a/app/src/main/java/io/legado/app/ui/widget/text/AutoCompleteTextView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/text/AutoCompleteTextView.kt @@ -19,9 +19,8 @@ import org.jetbrains.anko.sdk27.listeners.onClick @Suppress("unused") class AutoCompleteTextView @JvmOverloads constructor( context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = 0 -) : AppCompatAutoCompleteTextView(context, attrs, defStyleAttr) { + attrs: AttributeSet? = null +) : AppCompatAutoCompleteTextView(context, attrs) { var delCallBack: ((value: String) -> Unit)? = null diff --git a/app/src/main/java/io/legado/app/ui/widget/text/BadgeView.kt b/app/src/main/java/io/legado/app/ui/widget/text/BadgeView.kt index c24e13e87..353fa9de4 100644 --- a/app/src/main/java/io/legado/app/ui/widget/text/BadgeView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/text/BadgeView.kt @@ -24,11 +24,11 @@ import io.legado.app.utils.visible /** * Created by milad heydari on 5/6/2016. */ +@Suppress("MemberVisibilityCanBePrivate", "unused") class BadgeView @JvmOverloads constructor( context: Context, - attrs: AttributeSet? = null, - defStyle: Int = android.R.attr.textViewStyle -) : AppCompatTextView(context, attrs, defStyle) { + attrs: AttributeSet? = null +) : AppCompatTextView(context, attrs) { var isHideOnNull = true set(hideOnNull) { diff --git a/app/src/main/java/io/legado/app/ui/widget/text/InertiaScrollTextView.kt b/app/src/main/java/io/legado/app/ui/widget/text/InertiaScrollTextView.kt index 051d5af4e..9644b8676 100644 --- a/app/src/main/java/io/legado/app/ui/widget/text/InertiaScrollTextView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/text/InertiaScrollTextView.kt @@ -15,14 +15,11 @@ import kotlin.math.max import kotlin.math.min -open class InertiaScrollTextView : AppCompatTextView { - constructor(context: Context) : super(context) - - constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) - - constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) - : super(context, attrs, defStyleAttr) - +@Suppress("unused") +open class InertiaScrollTextView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null +) : AppCompatTextView(context, attrs) { private val scrollStateIdle = 0 private val scrollStateDragging = 1 @@ -218,7 +215,7 @@ open class InertiaScrollTextView : AppCompatTextView { } } - internal fun postOnAnimation() { + fun postOnAnimation() { if (mEatRunOnAnimationRequest) { mReSchedulePostAnimationCallback = true } else { diff --git a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt index b99f935eb..7366cb602 100644 --- a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt @@ -56,7 +56,7 @@ fun Context.getPrefString(key: String, defValue: String? = null) = fun Context.getPrefString(@StringRes keyId: Int, defValue: String? = null) = defaultSharedPreferences.getString(getString(keyId), defValue) -fun Context.putPrefString(key: String, value: String) = +fun Context.putPrefString(key: String, value: String?) = defaultSharedPreferences.edit { putString(key, value) } fun Context.getPrefStringSet( diff --git a/app/src/main/res/layout/dialog_page_key.xml b/app/src/main/res/layout/dialog_page_key.xml index f2e1c8a3a..8c5b7a1fa 100644 --- a/app/src/main/res/layout/dialog_page_key.xml +++ b/app/src/main/res/layout/dialog_page_key.xml @@ -26,7 +26,6 @@ android:id="@+id/et_prev" android:layout_width="match_parent" android:layout_height="wrap_content" - android:inputType="number" android:singleLine="true" /> @@ -41,11 +40,17 @@ android:id="@+id/et_next" android:layout_width="match_parent" android:layout_height="wrap_content" - android:inputType="number" android:singleLine="true" /> + + 全文搜索 关注公众号[开源阅读]获取订阅源! 当前没有发现源,关注公众号[开源阅读]添加带发现的书源! + 将焦点放到输入框按下物理按键会自动录入键值,多个按键会自动用英文逗号隔开. + 主题名称 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index e30d9bddf..17b939c02 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -769,5 +769,7 @@ 全文搜尋 關注公眾號[开源阅读]獲取訂閱源! 目前沒有發現源,關注公眾號[开源阅读]添加包含發現的書源! + 将焦点放到输入框按下物理按键会自动录入键值,多个按键会自动用英文逗号隔开. + 主题名称 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 270f502de..18c518d9c 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -772,5 +772,7 @@ 全文搜索 关注公众号[开源阅读]获取订阅源! 当前没有发现源,关注公众号[开源阅读]添加带发现的书源! + 将焦点放到输入框按下物理按键会自动录入键值,多个按键会自动用英文逗号隔开. + 主题名称 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7c257fcfc..cdb9bc509 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -775,5 +775,7 @@ Search content 关注公众号[开源阅读]获取订阅源! 当前没有发现源,关注公众号[开源阅读]添加带发现的书源! + 将焦点放到输入框按下物理按键会自动录入键值,多个按键会自动用英文逗号隔开. + 主题名称