From a96aa109544805db4c9484b22d0593cfb796e20e Mon Sep 17 00:00:00 2001 From: Modificator Date: Sun, 26 Jan 2020 13:43:47 +0800 Subject: [PATCH 001/296] ignore signing without property --- app/build.gradle | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 7eac96051..cae1dac53 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -20,13 +20,15 @@ def gitCommits = Integer.parseInt('git rev-list --count HEAD'.execute([], projec android { compileSdkVersion 29 signingConfigs { - myConfig { - storeFile file(RELEASE_STORE_FILE) - storePassword RELEASE_STORE_PASSWORD - keyAlias RELEASE_KEY_ALIAS - keyPassword RELEASE_KEY_PASSWORD - v1SigningEnabled true - v2SigningEnabled true + if (project.hasProperty("RELEASE_STORE_FILE")) { + myConfig { + storeFile file(RELEASE_STORE_FILE) + storePassword RELEASE_STORE_PASSWORD + keyAlias RELEASE_KEY_ALIAS + keyPassword RELEASE_KEY_PASSWORD + v1SigningEnabled true + v2SigningEnabled true + } } } defaultConfig { @@ -49,12 +51,16 @@ android { } buildTypes { release { - signingConfig signingConfigs.myConfig + if (project.hasProperty("RELEASE_STORE_FILE")) { + signingConfig signingConfigs.myConfig + } minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } debug { - signingConfig signingConfigs.myConfig + if (project.hasProperty("RELEASE_STORE_FILE")) { + signingConfig signingConfigs.myConfig + } applicationIdSuffix '.debug' versionNameSuffix 'debug' minifyEnabled false From e7c67fcc9d7765b243f50c0f8ca6793be14e658c Mon Sep 17 00:00:00 2001 From: Modificator Date: Sun, 26 Jan 2020 14:45:22 +0800 Subject: [PATCH 002/296] =?UTF-8?q?add=20theme.=20=E9=BB=91=E7=99=BD?= =?UTF-8?q?=E3=80=81A=E5=B1=8F=E9=BB=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/lib/theme/ATH.kt | 6 ++++-- .../io/legado/app/ui/config/ThemeConfigFragment.kt | 14 +++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/lib/theme/ATH.kt b/app/src/main/java/io/legado/app/lib/theme/ATH.kt index 57c7c8403..46622b869 100644 --- a/app/src/main/java/io/legado/app/lib/theme/ATH.kt +++ b/app/src/main/java/io/legado/app/lib/theme/ATH.kt @@ -5,6 +5,7 @@ import android.app.Activity import android.app.ActivityManager import android.content.Context import android.graphics.Color +import android.graphics.drawable.ColorDrawable import android.os.Build import android.view.View import android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR @@ -206,10 +207,11 @@ object ATH { .setSelectedColor(ThemeStore.accentColor(bottom_navigation_view.context)).create() itemIconTintList = colorStateList itemTextColor = colorStateList - itemBackgroundResource = when(context.isNightTheme) { + itemBackground = ColorDrawable(ThemeStore.primaryColor(bottomBar.context)) + /*itemBackgroundResource = when(context.isNightTheme) { true -> R.drawable.item_bg_dark false -> R.drawable.item_bg_light - } + }*/ } } 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 6c87ff0af..4dff95998 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 @@ -20,7 +20,7 @@ import io.legado.app.utils.* class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedPreferenceChangeListener { - val items = arrayOf("极简","曜夜","经典") + val items = arrayOf("极简","曜夜","经典","黑白","A屏黑") override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { addPreferencesFromResource(R.xml.pref_config_theme) @@ -124,6 +124,18 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar putPrefInt("colorBackground", getCompatColor(R.color.md_grey_100)) putPrefBoolean("isNightTheme", false) } + 3 -> { + putPrefInt("colorPrimary", getCompatColor(R.color.white)) + putPrefInt("colorAccent", getCompatColor(R.color.black)) + putPrefInt("colorBackground", getCompatColor(R.color.white)) + putPrefBoolean("isNightTheme", false) + } + 4 -> { + putPrefInt("colorPrimaryNight", getCompatColor(R.color.black)) + putPrefInt("colorAccentNight", getCompatColor(R.color.md_grey_600)) + putPrefInt("colorBackgroundNight", getCompatColor(R.color.black)) + putPrefBoolean("isNightTheme", true) + } } App.INSTANCE.applyDayNight() recreateActivities() From 433711e0f19952b8f42ceb5b39693104e5daf4e8 Mon Sep 17 00:00:00 2001 From: Modificator Date: Mon, 27 Jan 2020 17:22:30 +0800 Subject: [PATCH 003/296] add e-ink mode --- app/src/main/java/io/legado/app/utils/ContextExtensions.kt | 3 +++ app/src/main/res/values/strings.xml | 3 ++- app/src/main/res/xml/pref_main.xml | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) 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 7b920dfa7..e53b33e30 100644 --- a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt @@ -129,5 +129,8 @@ fun Context.shareWithQr(title: String, text: String) { val Context.isNightTheme: Boolean get() = getPrefBoolean("isNightTheme") +val Context.isEInkMode: Boolean + get() = getPrefBoolean("isEInkMode") + val Context.isTransparentStatusBar: Boolean get() = getPrefBoolean("transparentStatusBar", true) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 12ceceb6d..d481ccdff 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -77,7 +77,7 @@ 共%s个Text文件 加载中… 重试 - Web服务 + Web 服务 web编辑书源 http://%s:%d 离线下载 @@ -447,6 +447,7 @@ 切换显示样式 导入本地书籍需存储权限 夜间模式 + E-Ink 模式 本软件需要存储权限来存储备份书籍信息 再按一次退出程序 导入本地书籍需存储权限 diff --git a/app/src/main/res/xml/pref_main.xml b/app/src/main/res/xml/pref_main.xml index 297298599..f59dff9f7 100644 --- a/app/src/main/res/xml/pref_main.xml +++ b/app/src/main/res/xml/pref_main.xml @@ -18,6 +18,12 @@ android:title="@string/night_theme" app:iconSpaceReserved="false" /> + + Date: Wed, 29 Jan 2020 00:02:17 +0800 Subject: [PATCH 004/296] = --- app/src/main/res/xml/pref_main.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/src/main/res/xml/pref_main.xml b/app/src/main/res/xml/pref_main.xml index ea32b2865..29e66e13e 100644 --- a/app/src/main/res/xml/pref_main.xml +++ b/app/src/main/res/xml/pref_main.xml @@ -26,12 +26,6 @@ android:title="@string/eink_theme" app:iconSpaceReserved="false" /> - - Date: Fri, 20 Mar 2020 13:34:47 +0800 Subject: [PATCH 005/296] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=88=91=E7=9A=84UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/config/ThemeConfigFragment.kt | 7 +++++++ .../main/java/io/legado/app/ui/main/my/MyFragment.kt | 6 ------ .../java/io/legado/app/ui/widget/prefs/Preference.kt | 12 ++++++++++-- app/src/main/res/layout/view_preference.xml | 12 +++++++----- app/src/main/res/values/colors.xml | 2 +- app/src/main/res/xml/pref_config_read.xml | 2 +- app/src/main/res/xml/pref_config_theme.xml | 9 +++++++++ app/src/main/res/xml/pref_main.xml | 11 ----------- 8 files changed, 35 insertions(+), 26 deletions(-) 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 da2672841..7b163b3e6 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 @@ -19,6 +19,7 @@ import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ColorUtils import io.legado.app.ui.widget.number.NumberPickerDialog import io.legado.app.ui.widget.prefs.IconListPreference +import io.legado.app.ui.widget.prefs.NameListPreference import io.legado.app.utils.* @@ -33,6 +34,12 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar preferenceScreen.removePreference(it) } } + findPreference(PreferKey.themeMode)?.let { + it.setOnPreferenceChangeListener { _, _ -> + view?.post { App.INSTANCE.applyDayNight() } + true + } + } upPreferenceSummary("barElevation", AppConfig.elevation.toString()) } diff --git a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt index f3087f5e7..d948923e8 100644 --- a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt @@ -79,12 +79,6 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog. observeEvent(EventBus.WEB_SERVICE_STOP) { webServicePre?.isChecked = false } - findPreference(PreferKey.themeMode)?.let { - it.setOnPreferenceChangeListener { _, _ -> - view?.post { App.INSTANCE.applyDayNight() } - true - } - } if (requireContext().channel == "google") { findPreference("aboutCategory") ?.removePreference(findPreference("donate")) diff --git a/app/src/main/java/io/legado/app/ui/widget/prefs/Preference.kt b/app/src/main/java/io/legado/app/ui/widget/prefs/Preference.kt index 0190dcd9f..4bd3610b5 100644 --- a/app/src/main/java/io/legado/app/ui/widget/prefs/Preference.kt +++ b/app/src/main/java/io/legado/app/ui/widget/prefs/Preference.kt @@ -44,11 +44,17 @@ class Preference(context: Context, attrs: AttributeSet) : androidx.preference.Pr iconView.setImageDrawable(icon) iconView.setColorFilter(context.accentColor) } + + val paddingView = it.findViewById(R.id.preference_padding) + if (paddingView != null) { + paddingView.isVisible = view.isVisible && tvSummary != null && tvSummary.isVisible + } } if (weightLayoutRes != null && weightLayoutRes != 0 && viewId != null && viewId != 0) { val lay = it.findViewById(R.id.preference_widget) if (lay is FrameLayout) { + var needRequestLayout = false var v = it.itemView.findViewById(viewId) if (v == null) { val inflater: LayoutInflater = context.layoutInflater @@ -57,7 +63,8 @@ class Preference(context: Context, attrs: AttributeSet) : androidx.preference.Pr lay.addView(childView) lay.isVisible = true v = lay.findViewById(viewId) - } + } else + needRequestLayout = true if (weightWidth > 0 || weightHeight > 0) { val lp = lay.layoutParams @@ -66,7 +73,8 @@ class Preference(context: Context, attrs: AttributeSet) : androidx.preference.Pr if (weightWidth > 0) lp.width = (context.resources.displayMetrics.density * weightWidth).roundToInt() lay.layoutParams = lp - } + } else if (needRequestLayout) + v.requestLayout() return v } diff --git a/app/src/main/res/layout/view_preference.xml b/app/src/main/res/layout/view_preference.xml index 87b10ef5b..2b67899f9 100644 --- a/app/src/main/res/layout/view_preference.xml +++ b/app/src/main/res/layout/view_preference.xml @@ -7,7 +7,7 @@ android:paddingLeft="16dp" android:paddingTop="10dp" android:paddingRight="16dp" - android:paddingBottom="4dp" + android:paddingBottom="10dp" android:minHeight="42dp" android:clickable="true" android:orientation="horizontal" @@ -27,11 +27,11 @@ android:orientation="vertical" android:layout_weight="1.0" android:layout_width="0dp" + android:layout_gravity="center_vertical" android:layout_height="wrap_content"> + + @color/md_grey_50 @color/md_grey_100 @color/md_grey_200 - @color/md_grey_50 + #7fffffff #00000000 #10000000 diff --git a/app/src/main/res/xml/pref_config_read.xml b/app/src/main/res/xml/pref_config_read.xml index ef360b43c..6be6d1e50 100644 --- a/app/src/main/res/xml/pref_config_read.xml +++ b/app/src/main/res/xml/pref_config_read.xml @@ -60,7 +60,7 @@ android:key="selectText" app:iconSpaceReserved="false" /> - diff --git a/app/src/main/res/xml/pref_config_theme.xml b/app/src/main/res/xml/pref_config_theme.xml index bf90dd7ab..ef95487f9 100644 --- a/app/src/main/res/xml/pref_config_theme.xml +++ b/app/src/main/res/xml/pref_config_theme.xml @@ -12,6 +12,15 @@ app:icons="@array/icons" app:iconSpaceReserved="false" /> + + - - From 764bb1b624f92cea76fdc5d5fbc30f06f358e704 Mon Sep 17 00:00:00 2001 From: yangyxd Date: Fri, 20 Mar 2020 14:42:51 +0800 Subject: [PATCH 006/296] =?UTF-8?q?UI=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/drawable/ic_search.xml | 29 +++++++--------- .../main/res/layout/item_bookshelf_grid.xml | 4 +-- .../main/res/layout/item_bookshelf_list.xml | 34 +++++++++---------- app/src/main/res/layout/item_rss.xml | 4 +++ 4 files changed, 34 insertions(+), 37 deletions(-) diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml index 921e00d7a..b6805e004 100644 --- a/app/src/main/res/drawable/ic_search.xml +++ b/app/src/main/res/drawable/ic_search.xml @@ -1,17 +1,12 @@ - - - - + + + + diff --git a/app/src/main/res/layout/item_bookshelf_grid.xml b/app/src/main/res/layout/item_bookshelf_grid.xml index 50bb20d12..f96b8d507 100644 --- a/app/src/main/res/layout/item_bookshelf_grid.xml +++ b/app/src/main/res/layout/item_bookshelf_grid.xml @@ -61,8 +61,8 @@ android:id="@+id/tv_name" android:layout_width="0dp" android:layout_height="wrap_content" - android:paddingLeft="12dp" - android:paddingRight="12dp" + android:paddingLeft="4dp" + android:paddingRight="4dp" android:paddingBottom="4dp" android:includeFontPadding="false" android:gravity="top|center_horizontal" diff --git a/app/src/main/res/layout/item_bookshelf_list.xml b/app/src/main/res/layout/item_bookshelf_list.xml index b381aaa90..d715009d6 100644 --- a/app/src/main/res/layout/item_bookshelf_list.xml +++ b/app/src/main/res/layout/item_bookshelf_list.xml @@ -14,8 +14,8 @@ android:layout_width="60dp" android:layout_height="80dp" android:layout_marginStart="16dp" - android:layout_marginTop="12dp" - android:layout_marginBottom="8dp" + android:layout_marginTop="16dp" + android:layout_marginBottom="12dp" android:contentDescription="@string/img_cover" android:scaleType="centerCrop" android:src="@drawable/image_cover_default" @@ -56,10 +56,11 @@ android:id="@+id/tv_name" android:layout_width="0dp" android:layout_height="wrap_content" - android:layout_marginLeft="8dp" - android:layout_marginTop="8dp" + android:layout_marginLeft="16dp" + android:layout_marginTop="12dp" android:includeFontPadding="false" - android:paddingLeft="4dp" + android:paddingBottom="4dp" + android:paddingLeft="2dp" android:singleLine="true" android:text="@string/book_name" android:textColor="@color/tv_text_default" @@ -74,15 +75,14 @@ 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_constraintLeft_toLeftOf="@+id/tv_name" app:layout_constraintTop_toTopOf="@+id/tv_author" - app:tint="@color/tv_text_secondary" + app:tint="@color/tv_text_summary" tools:ignore="RtlHardcoded,RtlSymmetry" /> \ No newline at end of file diff --git a/app/src/main/res/layout/item_rss.xml b/app/src/main/res/layout/item_rss.xml index b06e2e37b..f3765bf58 100644 --- a/app/src/main/res/layout/item_rss.xml +++ b/app/src/main/res/layout/item_rss.xml @@ -20,6 +20,10 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="16dp" + android:textSize="13sp" + android:gravity="top|center_horizontal" + android:lines="2" + android:ellipsize="end" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toBottomOf="@+id/iv_icon" /> From 1ece88762e4dffcb5224a72a77021257484d93b0 Mon Sep 17 00:00:00 2001 From: yangyxd Date: Fri, 20 Mar 2020 15:59:39 +0800 Subject: [PATCH 007/296] =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/main/MainActivity.kt | 6 +++ .../ui/main/bookshelf/BookshelfFragment.kt | 4 ++ .../main/java/io/legado/app/utils/UIUtils.kt | 27 ++++++++++++ app/src/main/res/drawable/ic_add.xml | 20 ++++----- app/src/main/res/drawable/ic_add_online.xml | 26 ++++++----- app/src/main/res/drawable/ic_arrange.xml | 38 +++++++++------- .../main/res/drawable/ic_download_line.xml | 26 +++++------ app/src/main/res/drawable/ic_groups.xml | 29 ++++-------- app/src/main/res/drawable/ic_more.xml | 15 +++++++ app/src/main/res/drawable/ic_search.xml | 17 ++++--- app/src/main/res/drawable/ic_view_quilt.xml | 44 ++++++++----------- .../main/res/layout/item_bookshelf_list.xml | 9 +--- 12 files changed, 147 insertions(+), 114 deletions(-) create mode 100644 app/src/main/java/io/legado/app/utils/UIUtils.kt create mode 100644 app/src/main/res/drawable/ic_more.xml 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 0aa49ede7..859f63d9e 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,8 +1,13 @@ package io.legado.app.ui.main +import android.graphics.drawable.Drawable +import android.os.Build import android.os.Bundle import android.view.KeyEvent import android.view.MenuItem +import android.widget.Toolbar +import androidx.annotation.RequiresApi +import androidx.core.content.ContextCompat import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentStatePagerAdapter @@ -25,6 +30,7 @@ import io.legado.app.ui.main.rss.RssFragment import io.legado.app.ui.widget.dialog.TextDialog import io.legado.app.utils.* import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.view_title_bar.* class MainActivity : VMBaseActivity(R.layout.activity_main), BottomNavigationView.OnNavigationItemSelectedListener, diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt index 55dca8d77..ec3debf64 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt @@ -1,12 +1,15 @@ package io.legado.app.ui.main.bookshelf import android.annotation.SuppressLint +import android.os.Build import android.os.Bundle import android.view.LayoutInflater import android.view.Menu import android.view.MenuItem import android.view.View import androidx.appcompat.widget.SearchView +import androidx.appcompat.widget.Toolbar +import androidx.core.content.ContextCompat import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentStatePagerAdapter @@ -58,6 +61,7 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b setSupportToolbar(toolbar) initView() initBookGroupData() + UIUtils.setToolbarMoreIconCustomColor(toolbar) } override fun onCompatCreateOptionsMenu(menu: Menu) { diff --git a/app/src/main/java/io/legado/app/utils/UIUtils.kt b/app/src/main/java/io/legado/app/utils/UIUtils.kt new file mode 100644 index 000000000..e5ffa1881 --- /dev/null +++ b/app/src/main/java/io/legado/app/utils/UIUtils.kt @@ -0,0 +1,27 @@ +package io.legado.app.utils + +import android.graphics.ColorFilter +import android.graphics.PorterDuff +import android.graphics.PorterDuffColorFilter +import android.os.Build +import androidx.appcompat.widget.Toolbar +import androidx.core.content.ContextCompat +import io.legado.app.R + +@Suppress("unused") +object UIUtils { + + /** 设置更多工具条图标和颜色 */ + fun setToolbarMoreIconCustomColor(toolbar: Toolbar, colorId: Int? = null) { + if (toolbar == null) + return + val moreIcon = ContextCompat.getDrawable(toolbar.context, R.drawable.ic_more) + if(moreIcon != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (colorId != null ) { + moreIcon.colorFilter = PorterDuffColorFilter(ContextCompat.getColor(toolbar.context, colorId), PorterDuff.Mode.SRC_ATOP) + } + toolbar.overflowIcon = moreIcon + } + } + +} \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_add.xml b/app/src/main/res/drawable/ic_add.xml index c7542ba87..97328c410 100644 --- a/app/src/main/res/drawable/ic_add.xml +++ b/app/src/main/res/drawable/ic_add.xml @@ -1,11 +1,9 @@ - - - - - \ No newline at end of file + + + diff --git a/app/src/main/res/drawable/ic_add_online.xml b/app/src/main/res/drawable/ic_add_online.xml index 8a3cc9b8b..c7f649fd4 100644 --- a/app/src/main/res/drawable/ic_add_online.xml +++ b/app/src/main/res/drawable/ic_add_online.xml @@ -1,11 +1,15 @@ - - - - - \ No newline at end of file + + + + + diff --git a/app/src/main/res/drawable/ic_arrange.xml b/app/src/main/res/drawable/ic_arrange.xml index ce2d50152..cf0600e77 100644 --- a/app/src/main/res/drawable/ic_arrange.xml +++ b/app/src/main/res/drawable/ic_arrange.xml @@ -1,17 +1,21 @@ - - - - - - - \ No newline at end of file + + + + + + + diff --git a/app/src/main/res/drawable/ic_download_line.xml b/app/src/main/res/drawable/ic_download_line.xml index 3b0ae72ea..7f9bcad59 100644 --- a/app/src/main/res/drawable/ic_download_line.xml +++ b/app/src/main/res/drawable/ic_download_line.xml @@ -1,14 +1,12 @@ - - - - - - \ No newline at end of file + + + + diff --git a/app/src/main/res/drawable/ic_groups.xml b/app/src/main/res/drawable/ic_groups.xml index 0ebcd4526..165d4b705 100644 --- a/app/src/main/res/drawable/ic_groups.xml +++ b/app/src/main/res/drawable/ic_groups.xml @@ -1,20 +1,9 @@ - - - - - - - - \ No newline at end of file + + + diff --git a/app/src/main/res/drawable/ic_more.xml b/app/src/main/res/drawable/ic_more.xml new file mode 100644 index 000000000..b0357ce02 --- /dev/null +++ b/app/src/main/res/drawable/ic_more.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml index b6805e004..f207ed0a4 100644 --- a/app/src/main/res/drawable/ic_search.xml +++ b/app/src/main/res/drawable/ic_search.xml @@ -1,12 +1,15 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:pathData="M11,5.49A5.49,5.49 0,1 1,7.1 7.1,5.44 5.44,0 0,1 11,5.49M11,4a7,7 0,1 0,4.94 2A7,7 0,0 0,11 4Z" + android:fillColor="#202020"/> + + android:pathData="M17.14,16.39a0.74,0.74 0,0 0,-0.53 0.22,0.75 0.75,0 0,0 0,1.06l2.11,2.11a0.74,0.74 0,0 0,0.53 0.22,0.73 0.73,0 0,0 0.53,-0.22 0.75,0.75 0,0 0,0 -1.06l-2.11,-2.11a0.74,0.74 0,0 0,-0.53 -0.22Z"/> diff --git a/app/src/main/res/drawable/ic_view_quilt.xml b/app/src/main/res/drawable/ic_view_quilt.xml index a0fb3d300..eecbde250 100644 --- a/app/src/main/res/drawable/ic_view_quilt.xml +++ b/app/src/main/res/drawable/ic_view_quilt.xml @@ -1,26 +1,18 @@ - - - - - - - - \ 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 d715009d6..3d6f71213 100644 --- a/app/src/main/res/layout/item_bookshelf_list.xml +++ b/app/src/main/res/layout/item_bookshelf_list.xml @@ -56,7 +56,7 @@ android:id="@+id/tv_name" android:layout_width="0dp" android:layout_height="wrap_content" - android:layout_marginLeft="16dp" + android:layout_marginLeft="10dp" android:layout_marginTop="12dp" android:includeFontPadding="false" android:paddingBottom="4dp" @@ -175,12 +175,5 @@ app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" /> - \ No newline at end of file From b758beaf0980676698a603ec89c8154187b7c945 Mon Sep 17 00:00:00 2001 From: yangyxd Date: Fri, 20 Mar 2020 16:42:52 +0800 Subject: [PATCH 008/296] =?UTF-8?q?=E8=B0=83=E6=95=B4UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/base/BaseFragment.kt | 5 ++++ .../ui/main/bookshelf/BookshelfFragment.kt | 1 - .../io/legado/app/utils/MenuExtensions.kt | 7 +----- .../main/java/io/legado/app/utils/UIUtils.kt | 23 +++++++++++++++---- app/src/main/res/drawable/ic_groups.xml | 12 +++++----- app/src/main/res/drawable/ic_groups_menu.xml | 9 ++++++++ app/src/main/res/menu/main_bookshelf.xml | 2 +- 7 files changed, 41 insertions(+), 18 deletions(-) create mode 100644 app/src/main/res/drawable/ic_groups_menu.xml 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 c19033aa8..c0b41fc40 100644 --- a/app/src/main/java/io/legado/app/base/BaseFragment.kt +++ b/app/src/main/java/io/legado/app/base/BaseFragment.kt @@ -6,7 +6,11 @@ import android.view.* import androidx.appcompat.view.SupportMenuInflater import androidx.appcompat.widget.Toolbar import androidx.fragment.app.Fragment +import io.legado.app.R +import io.legado.app.constant.Theme +import io.legado.app.utils.UIUtils import io.legado.app.utils.applyTint +import kotlinx.android.synthetic.main.view_title_bar.* import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -52,6 +56,7 @@ abstract class BaseFragment(layoutID: Int) : Fragment(layoutID), supportToolbar?.let { it.menu.apply { onCompatCreateOptionsMenu(this) + UIUtils.setToolbarMoreIconCustomColor(toolbar, UIUtils.getMenuColor(requireContext())) applyTint(requireContext()) } diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt index ec3debf64..5cf6de284 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt @@ -61,7 +61,6 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b setSupportToolbar(toolbar) initView() initBookGroupData() - UIUtils.setToolbarMoreIconCustomColor(toolbar) } override fun onCompatCreateOptionsMenu(menu: Menu) { 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 9f13d543d..9167eda46 100644 --- a/app/src/main/java/io/legado/app/utils/MenuExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/MenuExtensions.kt @@ -19,13 +19,8 @@ fun Menu.applyTint(context: Context, theme: Theme = Theme.Auto): Menu = this.let if (menu is MenuBuilder) { menu.setOptionalIconsVisible(true) } - val primaryTextColor = context.primaryTextColor val defaultTextColor = context.getCompatColor(R.color.tv_text_default) - val tintColor = when (theme) { - Theme.Dark -> context.getCompatColor(R.color.md_white_1000) - Theme.Light -> context.getCompatColor(R.color.md_black_1000) - else -> primaryTextColor - } + val tintColor = UIUtils.getMenuColor(context, theme) menu.forEach { item -> (item as MenuItemImpl).let { impl -> //overflow:展开的item diff --git a/app/src/main/java/io/legado/app/utils/UIUtils.kt b/app/src/main/java/io/legado/app/utils/UIUtils.kt index e5ffa1881..9b2db69ff 100644 --- a/app/src/main/java/io/legado/app/utils/UIUtils.kt +++ b/app/src/main/java/io/legado/app/utils/UIUtils.kt @@ -1,27 +1,42 @@ package io.legado.app.utils -import android.graphics.ColorFilter +import android.content.Context import android.graphics.PorterDuff import android.graphics.PorterDuffColorFilter import android.os.Build import androidx.appcompat.widget.Toolbar import androidx.core.content.ContextCompat import io.legado.app.R +import io.legado.app.constant.Theme +import io.legado.app.lib.theme.primaryTextColor @Suppress("unused") object UIUtils { /** 设置更多工具条图标和颜色 */ - fun setToolbarMoreIconCustomColor(toolbar: Toolbar, colorId: Int? = null) { + fun setToolbarMoreIconCustomColor(toolbar: Toolbar, color: Int? = null) { if (toolbar == null) return val moreIcon = ContextCompat.getDrawable(toolbar.context, R.drawable.ic_more) if(moreIcon != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - if (colorId != null ) { - moreIcon.colorFilter = PorterDuffColorFilter(ContextCompat.getColor(toolbar.context, colorId), PorterDuff.Mode.SRC_ATOP) + if (color != null ) { + moreIcon.colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP) } toolbar.overflowIcon = moreIcon } } + + fun getMenuColor(context: Context, theme: Theme = Theme.Auto, requiresOverflow: Boolean = false): Int { + val defaultTextColor = context.getCompatColor(R.color.tv_text_default) + if (requiresOverflow) + return defaultTextColor + val primaryTextColor = context.primaryTextColor + return when (theme) { + Theme.Dark -> context.getCompatColor(R.color.md_white_1000) + Theme.Light -> context.getCompatColor(R.color.md_black_1000) + else -> primaryTextColor + } + } + } \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_groups.xml b/app/src/main/res/drawable/ic_groups.xml index 165d4b705..f79df8df8 100644 --- a/app/src/main/res/drawable/ic_groups.xml +++ b/app/src/main/res/drawable/ic_groups.xml @@ -1,9 +1,9 @@ + android:width="16dp" + android:height="16dp" + android:viewportWidth="16" + android:viewportHeight="16"> + android:fillColor="#FF000000" + android:pathData="M15,0L6.15,0a1,1 0,0 0,-1 1L5.15,2.25L1,2.25a1,1 0,0 0,-1 1v9.5a1,1 0,0 0,1 1L5.17,13.75L5.17,15a1,1 0,0 0,1 1L15,16a1,1 0,0 0,1 -1L16,11a1,1 0,0 0,-1 -1L6.15,10a1,1 0,0 0,-1 1v1.25L1.48,12.25L1.48,3.75L5.17,3.75L5.17,5a1,1 0,0 0,1 1L15,6a1,1 0,0 0,1 -1L16,1a1,1 0,0 0,-1 -1ZM6.65,4.5v-3h7.87v3ZM6.65,14.5v-3h7.87v3Z"/> diff --git a/app/src/main/res/drawable/ic_groups_menu.xml b/app/src/main/res/drawable/ic_groups_menu.xml new file mode 100644 index 000000000..165d4b705 --- /dev/null +++ b/app/src/main/res/drawable/ic_groups_menu.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/menu/main_bookshelf.xml b/app/src/main/res/menu/main_bookshelf.xml index 1c63a7629..867eab0f4 100644 --- a/app/src/main/res/menu/main_bookshelf.xml +++ b/app/src/main/res/menu/main_bookshelf.xml @@ -28,7 +28,7 @@ From 89d6a365cddc1e6c5ad3db48fb909b64f5021601 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 26 Apr 2020 13:40:34 +0800 Subject: [PATCH 009/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/help/storage/ImportOldData.kt | 4 +- .../io/legado/app/help/storage/OldReplace.kt | 32 ++++++ .../io/legado/app/help/storage/OldRule.kt | 106 ++++++++++++------ 3 files changed, 106 insertions(+), 36 deletions(-) create mode 100644 app/src/main/java/io/legado/app/help/storage/OldReplace.kt diff --git a/app/src/main/java/io/legado/app/help/storage/ImportOldData.kt b/app/src/main/java/io/legado/app/help/storage/ImportOldData.kt index 4af39cbb2..9882e4d4f 100644 --- a/app/src/main/java/io/legado/app/help/storage/ImportOldData.kt +++ b/app/src/main/java/io/legado/app/help/storage/ImportOldData.kt @@ -136,14 +136,12 @@ object ImportOldData { return bookSources.size } - - fun importOldReplaceRule(json: String): Int { val replaceRules = mutableListOf() val items: List> = Restore.jsonPath.parse(json).read("$") for (item in items) { val jsonItem = Restore.jsonPath.parse(item) - OldRule.jsonToReplaceRule(jsonItem.jsonString())?.let { + OldReplace.jsonToReplaceRule(jsonItem.jsonString())?.let { if (it.isValid()){ replaceRules.add(it) } diff --git a/app/src/main/java/io/legado/app/help/storage/OldReplace.kt b/app/src/main/java/io/legado/app/help/storage/OldReplace.kt new file mode 100644 index 000000000..d658106dc --- /dev/null +++ b/app/src/main/java/io/legado/app/help/storage/OldReplace.kt @@ -0,0 +1,32 @@ +package io.legado.app.help.storage + +import io.legado.app.data.entities.ReplaceRule +import io.legado.app.utils.* + +object OldReplace { + + fun jsonToReplaceRule(json: String): ReplaceRule? { + var replaceRule: ReplaceRule? = null + runCatching { + replaceRule = GSON.fromJsonObject(json.trim()) + } + runCatching { + if (replaceRule == null || replaceRule?.pattern.isNullOrBlank()) { + val jsonItem = Restore.jsonPath.parse(json.trim()) + val rule = ReplaceRule() + rule.id = jsonItem.readLong("$.id") ?: System.currentTimeMillis() + rule.pattern = jsonItem.readString("$.regex") ?: "" + if (rule.pattern.isEmpty()) return null + rule.name = jsonItem.readString("$.replaceSummary") ?: "" + rule.replacement = jsonItem.readString("$.replacement") ?: "" + rule.isRegex = jsonItem.readBool("$.isRegex") == true + rule.scope = jsonItem.readString("$.useTo") + rule.isEnabled = jsonItem.readBool("$.enable") == true + rule.order = jsonItem.readInt("$.serialNumber") ?: 0 + return rule + } + } + return replaceRule + } + +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/help/storage/OldRule.kt b/app/src/main/java/io/legado/app/help/storage/OldRule.kt index 32af1f9f5..a91766bde 100644 --- a/app/src/main/java/io/legado/app/help/storage/OldRule.kt +++ b/app/src/main/java/io/legado/app/help/storage/OldRule.kt @@ -3,7 +3,6 @@ package io.legado.app.help.storage import io.legado.app.constant.AppConst import io.legado.app.constant.BookType import io.legado.app.data.entities.BookSource -import io.legado.app.data.entities.ReplaceRule import io.legado.app.data.entities.rule.* import io.legado.app.help.storage.Restore.jsonPath import io.legado.app.utils.* @@ -14,13 +13,15 @@ object OldRule { private val jsPattern = Pattern.compile("\\{\\{.+?\\}\\}", Pattern.CASE_INSENSITIVE) fun jsonToBookSource(json: String): BookSource? { - var source: BookSource? = null - runCatching { - source = GSON.fromJsonObject(json.trim()) + val source = BookSource() + val sourceAny = try { + GSON.fromJsonObject(json.trim()) + } catch (e: Exception) { + null } runCatching { - if (source == null || source?.ruleToc == null) { - source = BookSource().apply { + if (sourceAny?.ruleToc == null) { + source.apply { val jsonItem = jsonPath.parse(json.trim()) bookSourceUrl = jsonItem.readString("bookSourceUrl") ?: "" bookSourceName = jsonItem.readString("bookSourceName") ?: "" @@ -82,11 +83,73 @@ object OldRule { nextContentUrl = toNewRule(jsonItem.readString("ruleContentUrlNext")) ) } + } else { + source.bookSourceUrl = sourceAny.bookSourceUrl + source.bookSourceName = sourceAny.bookSourceName + source.bookSourceGroup = sourceAny.bookSourceGroup + source.bookSourceType = sourceAny.bookSourceType + source.bookUrlPattern = sourceAny.bookUrlPattern + source.customOrder = sourceAny.customOrder + source.enabled = sourceAny.enabled + source.enabledExplore = sourceAny.enabledExplore + source.header = sourceAny.header + source.loginUrl = sourceAny.loginUrl + source.lastUpdateTime = sourceAny.lastUpdateTime + source.weight = sourceAny.weight + source.exploreUrl = sourceAny.exploreUrl + source.ruleExplore = if (sourceAny.ruleExplore is String) { + GSON.fromJsonObject(sourceAny.ruleExplore as? String) + } else { + GSON.fromJsonObject(GSON.toJson(sourceAny.ruleExplore)) + } + source.searchUrl = sourceAny.searchUrl + source.ruleSearch = if (sourceAny.ruleSearch is String) { + GSON.fromJsonObject(sourceAny.ruleSearch as? String) + } else { + GSON.fromJsonObject(GSON.toJson(sourceAny.ruleSearch)) + } + source.ruleBookInfo = if (sourceAny.ruleBookInfo is String) { + GSON.fromJsonObject(sourceAny.ruleBookInfo as? String) + } else { + GSON.fromJsonObject(GSON.toJson(sourceAny.ruleBookInfo)) + } + source.ruleToc = if (sourceAny.ruleToc is String) { + GSON.fromJsonObject(sourceAny.ruleToc as? String) + } else { + GSON.fromJsonObject(GSON.toJson(sourceAny.ruleToc)) + } + source.ruleContent = if (sourceAny.ruleContent is String) { + GSON.fromJsonObject(sourceAny.ruleContent as? String) + } else { + GSON.fromJsonObject(GSON.toJson(sourceAny.ruleContent)) + } } } return source } + data class BookSourceAny( + var bookSourceName: String = "", // 名称 + var bookSourceGroup: String? = null, // 分组 + var bookSourceUrl: String = "", // 地址,包括 http/https + var bookSourceType: Int = BookType.default, // 类型,0 文本,1 音频 + var bookUrlPattern: String? = null, // 详情页url正则 + var customOrder: Int = 0, // 手动排序编号 + var enabled: Boolean = true, // 是否启用 + var enabledExplore: Boolean = true, // 启用发现 + var header: String? = null, // 请求头 + var loginUrl: String? = null, // 登录地址 + var lastUpdateTime: Long = 0, // 最后更新时间,用于排序 + var weight: Int = 0, // 智能排序的权重 + var exploreUrl: String? = null, // 发现url + var ruleExplore: Any? = null, // 发现规则 + var searchUrl: String? = null, // 搜索url + var ruleSearch: Any? = null, // 搜索规则 + var ruleBookInfo: Any? = null, // 书籍信息页规则 + var ruleToc: Any? = null, // 目录页规则 + var ruleContent: Any? = null // 正文页规则 + ) + // default规则适配 // #正则#替换内容 替换成 ##正则##替换内容 // | 替换成 || @@ -109,8 +172,8 @@ object OldRule { !newRule.startsWith("//") && !newRule.startsWith("##") && !newRule.startsWith(":") && - !newRule.contains("@js:",true) && - !newRule.contains("",true) + !newRule.contains("@js:", true) && + !newRule.contains("", true) ) { if (newRule.contains("#") && !newRule.contains("##")) { newRule = oldRule.replace("#", "##") @@ -137,10 +200,10 @@ object OldRule { } } if (allinone) { - newRule = "+" + newRule + newRule = "+$newRule" } if (reverse) { - newRule = "-" + newRule + newRule = "-$newRule" } return newRule } @@ -211,27 +274,4 @@ object OldRule { return GSON.toJson(map) } - fun jsonToReplaceRule(json: String): ReplaceRule? { - var replaceRule: ReplaceRule? = null - runCatching { - replaceRule = GSON.fromJsonObject(json.trim()) - } - runCatching { - if (replaceRule == null || replaceRule?.pattern.isNullOrBlank()) { - val jsonItem = jsonPath.parse(json.trim()) - val rule = ReplaceRule() - rule.id = jsonItem.readLong("$.id") ?: System.currentTimeMillis() - rule.pattern = jsonItem.readString("$.regex") ?: "" - if (rule.pattern.isEmpty()) return null - rule.name = jsonItem.readString("$.replaceSummary") ?: "" - rule.replacement = jsonItem.readString("$.replacement") ?: "" - rule.isRegex = jsonItem.readBool("$.isRegex") == true - rule.scope = jsonItem.readString("$.useTo") - rule.isEnabled = jsonItem.readBool("$.enable") == true - rule.order = jsonItem.readInt("$.serialNumber") ?: 0 - return rule - } - } - return replaceRule - } } From d796a70f783efbc3f6c5826683e521f707f663d6 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 26 Apr 2020 15:32:46 +0800 Subject: [PATCH 010/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 82912fde4..b13c69030 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/04/26** +* 添加导入旧的书源转换 + **2020/04/25** * 修复翻页按键设置为空时崩溃的bug * 翻页按键优先自定义按键,可覆盖音量按键 From 507fbdee701cea8a61ca3d0c4e4982b1a5700a0b Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 26 Apr 2020 19:17:11 +0800 Subject: [PATCH 011/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/constant/AppConst.kt | 11 +++++++++++ .../ui/book/source/edit/BookSourceEditActivity.kt | 11 +---------- .../app/ui/rss/source/edit/RssSourceEditActivity.kt | 12 +----------- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/io/legado/app/constant/AppConst.kt b/app/src/main/java/io/legado/app/constant/AppConst.kt index c9e5a6c39..cf37e2b10 100644 --- a/app/src/main/java/io/legado/app/constant/AppConst.kt +++ b/app/src/main/java/io/legado/app/constant/AppConst.kt @@ -56,4 +56,15 @@ object AppConst { const val notificationIdAudio = 1144772 const val notificationIdWeb = 1144773 const val notificationIdDownload = 1144774 + + val urlOption: String by lazy { + """ + ,{ + "charset": "", + "method": "POST", + "body": "", + "headers": {"User-Agent": ""} + } + """.trimIndent() + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt index c1d64776f..71ee36149 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt @@ -367,16 +367,7 @@ class BookSourceEditActivity : override fun sendText(text: String) { if (text == AppConst.keyboardToolChars[0]) { - insertText( - """ - ,{ - "charset": "", - "method": "POST", - "body": "", - "headers": {"User-Agent": ""} - } - """.trimIndent() - ) + insertText(AppConst.urlOption) } else { insertText(text) } diff --git a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt index ed18f8b69..d1e1b52e7 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt @@ -200,17 +200,7 @@ class RssSourceEditActivity : override fun sendText(text: String) { if (text == AppConst.keyboardToolChars[0]) { - insertText( - """ - ,{ - "charset": "", - "method": "POST", - "body": "", - "headers": {"User-Agent": ""} - } - - """.trimIndent() - ) + insertText(AppConst.urlOption) } else { insertText(text) } From f85c16562c591d144601434888163aa53fe81703 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 26 Apr 2020 22:42:16 +0800 Subject: [PATCH 012/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/storage/OldRule.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/io/legado/app/help/storage/OldRule.kt b/app/src/main/java/io/legado/app/help/storage/OldRule.kt index a91766bde..f5919eb2c 100644 --- a/app/src/main/java/io/legado/app/help/storage/OldRule.kt +++ b/app/src/main/java/io/legado/app/help/storage/OldRule.kt @@ -1,5 +1,6 @@ package io.legado.app.help.storage +import androidx.annotation.Keep import io.legado.app.constant.AppConst import io.legado.app.constant.BookType import io.legado.app.data.entities.BookSource @@ -128,6 +129,7 @@ object OldRule { return source } + @Keep data class BookSourceAny( var bookSourceName: String = "", // 名称 var bookSourceGroup: String? = null, // 分组 From acfe4de00833384cf5bc47111c3fc22dc9a19784 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 27 Apr 2020 11:33:29 +0800 Subject: [PATCH 013/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/model/analyzeRule/AnalyzeUrl.kt | 1 + .../io/legado/app/utils/GsonExtensions.kt | 76 ++++++++++++++++++- 2 files changed, 74 insertions(+), 3 deletions(-) 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 20f03797e..f0b9cb3b6 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 @@ -162,6 +162,7 @@ class AnalyzeUrl( options.method?.let { if (it.equals("POST", true)) method = RequestMethod.POST } options.headers?.let { headers -> if (headers is Map<*, *>) { + @Suppress("unchecked_cast") headerMap.putAll(headers as Map) } if (headers is String) { diff --git a/app/src/main/java/io/legado/app/utils/GsonExtensions.kt b/app/src/main/java/io/legado/app/utils/GsonExtensions.kt index 3f736abc5..b2ae3d297 100644 --- a/app/src/main/java/io/legado/app/utils/GsonExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/GsonExtensions.kt @@ -1,15 +1,20 @@ package io.legado.app.utils -import com.google.gson.Gson -import com.google.gson.GsonBuilder -import com.google.gson.JsonSyntaxException +import com.google.gson.* +import com.google.gson.internal.LinkedTreeMap import com.google.gson.reflect.TypeToken import org.jetbrains.anko.attempt import java.lang.reflect.ParameterizedType import java.lang.reflect.Type +import kotlin.math.ceil + val GSON: Gson by lazy { GsonBuilder() + .registerTypeAdapter( + object : TypeToken?>() {}.type, + MapDeserializerDoubleAsIntFix() + ) .disableHtmlEscaping() .setPrettyPrinting() .create() @@ -40,3 +45,68 @@ class ParameterizedTypeImpl(private val clazz: Class<*>) : ParameterizedType { override fun getActualTypeArguments(): Array = arrayOf(clazz) } + +/** + * 修复Int变为Double的问题 + */ +class MapDeserializerDoubleAsIntFix : + JsonDeserializer?> { + + @Throws(JsonParseException::class) + override fun deserialize( + jsonElement: JsonElement, + type: Type, + jsonDeserializationContext: JsonDeserializationContext + ): Map? { + @Suppress("unchecked_cast") + return read(jsonElement) as? Map + } + + fun read(`in`: JsonElement): Any? { + when { + `in`.isJsonArray -> { + val list: MutableList = ArrayList() + val arr = `in`.asJsonArray + for (anArr in arr) { + list.add(read(anArr)) + } + return list + } + `in`.isJsonObject -> { + val map: MutableMap = + LinkedTreeMap() + val obj = `in`.asJsonObject + val entitySet = + obj.entrySet() + for ((key, value) in entitySet) { + map[key] = read(value) + } + return map + } + `in`.isJsonPrimitive -> { + val prim = `in`.asJsonPrimitive + when { + prim.isBoolean -> { + return prim.asBoolean + } + prim.isString -> { + return prim.asString + } + prim.isNumber -> { + val num: Number = prim.asNumber + // here you can handle double int/long values + // and return any type you want + // this solution will transform 3.0 float to long values + return if (ceil(num.toDouble()) == num.toLong().toDouble()) { + num.toLong() + } else { + num.toDouble() + } + } + } + } + } + return null + } + +} \ No newline at end of file From b3bc9ac976e63e93e79937855072c700b188742c Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 27 Apr 2020 12:30:59 +0800 Subject: [PATCH 014/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/utils/GsonExtensions.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/utils/GsonExtensions.kt b/app/src/main/java/io/legado/app/utils/GsonExtensions.kt index b2ae3d297..773cd8030 100644 --- a/app/src/main/java/io/legado/app/utils/GsonExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/GsonExtensions.kt @@ -50,16 +50,16 @@ class ParameterizedTypeImpl(private val clazz: Class<*>) : ParameterizedType { * 修复Int变为Double的问题 */ class MapDeserializerDoubleAsIntFix : - JsonDeserializer?> { + JsonDeserializer?> { @Throws(JsonParseException::class) override fun deserialize( jsonElement: JsonElement, type: Type, jsonDeserializationContext: JsonDeserializationContext - ): Map? { + ): Map? { @Suppress("unchecked_cast") - return read(jsonElement) as? Map + return read(jsonElement) as? Map } fun read(`in`: JsonElement): Any? { From 7ddad991608dec94aa5aa57b4dd0225de1f171bc Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 27 Apr 2020 20:22:29 +0800 Subject: [PATCH 015/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/service/BaseReadAloudService.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt b/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt index e4a34da52..64bcf6a80 100644 --- a/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt @@ -116,7 +116,9 @@ abstract class BaseReadAloudService : BaseService(), } } else { textChapter.getUnRead(pageIndex).split("\n").forEach { - contentList.add(it) + if (it.isNotEmpty()) { + contentList.add(it) + } } } if (play) play() From d9c7f73764465598a0a0c56405803ed3506d543f Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 27 Apr 2020 20:23:53 +0800 Subject: [PATCH 016/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index b13c69030..e291d117d 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -5,6 +5,7 @@ **2020/04/26** * 添加导入旧的书源转换 +* 修复不自动朗读下一章的bug **2020/04/25** * 修复翻页按键设置为空时崩溃的bug From a3ddf6a435b846113641d9e57a02f88da3fe6fcc Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 27 Apr 2020 20:45:28 +0800 Subject: [PATCH 017/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/service/TTSReadAloudService.kt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt b/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt index 1f63dac89..8d8c5f39f 100644 --- a/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt @@ -20,11 +20,13 @@ import java.util.* class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener { companion object { - var textToSpeech: TextToSpeech? = null + private var textToSpeech: TextToSpeech? = null fun clearTTS() { - textToSpeech?.stop() - textToSpeech?.shutdown() + textToSpeech?.let { + it.stop() + it.shutdown() + } textToSpeech = null } } @@ -45,9 +47,11 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener @Synchronized override fun onInit(status: Int) { if (status == TextToSpeech.SUCCESS) { - textToSpeech?.language = Locale.CHINA - textToSpeech?.setOnUtteranceProgressListener(TTSUtteranceListener()) - ttsInitFinish = true + textToSpeech?.let { + it.language = Locale.CHINA + it.setOnUtteranceProgressListener(TTSUtteranceListener()) + ttsInitFinish = true + } play() } else { launch { From dd53f0a260d25e67ccb1b5b8cc009347fd88c103 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 27 Apr 2020 20:47:35 +0800 Subject: [PATCH 018/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/service/TTSReadAloudService.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt b/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt index 8d8c5f39f..5cdf939f3 100644 --- a/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt @@ -21,6 +21,7 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener companion object { private var textToSpeech: TextToSpeech? = null + private var ttsInitFinish = false fun clearTTS() { textToSpeech?.let { @@ -28,11 +29,10 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener it.shutdown() } textToSpeech = null + ttsInitFinish = false } } - private var ttsInitFinish = false - override fun onCreate() { super.onCreate() textToSpeech = TextToSpeech(this, this) From 9985f3b61c0ebae551ab2a00f3242feb18870714 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 29 Apr 2020 13:51:30 +0800 Subject: [PATCH 019/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 +- .../app/model/analyzeRule/AnalyzeUrl.kt | 31 +++++++++++-------- .../io/legado/app/ui/main/rss/RssAdapter.kt | 26 ++++++++++++++++ app/src/main/res/menu/rss_main_item.xml | 16 ++++++++++ 4 files changed, 61 insertions(+), 14 deletions(-) create mode 100644 app/src/main/res/menu/rss_main_item.xml diff --git a/app/build.gradle b/app/build.gradle index 844f12227..e8aa82313 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -117,7 +117,7 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" //fireBase - implementation 'com.google.firebase:firebase-core:17.3.0' + implementation 'com.google.firebase:firebase-core:17.4.0' implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1' //androidX 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 f0b9cb3b6..fbd1f28c7 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 @@ -51,7 +51,7 @@ class AnalyzeUrl( private var queryStr: String? = null private val fieldMap = LinkedHashMap() private var charset: String? = null - private var body: Any? = null + private var body: String? = null private var requestBody: RequestBody? = null private var method = RequestMethod.GET @@ -157,10 +157,10 @@ class AnalyzeUrl( baseUrl = it } if (urlArray.size > 1) { - val options = GSON.fromJsonObject(urlArray[1]) - options?.let { _ -> - options.method?.let { if (it.equals("POST", true)) method = RequestMethod.POST } - options.headers?.let { headers -> + val option = GSON.fromJsonObject(urlArray[1]) + option?.let { _ -> + option.method?.let { if (it.equals("POST", true)) method = RequestMethod.POST } + option.headers?.let { headers -> if (headers is Map<*, *>) { @Suppress("unchecked_cast") headerMap.putAll(headers as Map) @@ -170,9 +170,14 @@ class AnalyzeUrl( ?.let { headerMap.putAll(it) } } } - body = options.body - charset = options.charset - options.webView?.let { + + charset = option.charset + body = if (option.body is String) { + option.body + } else { + GSON.toJson(option.body) + } + option.webView?.let { if (it.toString().isNotEmpty()) { useWebView = true } @@ -191,13 +196,13 @@ class AnalyzeUrl( } RequestMethod.POST -> { body?.let { - if (it is String) { - analyzeFields(it) + if (it.isJson()) { + requestBody = RequestBody.create(jsonType, GSON.toJson(it)) } else { - body = RequestBody.create(jsonType, GSON.toJson(it)) + analyzeFields(it) } } ?: let { - body = FormBody.Builder().build() + requestBody = FormBody.Builder().build() } } } @@ -288,7 +293,7 @@ class AnalyzeUrl( params.requestMethod = method params.javaScript = jsStr params.sourceRegex = sourceRegex - params.postData = body?.toString()?.toByteArray() + params.postData = body?.toByteArray() params.tag = tag return HttpHelper.ajax(params) } diff --git a/app/src/main/java/io/legado/app/ui/main/rss/RssAdapter.kt b/app/src/main/java/io/legado/app/ui/main/rss/RssAdapter.kt index d58f7587e..d5ed336e4 100644 --- a/app/src/main/java/io/legado/app/ui/main/rss/RssAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/main/rss/RssAdapter.kt @@ -1,6 +1,8 @@ package io.legado.app.ui.main.rss import android.content.Context +import android.view.View +import androidx.appcompat.widget.PopupMenu import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter @@ -8,6 +10,7 @@ import io.legado.app.data.entities.RssSource import io.legado.app.help.ImageLoader import kotlinx.android.synthetic.main.item_rss.view.* import org.jetbrains.anko.sdk27.listeners.onClick +import org.jetbrains.anko.sdk27.listeners.onLongClick class RssAdapter(context: Context, val callBack: CallBack) : SimpleRecyclerAdapter(context, R.layout.item_rss) { @@ -29,6 +32,29 @@ class RssAdapter(context: Context, val callBack: CallBack) : callBack.openRss(it) } } + holder.itemView.onLongClick { + getItem(holder.layoutPosition)?.let { + showMenu(holder.itemView, it) + } + true + } + } + + private fun showMenu(view: View, rssSource: RssSource) { + val popupMenu = PopupMenu(context, view) + popupMenu.inflate(R.menu.rss_main_item) + popupMenu.setOnMenuItemClickListener { + when (it.itemId) { + R.id.menu_top -> { + } + R.id.menu_edit -> { + } + R.id.menu_del -> { + } + } + true + } + popupMenu.show() } interface CallBack { diff --git a/app/src/main/res/menu/rss_main_item.xml b/app/src/main/res/menu/rss_main_item.xml new file mode 100644 index 000000000..19dc2f30a --- /dev/null +++ b/app/src/main/res/menu/rss_main_item.xml @@ -0,0 +1,16 @@ + + + + + + + + + + \ No newline at end of file From 692b0a0258c3b49f610217a5b2c8850784b50a2b Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 29 Apr 2020 15:05:10 +0800 Subject: [PATCH 020/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 fbd1f28c7..60e2af6f5 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 @@ -197,7 +197,7 @@ class AnalyzeUrl( RequestMethod.POST -> { body?.let { if (it.isJson()) { - requestBody = RequestBody.create(jsonType, GSON.toJson(it)) + requestBody = RequestBody.create(jsonType, it) } else { analyzeFields(it) } From 32324d07528a161cedefcfdf08b976a4601c3f9a Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 29 Apr 2020 15:06:13 +0800 Subject: [PATCH 021/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index e291d117d..a955e1130 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/04/29** +* 修复bug + **2020/04/26** * 添加导入旧的书源转换 * 修复不自动朗读下一章的bug From 9e28739bf3ae07b82630de27a0300de758fc37a8 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 29 Apr 2020 15:17:33 +0800 Subject: [PATCH 022/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt | 2 -- 1 file changed, 2 deletions(-) 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 60e2af6f5..0e6031755 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 @@ -170,7 +170,6 @@ class AnalyzeUrl( ?.let { headerMap.putAll(it) } } } - charset = option.charset body = if (option.body is String) { option.body @@ -208,7 +207,6 @@ class AnalyzeUrl( } } - /** * 解析QueryMap */ From 995dde909680371e59afb771dff5fb65a3292a37 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 29 Apr 2020 17:21:26 +0800 Subject: [PATCH 023/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/main/rss/RssAdapter.kt | 12 +++++------ .../io/legado/app/ui/main/rss/RssFragment.kt | 21 +++++++++++++++++-- .../rss/source/manage/RssSourceViewModel.kt | 3 +-- .../io/legado/app/utils/ViewExtensions.kt | 17 +++++++++++++++ 4 files changed, 43 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/main/rss/RssAdapter.kt b/app/src/main/java/io/legado/app/ui/main/rss/RssAdapter.kt index d5ed336e4..05107ec39 100644 --- a/app/src/main/java/io/legado/app/ui/main/rss/RssAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/main/rss/RssAdapter.kt @@ -45,12 +45,9 @@ class RssAdapter(context: Context, val callBack: CallBack) : popupMenu.inflate(R.menu.rss_main_item) popupMenu.setOnMenuItemClickListener { when (it.itemId) { - R.id.menu_top -> { - } - R.id.menu_edit -> { - } - R.id.menu_del -> { - } + R.id.menu_top -> callBack.toTop(rssSource) + R.id.menu_edit -> callBack.edit(rssSource) + R.id.menu_del -> callBack.del(rssSource) } true } @@ -59,5 +56,8 @@ class RssAdapter(context: Context, val callBack: CallBack) : interface CallBack { fun openRss(rssSource: RssSource) + fun toTop(rssSource: RssSource) + fun edit(rssSource: RssSource) + fun del(rssSource: RssSource) } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/main/rss/RssFragment.kt b/app/src/main/java/io/legado/app/ui/main/rss/RssFragment.kt index 5bb42f081..334ce9e64 100644 --- a/app/src/main/java/io/legado/app/ui/main/rss/RssFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/rss/RssFragment.kt @@ -8,22 +8,27 @@ import androidx.lifecycle.Observer import androidx.recyclerview.widget.GridLayoutManager import io.legado.app.App import io.legado.app.R -import io.legado.app.base.BaseFragment +import io.legado.app.base.VMBaseFragment import io.legado.app.data.entities.RssSource import io.legado.app.lib.theme.ATH import io.legado.app.ui.main.MainViewModel import io.legado.app.ui.rss.article.RssSortActivity import io.legado.app.ui.rss.favorites.RssFavoritesActivity +import io.legado.app.ui.rss.source.edit.RssSourceEditActivity import io.legado.app.ui.rss.source.manage.RssSourceActivity +import io.legado.app.ui.rss.source.manage.RssSourceViewModel +import io.legado.app.utils.getViewModel import io.legado.app.utils.getViewModelOfActivity import io.legado.app.utils.startActivity import kotlinx.android.synthetic.main.fragment_rss.* import kotlinx.android.synthetic.main.view_title_bar.* -class RssFragment : BaseFragment(R.layout.fragment_rss), +class RssFragment : VMBaseFragment(R.layout.fragment_rss), RssAdapter.CallBack { private lateinit var adapter: RssAdapter + override val viewModel: RssSourceViewModel + get() = getViewModel(RssSourceViewModel::class.java) override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { setSupportToolbar(toolbar) @@ -62,4 +67,16 @@ class RssFragment : BaseFragment(R.layout.fragment_rss), override fun openRss(rssSource: RssSource) { startActivity(Pair("url", rssSource.sourceUrl)) } + + override fun toTop(rssSource: RssSource) { + viewModel.topSource(rssSource) + } + + override fun edit(rssSource: RssSource) { + startActivity(Pair("data", rssSource.sourceUrl)) + } + + override fun del(rssSource: RssSource) { + viewModel.del(rssSource) + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt index 42b354709..65c5bc093 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt @@ -147,7 +147,6 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application) null } } - if (null != content) { GSON.fromJsonArray(content)?.let { App.db.rssSourceDao().insert(*it.toTypedArray()) @@ -215,8 +214,8 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application) } App.db.rssSourceDao().insert(*sources.toTypedArray()) return sources.size - } return 0 } + } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/utils/ViewExtensions.kt b/app/src/main/java/io/legado/app/utils/ViewExtensions.kt index e37539851..7ed6d8cd6 100644 --- a/app/src/main/java/io/legado/app/utils/ViewExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ViewExtensions.kt @@ -1,5 +1,6 @@ package io.legado.app.utils +import android.annotation.SuppressLint import android.content.Context import android.graphics.Bitmap import android.graphics.Canvas @@ -11,8 +12,11 @@ import android.view.inputmethod.InputMethodManager import android.widget.RadioGroup import android.widget.SeekBar import androidx.appcompat.app.AppCompatActivity +import androidx.appcompat.view.menu.MenuPopupHelper +import androidx.appcompat.widget.PopupMenu import androidx.core.view.get import io.legado.app.App +import java.lang.reflect.Field private tailrec fun getCompatActivity(context: Context?): AppCompatActivity? { @@ -107,4 +111,17 @@ fun RadioGroup.getCheckedIndex(): Int { fun RadioGroup.checkByIndex(index: Int) { check(get(index).id) +} + +@SuppressLint("RestrictedApi") +fun PopupMenu.show(x: Int, y: Int) { + try { + val field: Field = this.javaClass.getDeclaredField("mPopup") + field.isAccessible = true + (field.get(this) as MenuPopupHelper).show(x, y) + } catch (e: NoSuchFieldException) { + e.printStackTrace() + } catch (e: IllegalAccessException) { + e.printStackTrace() + } } \ No newline at end of file From 1e30b0053d77fbca10d6ab0c61af1eefc1e7eaaf Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 29 Apr 2020 17:22:18 +0800 Subject: [PATCH 024/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index a955e1130..470ceb318 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -5,6 +5,7 @@ **2020/04/29** * 修复bug +* 订阅界面添加长按菜单 **2020/04/26** * 添加导入旧的书源转换 From 563636cea2fa1e8b77a9915aac7f55bfbed26cd5 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 1 May 2020 10:38:55 +0800 Subject: [PATCH 025/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/service/TTSReadAloudService.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt b/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt index 5cdf939f3..0fba1d507 100644 --- a/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt @@ -35,10 +35,15 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener override fun onCreate() { super.onCreate() - textToSpeech = TextToSpeech(this, this) + initTts() upSpeechRate() } + private fun initTts() { + ttsInitFinish = false + textToSpeech = TextToSpeech(this, this) + } + override fun onDestroy() { super.onDestroy() clearTTS() @@ -98,7 +103,7 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener if (this.getPrefBoolean("ttsFollowSys", true)) { if (reset) { clearTTS() - textToSpeech = TextToSpeech(this, this) + initTts() } } else { textToSpeech?.setSpeechRate((AppConfig.ttsSpeechRate + 5) / 10f) From a7f35e66f856680c1a701722c11cf4349ffa0fb5 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 1 May 2020 10:39:58 +0800 Subject: [PATCH 026/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 470ceb318..e524493bd 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/05/01** +* 尝试修复朗读时可能错位的bug + **2020/04/29** * 修复bug * 订阅界面添加长按菜单 From d9224fa38943be7ed4f22f7ca6dbcc1359442634 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 1 May 2020 17:45:46 +0800 Subject: [PATCH 027/296] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=8D=A2=E6=BA=90=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/AppConfig.kt | 2 ++ .../java/io/legado/app/ui/book/read/ReadBookViewModel.kt | 2 ++ app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/pref_config_read.xml | 6 ++++++ 4 files changed, 11 insertions(+) diff --git a/app/src/main/java/io/legado/app/help/AppConfig.kt b/app/src/main/java/io/legado/app/help/AppConfig.kt index 9d2a3f679..547322cce 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -127,6 +127,8 @@ object AppConfig { App.INSTANCE.putPrefInt("elevation", value) } + val autoChangeSource: Boolean get() = App.INSTANCE.getPrefBoolean("autoChangeSource", true) + val readBodyToLh: Boolean get() = App.INSTANCE.getPrefBoolean(PreferKey.readBodyToLh, true) val isGooglePlay: Boolean get() = App.INSTANCE.channel == "google" diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt index cc129056a..bf6ad1925 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt @@ -7,6 +7,7 @@ import io.legado.app.R import io.legado.app.base.BaseViewModel import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter +import io.legado.app.help.AppConfig import io.legado.app.help.BookHelp import io.legado.app.help.IntentDataHelp import io.legado.app.model.WebBook @@ -163,6 +164,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { } private fun autoChangeSource(name: String, author: String) { + if (!AppConfig.autoChangeSource) return execute { App.db.bookSourceDao().allTextEnabled.forEach { source -> try { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index edf2698e6..3d3014c89 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -689,5 +689,6 @@ 夜间,强调色 夜间,背景色 夜间,底栏色 + 自动换源 diff --git a/app/src/main/res/xml/pref_config_read.xml b/app/src/main/res/xml/pref_config_read.xml index 6b55f0fcc..1ed0294e5 100644 --- a/app/src/main/res/xml/pref_config_read.xml +++ b/app/src/main/res/xml/pref_config_read.xml @@ -60,6 +60,12 @@ android:key="volumeKeyPageOnPlay" app:iconSpaceReserved="false" /> + + Date: Fri, 1 May 2020 17:46:37 +0800 Subject: [PATCH 028/296] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=8D=A2=E6=BA=90=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index e524493bd..bb0020aa2 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -5,6 +5,7 @@ **2020/05/01** * 尝试修复朗读时可能错位的bug +* 添加自动换源配置 **2020/04/29** * 修复bug From cb1cfe5fed9597b76a160ec8fa4191433f173e4a Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 1 May 2020 22:08:20 +0800 Subject: [PATCH 029/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/about/AboutActivity.kt | 2 +- .../book/changesource/ChangeSourceAdapter.kt | 21 ++++++++++ .../book/changesource/ChangeSourceDialog.kt | 4 ++ .../changesource/ChangeSourceViewModel.kt | 6 +++ .../io/legado/app/ui/main/rss/RssAdapter.kt | 2 +- app/src/main/res/menu/change_source_item.xml | 8 ++++ app/src/main/res/values-zh-rHK/strings.xml | 7 +++- app/src/main/res/values/pref_key_value.xml | 39 ++++++++++--------- app/src/main/res/values/strings.xml | 6 +-- 9 files changed, 69 insertions(+), 26 deletions(-) create mode 100644 app/src/main/res/menu/change_source_item.xml diff --git a/app/src/main/java/io/legado/app/ui/about/AboutActivity.kt b/app/src/main/java/io/legado/app/ui/about/AboutActivity.kt index d86cb39a1..88617509b 100644 --- a/app/src/main/java/io/legado/app/ui/about/AboutActivity.kt +++ b/app/src/main/java/io/legado/app/ui/about/AboutActivity.kt @@ -26,7 +26,7 @@ class AboutActivity : BaseActivity(R.layout.activity_about) { tv_app_summary.post { val span = ForegroundColorSpan(accentColor) val spannableString = SpannableString(tv_app_summary.text) - val start = spannableString.indexOf("开源阅读软件") + val start = spannableString.indexOf(getString(R.string.legado_gzh)) spannableString.setSpan( span, start, start + 6, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt index 132858e0f..287754b84 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt @@ -2,6 +2,8 @@ package io.legado.app.ui.book.changesource import android.content.Context import android.os.Bundle +import android.view.View +import androidx.appcompat.widget.PopupMenu import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter @@ -10,6 +12,7 @@ import io.legado.app.utils.invisible import io.legado.app.utils.visible import kotlinx.android.synthetic.main.item_change_source.view.* import org.jetbrains.anko.sdk27.listeners.onClick +import org.jetbrains.anko.sdk27.listeners.onLongClick class ChangeSourceAdapter(context: Context, val callBack: CallBack) : @@ -43,10 +46,28 @@ class ChangeSourceAdapter(context: Context, val callBack: CallBack) : callBack.changeTo(it) } } + holder.itemView.onLongClick { + showMenu(holder.itemView, getItem(holder.layoutPosition)) + true + } + } + + private fun showMenu(view: View, searchBook: SearchBook?) { + searchBook ?: return + val popupMenu = PopupMenu(context, view) + popupMenu.inflate(R.menu.change_source_item) + popupMenu.setOnMenuItemClickListener { + when (it.itemId) { + R.id.menu_disable_book_source -> callBack.disableSource(searchBook.origin) + } + true + } + popupMenu.show() } interface CallBack { val bookUrl: String? fun changeTo(searchBook: SearchBook) + fun disableSource(sourceUrl: String) } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt index bb60c19d4..75df41680 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt @@ -185,6 +185,10 @@ class ChangeSourceDialog : BaseDialogFragment(), override val bookUrl: String? get() = callBack?.oldBook?.bookUrl + override fun disableSource(sourceUrl: String) { + viewModel.disableSource(sourceUrl) + } + interface CallBack { val oldBook: Book? fun changeTo(book: Book) diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt index b375aed11..48527a32a 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt @@ -165,4 +165,10 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio searchPool.close() } + fun disableSource(sourceUrl: String) { + execute { + + } + } + } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/main/rss/RssAdapter.kt b/app/src/main/java/io/legado/app/ui/main/rss/RssAdapter.kt index 05107ec39..955c5ded3 100644 --- a/app/src/main/java/io/legado/app/ui/main/rss/RssAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/main/rss/RssAdapter.kt @@ -34,7 +34,7 @@ class RssAdapter(context: Context, val callBack: CallBack) : } holder.itemView.onLongClick { getItem(holder.layoutPosition)?.let { - showMenu(holder.itemView, it) + showMenu(holder.itemView.iv_icon, it) } true } diff --git a/app/src/main/res/menu/change_source_item.xml b/app/src/main/res/menu/change_source_item.xml new file mode 100644 index 000000000..49c724fee --- /dev/null +++ b/app/src/main/res/menu/change_source_item.xml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 7f07c94e0..8c4f76d1c 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -88,7 +88,7 @@ 下載已選擇的章節到本地 換源 - \u3000\u3000這是一款使用 Kotlin 全新開發的開源的閲讀應用程式,歡迎你的加入。關注公眾號[开源阅读软件]! + \u3000\u3000這是一款使用 Kotlin 全新開發的開源的閲讀應用程式,歡迎你的加入。關注公眾號[开源阅读]! 閲讀3.0下載地址:\nhttps://play.google.com/store/apps/details?id=io.legado.app @@ -664,7 +664,7 @@ 關注公衆號 WeChat 你的支持是我更新的動力 - 公众号[开源阅读软件] + 公众号[开源阅读] 正在自動換源 點擊加入 @@ -685,4 +685,7 @@ 夜間,強調色 夜間,背景色 夜間,導航欄顏色 + 隐藏页眉 + 隐藏页脚 + 自动换源 diff --git a/app/src/main/res/values/pref_key_value.xml b/app/src/main/res/values/pref_key_value.xml index e9aef95f4..f1f70b8c5 100644 --- a/app/src/main/res/values/pref_key_value.xml +++ b/app/src/main/res/values/pref_key_value.xml @@ -1,22 +1,23 @@ - - auto_refresh - list_screen_direction - full_screen - threads_num - user_agent - bookshelf_px - read_type - expandGroupFind - defaultToRead - autoDownload - checkUpdate + + auto_refresh + list_screen_direction + full_screen + threads_num + user_agent + bookshelf_px + read_type + expandGroupFind + defaultToRead + autoDownload + checkUpdate + 开源阅读 - https://gitee.com/alanskycn/yuedu/blob/master/Rule/README.md - https://github.com/gedoor/legado - https://github.com/gedoor/legado/graphs/contributors - https://gedoor.github.io/MyBookshelf/disclaimer.html - https://gedoor.github.io/MyBookshelf/ - https://github.com/gedoor/legado/releases/latest - https://api.github.com/repos/gedoor/legado/releases/latest + https://gitee.com/alanskycn/yuedu/blob/master/Rule/README.md + https://github.com/gedoor/legado + https://github.com/gedoor/legado/graphs/contributors + https://gedoor.github.io/MyBookshelf/disclaimer.html + https://gedoor.github.io/MyBookshelf/ + https://github.com/gedoor/legado/releases/latest + https://api.github.com/repos/gedoor/legado/releases/latest diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3d3014c89..b3783a88b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -88,7 +88,7 @@ 下载选择的章节到本地 换源 - \u3000\u3000这是一款使用Kotlin全新开发的开源的阅读软件,欢迎您的加入。关注公众号[开源阅读软件]! + \u3000\u3000这是一款使用Kotlin全新开发的开源的阅读软件,欢迎您的加入。关注公众号[开源阅读]! 阅读3.0下载地址:\nhttps://play.google.com/store/apps/details?id=io.legado.app @@ -662,11 +662,11 @@ 联系我们 开源许可 其它 - 开源阅读软件 + 开源阅读 关注公众号 微信 您的支持是我更新的动力 - 公众号[开源阅读软件] + 公众号[开源阅读] 正在自动换源 点击加入 From ea74a093fb31d3e26321bc0e8e7e3dba23f6d39d Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 1 May 2020 22:57:28 +0800 Subject: [PATCH 030/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/book/changesource/ChangeSourceViewModel.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt index 48527a32a..93b02a425 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt @@ -167,7 +167,10 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio fun disableSource(sourceUrl: String) { execute { - + App.db.bookSourceDao().getBookSource(sourceUrl)?.let { source -> + source.enabled = false + App.db.bookSourceDao().update(source) + } } } From 7d59375fc14f3e11953c63254e03467dc1d85eee Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 1 May 2020 23:01:30 +0800 Subject: [PATCH 031/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index bb0020aa2..8daa85570 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -6,6 +6,7 @@ **2020/05/01** * 尝试修复朗读时可能错位的bug * 添加自动换源配置 +* 换源添加禁用菜单 **2020/04/29** * 修复bug From 455418ecaa926a1f6fbb73419fccb0a3c7e83b1b Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 1 May 2020 23:12:50 +0800 Subject: [PATCH 032/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/book/changesource/ChangeSourceAdapter.kt | 7 +++++-- .../legado/app/ui/book/changesource/ChangeSourceDialog.kt | 4 ++-- .../app/ui/book/changesource/ChangeSourceViewModel.kt | 5 +++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt index 287754b84..3a148a2c2 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt @@ -58,7 +58,10 @@ class ChangeSourceAdapter(context: Context, val callBack: CallBack) : popupMenu.inflate(R.menu.change_source_item) popupMenu.setOnMenuItemClickListener { when (it.itemId) { - R.id.menu_disable_book_source -> callBack.disableSource(searchBook.origin) + R.id.menu_disable_book_source -> { + callBack.disableSource(searchBook) + removeItem(searchBook) + } } true } @@ -68,6 +71,6 @@ class ChangeSourceAdapter(context: Context, val callBack: CallBack) : interface CallBack { val bookUrl: String? fun changeTo(searchBook: SearchBook) - fun disableSource(sourceUrl: String) + fun disableSource(searchBook: SearchBook) } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt index 75df41680..09fa066ec 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt @@ -185,8 +185,8 @@ class ChangeSourceDialog : BaseDialogFragment(), override val bookUrl: String? get() = callBack?.oldBook?.bookUrl - override fun disableSource(sourceUrl: String) { - viewModel.disableSource(sourceUrl) + override fun disableSource(searchBook: SearchBook) { + viewModel.disableSource(searchBook) } interface CallBack { diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt index 93b02a425..e5adf9e85 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt @@ -165,12 +165,13 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio searchPool.close() } - fun disableSource(sourceUrl: String) { + fun disableSource(searchBook: SearchBook) { execute { - App.db.bookSourceDao().getBookSource(sourceUrl)?.let { source -> + App.db.bookSourceDao().getBookSource(searchBook.origin)?.let { source -> source.enabled = false App.db.bookSourceDao().update(source) } + searchBooks.remove(searchBook) } } From 86f6be14885e31895dc9271b9d689ad2db62ecf4 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 1 May 2020 23:27:40 +0800 Subject: [PATCH 033/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/ui/about/AboutActivity.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/about/AboutActivity.kt b/app/src/main/java/io/legado/app/ui/about/AboutActivity.kt index 88617509b..1ce1202de 100644 --- a/app/src/main/java/io/legado/app/ui/about/AboutActivity.kt +++ b/app/src/main/java/io/legado/app/ui/about/AboutActivity.kt @@ -26,9 +26,10 @@ class AboutActivity : BaseActivity(R.layout.activity_about) { tv_app_summary.post { val span = ForegroundColorSpan(accentColor) val spannableString = SpannableString(tv_app_summary.text) - val start = spannableString.indexOf(getString(R.string.legado_gzh)) + val gzh = getString(R.string.legado_gzh) + val start = spannableString.indexOf(gzh) spannableString.setSpan( - span, start, start + 6, + span, start, start + gzh.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE ) tv_app_summary.text = spannableString From 581f73054bfbb371d9bc4b45b0f8be8c54758bbc Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 2 May 2020 09:21:24 +0800 Subject: [PATCH 034/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/service/help/ReadBook.kt | 15 +++++++-------- .../legado/app/ui/book/read/ReadBookViewModel.kt | 12 ++++++++---- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/help/ReadBook.kt b/app/src/main/java/io/legado/app/service/help/ReadBook.kt index 1ef4a3caa..b7338596c 100644 --- a/app/src/main/java/io/legado/app/service/help/ReadBook.kt +++ b/app/src/main/java/io/legado/app/service/help/ReadBook.kt @@ -36,7 +36,7 @@ object ReadBook { var msg: String? = null private val loadingChapters = arrayListOf() - fun resetData(book: Book, noSource: (name: String, author: String) -> Unit) { + fun resetData(book: Book) { this.book = book titleDate.postValue(book.name) durChapterIndex = book.durChapterIndex @@ -46,20 +46,19 @@ object ReadBook { prevTextChapter = null curTextChapter = null nextTextChapter = null - upWebBook(book, noSource) + upWebBook(book) } - fun upWebBook(book: Book?, noSource: (name: String, author: String) -> Unit) { + fun upWebBook(book: Book?) { book ?: return - if (book.origin == BookType.local) { - webBook = null + webBook = if (book.origin == BookType.local) { + null } else { val bookSource = App.db.bookSourceDao().getBookSource(book.origin) if (bookSource != null) { - webBook = WebBook(bookSource) + WebBook(bookSource) } else { - webBook = null - noSource.invoke(book.name, book.author) + null } } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt index bf6ad1925..d73ffd07a 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt @@ -40,8 +40,10 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { private fun initBook(book: Book) { if (ReadBook.book?.bookUrl != book.bookUrl) { - ReadBook.resetData(book) { name, author -> - autoChangeSource(name, author) + ReadBook.resetData(book) + if (ReadBook.webBook == null) { + autoChangeSource(book.name, book.author) + return } isInitFinish = true ReadBook.chapterSize = App.db.bookChapterDao().getChapterCount(book.bookUrl) @@ -63,8 +65,10 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { } else { isInitFinish = true ReadBook.titleDate.postValue(book.name) - ReadBook.upWebBook(book) { name, author -> - autoChangeSource(name, author) + ReadBook.upWebBook(book) + if (ReadBook.webBook == null) { + autoChangeSource(book.name, book.author) + return } ReadBook.chapterSize = App.db.bookChapterDao().getChapterCount(book.bookUrl) if (ReadBook.chapterSize == 0) { From 4501ac792bfa26ebe65ee40701ead4ff96fa0873 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 2 May 2020 09:24:59 +0800 Subject: [PATCH 035/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 8daa85570..8155ed74e 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/05/02** +* 修复不停换源的bug + **2020/05/01** * 尝试修复朗读时可能错位的bug * 添加自动换源配置 From d2a6a7beb620c83336dff61be80fefa53090ffc4 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 2 May 2020 10:36:00 +0800 Subject: [PATCH 036/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + .../main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 8155ed74e..54d4d2906 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -5,6 +5,7 @@ **2020/05/02** * 修复不停换源的bug +* 修复本地书籍自动换源 **2020/05/01** * 尝试修复朗读时可能错位的bug diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt index d73ffd07a..a4755213d 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt @@ -41,7 +41,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { private fun initBook(book: Book) { if (ReadBook.book?.bookUrl != book.bookUrl) { ReadBook.resetData(book) - if (ReadBook.webBook == null) { + if (!book.isLocalBook() && ReadBook.webBook == null) { autoChangeSource(book.name, book.author) return } @@ -66,7 +66,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { isInitFinish = true ReadBook.titleDate.postValue(book.name) ReadBook.upWebBook(book) - if (ReadBook.webBook == null) { + if (!book.isLocalBook() && ReadBook.webBook == null) { autoChangeSource(book.name, book.author) return } From 1e6259c44af328ccc9452482519225e0cd09b9a5 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 2 May 2020 11:06:22 +0800 Subject: [PATCH 037/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index e8aa82313..75fdfb620 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -19,7 +19,7 @@ def gitCommits = Integer.parseInt('git rev-list --count HEAD'.execute([], projec android { compileSdkVersion 29 - flavorDimensions ("version") + flavorDimensions("version") signingConfigs { if (project.hasProperty("RELEASE_STORE_FILE")) { myConfig { @@ -195,4 +195,10 @@ dependencies { } -apply plugin: 'com.google.gms.google-services' \ No newline at end of file +apply plugin: 'com.google.gms.google-services' + +afterEvaluate { + for (Task task : project.tasks.matching { it.name.startsWith('crashlyticsUploadDeobs') }) { + task.enabled = false + } +} \ No newline at end of file From 4b419a6de80cb3bce03d3927fdff43abcc9e9431 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 2 May 2020 19:27:33 +0800 Subject: [PATCH 038/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/ui/about/DonateFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/about/DonateFragment.kt b/app/src/main/java/io/legado/app/ui/about/DonateFragment.kt index f82fa1b64..b716c8f05 100644 --- a/app/src/main/java/io/legado/app/ui/about/DonateFragment.kt +++ b/app/src/main/java/io/legado/app/ui/about/DonateFragment.kt @@ -35,7 +35,7 @@ class DonateFragment : PreferenceFragmentCompat() { "zfbSkRwm" -> requireContext().openUrl(zfbSkRwmUrl) "qqSkRwm" -> requireContext().openUrl(qqSkRwmUrl) "zfbHbSsm" -> getZfbHb(requireContext()) - "gzGzh" -> requireContext().sendToClip("开源阅读软件") + "gzGzh" -> requireContext().sendToClip("开源阅读") } return super.onPreferenceTreeClick(preference) } From d09a530c0d1d5c1c68ebb8799331d0de9f2fdcee Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 2 May 2020 19:53:04 +0800 Subject: [PATCH 039/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/service/CheckSourceService.kt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/CheckSourceService.kt b/app/src/main/java/io/legado/app/service/CheckSourceService.kt index 8cbd80afd..896e7bb75 100644 --- a/app/src/main/java/io/legado/app/service/CheckSourceService.kt +++ b/app/src/main/java/io/legado/app/service/CheckSourceService.kt @@ -20,7 +20,7 @@ import java.util.concurrent.Executors import kotlin.math.min class CheckSourceService : BaseService() { - private val threadCount = AppConfig.threadCount + private var threadCount = AppConfig.threadCount private var searchPool = Executors.newFixedThreadPool(threadCount).asCoroutineDispatcher() private var tasks = CompositeCoroutine() private val allIds = ArrayList() @@ -58,20 +58,24 @@ class CheckSourceService : BaseService() { checkedIds.clear() allIds.addAll(ids) processIndex = 0 + threadCount = min(allIds.size, threadCount) updateNotification(0, getString(R.string.progress_show, 0, allIds.size)) - for (i in 0 until min(threadCount, allIds.size)) { + for (i in 0 until threadCount) { check() } } - + /** + * 检测 + */ private fun check() { + val index = processIndex synchronized(this) { processIndex++ } execute { - if (processIndex < allIds.size) { - val sourceUrl = allIds[processIndex] + if (index < allIds.size) { + val sourceUrl = allIds[index] App.db.bookSourceDao().getBookSource(sourceUrl)?.let { source -> if (source.searchUrl.isNullOrEmpty()) { onNext(sourceUrl) @@ -102,7 +106,7 @@ class CheckSourceService : BaseService() { checkedIds.size, getString(R.string.progress_show, checkedIds.size, allIds.size) ) - if (processIndex >= allIds.size + min(threadCount, allIds.size) - 1) { + if (processIndex >= allIds.size + threadCount - 1) { stopSelf() } } From 366cbc78d264358f527d4fc125eea3b850accb01 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 2 May 2020 19:54:46 +0800 Subject: [PATCH 040/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 54d4d2906..23a75875a 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -6,6 +6,7 @@ **2020/05/02** * 修复不停换源的bug * 修复本地书籍自动换源 +* 修复书源校验的一些问题 **2020/05/01** * 尝试修复朗读时可能错位的bug From 644ee089feb7550d191023b50c73c63d4e1c9b58 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 2 May 2020 20:55:39 +0800 Subject: [PATCH 041/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/data/AppDatabase.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 5045b9ce4..023e1dffb 100644 --- a/app/src/main/java/io/legado/app/data/AppDatabase.kt +++ b/app/src/main/java/io/legado/app/data/AppDatabase.kt @@ -39,7 +39,7 @@ abstract class AppDatabase : RoomDatabase() { CREATE TABLE txtTocRules(id INTEGER NOT NULL, name TEXT NOT NULL, rule TEXT NOT NULL, serialNumber INTEGER NOT NULL, enable INTEGER NOT NULL, PRIMARY KEY (id)) - """ + """ ) } }) From 31f390a1d2a70b86f9b1c05054c684a6b643b735 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 2 May 2020 21:36:09 +0800 Subject: [PATCH 042/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/ui/widget/prefs/Preference.kt | 3 ++- app/src/main/res/layout/view_preference.xml | 4 ++-- app/src/main/res/values-zh-rHK/strings.xml | 8 ++++---- app/src/main/res/values/strings.xml | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/widget/prefs/Preference.kt b/app/src/main/java/io/legado/app/ui/widget/prefs/Preference.kt index 2ebb11344..6226ab30a 100644 --- a/app/src/main/java/io/legado/app/ui/widget/prefs/Preference.kt +++ b/app/src/main/java/io/legado/app/ui/widget/prefs/Preference.kt @@ -8,6 +8,7 @@ import android.view.View import android.widget.FrameLayout import android.widget.ImageView import android.widget.TextView +import androidx.core.view.isGone import androidx.core.view.isVisible import androidx.preference.PreferenceViewHolder import io.legado.app.R @@ -45,7 +46,7 @@ class Preference(context: Context, attrs: AttributeSet) : val tvSummary = it.findViewById(R.id.preference_desc) if (tvSummary is TextView) { tvSummary.text = summary - tvSummary.isVisible = summary != null && summary.isNotEmpty() + tvSummary.isGone = summary.isNullOrEmpty() } val iconView = it.findViewById(R.id.preference_icon) diff --git a/app/src/main/res/layout/view_preference.xml b/app/src/main/res/layout/view_preference.xml index 87b10ef5b..c8d72c3bc 100644 --- a/app/src/main/res/layout/view_preference.xml +++ b/app/src/main/res/layout/view_preference.xml @@ -7,10 +7,11 @@ android:paddingLeft="16dp" android:paddingTop="10dp" android:paddingRight="16dp" - android:paddingBottom="4dp" + android:paddingBottom="10dp" android:minHeight="42dp" android:clickable="true" android:orientation="horizontal" + android:gravity="center_vertical" android:focusable="true"> 章節名稱規則 (ChapterName) 章節 URL 規則 (chapterUrl) VIP 標識 (isVip) - 章節信息 (ChapterInfo) + 更新時間 (ChapterInfo) 正文規則 (content) 正文下一頁 URL 規則 (nextContentUrl) webJs @@ -685,7 +685,7 @@ 夜間,強調色 夜間,背景色 夜間,導航欄顏色 - 隐藏页眉 - 隐藏页脚 - 自动换源 + 隱藏頁眉 + 隱藏頁脚 + 自動換源 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b3783a88b..339cdc437 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -401,7 +401,7 @@ 章节名称规则(ChapterName) 章节URL规则(chapterUrl) VIP标识(isVip) - 章节信息(ChapterInfo) + 更新时间(ChapterInfo) 正文规则(content) 正文下一页URL规则(nextContentUrl) webJs From d7d42dd8b3a34b7053a562457e1d9e20265f2387 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 2 May 2020 23:00:41 +0800 Subject: [PATCH 043/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/page/ContentView.kt | 40 +- .../io/legado/app/utils/ConstraintUtil.kt | 404 +++++++++--------- 2 files changed, 241 insertions(+), 203 deletions(-) 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 67e40bf0e..46354eecd 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 @@ -4,6 +4,7 @@ import android.annotation.SuppressLint import android.content.Context import android.graphics.drawable.Drawable import android.view.MotionEvent +import android.view.ViewGroup import android.widget.FrameLayout import androidx.core.view.isGone import androidx.core.view.isInvisible @@ -15,10 +16,7 @@ import io.legado.app.help.ReadBookConfig import io.legado.app.help.ReadTipConfig import io.legado.app.ui.book.read.page.entities.TextPage import io.legado.app.ui.widget.BatteryView -import io.legado.app.utils.dp -import io.legado.app.utils.getCompatColor -import io.legado.app.utils.statusBarHeight -import io.legado.app.utils.visible +import io.legado.app.utils.* import kotlinx.android.synthetic.main.view_book_page.view.* import java.util.* @@ -102,10 +100,24 @@ class ContentView(context: Context) : FrameLayout(context) { ll_footer.isGone = hideFooter } tvTitle = when (ReadTipConfig.chapterTitle) { - ReadTipConfig.tipHeaderLeft -> tv_header_left + ReadTipConfig.tipHeaderLeft -> { + ConstraintUtil(ll_header).begin() + .rightToLeftOf(R.id.tv_header_left, R.id.tv_header_right) + .setWidth(R.id.tv_header_left, 0) + .setHorizontalWeight(R.id.tv_header_left, 1f) + .commit() + tv_header_left + } ReadTipConfig.tipHeaderMiddle -> tv_header_middle ReadTipConfig.tipHeaderRight -> tv_header_right - ReadTipConfig.tipFooterLeft -> tv_footer_left + ReadTipConfig.tipFooterLeft -> { + ConstraintUtil(ll_footer).begin() + .rightToLeftOf(R.id.tv_footer_left, R.id.tv_footer_right) + .setWidth(R.id.tv_footer_left, 0) + .setHorizontalWeight(R.id.tv_footer_left, 1f) + .commit() + tv_footer_left + } ReadTipConfig.tipFooterMiddle -> tv_footer_middle ReadTipConfig.tipFooterRight -> tv_footer_right else -> null @@ -128,10 +140,22 @@ class ContentView(context: Context) : FrameLayout(context) { textSize = 12f } tvBattery = when (ReadTipConfig.battery) { - ReadTipConfig.tipHeaderLeft -> tv_header_left + ReadTipConfig.tipHeaderLeft -> { + ConstraintUtil(ll_header).begin() + .clear(R.id.tv_header_left, 2) + .setWidth(R.id.tv_header_left, ViewGroup.LayoutParams.WRAP_CONTENT) + .commit() + tv_header_left + } ReadTipConfig.tipHeaderMiddle -> tv_header_middle ReadTipConfig.tipHeaderRight -> tv_header_right - ReadTipConfig.tipFooterLeft -> tv_footer_left + ReadTipConfig.tipFooterLeft -> { + ConstraintUtil(ll_header).begin() + .clear(R.id.tv_footer_left, 2) + .setWidth(R.id.tv_footer_left, ViewGroup.LayoutParams.WRAP_CONTENT) + .commit() + tv_footer_left + } ReadTipConfig.tipFooterMiddle -> tv_footer_middle ReadTipConfig.tipFooterRight -> tv_footer_right else -> null diff --git a/app/src/main/java/io/legado/app/utils/ConstraintUtil.kt b/app/src/main/java/io/legado/app/utils/ConstraintUtil.kt index 154cce984..b7ef740cc 100644 --- a/app/src/main/java/io/legado/app/utils/ConstraintUtil.kt +++ b/app/src/main/java/io/legado/app/utils/ConstraintUtil.kt @@ -6,7 +6,7 @@ import androidx.constraintlayout.widget.ConstraintSet import androidx.transition.TransitionManager -class ConstraintUtil(val constraintLayout: ConstraintLayout) { +class ConstraintUtil(private val constraintLayout: ConstraintLayout) { private var begin: ConstraintBegin? = null private val applyConstraintSet = ConstraintSet() @@ -19,14 +19,14 @@ class ConstraintUtil(val constraintLayout: ConstraintLayout) { /** * 开始修改 */ - fun begin(): ConstraintBegin? { + fun begin(): ConstraintBegin { synchronized(ConstraintBegin::class.java) { if (begin == null) { - begin = ConstraintBegin() + begin = ConstraintBegin(constraintLayout, applyConstraintSet) } } applyConstraintSet.clone(constraintLayout) - return begin + return begin!! } /** @@ -53,214 +53,228 @@ class ConstraintUtil(val constraintLayout: ConstraintLayout) { resetConstraintSet.applyTo(constraintLayout) } - inner class ConstraintBegin { - /** - * 清除关系

- * 注意:这里不仅仅会清除关系,还会清除对应控件的宽高为 w:0,h:0 - * @param viewIds - * @return - */ - fun clear(@IdRes vararg viewIds: Int): ConstraintBegin { - for (viewId in viewIds) { - applyConstraintSet.clear(viewId) - } - return this - } +} - /** - * 清除某个控件的,某个关系 - * @param viewId - * @param anchor - * @return - */ - fun clear(viewId: Int, anchor: Int): ConstraintBegin { - applyConstraintSet.clear(viewId, anchor) - return this - } +class ConstraintBegin( + private val constraintLayout: ConstraintLayout, + private val applyConstraintSet: ConstraintSet +) { - /** - * 为某个控件设置 margin - * @param viewId 某个控件ID - * @param left marginLeft - * @param top marginTop - * @param right marginRight - * @param bottom marginBottom - * @return - */ - fun setMargin( - @IdRes viewId: Int, - left: Int, - top: Int, - right: Int, - bottom: Int - ): ConstraintBegin { - setMarginLeft(viewId, left) - setMarginTop(viewId, top) - setMarginRight(viewId, right) - setMarginBottom(viewId, bottom) - return this + /** + * 清除关系

+ * 注意:这里不仅仅会清除关系,还会清除对应控件的宽高为 w:0,h:0 + * @param viewIds + * @return + */ + fun clear(@IdRes vararg viewIds: Int): ConstraintBegin { + for (viewId in viewIds) { + applyConstraintSet.clear(viewId) } + return this + } - /** - * 为某个控件设置 marginLeft - * @param viewId 某个控件ID - * @param left marginLeft - * @return - */ - fun setMarginLeft(@IdRes viewId: Int, left: Int): ConstraintBegin { - applyConstraintSet.setMargin(viewId, ConstraintSet.LEFT, left) - return this - } + /** + * 清除某个控件的,某个关系 + * @param viewId + * @param anchor + * @return + */ + fun clear(viewId: Int, anchor: Int): ConstraintBegin { + applyConstraintSet.clear(viewId, anchor) + return this + } - /** - * 为某个控件设置 marginRight - * @param viewId 某个控件ID - * @param right marginRight - * @return - */ - fun setMarginRight(@IdRes viewId: Int, right: Int): ConstraintBegin { - applyConstraintSet.setMargin(viewId, ConstraintSet.RIGHT, right) - return this - } + fun setHorizontalWeight(viewId: Int, weight: Float): ConstraintBegin { + applyConstraintSet.setHorizontalWeight(viewId, weight) + return this + } - /** - * 为某个控件设置 marginTop - * @param viewId 某个控件ID - * @param top marginTop - * @return - */ - fun setMarginTop(@IdRes viewId: Int, top: Int): ConstraintBegin { - applyConstraintSet.setMargin(viewId, ConstraintSet.TOP, top) - return this - } + fun setVerticalWeight(viewId: Int, weight: Float): ConstraintBegin { + applyConstraintSet.setVerticalWeight(viewId, weight) + return this + } - /** - * 为某个控件设置marginBottom - * @param viewId 某个控件ID - * @param bottom marginBottom - * @return - */ - fun setMarginBottom(@IdRes viewId: Int, bottom: Int): ConstraintBegin { - applyConstraintSet.setMargin(viewId, ConstraintSet.BOTTOM, bottom) - return this - } + /** + * 为某个控件设置 margin + * @param viewId 某个控件ID + * @param left marginLeft + * @param top marginTop + * @param right marginRight + * @param bottom marginBottom + * @return + */ + fun setMargin( + @IdRes viewId: Int, + left: Int, + top: Int, + right: Int, + bottom: Int + ): ConstraintBegin { + setMarginLeft(viewId, left) + setMarginTop(viewId, top) + setMarginRight(viewId, right) + setMarginBottom(viewId, bottom) + return this + } - /** - * 为某个控件设置关联关系 left_to_left_of - * @param startId - * @param endId - * @return - */ - fun Left_toLeftOf(@IdRes startId: Int, @IdRes endId: Int): ConstraintBegin { - applyConstraintSet.connect(startId, ConstraintSet.LEFT, endId, ConstraintSet.LEFT) - return this - } + /** + * 为某个控件设置 marginLeft + * @param viewId 某个控件ID + * @param left marginLeft + * @return + */ + fun setMarginLeft(@IdRes viewId: Int, left: Int): ConstraintBegin { + applyConstraintSet.setMargin(viewId, ConstraintSet.LEFT, left) + return this + } - /** - * 为某个控件设置关联关系 left_to_right_of - * @param startId - * @param endId - * @return - */ - fun Left_toRightOf(@IdRes startId: Int, @IdRes endId: Int): ConstraintBegin { - applyConstraintSet.connect(startId, ConstraintSet.LEFT, endId, ConstraintSet.RIGHT) - return this - } + /** + * 为某个控件设置 marginRight + * @param viewId 某个控件ID + * @param right marginRight + * @return + */ + fun setMarginRight(@IdRes viewId: Int, right: Int): ConstraintBegin { + applyConstraintSet.setMargin(viewId, ConstraintSet.RIGHT, right) + return this + } - /** - * 为某个控件设置关联关系 top_to_top_of - * @param startId - * @param endId - * @return - */ - fun Top_toTopOf(@IdRes startId: Int, @IdRes endId: Int): ConstraintBegin { - applyConstraintSet.connect(startId, ConstraintSet.TOP, endId, ConstraintSet.TOP) - return this - } + /** + * 为某个控件设置 marginTop + * @param viewId 某个控件ID + * @param top marginTop + * @return + */ + fun setMarginTop(@IdRes viewId: Int, top: Int): ConstraintBegin { + applyConstraintSet.setMargin(viewId, ConstraintSet.TOP, top) + return this + } - /** - * 为某个控件设置关联关系 top_to_bottom_of - * @param startId - * @param endId - * @return - */ - fun Top_toBottomOf(@IdRes startId: Int, @IdRes endId: Int): ConstraintBegin { - applyConstraintSet.connect(startId, ConstraintSet.TOP, endId, ConstraintSet.BOTTOM) - return this - } + /** + * 为某个控件设置marginBottom + * @param viewId 某个控件ID + * @param bottom marginBottom + * @return + */ + fun setMarginBottom(@IdRes viewId: Int, bottom: Int): ConstraintBegin { + applyConstraintSet.setMargin(viewId, ConstraintSet.BOTTOM, bottom) + return this + } - /** - * 为某个控件设置关联关系 right_to_left_of - * @param startId - * @param endId - * @return - */ - fun Right_toLeftOf(@IdRes startId: Int, @IdRes endId: Int): ConstraintBegin { - applyConstraintSet.connect(startId, ConstraintSet.RIGHT, endId, ConstraintSet.LEFT) - return this - } + /** + * 为某个控件设置关联关系 left_to_left_of + * @param startId + * @param endId + * @return + */ + fun leftToLeftOf(@IdRes startId: Int, @IdRes endId: Int): ConstraintBegin { + applyConstraintSet.connect(startId, ConstraintSet.LEFT, endId, ConstraintSet.LEFT) + return this + } - /** - * 为某个控件设置关联关系 right_to_right_of - * @param startId - * @param endId - * @return - */ - fun Right_toRightOf(@IdRes startId: Int, @IdRes endId: Int): ConstraintBegin { - applyConstraintSet.connect(startId, ConstraintSet.RIGHT, endId, ConstraintSet.RIGHT) - return this - } + /** + * 为某个控件设置关联关系 left_to_right_of + * @param startId + * @param endId + * @return + */ + fun leftToRightOf(@IdRes startId: Int, @IdRes endId: Int): ConstraintBegin { + applyConstraintSet.connect(startId, ConstraintSet.LEFT, endId, ConstraintSet.RIGHT) + return this + } - /** - * 为某个控件设置关联关系 bottom_to_bottom_of - * @param startId - * @param endId - * @return - */ - fun Bottom_toBottomOf(@IdRes startId: Int, @IdRes endId: Int): ConstraintBegin { - applyConstraintSet.connect(startId, ConstraintSet.BOTTOM, endId, ConstraintSet.BOTTOM) - return this - } + /** + * 为某个控件设置关联关系 top_to_top_of + * @param startId + * @param endId + * @return + */ + fun topToTopOf(@IdRes startId: Int, @IdRes endId: Int): ConstraintBegin { + applyConstraintSet.connect(startId, ConstraintSet.TOP, endId, ConstraintSet.TOP) + return this + } - /** - * 为某个控件设置关联关系 bottom_to_top_of - * @param startId - * @param endId - * @return - */ - fun Bottom_toTopOf(@IdRes startId: Int, @IdRes endId: Int): ConstraintBegin { - applyConstraintSet.connect(startId, ConstraintSet.BOTTOM, endId, ConstraintSet.TOP) - return this - } + /** + * 为某个控件设置关联关系 top_to_bottom_of + * @param startId + * @param endId + * @return + */ + fun topToBottomOf(@IdRes startId: Int, @IdRes endId: Int): ConstraintBegin { + applyConstraintSet.connect(startId, ConstraintSet.TOP, endId, ConstraintSet.BOTTOM) + return this + } - /** - * 为某个控件设置宽度 - * @param viewId - * @param width - * @return - */ - fun setWidth(@IdRes viewId: Int, width: Int): ConstraintBegin { - applyConstraintSet.constrainWidth(viewId, width) - return this - } + /** + * 为某个控件设置关联关系 right_to_left_of + * @param startId + * @param endId + * @return + */ + fun rightToLeftOf(@IdRes startId: Int, @IdRes endId: Int): ConstraintBegin { + applyConstraintSet.connect(startId, ConstraintSet.RIGHT, endId, ConstraintSet.LEFT) + return this + } - /** - * 某个控件设置高度 - * @param viewId - * @param height - * @return - */ - fun setHeight(@IdRes viewId: Int, height: Int): ConstraintBegin { - applyConstraintSet.constrainHeight(viewId, height) - return this - } + /** + * 为某个控件设置关联关系 right_to_right_of + * @param startId + * @param endId + * @return + */ + fun rightToRightOf(@IdRes startId: Int, @IdRes endId: Int): ConstraintBegin { + applyConstraintSet.connect(startId, ConstraintSet.RIGHT, endId, ConstraintSet.RIGHT) + return this + } - /** - * 提交应用生效 - */ - fun commit() { - applyConstraintSet.applyTo(constraintLayout) - } + /** + * 为某个控件设置关联关系 bottom_to_bottom_of + * @param startId + * @param endId + * @return + */ + fun bottomToBottomOf(@IdRes startId: Int, @IdRes endId: Int): ConstraintBegin { + applyConstraintSet.connect(startId, ConstraintSet.BOTTOM, endId, ConstraintSet.BOTTOM) + return this + } + + /** + * 为某个控件设置关联关系 bottom_to_top_of + * @param startId + * @param endId + * @return + */ + fun bottomToTopOf(@IdRes startId: Int, @IdRes endId: Int): ConstraintBegin { + applyConstraintSet.connect(startId, ConstraintSet.BOTTOM, endId, ConstraintSet.TOP) + return this } -} \ No newline at end of file + /** + * 为某个控件设置宽度 + * @param viewId + * @param width + * @return + */ + fun setWidth(@IdRes viewId: Int, width: Int): ConstraintBegin { + applyConstraintSet.constrainWidth(viewId, width) + return this + } + + /** + * 某个控件设置高度 + * @param viewId + * @param height + * @return + */ + fun setHeight(@IdRes viewId: Int, height: Int): ConstraintBegin { + applyConstraintSet.constrainHeight(viewId, height) + return this + } + + /** + * 提交应用生效 + */ + fun commit() { + applyConstraintSet.applyTo(constraintLayout) + } +} From c710aff4c447d02d1642116486954a778049931d Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 2 May 2020 23:08:57 +0800 Subject: [PATCH 044/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/ui/book/read/page/ContentView.kt | 2 ++ 1 file changed, 2 insertions(+) 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 46354eecd..1c602e444 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 @@ -144,6 +144,7 @@ class ContentView(context: Context) : FrameLayout(context) { ConstraintUtil(ll_header).begin() .clear(R.id.tv_header_left, 2) .setWidth(R.id.tv_header_left, ViewGroup.LayoutParams.WRAP_CONTENT) + .setHorizontalWeight(R.id.tv_footer_left, 0f) .commit() tv_header_left } @@ -153,6 +154,7 @@ class ContentView(context: Context) : FrameLayout(context) { ConstraintUtil(ll_header).begin() .clear(R.id.tv_footer_left, 2) .setWidth(R.id.tv_footer_left, ViewGroup.LayoutParams.WRAP_CONTENT) + .setHorizontalWeight(R.id.tv_footer_left, 0f) .commit() tv_footer_left } From dbe03c79f7b87bc74e2dd41f0f962517f4a5ced6 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 3 May 2020 00:07:02 +0800 Subject: [PATCH 045/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/config/TipConfigDialog.kt | 12 ++++++++++-- .../io/legado/app/ui/book/read/page/ContentView.kt | 9 ++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt index 2635b70b2..c48edc0be 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt @@ -86,7 +86,11 @@ class TipConfigDialog : BaseDialogFragment() { tipHeaderLeft = i tv_header_left.text = tipArray[i] } - postEvent(EventBus.UP_CONFIG, true) + if (i == ReadTipConfig.battery) { + activity?.recreate() + } else { + postEvent(EventBus.UP_CONFIG, true) + } } } tv_header_middle.onClick { @@ -179,7 +183,11 @@ class TipConfigDialog : BaseDialogFragment() { tipFooterLeft = i tv_footer_left.text = tipArray[i] } - postEvent(EventBus.UP_CONFIG, true) + if (i == ReadTipConfig.battery) { + activity?.recreate() + } else { + postEvent(EventBus.UP_CONFIG, true) + } } } tv_footer_middle.onClick { 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 1c602e444..7015404cb 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 @@ -4,7 +4,6 @@ import android.annotation.SuppressLint import android.content.Context import android.graphics.drawable.Drawable import android.view.MotionEvent -import android.view.ViewGroup import android.widget.FrameLayout import androidx.core.view.isGone import androidx.core.view.isInvisible @@ -143,8 +142,8 @@ class ContentView(context: Context) : FrameLayout(context) { ReadTipConfig.tipHeaderLeft -> { ConstraintUtil(ll_header).begin() .clear(R.id.tv_header_left, 2) - .setWidth(R.id.tv_header_left, ViewGroup.LayoutParams.WRAP_CONTENT) - .setHorizontalWeight(R.id.tv_footer_left, 0f) + .setHorizontalWeight(R.id.tv_footer_left, 0.0F) + .setWidth(R.id.tv_header_left, LayoutParams.WRAP_CONTENT) .commit() tv_header_left } @@ -153,8 +152,8 @@ class ContentView(context: Context) : FrameLayout(context) { ReadTipConfig.tipFooterLeft -> { ConstraintUtil(ll_header).begin() .clear(R.id.tv_footer_left, 2) - .setWidth(R.id.tv_footer_left, ViewGroup.LayoutParams.WRAP_CONTENT) - .setHorizontalWeight(R.id.tv_footer_left, 0f) + .setHorizontalWeight(R.id.tv_footer_left, 0.0F) + .setWidth(R.id.tv_footer_left, LayoutParams.WRAP_CONTENT) .commit() tv_footer_left } From b636bd23a6c9a30a436a6a747b68232ba3314bbc Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 3 May 2020 08:52:36 +0800 Subject: [PATCH 046/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/layout/view_preference.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/layout/view_preference.xml b/app/src/main/res/layout/view_preference.xml index c8d72c3bc..f825afe26 100644 --- a/app/src/main/res/layout/view_preference.xml +++ b/app/src/main/res/layout/view_preference.xml @@ -32,7 +32,6 @@ + android:layout_height="wrap_content" + android:layout_marginTop="8dp" /> + Date: Sun, 3 May 2020 10:06:54 +0800 Subject: [PATCH 047/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/book/read/config/TipConfigDialog.kt | 12 +--- .../app/ui/book/read/page/ContentView.kt | 65 ++++++------------- .../io/legado/app/ui/widget/BatteryView.kt | 4 +- app/src/main/res/layout/view_book_page.xml | 26 ++++++++ 4 files changed, 50 insertions(+), 57 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt index c48edc0be..2635b70b2 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt @@ -86,11 +86,7 @@ class TipConfigDialog : BaseDialogFragment() { tipHeaderLeft = i tv_header_left.text = tipArray[i] } - if (i == ReadTipConfig.battery) { - activity?.recreate() - } else { - postEvent(EventBus.UP_CONFIG, true) - } + postEvent(EventBus.UP_CONFIG, true) } } tv_header_middle.onClick { @@ -183,11 +179,7 @@ class TipConfigDialog : BaseDialogFragment() { tipFooterLeft = i tv_footer_left.text = tipArray[i] } - if (i == ReadTipConfig.battery) { - activity?.recreate() - } else { - postEvent(EventBus.UP_CONFIG, true) - } + postEvent(EventBus.UP_CONFIG, true) } } tv_footer_middle.onClick { 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 7015404cb..0be240cc1 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 @@ -15,7 +15,10 @@ import io.legado.app.help.ReadBookConfig import io.legado.app.help.ReadTipConfig import io.legado.app.ui.book.read.page.entities.TextPage import io.legado.app.ui.widget.BatteryView -import io.legado.app.utils.* +import io.legado.app.utils.dp +import io.legado.app.utils.getCompatColor +import io.legado.app.utils.statusBarHeight +import io.legado.app.utils.visible import kotlinx.android.synthetic.main.view_book_page.view.* import java.util.* @@ -46,15 +49,19 @@ class ContentView(context: Context) : FrameLayout(context) { fun upStyle() { ReadBookConfig.apply { + bv_header_left.typeface = ChapterProvider.typeface tv_header_left.typeface = ChapterProvider.typeface tv_header_middle.typeface = ChapterProvider.typeface tv_header_right.typeface = ChapterProvider.typeface + bv_footer_left.typeface = ChapterProvider.typeface tv_footer_left.typeface = ChapterProvider.typeface tv_footer_middle.typeface = ChapterProvider.typeface tv_footer_right.typeface = ChapterProvider.typeface + bv_header_left.setColor(durConfig.textColor()) tv_header_left.setColor(durConfig.textColor()) tv_header_middle.setColor(durConfig.textColor()) tv_header_right.setColor(durConfig.textColor()) + bv_footer_left.setColor(durConfig.textColor()) tv_footer_left.setColor(durConfig.textColor()) tv_footer_middle.setColor(durConfig.textColor()) tv_footer_right.setColor(durConfig.textColor()) @@ -83,40 +90,22 @@ class ContentView(context: Context) : FrameLayout(context) { fun upTipStyle() { ReadTipConfig.apply { - val tipHeaderLeftNone = tipHeaderLeft == none - val tipHeaderRightNone = tipHeaderRight == none - val tipHeaderMiddleNone = tipHeaderMiddle == none - val tipFooterLeftNone = tipFooterLeft == none - val tipFooterRightNone = tipFooterRight == none - val tipFooterMiddleNone = tipFooterMiddle == none - tv_header_left.isInvisible = tipHeaderLeftNone - tv_header_right.isGone = tipHeaderRightNone - tv_header_middle.isGone = tipHeaderMiddleNone - tv_footer_left.isInvisible = tipFooterLeftNone - tv_footer_right.isGone = tipFooterRightNone - tv_footer_middle.isGone = tipFooterMiddleNone + tv_header_left.isInvisible = tipHeaderLeft != chapterTitle + bv_header_left.isInvisible = tipHeaderLeft == none || !tv_header_left.isInvisible + tv_header_right.isGone = tipHeaderRight == none + tv_header_middle.isGone = tipHeaderMiddle == none + tv_footer_left.isInvisible = tipFooterLeft != chapterTitle + bv_footer_left.isInvisible = tipFooterLeft == none || !tv_footer_left.isInvisible + tv_footer_right.isGone = tipFooterRight == none + tv_footer_middle.isGone = tipFooterMiddle == none ll_header.isGone = hideHeader ll_footer.isGone = hideFooter } tvTitle = when (ReadTipConfig.chapterTitle) { - ReadTipConfig.tipHeaderLeft -> { - ConstraintUtil(ll_header).begin() - .rightToLeftOf(R.id.tv_header_left, R.id.tv_header_right) - .setWidth(R.id.tv_header_left, 0) - .setHorizontalWeight(R.id.tv_header_left, 1f) - .commit() - tv_header_left - } + ReadTipConfig.tipHeaderLeft -> tv_header_left ReadTipConfig.tipHeaderMiddle -> tv_header_middle ReadTipConfig.tipHeaderRight -> tv_header_right - ReadTipConfig.tipFooterLeft -> { - ConstraintUtil(ll_footer).begin() - .rightToLeftOf(R.id.tv_footer_left, R.id.tv_footer_right) - .setWidth(R.id.tv_footer_left, 0) - .setHorizontalWeight(R.id.tv_footer_left, 1f) - .commit() - tv_footer_left - } + ReadTipConfig.tipFooterLeft -> tv_footer_left ReadTipConfig.tipFooterMiddle -> tv_footer_middle ReadTipConfig.tipFooterRight -> tv_footer_right else -> null @@ -139,24 +128,10 @@ class ContentView(context: Context) : FrameLayout(context) { textSize = 12f } tvBattery = when (ReadTipConfig.battery) { - ReadTipConfig.tipHeaderLeft -> { - ConstraintUtil(ll_header).begin() - .clear(R.id.tv_header_left, 2) - .setHorizontalWeight(R.id.tv_footer_left, 0.0F) - .setWidth(R.id.tv_header_left, LayoutParams.WRAP_CONTENT) - .commit() - tv_header_left - } + ReadTipConfig.tipHeaderLeft -> bv_header_left ReadTipConfig.tipHeaderMiddle -> tv_header_middle ReadTipConfig.tipHeaderRight -> tv_header_right - ReadTipConfig.tipFooterLeft -> { - ConstraintUtil(ll_header).begin() - .clear(R.id.tv_footer_left, 2) - .setHorizontalWeight(R.id.tv_footer_left, 0.0F) - .setWidth(R.id.tv_footer_left, LayoutParams.WRAP_CONTENT) - .commit() - tv_footer_left - } + ReadTipConfig.tipFooterLeft -> bv_footer_left ReadTipConfig.tipFooterMiddle -> tv_footer_middle ReadTipConfig.tipFooterRight -> tv_footer_right else -> null 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 eabfad602..d9725f019 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 @@ -39,9 +39,9 @@ class BatteryView(context: Context, attrs: AttributeSet?) : AppCompatTextView(co if (!isBattery) return outFrame.set( 1.dp, - layout.getLineTop(0) + 2.dp, + layout.getLineBaseline(0) + layout.getLineAscent(0) + 2.dp, width - 3.dp, - layout.getLineBottom(0) - 2.dp + layout.getLineBaseline(0) + 2.dp ) val dj = (outFrame.bottom - outFrame.top) / 3 polar.set( diff --git a/app/src/main/res/layout/view_book_page.xml b/app/src/main/res/layout/view_book_page.xml index ec591bc6f..95fd4f1f3 100644 --- a/app/src/main/res/layout/view_book_page.xml +++ b/app/src/main/res/layout/view_book_page.xml @@ -20,6 +20,19 @@ + + + + Date: Sun, 3 May 2020 10:13:11 +0800 Subject: [PATCH 048/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 23a75875a..750284672 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/05/03** +* 优化一些界面显示问题 + **2020/05/02** * 修复不停换源的bug * 修复本地书籍自动换源 From 718f312d1d4e7490baed912bca8d22a271e0510a Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 3 May 2020 10:44:46 +0800 Subject: [PATCH 049/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/book/read/page/ContentView.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 0be240cc1..8058c0a04 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 @@ -115,10 +115,10 @@ class ContentView(context: Context) : FrameLayout(context) { textSize = 12f } tvTime = when (ReadTipConfig.time) { - ReadTipConfig.tipHeaderLeft -> tv_header_left + ReadTipConfig.tipHeaderLeft -> bv_header_left ReadTipConfig.tipHeaderMiddle -> tv_header_middle ReadTipConfig.tipHeaderRight -> tv_header_right - ReadTipConfig.tipFooterLeft -> tv_footer_left + ReadTipConfig.tipFooterLeft -> bv_footer_left ReadTipConfig.tipFooterMiddle -> tv_footer_middle ReadTipConfig.tipFooterRight -> tv_footer_right else -> null @@ -141,10 +141,10 @@ class ContentView(context: Context) : FrameLayout(context) { textSize = 10f } tvPage = when (ReadTipConfig.page) { - ReadTipConfig.tipHeaderLeft -> tv_header_left + ReadTipConfig.tipHeaderLeft -> bv_header_left ReadTipConfig.tipHeaderMiddle -> tv_header_middle ReadTipConfig.tipHeaderRight -> tv_header_right - ReadTipConfig.tipFooterLeft -> tv_footer_left + ReadTipConfig.tipFooterLeft -> bv_footer_left ReadTipConfig.tipFooterMiddle -> tv_footer_middle ReadTipConfig.tipFooterRight -> tv_footer_right else -> null @@ -154,10 +154,10 @@ class ContentView(context: Context) : FrameLayout(context) { textSize = 12f } tvTotalProgress = when (ReadTipConfig.totalProgress) { - ReadTipConfig.tipHeaderLeft -> tv_header_left + ReadTipConfig.tipHeaderLeft -> bv_header_left ReadTipConfig.tipHeaderMiddle -> tv_header_middle ReadTipConfig.tipHeaderRight -> tv_header_right - ReadTipConfig.tipFooterLeft -> tv_footer_left + ReadTipConfig.tipFooterLeft -> bv_footer_left ReadTipConfig.tipFooterMiddle -> tv_footer_middle ReadTipConfig.tipFooterRight -> tv_footer_right else -> null @@ -167,10 +167,10 @@ class ContentView(context: Context) : FrameLayout(context) { textSize = 12f } tvPageAndTotal = when (ReadTipConfig.pageAndTotal) { - ReadTipConfig.tipHeaderLeft -> tv_header_left + ReadTipConfig.tipHeaderLeft -> bv_header_left ReadTipConfig.tipHeaderMiddle -> tv_header_middle ReadTipConfig.tipHeaderRight -> tv_header_right - ReadTipConfig.tipFooterLeft -> tv_footer_left + ReadTipConfig.tipFooterLeft -> bv_footer_left ReadTipConfig.tipFooterMiddle -> tv_footer_middle ReadTipConfig.tipFooterRight -> tv_footer_right else -> null From bf9f9791067ac571e210df01e92da099a20914cc Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 3 May 2020 12:28:42 +0800 Subject: [PATCH 050/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/data/entities/RssArticle.kt | 2 +- .../app/ui/rss/article/RssArticlesViewModel.kt | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/entities/RssArticle.kt b/app/src/main/java/io/legado/app/data/entities/RssArticle.kt index 15dafa3ab..d9ae5531b 100644 --- a/app/src/main/java/io/legado/app/data/entities/RssArticle.kt +++ b/app/src/main/java/io/legado/app/data/entities/RssArticle.kt @@ -21,7 +21,7 @@ data class RssArticle( ) { override fun hashCode(): Int { - return super.hashCode() + return link.hashCode() } override fun equals(other: Any?): Boolean { diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesViewModel.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesViewModel.kt index 3bcfc00ab..4a7c66cf7 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesViewModel.kt @@ -5,7 +5,6 @@ import android.os.Bundle import androidx.lifecycle.MutableLiveData import io.legado.app.App import io.legado.app.base.BaseViewModel -import io.legado.app.data.entities.RssArticle import io.legado.app.data.entities.RssSource import io.legado.app.model.Rss import kotlinx.coroutines.Dispatchers @@ -16,7 +15,6 @@ class RssArticlesViewModel(application: Application) : BaseViewModel(application var isLoading = true var order = System.currentTimeMillis() private var nextPageUrl: String? = null - private val articles = arrayListOf() var sortName: String = "" var sortUrl: String = "" @@ -62,10 +60,13 @@ class RssArticlesViewModel(application: Application) : BaseViewModel(application nextPageUrl = it.nextPageUrl it.articles.let { list -> if (list.isEmpty()) { - loadFinally.postValue(true) + loadFinally.postValue(false) return@let } - if (articles.contains(list.first())) { + val firstArticle = list.first() + if (App.db.rssArticleDao() + .get(firstArticle.origin, firstArticle.link) != null + ) { loadFinally.postValue(false) } else { list.forEach { rssArticle -> @@ -76,6 +77,9 @@ class RssArticlesViewModel(application: Application) : BaseViewModel(application } isLoading = false } + .onError { + loadFinally.postValue(false) + } } else { loadFinally.postValue(false) } From 51b2ee20e804fffb87ec9c5dfd3366e259b0b9a1 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 3 May 2020 12:32:29 +0800 Subject: [PATCH 051/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/rss/article/RssArticlesViewModel.kt | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesViewModel.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesViewModel.kt index 4a7c66cf7..8d2d06df8 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesViewModel.kt @@ -5,6 +5,7 @@ import android.os.Bundle import androidx.lifecycle.MutableLiveData import io.legado.app.App import io.legado.app.base.BaseViewModel +import io.legado.app.data.entities.RssArticle import io.legado.app.data.entities.RssSource import io.legado.app.model.Rss import kotlinx.coroutines.Dispatchers @@ -58,24 +59,7 @@ class RssArticlesViewModel(application: Application) : BaseViewModel(application Rss.getArticles(sortName, pageUrl, rssSource, pageUrl) .onSuccess(Dispatchers.IO) { nextPageUrl = it.nextPageUrl - it.articles.let { list -> - if (list.isEmpty()) { - loadFinally.postValue(false) - return@let - } - val firstArticle = list.first() - if (App.db.rssArticleDao() - .get(firstArticle.origin, firstArticle.link) != null - ) { - loadFinally.postValue(false) - } else { - list.forEach { rssArticle -> - rssArticle.order = order-- - } - App.db.rssArticleDao().insert(*list.toTypedArray()) - } - } - isLoading = false + loadMoreSuccess(it.articles) } .onError { loadFinally.postValue(false) @@ -85,5 +69,25 @@ class RssArticlesViewModel(application: Application) : BaseViewModel(application } } + private fun loadMoreSuccess(articles: MutableList) { + articles.let { list -> + if (list.isEmpty()) { + loadFinally.postValue(false) + return@let + } + val firstArticle = list.first() + val dbArticle = App.db.rssArticleDao() + .get(firstArticle.origin, firstArticle.link) + if (dbArticle != null) { + loadFinally.postValue(false) + } else { + list.forEach { rssArticle -> + rssArticle.order = order-- + } + App.db.rssArticleDao().insert(*list.toTypedArray()) + } + } + isLoading = false + } } \ No newline at end of file From 4fcee4175e0d102a204d370ab58904328b1ec241 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 3 May 2020 17:35:23 +0800 Subject: [PATCH 052/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/service/TTSReadAloudService.kt | 37 +++++++------------ 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt b/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt index 0fba1d507..28b7efdc9 100644 --- a/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt @@ -1,7 +1,6 @@ package io.legado.app.service import android.app.PendingIntent -import android.os.Build import android.speech.tts.TextToSpeech import android.speech.tts.UtteranceProgressListener import io.legado.app.R @@ -33,6 +32,8 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener } } + private val ttsUtteranceListener = TTSUtteranceListener() + override fun onCreate() { super.onCreate() initTts() @@ -41,7 +42,9 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener private fun initTts() { ttsInitFinish = false - textToSpeech = TextToSpeech(this, this) + textToSpeech = TextToSpeech(this, this).apply { + setOnUtteranceProgressListener(ttsUtteranceListener) + } } override fun onDestroy() { @@ -54,10 +57,9 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener if (status == TextToSpeech.SUCCESS) { textToSpeech?.let { it.language = Locale.CHINA - it.setOnUtteranceProgressListener(TTSUtteranceListener()) ttsInitFinish = true + play() } - play() } else { launch { toast(R.string.tts_init_failed) @@ -73,29 +75,18 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener if (requestFocus()) { MediaHelp.playSilentSound(this) super.play() + textToSpeech?.stop() for (i in nowSpeak until contentList.size) { - if (i == 0) { - speak(contentList[i], TextToSpeech.QUEUE_FLUSH, AppConst.APP_TAG + i) - } else { - speak(contentList[i], TextToSpeech.QUEUE_ADD, AppConst.APP_TAG + i) - } + textToSpeech?.speak( + contentList[i], + TextToSpeech.QUEUE_ADD, + null, + AppConst.APP_TAG + i + ) } } } - private fun speak(content: String, queueMode: Int, utteranceId: String) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - textToSpeech?.speak(content, queueMode, null, utteranceId) - } else { - @Suppress("DEPRECATION") - textToSpeech?.speak( - content, - queueMode, - hashMapOf(Pair(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, utteranceId)) - ) - } - } - /** * 更新朗读速度 */ @@ -161,8 +152,8 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener pageIndex++ ReadBook.moveToNextPage() } + postEvent(EventBus.TTS_PROGRESS, readAloudNumber + 1) } - postEvent(EventBus.TTS_PROGRESS, readAloudNumber + 1) } override fun onDone(s: String) { From 89d45b80a19ee074bdab12ef4991a897a3c85ee2 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 3 May 2020 18:27:04 +0800 Subject: [PATCH 053/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt index 8672d04bb..5d8ec5d82 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt @@ -18,6 +18,7 @@ import io.legado.app.help.ReadBookConfig import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.bottomBackground import io.legado.app.ui.book.read.Help +import io.legado.app.utils.dp import io.legado.app.utils.getPrefBoolean import io.legado.app.utils.postEvent @@ -38,7 +39,7 @@ class MoreConfigDialog : DialogFragment() { attr.dimAmount = 0.0f attr.gravity = Gravity.BOTTOM it.attributes = attr - it.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) + it.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, 360.dp) } } From 043f8fbe0f3022359e1b7a935cf698a17ac904ea Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 3 May 2020 19:52:05 +0800 Subject: [PATCH 054/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/data/AppDatabase.kt | 38 ++++++++++++------- .../io/legado/app/data/entities/RssSource.kt | 2 + .../book/read/config/ReadAloudConfigDialog.kt | 5 ++- 3 files changed, 30 insertions(+), 15 deletions(-) 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 023e1dffb..55978fe2f 100644 --- a/app/src/main/java/io/legado/app/data/AppDatabase.kt +++ b/app/src/main/java/io/legado/app/data/AppDatabase.kt @@ -19,7 +19,7 @@ import kotlinx.coroutines.launch ReplaceRule::class, SearchBook::class, SearchKeyword::class, Cookie::class, RssSource::class, Bookmark::class, RssArticle::class, RssReadRecord::class, RssStar::class, TxtTocRule::class], - version = 11, + version = 12, exportSchema = true ) abstract class AppDatabase : RoomDatabase() { @@ -31,18 +31,7 @@ abstract class AppDatabase : RoomDatabase() { fun createDatabase(context: Context): AppDatabase { return Room.databaseBuilder(context, AppDatabase::class.java, DATABASE_NAME) .fallbackToDestructiveMigration() - .addMigrations(object : Migration(10, 11) { - override fun migrate(database: SupportSQLiteDatabase) { - database.execSQL("DROP TABLE txtTocRules") - database.execSQL( - """ - CREATE TABLE txtTocRules(id INTEGER NOT NULL, - name TEXT NOT NULL, rule TEXT NOT NULL, serialNumber INTEGER NOT NULL, - enable INTEGER NOT NULL, PRIMARY KEY (id)) - """ - ) - } - }) + .addMigrations(migration_10_11, migration_11_12) .addCallback(object : Callback() { override fun onDestructiveMigration(db: SupportSQLiteDatabase) { GlobalScope.launch { Restore.restoreDatabase(Backup.backupPath) } @@ -50,6 +39,29 @@ abstract class AppDatabase : RoomDatabase() { }) .build() } + + private val migration_10_11 = object : Migration(10, 11) { + override fun migrate(database: SupportSQLiteDatabase) { + database.execSQL("DROP TABLE txtTocRules") + database.execSQL( + """ + CREATE TABLE txtTocRules(id INTEGER NOT NULL, + name TEXT NOT NULL, rule TEXT NOT NULL, serialNumber INTEGER NOT NULL, + enable INTEGER NOT NULL, PRIMARY KEY (id)) + """ + ) + } + } + + private val migration_11_12 = object : Migration(11, 12) { + override fun migrate(database: SupportSQLiteDatabase) { + database.execSQL( + """ + ALTER TABLE rssSources ADD css TEXT + """ + ) + } + } } abstract fun bookDao(): BookDao diff --git a/app/src/main/java/io/legado/app/data/entities/RssSource.kt b/app/src/main/java/io/legado/app/data/entities/RssSource.kt index e9a58ee98..e9a25c58c 100644 --- a/app/src/main/java/io/legado/app/data/entities/RssSource.kt +++ b/app/src/main/java/io/legado/app/data/entities/RssSource.kt @@ -34,9 +34,11 @@ data class RssSource( var ruleImage: String? = null, var ruleLink: String? = null, var ruleContent: String? = null, + var css: String? = null, var header: String? = null, var enableJs: Boolean = false, var loadWithBaseUrl: Boolean = false, + var customOrder: Int = 0 ) : Parcelable, JsExtensions { diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudConfigDialog.kt index 294a1c127..cdb10159e 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudConfigDialog.kt @@ -16,6 +16,7 @@ import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey import io.legado.app.help.AppConfig import io.legado.app.lib.theme.ATH +import io.legado.app.lib.theme.backgroundColor import io.legado.app.service.BaseReadAloudService import io.legado.app.service.help.ReadAloud import io.legado.app.ui.book.read.Help @@ -42,8 +43,8 @@ class ReadAloudConfigDialog : DialogFragment() { container: ViewGroup?, savedInstanceState: Bundle? ): View? { - val view = LinearLayout(context) - view.setBackgroundResource(R.color.background) + val view = LinearLayout(requireContext()) + view.setBackgroundColor(requireContext().backgroundColor) view.id = R.id.tag1 container?.addView(view) return view From a5e2fdb3123be6aa5fb9934eb0105fc585c7be93 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 3 May 2020 20:02:28 +0800 Subject: [PATCH 055/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/data/AppDatabase.kt | 2 +- app/src/main/java/io/legado/app/data/entities/RssSource.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 55978fe2f..d2256dd85 100644 --- a/app/src/main/java/io/legado/app/data/AppDatabase.kt +++ b/app/src/main/java/io/legado/app/data/AppDatabase.kt @@ -57,7 +57,7 @@ abstract class AppDatabase : RoomDatabase() { override fun migrate(database: SupportSQLiteDatabase) { database.execSQL( """ - ALTER TABLE rssSources ADD css TEXT + ALTER TABLE rssSources ADD style TEXT """ ) } diff --git a/app/src/main/java/io/legado/app/data/entities/RssSource.kt b/app/src/main/java/io/legado/app/data/entities/RssSource.kt index e9a25c58c..a7948e6e7 100644 --- a/app/src/main/java/io/legado/app/data/entities/RssSource.kt +++ b/app/src/main/java/io/legado/app/data/entities/RssSource.kt @@ -34,7 +34,7 @@ data class RssSource( var ruleImage: String? = null, var ruleLink: String? = null, var ruleContent: String? = null, - var css: String? = null, + var style: String? = null, var header: String? = null, var enableJs: Boolean = false, var loadWithBaseUrl: Boolean = false, From 0e818f62a46c4fd63efaceec76ae2940849b1eaf Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 3 May 2020 21:19:28 +0800 Subject: [PATCH 056/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt | 2 ++ app/src/main/res/values-zh-rHK/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 3 files changed, 4 insertions(+) diff --git a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt index d1e1b52e7..bd070639a 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt @@ -144,6 +144,7 @@ class RssSourceEditActivity : add(EditEntity("ruleImage", rssSource?.ruleImage, R.string.r_image)) add(EditEntity("ruleLink", rssSource?.ruleLink, R.string.r_link)) add(EditEntity("ruleContent", rssSource?.ruleContent, R.string.r_content)) + add(EditEntity("style", rssSource?.style, R.string.r_style)) add(EditEntity("header", rssSource?.header, R.string.source_http_header)) } adapter.editEntities = sourceEntities @@ -169,6 +170,7 @@ class RssSourceEditActivity : "ruleImage" -> source.ruleImage = it.value "ruleLink" -> source.ruleLink = it.value "ruleContent" -> source.ruleContent = it.value + "style" -> source.style = it.value "header" -> source.header = it.value } } diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 2fd588c82..79ff25a1c 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -417,6 +417,7 @@ 描述規則 (ruleDescription) 圖片 url 規則 (ruleImage) 內容規則 (ruleContent) + 樣式 鏈接規則 (ruleLink) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 339cdc437..448a53465 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -417,6 +417,7 @@ 描述规则(ruleDescription) 图片url规则(ruleImage) 内容规则(ruleContent) + 样式 链接规则(ruleLink) From a3918564e892e5138b4ebf28e85ee95de06ba3ba Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 3 May 2020 21:37:37 +0800 Subject: [PATCH 057/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/rss/read/ReadRssViewModel.kt | 33 ++++++++++++------- app/src/main/res/values-zh-rHK/strings.xml | 2 +- app/src/main/res/values/strings.xml | 2 +- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt index f5b84642f..72af31aca 100644 --- a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt @@ -138,17 +138,28 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application), } fun clHtml(content: String): String { - return if (content.contains(" - $content - """.trimIndent() + return when { + !rssSource?.style.isNullOrEmpty() -> { + """ + + $content + """.trimIndent() + } + content.contains(" + $content + """.trimIndent() + } } } diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 79ff25a1c..7aa554fdb 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -417,7 +417,7 @@ 描述規則 (ruleDescription) 圖片 url 規則 (ruleImage) 內容規則 (ruleContent) - 樣式 + 樣式 (style) 鏈接規則 (ruleLink) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 448a53465..83e6bdc84 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -417,7 +417,7 @@ 描述规则(ruleDescription) 图片url规则(ruleImage) 内容规则(ruleContent) - 样式 + 样式(style) 链接规则(ruleLink) From bcb0d592e3b4c3515c9d920ea0f86b34ea23b84f Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 3 May 2020 22:16:22 +0800 Subject: [PATCH 058/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 750284672..950d9837d 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -5,6 +5,7 @@ **2020/05/03** * 优化一些界面显示问题 +* 订阅源添加style **2020/05/02** * 修复不停换源的bug From 2a4fbce07975225c3f93ce71ad14f5007ab4851e Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 3 May 2020 23:07:07 +0800 Subject: [PATCH 059/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/BookHelp.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 dafaaec8c..3c0fa644e 100644 --- a/app/src/main/java/io/legado/app/help/BookHelp.kt +++ b/app/src/main/java/io/legado/app/help/BookHelp.kt @@ -241,9 +241,10 @@ object BookHelp { val contents = arrayListOf() c.split("\n").forEach { val str = it.replace("^\\s+".toRegex(), "") + .replace("\r", "") if (contents.isEmpty()) { contents.add(title) - if (it != title && it.isNotEmpty()) { + if (str != title && it.isNotEmpty()) { contents.add("${ReadBookConfig.bodyIndent}$str") } } else if (str.isNotEmpty()) { From 0b179711abc8d6fcec48e6c01d3b1e99eac4ae8a Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 3 May 2020 23:07:37 +0800 Subject: [PATCH 060/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 950d9837d..50c383639 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -6,6 +6,7 @@ **2020/05/03** * 优化一些界面显示问题 * 订阅源添加style +* 修复一些重复目录的bug **2020/05/02** * 修复不停换源的bug From 3b5b5e805edcecb0ccbd336f0be0c32e6f952791 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 4 May 2020 17:51:15 +0800 Subject: [PATCH 061/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/service/DownloadService.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/DownloadService.kt b/app/src/main/java/io/legado/app/service/DownloadService.kt index 1cbfe44f4..bf6b90629 100644 --- a/app/src/main/java/io/legado/app/service/DownloadService.kt +++ b/app/src/main/java/io/legado/app/service/DownloadService.kt @@ -30,7 +30,7 @@ class DownloadService : BaseService() { private val handler = Handler() private var runnable: Runnable = Runnable { upDownload() } private val downloadMap = hashMapOf>() - private val downloadCount = hashMapOf(); + private val downloadCount = hashMapOf() private val finalMap = hashMapOf>() private var notificationContent = "正在启动下载" @@ -199,11 +199,11 @@ class DownloadService : BaseService() { var successCount = 0 //下载成功的条目数量 fun increaseSuccess() { - ++successCount; + ++successCount } fun increaseFinished() { - ++downloadFinishedCount; + ++downloadFinishedCount } } } \ No newline at end of file From 661e9d8b06ed65cec022441e4ebd91d41b42b832 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 4 May 2020 22:39:42 +0800 Subject: [PATCH 062/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/model/localBook/AnalyzeTxtFile.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/model/localBook/AnalyzeTxtFile.kt b/app/src/main/java/io/legado/app/model/localBook/AnalyzeTxtFile.kt index 494437d92..15e8597c2 100644 --- a/app/src/main/java/io/legado/app/model/localBook/AnalyzeTxtFile.kt +++ b/app/src/main/java/io/legado/app/model/localBook/AnalyzeTxtFile.kt @@ -40,6 +40,7 @@ class AnalyzeTxtFile { book: Book, pattern: Pattern? ): ArrayList { + bookStream.seek(0) val toc = arrayListOf() var tocRule: TxtTocRule? = null val rulePattern = pattern ?: let { @@ -83,7 +84,8 @@ class AnalyzeTxtFile { //获取章节内容 val chapterContent = blockContent.substring(seekPos, chapterStart) val chapterLength = chapterContent.toByteArray(charset).size - if (chapterLength > 30000 && pattern == null) { + val lastStart = toc.lastOrNull()?.start ?: 0 + if (curOffset + chapterLength - lastStart > 50000 && pattern == null) { //移除不匹配的规则 tocRules.remove(tocRule) return analyze(bookStream, book, null) @@ -139,6 +141,11 @@ class AnalyzeTxtFile { //设置指针偏移 seekPos += chapterContent.length } + if (seekPos == 0 && length > 50000 && pattern == null) { + //移除不匹配的规则 + tocRules.remove(tocRule) + return analyze(bookStream, book, null) + } } else { //进行本地虚拟分章 //章节在buffer的偏移量 var chapterOffset = 0 From 31d05fd9002cc915f70c1fa4895d78fecde29266 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 4 May 2020 22:42:24 +0800 Subject: [PATCH 063/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 50c383639..34f05518c 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/05/04** +* 优化txt文件目录解析 + **2020/05/03** * 优化一些界面显示问题 * 订阅源添加style From 0dcc7ca8406278dbfc281479c620c8899b2497a0 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 5 May 2020 11:26:58 +0800 Subject: [PATCH 064/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/service/BaseReadAloudService.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt b/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt index 64bcf6a80..6dee23a92 100644 --- a/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt @@ -44,7 +44,7 @@ abstract class BaseReadAloudService : BaseService(), private lateinit var audioManager: AudioManager private var mFocusRequest: AudioFocusRequest? = null private var broadcastReceiver: BroadcastReceiver? = null - private var mediaSessionCompat: MediaSessionCompat? = null + private lateinit var mediaSessionCompat: MediaSessionCompat private var title: String = "" private var subtitle: String = "" internal val contentList = arrayListOf() @@ -59,6 +59,7 @@ abstract class BaseReadAloudService : BaseService(), isRun = true audioManager = getSystemService(Context.AUDIO_SERVICE) as AudioManager mFocusRequest = MediaHelp.getFocusRequest(this) + mediaSessionCompat = MediaSessionCompat(this, "readAloud") initMediaSession() initBroadcastReceiver() upNotification() @@ -72,7 +73,7 @@ abstract class BaseReadAloudService : BaseService(), unregisterReceiver(broadcastReceiver) postEvent(EventBus.ALOUD_STATE, Status.STOP) upMediaSessionPlaybackState(PlaybackStateCompat.STATE_STOPPED) - mediaSessionCompat?.release() + mediaSessionCompat.release() } override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { @@ -202,7 +203,7 @@ abstract class BaseReadAloudService : BaseService(), * 更新媒体状态 */ private fun upMediaSessionPlaybackState(state: Int) { - mediaSessionCompat?.setPlaybackState( + mediaSessionCompat.setPlaybackState( PlaybackStateCompat.Builder() .setActions(MediaHelp.MEDIA_SESSION_ACTIONS) .setState(state, nowSpeak.toLong(), 1f) @@ -214,13 +215,12 @@ abstract class BaseReadAloudService : BaseService(), * 初始化MediaSession, 注册多媒体按钮 */ private fun initMediaSession() { - mediaSessionCompat = MediaSessionCompat(this, "readAloud") - mediaSessionCompat?.setCallback(object : MediaSessionCompat.Callback() { + mediaSessionCompat.setCallback(object : MediaSessionCompat.Callback() { override fun onMediaButtonEvent(mediaButtonEvent: Intent): Boolean { return MediaButtonReceiver.handleIntent(this@BaseReadAloudService, mediaButtonEvent) } }) - mediaSessionCompat?.setMediaButtonReceiver( + mediaSessionCompat.setMediaButtonReceiver( PendingIntent.getBroadcast( this, 0, @@ -233,7 +233,7 @@ abstract class BaseReadAloudService : BaseService(), PendingIntent.FLAG_CANCEL_CURRENT ) ) - mediaSessionCompat?.isActive = true + mediaSessionCompat.isActive = true } /** @@ -323,7 +323,7 @@ abstract class BaseReadAloudService : BaseService(), ) builder.setStyle( androidx.media.app.NotificationCompat.MediaStyle() - .setMediaSession(mediaSessionCompat?.sessionToken) + .setMediaSession(mediaSessionCompat.sessionToken) .setShowActionsInCompactView(0, 1, 2) ) builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC) From bc4422a3aeec2b4a5490e80a9ac9c46a47f1b2b0 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 5 May 2020 11:31:55 +0800 Subject: [PATCH 065/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/service/TTSReadAloudService.kt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt b/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt index 28b7efdc9..b54bdb154 100644 --- a/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt @@ -69,10 +69,7 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener @Synchronized override fun play() { - if (contentList.isEmpty() || !ttsInitFinish) { - return - } - if (requestFocus()) { + if (contentList.isNotEmpty() && ttsInitFinish && requestFocus()) { MediaHelp.playSilentSound(this) super.play() textToSpeech?.stop() From 1bfeebc0f2f02e026da8ce2828c24a2a7ed6b6d1 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 5 May 2020 11:33:26 +0800 Subject: [PATCH 066/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/service/TTSReadAloudService.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt b/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt index b54bdb154..0517ca2fc 100644 --- a/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt @@ -52,7 +52,6 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener clearTTS() } - @Synchronized override fun onInit(status: Int) { if (status == TextToSpeech.SUCCESS) { textToSpeech?.let { From f4effb2ca7c0b035c5e53a48f6ec73c7d0db8b54 Mon Sep 17 00:00:00 2001 From: yangyxd Date: Wed, 6 May 2020 17:40:17 +0800 Subject: [PATCH 067/296] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AF=86=E5=88=ABrss?= =?UTF-8?q?=E5=88=86=E7=BB=84=E4=B8=AD=E7=9A=84=E9=A2=91=E9=81=93=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=EF=BC=8C=E5=9C=A8=E8=8F=9C=E5=8D=95=E4=B8=AD=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E5=88=87=E6=8D=A2=E9=A2=91=E9=81=93=EF=BC=88=E4=B8=8E?= =?UTF-8?q?=E4=B9=8B=E5=89=8D=E7=9A=84sortUrls=E4=B8=8D=E5=86=B2=E7=AA=81)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/rss/article/RssSortActivity.kt | 42 ++++++++++++++++++- app/src/main/res/menu/rss_articles.xml | 4 ++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt index 2d45bcd70..4acd423d1 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt @@ -5,6 +5,7 @@ import android.content.Intent import android.os.Bundle import android.view.Menu import android.view.MenuItem +import android.view.SubMenu import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentStatePagerAdapter @@ -17,6 +18,7 @@ import io.legado.app.utils.gone import io.legado.app.utils.visible import kotlinx.android.synthetic.main.activity_rss_artivles.* import org.jetbrains.anko.startActivityForResult +import java.util.LinkedHashMap class RssSortActivity : VMBaseActivity(R.layout.activity_rss_artivles) { @@ -25,6 +27,8 @@ class RssSortActivity : VMBaseActivity(R.layout.activity_rss_a private val editSource = 12319 private val fragments = linkedMapOf() private lateinit var adapter: TabFragmentPageAdapter + private val channels = LinkedHashMap() + private var groupMenu: Menu? = null override fun onActivityCreated(savedInstanceState: Bundle?) { adapter = TabFragmentPageAdapter(supportFragmentManager) @@ -34,6 +38,7 @@ class RssSortActivity : VMBaseActivity(R.layout.activity_rss_a title_bar.title = it }) viewModel.initData(intent) { + upChannelMenu() upFragments() } } @@ -43,6 +48,12 @@ class RssSortActivity : VMBaseActivity(R.layout.activity_rss_a return super.onCompatCreateOptionsMenu(menu) } + override fun onPrepareOptionsMenu(menu: Menu?): Boolean { + groupMenu = menu + upChannelMenu() + return super.onPrepareOptionsMenu(menu) + } + override fun onCompatOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { R.id.menu_edit_source -> viewModel.rssSource?.sourceUrl?.let { @@ -54,15 +65,44 @@ class RssSortActivity : VMBaseActivity(R.layout.activity_rss_a } } } + if (item.groupId == R.id.source_channel) { + var key = item.title.toString(); + var i = fragments.keys.indexOf(key) + if (i >= 0) + view_pager.currentItem = i + } return super.onCompatOptionsItemSelected(item) } + private fun upChannelMenu() { + // 加入频道列表 + groupMenu?.removeGroup(R.id.source_channel) + var sourceChannel = viewModel.rssSource?.sourceGroup + channels.clear() + sourceChannel?.split("\n\n")?.forEach { c -> + val d = c.split("::") + if (d.size > 1) { + channels[d[0]] = d[1] + var item = groupMenu?.add(R.id.source_channel, Menu.NONE, Menu.NONE, d[0]) + item?.isCheckable = true + var keys = fragments.keys + item?.isChecked = keys.indexOf(d[0]) == view_pager.currentItem + } + } + } + private fun upFragments() { fragments.clear() viewModel.rssSource?.sortUrls()?.forEach { fragments[it.key] = RssArticlesFragment.create(it.key, it.value) } - if (fragments.size == 1) { + var sortUrlsSize = fragments.size + if (sortUrlsSize <= 1) { + channels?.forEach { + fragments[it.key] = RssArticlesFragment.create(it.key, it.value) + } + } + if (sortUrlsSize == 1) { tab_layout.gone() } else { tab_layout.visible() diff --git a/app/src/main/res/menu/rss_articles.xml b/app/src/main/res/menu/rss_articles.xml index 03d187bcd..831b908a5 100644 --- a/app/src/main/res/menu/rss_articles.xml +++ b/app/src/main/res/menu/rss_articles.xml @@ -12,4 +12,8 @@ android:title="@string/clear" app:showAsAction="never" /> + + + + \ No newline at end of file From 9a5d19ad0ce8965a1f635dc10bd374d90fd066f1 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 7 May 2020 14:37:11 +0800 Subject: [PATCH 068/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/base/BaseFragment.kt | 5 --- .../io/legado/app/ui/main/MainActivity.kt | 6 --- .../ui/main/bookshelf/BookshelfFragment.kt | 3 -- .../app/ui/rss/article/RssSortActivity.kt | 17 ++++----- .../legado/app/ui/widget/prefs/Preference.kt | 4 -- .../main/java/io/legado/app/utils/UIUtils.kt | 15 +++++--- app/src/main/res/drawable/ic_add.xml | 14 ++++--- app/src/main/res/drawable/ic_add_online.xml | 20 ++++------ app/src/main/res/drawable/ic_arrange.xml | 32 +++++++--------- .../main/res/drawable/ic_download_line.xml | 16 ++++---- app/src/main/res/drawable/ic_groups.xml | 27 +++++++++---- app/src/main/res/drawable/ic_groups_menu.xml | 9 ----- app/src/main/res/drawable/ic_search.xml | 28 +++++++------- app/src/main/res/drawable/ic_view_quilt.xml | 38 +++++++++++-------- app/src/main/res/layout/view_preference.xml | 8 +--- app/src/main/res/menu/main_bookshelf.xml | 2 +- 16 files changed, 116 insertions(+), 128 deletions(-) delete mode 100644 app/src/main/res/drawable/ic_groups_menu.xml 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 c0b41fc40..c19033aa8 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,7 @@ import android.view.* import androidx.appcompat.view.SupportMenuInflater import androidx.appcompat.widget.Toolbar import androidx.fragment.app.Fragment -import io.legado.app.R -import io.legado.app.constant.Theme -import io.legado.app.utils.UIUtils import io.legado.app.utils.applyTint -import kotlinx.android.synthetic.main.view_title_bar.* import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -56,7 +52,6 @@ abstract class BaseFragment(layoutID: Int) : Fragment(layoutID), supportToolbar?.let { it.menu.apply { onCompatCreateOptionsMenu(this) - UIUtils.setToolbarMoreIconCustomColor(toolbar, UIUtils.getMenuColor(requireContext())) applyTint(requireContext()) } 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 e8b2870cb..181ec0330 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,13 +1,8 @@ package io.legado.app.ui.main -import android.graphics.drawable.Drawable -import android.os.Build import android.os.Bundle import android.view.KeyEvent import android.view.MenuItem -import android.widget.Toolbar -import androidx.annotation.RequiresApi -import androidx.core.content.ContextCompat import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentStatePagerAdapter @@ -31,7 +26,6 @@ import io.legado.app.ui.main.rss.RssFragment import io.legado.app.ui.widget.dialog.TextDialog import io.legado.app.utils.* import kotlinx.android.synthetic.main.activity_main.* -import kotlinx.android.synthetic.main.view_title_bar.* class MainActivity : VMBaseActivity(R.layout.activity_main), BottomNavigationView.OnNavigationItemSelectedListener, diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt index 329c19e85..f51bdc0a6 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt @@ -1,15 +1,12 @@ package io.legado.app.ui.main.bookshelf import android.annotation.SuppressLint -import android.os.Build import android.os.Bundle import android.view.LayoutInflater import android.view.Menu import android.view.MenuItem import android.view.View import androidx.appcompat.widget.SearchView -import androidx.appcompat.widget.Toolbar -import androidx.core.content.ContextCompat import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentStatePagerAdapter diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt index 4acd423d1..d7c7087d4 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt @@ -5,7 +5,6 @@ import android.content.Intent import android.os.Bundle import android.view.Menu import android.view.MenuItem -import android.view.SubMenu import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentStatePagerAdapter @@ -18,7 +17,7 @@ import io.legado.app.utils.gone import io.legado.app.utils.visible import kotlinx.android.synthetic.main.activity_rss_artivles.* import org.jetbrains.anko.startActivityForResult -import java.util.LinkedHashMap +import java.util.* class RssSortActivity : VMBaseActivity(R.layout.activity_rss_artivles) { @@ -66,8 +65,8 @@ class RssSortActivity : VMBaseActivity(R.layout.activity_rss_a } } if (item.groupId == R.id.source_channel) { - var key = item.title.toString(); - var i = fragments.keys.indexOf(key) + val key = item.title.toString(); + val i = fragments.keys.indexOf(key) if (i >= 0) view_pager.currentItem = i } @@ -77,15 +76,15 @@ class RssSortActivity : VMBaseActivity(R.layout.activity_rss_a private fun upChannelMenu() { // 加入频道列表 groupMenu?.removeGroup(R.id.source_channel) - var sourceChannel = viewModel.rssSource?.sourceGroup + val sourceChannel = viewModel.rssSource?.sourceGroup channels.clear() sourceChannel?.split("\n\n")?.forEach { c -> val d = c.split("::") if (d.size > 1) { channels[d[0]] = d[1] - var item = groupMenu?.add(R.id.source_channel, Menu.NONE, Menu.NONE, d[0]) + val item = groupMenu?.add(R.id.source_channel, Menu.NONE, Menu.NONE, d[0]) item?.isCheckable = true - var keys = fragments.keys + val keys = fragments.keys item?.isChecked = keys.indexOf(d[0]) == view_pager.currentItem } } @@ -96,9 +95,9 @@ class RssSortActivity : VMBaseActivity(R.layout.activity_rss_a viewModel.rssSource?.sortUrls()?.forEach { fragments[it.key] = RssArticlesFragment.create(it.key, it.value) } - var sortUrlsSize = fragments.size + val sortUrlsSize = fragments.size if (sortUrlsSize <= 1) { - channels?.forEach { + channels.forEach { fragments[it.key] = RssArticlesFragment.create(it.key, it.value) } } diff --git a/app/src/main/java/io/legado/app/ui/widget/prefs/Preference.kt b/app/src/main/java/io/legado/app/ui/widget/prefs/Preference.kt index 9152be216..f16799d0e 100644 --- a/app/src/main/java/io/legado/app/ui/widget/prefs/Preference.kt +++ b/app/src/main/java/io/legado/app/ui/widget/prefs/Preference.kt @@ -56,10 +56,6 @@ class Preference(context: Context, attrs: AttributeSet) : iconView.setColorFilter(context.accentColor) } - val paddingView = it.findViewById(R.id.preference_padding) - if (paddingView != null) { - paddingView.isVisible = view.isVisible && tvSummary != null && tvSummary.isVisible - } } if (weightLayoutRes != null && weightLayoutRes != 0 && viewId != null && viewId != 0) { diff --git a/app/src/main/java/io/legado/app/utils/UIUtils.kt b/app/src/main/java/io/legado/app/utils/UIUtils.kt index 9b2db69ff..31b02199b 100644 --- a/app/src/main/java/io/legado/app/utils/UIUtils.kt +++ b/app/src/main/java/io/legado/app/utils/UIUtils.kt @@ -14,12 +14,11 @@ import io.legado.app.lib.theme.primaryTextColor object UIUtils { /** 设置更多工具条图标和颜色 */ - fun setToolbarMoreIconCustomColor(toolbar: Toolbar, color: Int? = null) { - if (toolbar == null) - return + fun setToolbarMoreIconCustomColor(toolbar: Toolbar?, color: Int? = null) { + toolbar ?: return val moreIcon = ContextCompat.getDrawable(toolbar.context, R.drawable.ic_more) - if(moreIcon != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - if (color != null ) { + if (moreIcon != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (color != null) { moreIcon.colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP) } toolbar.overflowIcon = moreIcon @@ -27,7 +26,11 @@ object UIUtils { } - fun getMenuColor(context: Context, theme: Theme = Theme.Auto, requiresOverflow: Boolean = false): Int { + fun getMenuColor( + context: Context, + theme: Theme = Theme.Auto, + requiresOverflow: Boolean = false + ): Int { val defaultTextColor = context.getCompatColor(R.color.tv_text_default) if (requiresOverflow) return defaultTextColor diff --git a/app/src/main/res/drawable/ic_add.xml b/app/src/main/res/drawable/ic_add.xml index 97328c410..b4f63fa80 100644 --- a/app/src/main/res/drawable/ic_add.xml +++ b/app/src/main/res/drawable/ic_add.xml @@ -1,9 +1,11 @@ + - - + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_add_online.xml b/app/src/main/res/drawable/ic_add_online.xml index c7f649fd4..d11efea01 100644 --- a/app/src/main/res/drawable/ic_add_online.xml +++ b/app/src/main/res/drawable/ic_add_online.xml @@ -1,15 +1,11 @@ + - - - - + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_arrange.xml b/app/src/main/res/drawable/ic_arrange.xml index cf0600e77..416dbf843 100644 --- a/app/src/main/res/drawable/ic_arrange.xml +++ b/app/src/main/res/drawable/ic_arrange.xml @@ -1,21 +1,17 @@ + - - - - - - + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_download_line.xml b/app/src/main/res/drawable/ic_download_line.xml index 7f9bcad59..c882860c7 100644 --- a/app/src/main/res/drawable/ic_download_line.xml +++ b/app/src/main/res/drawable/ic_download_line.xml @@ -1,12 +1,14 @@ + + + android:fillColor="#595757" + android:pathData="M16.712,20 L7.288,20 C5.474,20,4,18.633,4,16.952 L4,14.287 L5.524,14.287 L5.524,16.952 C5.524,17.792,6.316,18.476,7.288,18.476 L16.713,18.476 C17.685,18.476,18.477,17.791,18.477,16.952 L18.477,14.287 L20,14.287 L20,16.952 C20,18.633,18.526,20,16.712,20 Z" /> - + android:fillColor="#595757" + android:pathData="M12,15.742 L7.382,11.127 L8.459,10.05 L11.239,12.827 L11.239,4 L12.761,4 L12.761,12.827 L15.541,10.05 L16.618,11.127 Z" /> + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_groups.xml b/app/src/main/res/drawable/ic_groups.xml index f79df8df8..e15e9af8e 100644 --- a/app/src/main/res/drawable/ic_groups.xml +++ b/app/src/main/res/drawable/ic_groups.xml @@ -1,9 +1,20 @@ + - - + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_groups_menu.xml b/app/src/main/res/drawable/ic_groups_menu.xml deleted file mode 100644 index 165d4b705..000000000 --- a/app/src/main/res/drawable/ic_groups_menu.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml index f207ed0a4..b915218e5 100644 --- a/app/src/main/res/drawable/ic_search.xml +++ b/app/src/main/res/drawable/ic_search.xml @@ -1,15 +1,17 @@ - - - - + android:viewportHeight="48" + android:viewportWidth="48" + android:width="24dp" + xmlns:android="http://schemas.android.com/apk/res/android"> + + diff --git a/app/src/main/res/drawable/ic_view_quilt.xml b/app/src/main/res/drawable/ic_view_quilt.xml index eecbde250..88b5317e7 100644 --- a/app/src/main/res/drawable/ic_view_quilt.xml +++ b/app/src/main/res/drawable/ic_view_quilt.xml @@ -1,18 +1,26 @@ + - - - - - + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/view_preference.xml b/app/src/main/res/layout/view_preference.xml index acae86b8e..f825afe26 100644 --- a/app/src/main/res/layout/view_preference.xml +++ b/app/src/main/res/layout/view_preference.xml @@ -28,7 +28,6 @@ android:orientation="vertical" android:layout_weight="1.0" android:layout_width="0dp" - android:layout_gravity="center_vertical" android:layout_height="wrap_content"> - - From 1b9232097535f6d3f9942a219ba0bdeccb627c50 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 10 May 2020 08:47:38 +0800 Subject: [PATCH 069/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 34f05518c..e36a350ff 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/05/10** +* 添加识别rss分组中的频道信息,在菜单中可以切换频道 from yangyxd + **2020/05/04** * 优化txt文件目录解析 From 8e486e77f6d87c047a2bd3e69c7a6bcdb7f35411 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 10 May 2020 09:23:40 +0800 Subject: [PATCH 070/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + .../app/ui/book/source/manage/BookSourceActivity.kt | 1 + .../app/ui/book/source/manage/BookSourceViewModel.kt | 9 ++++++--- .../legado/app/ui/rss/source/manage/RssSourceActivity.kt | 3 +-- .../app/ui/rss/source/manage/RssSourceViewModel.kt | 9 ++++++--- app/src/main/res/menu/book_source_sel.xml | 5 +++++ app/src/main/res/menu/rss_source_sel.xml | 9 ++++----- 7 files changed, 24 insertions(+), 13 deletions(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index e36a350ff..b69dc9d11 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -5,6 +5,7 @@ **2020/05/10** * 添加识别rss分组中的频道信息,在菜单中可以切换频道 from yangyxd +* 书源添加批量置顶 **2020/05/04** * 优化txt文件目录解析 diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt index d3cb63af3..088d6855b 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt @@ -203,6 +203,7 @@ class BookSourceActivity : VMBaseActivity(R.layout.activity R.id.menu_disable_explore -> viewModel.disableSelectExplore(adapter.getSelection()) R.id.menu_export_selection -> FilePicker.selectFolder(this, exportRequestCode) R.id.menu_check_source -> CheckSource.start(this, adapter.getSelection()) + R.id.menu_top_sel -> viewModel.topSource(*adapter.getSelection().toTypedArray()) } return true } diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt index 5857fe8ef..e3ea49495 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt @@ -19,10 +19,13 @@ import java.io.File class BookSourceViewModel(application: Application) : BaseViewModel(application) { - fun topSource(bookSource: BookSource) { + fun topSource(vararg sources: BookSource) { execute { - bookSource.customOrder = App.db.bookSourceDao().minOrder - 1 - App.db.bookSourceDao().insert(bookSource) + val minOrder = App.db.bookSourceDao().minOrder - 1 + sources.forEachIndexed { index, bookSource -> + bookSource.customOrder = minOrder - index + } + App.db.bookSourceDao().update(*sources) } } diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt index 1f7503e47..f945dcc15 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt @@ -106,8 +106,7 @@ class RssSourceActivity : VMBaseActivity(R.layout.activity_r R.id.menu_disable_selection -> viewModel.disableSelection(adapter.getSelection()) R.id.menu_del_selection -> viewModel.delSelection(adapter.getSelection()) R.id.menu_export_selection -> FilePicker.selectFolder(this, exportRequestCode) - R.id.menu_check_source -> { - } + R.id.menu_top_sel -> viewModel.topSource(*adapter.getSelection().toTypedArray()) } return true } diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt index 65c5bc093..723710c7d 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt @@ -17,10 +17,13 @@ import java.io.File class RssSourceViewModel(application: Application) : BaseViewModel(application) { - fun topSource(rssSource: RssSource) { + fun topSource(vararg sources: RssSource) { execute { - rssSource.customOrder = App.db.rssSourceDao().minOrder - 1 - App.db.rssSourceDao().insert(rssSource) + val minOrder = App.db.rssSourceDao().minOrder - 1 + sources.forEachIndexed { index, rssSource -> + rssSource.customOrder = minOrder - index + } + App.db.rssSourceDao().update(*sources) } } diff --git a/app/src/main/res/menu/book_source_sel.xml b/app/src/main/res/menu/book_source_sel.xml index 456bf4645..dd245cd43 100644 --- a/app/src/main/res/menu/book_source_sel.xml +++ b/app/src/main/res/menu/book_source_sel.xml @@ -22,6 +22,11 @@ android:title="@string/disable_explore" app:showAsAction="never" /> + + From 086ccc4c405d0d2c5f49ba4808f6cc0bd96eac63 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 10 May 2020 09:58:54 +0800 Subject: [PATCH 071/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/debug/res/values/strings.xml | 4 +- .../book/source/manage/BookSourceActivity.kt | 5 +++ .../book/source/manage/BookSourceAdapter.kt | 2 + .../book/source/manage/BookSourceViewModel.kt | 10 +++++ .../ui/rss/source/manage/RssSourceActivity.kt | 5 +++ .../ui/rss/source/manage/RssSourceAdapter.kt | 2 + .../rss/source/manage/RssSourceViewModel.kt | 10 +++++ app/src/main/res/menu/book_source_item.xml | 4 ++ app/src/main/res/menu/book_source_sel.xml | 5 +++ app/src/main/res/menu/rss_source_item.xml | 4 ++ app/src/main/res/menu/rss_source_sel.xml | 5 +++ app/src/main/res/values-zh-rHK/strings.xml | 1 + app/src/main/res/values/pref_key_value.xml | 40 +++++++++---------- app/src/main/res/values/strings.xml | 1 + 14 files changed, 76 insertions(+), 22 deletions(-) diff --git a/app/src/debug/res/values/strings.xml b/app/src/debug/res/values/strings.xml index e4464c88d..f465472f0 100644 --- a/app/src/debug/res/values/strings.xml +++ b/app/src/debug/res/values/strings.xml @@ -1,4 +1,4 @@ - 阅读·D - 阅读·D·搜索 + 阅读·D + 阅读·D·搜索 \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt index 088d6855b..a765f3b4f 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt @@ -204,6 +204,7 @@ class BookSourceActivity : VMBaseActivity(R.layout.activity R.id.menu_export_selection -> FilePicker.selectFolder(this, exportRequestCode) R.id.menu_check_source -> CheckSource.start(this, adapter.getSelection()) R.id.menu_top_sel -> viewModel.topSource(*adapter.getSelection().toTypedArray()) + R.id.menu_bottom_sel -> viewModel.bottomSource(*adapter.getSelection().toTypedArray()) } return true } @@ -287,6 +288,10 @@ class BookSourceActivity : VMBaseActivity(R.layout.activity viewModel.topSource(bookSource) } + override fun toBottom(bookSource: BookSource) { + viewModel.bottomSource(bookSource) + } + override fun onFilePicked(requestCode: Int, currentPath: String) { when (requestCode) { exportRequestCode -> viewModel.exportSelection( diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt index eb37cb868..c420284f8 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt @@ -138,6 +138,7 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : popupMenu.setOnMenuItemClickListener { menuItem -> when (menuItem.itemId) { R.id.menu_top -> callBack.toTop(source) + R.id.menu_bottom -> callBack.toBottom(source) R.id.menu_del -> callBack.del(source) R.id.menu_enable_explore -> { callBack.update(source.copy(enabledExplore = !source.enabledExplore)) @@ -197,6 +198,7 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : fun edit(bookSource: BookSource) fun update(vararg bookSource: BookSource) fun toTop(bookSource: BookSource) + fun toBottom(bookSource: BookSource) fun upOrder() fun upCountView() } diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt index e3ea49495..99e3fc387 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt @@ -29,6 +29,16 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) } } + fun bottomSource(vararg sources: BookSource) { + execute { + val maxOrder = App.db.bookSourceDao().minOrder + 1 + sources.forEachIndexed { index, bookSource -> + bookSource.customOrder = maxOrder + index + } + App.db.bookSourceDao().update(*sources) + } + } + fun del(bookSource: BookSource) { execute { App.db.bookSourceDao().delete(bookSource) } } diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt index f945dcc15..13f270d6a 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt @@ -107,6 +107,7 @@ class RssSourceActivity : VMBaseActivity(R.layout.activity_r R.id.menu_del_selection -> viewModel.delSelection(adapter.getSelection()) R.id.menu_export_selection -> FilePicker.selectFolder(this, exportRequestCode) R.id.menu_top_sel -> viewModel.topSource(*adapter.getSelection().toTypedArray()) + R.id.menu_bottom_sel -> viewModel.bottomSource(*adapter.getSelection().toTypedArray()) } return true } @@ -338,6 +339,10 @@ class RssSourceActivity : VMBaseActivity(R.layout.activity_r viewModel.topSource(source) } + override fun toBottom(source: RssSource) { + viewModel.bottomSource(source) + } + override fun upOrder() { viewModel.upOrder() } diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt index 72de1e250..28ee9b48c 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt @@ -111,6 +111,7 @@ class RssSourceAdapter(context: Context, val callBack: CallBack) : popupMenu.setOnMenuItemClickListener { menuItem -> when (menuItem.itemId) { R.id.menu_top -> callBack.toTop(source) + R.id.menu_bottom -> callBack.toBottom(source) R.id.menu_del -> callBack.del(source) } true @@ -151,6 +152,7 @@ class RssSourceAdapter(context: Context, val callBack: CallBack) : fun edit(source: RssSource) fun update(vararg source: RssSource) fun toTop(source: RssSource) + fun toBottom(source: RssSource) fun upOrder() fun upCountView() } diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt index 723710c7d..a506bad24 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt @@ -27,6 +27,16 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application) } } + fun bottomSource(vararg sources: RssSource) { + execute { + val maxOrder = App.db.rssSourceDao().maxOrder + 1 + sources.forEachIndexed { index, rssSource -> + rssSource.customOrder = maxOrder + index + } + App.db.rssSourceDao().update(*sources) + } + } + fun del(rssSource: RssSource) { execute { App.db.rssSourceDao().delete(rssSource) } } diff --git a/app/src/main/res/menu/book_source_item.xml b/app/src/main/res/menu/book_source_item.xml index a3cdcd258..c61d69dab 100644 --- a/app/src/main/res/menu/book_source_item.xml +++ b/app/src/main/res/menu/book_source_item.xml @@ -5,6 +5,10 @@ android:id="@+id/menu_top" android:title="@string/to_top" /> + + diff --git a/app/src/main/res/menu/book_source_sel.xml b/app/src/main/res/menu/book_source_sel.xml index dd245cd43..5ed76592d 100644 --- a/app/src/main/res/menu/book_source_sel.xml +++ b/app/src/main/res/menu/book_source_sel.xml @@ -27,6 +27,11 @@ android:title="@string/to_top" app:showAsAction="never" /> + + + + diff --git a/app/src/main/res/menu/rss_source_sel.xml b/app/src/main/res/menu/rss_source_sel.xml index ffbfacf98..2c0b61e80 100644 --- a/app/src/main/res/menu/rss_source_sel.xml +++ b/app/src/main/res/menu/rss_source_sel.xml @@ -17,6 +17,11 @@ android:title="@string/to_top" app:showAsAction="never" /> + + 隱藏頁眉 隱藏頁脚 自動換源 + 置底 diff --git a/app/src/main/res/values/pref_key_value.xml b/app/src/main/res/values/pref_key_value.xml index f1f70b8c5..017bfe798 100644 --- a/app/src/main/res/values/pref_key_value.xml +++ b/app/src/main/res/values/pref_key_value.xml @@ -1,23 +1,23 @@ - - auto_refresh - list_screen_direction - full_screen - threads_num - user_agent - bookshelf_px - read_type - expandGroupFind - defaultToRead - autoDownload - checkUpdate - 开源阅读 + + auto_refresh + list_screen_direction + full_screen + threads_num + user_agent + bookshelf_px + read_type + expandGroupFind + defaultToRead + autoDownload + checkUpdate + 开源阅读 - https://gitee.com/alanskycn/yuedu/blob/master/Rule/README.md - https://github.com/gedoor/legado - https://github.com/gedoor/legado/graphs/contributors - https://gedoor.github.io/MyBookshelf/disclaimer.html - https://gedoor.github.io/MyBookshelf/ - https://github.com/gedoor/legado/releases/latest - https://api.github.com/repos/gedoor/legado/releases/latest + https://gitee.com/alanskycn/yuedu/blob/master/Rule/README.md + https://github.com/gedoor/legado + https://github.com/gedoor/legado/graphs/contributors + https://gedoor.github.io/MyBookshelf/disclaimer.html + https://gedoor.github.io/MyBookshelf/ + https://github.com/gedoor/legado/releases/latest + https://api.github.com/repos/gedoor/legado/releases/latest diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 83e6bdc84..f01493465 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -308,6 +308,7 @@ 行距 段距 置顶 + 置底 自动展开发现 默认展开第一组发现 当前线程数 %s From 102cd92f4ebed9e8f38bffc6919940bb25084a06 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 10 May 2020 10:00:05 +0800 Subject: [PATCH 072/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index b69dc9d11..c7184b6c7 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -5,7 +5,7 @@ **2020/05/10** * 添加识别rss分组中的频道信息,在菜单中可以切换频道 from yangyxd -* 书源添加批量置顶 +* 源管理添加置底,批量置顶,批量置地 **2020/05/04** * 优化txt文件目录解析 From d9a57163618ec6cb6b0c766daaf6eb0e7100df42 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 10 May 2020 10:10:40 +0800 Subject: [PATCH 073/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/book/source/manage/BookSourceViewModel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt index 99e3fc387..3ffd37543 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt @@ -31,7 +31,7 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) fun bottomSource(vararg sources: BookSource) { execute { - val maxOrder = App.db.bookSourceDao().minOrder + 1 + val maxOrder = App.db.bookSourceDao().maxOrder + 1 sources.forEachIndexed { index, bookSource -> bookSource.customOrder = maxOrder + index } From 408720e25b2c5a2d081f4ad1dbc8fa440367d60d Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 10 May 2020 10:18:09 +0800 Subject: [PATCH 074/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/service/help/CheckSource.kt | 2 +- .../app/ui/book/source/manage/BookSourceAdapter.kt | 6 +++--- .../ui/book/source/manage/BookSourceViewModel.kt | 14 +++++++------- .../app/ui/rss/source/manage/RssSourceActivity.kt | 2 +- .../app/ui/rss/source/manage/RssSourceAdapter.kt | 6 +++--- .../app/ui/rss/source/manage/RssSourceViewModel.kt | 10 +++++----- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/help/CheckSource.kt b/app/src/main/java/io/legado/app/service/help/CheckSource.kt index 1f13723a2..b0a33953b 100644 --- a/app/src/main/java/io/legado/app/service/help/CheckSource.kt +++ b/app/src/main/java/io/legado/app/service/help/CheckSource.kt @@ -10,7 +10,7 @@ import org.jetbrains.anko.toast object CheckSource { - fun start(context: Context, sources: LinkedHashSet) { + fun start(context: Context, sources: List) { if (sources.isEmpty()) { context.toast(R.string.non_select) return diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt index c420284f8..a035341ee 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt @@ -46,14 +46,14 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : callBack.upCountView() } - fun getSelection(): LinkedHashSet { - val selection = linkedSetOf() + fun getSelection(): List { + val selection = arrayListOf() getItems().map { if (selected.contains(it)) { selection.add(it) } } - return selection + return selection.sortedBy { it.customOrder } } override fun convert(holder: ItemViewHolder, item: BookSource, payloads: MutableList) { diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt index 3ffd37543..5077a71cf 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt @@ -57,7 +57,7 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) } } - fun enableSelection(sources: LinkedHashSet) { + fun enableSelection(sources: List) { execute { val list = arrayListOf() sources.forEach { @@ -67,7 +67,7 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) } } - fun disableSelection(sources: LinkedHashSet) { + fun disableSelection(sources: List) { execute { val list = arrayListOf() sources.forEach { @@ -77,7 +77,7 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) } } - fun enableSelectExplore(sources: LinkedHashSet) { + fun enableSelectExplore(sources: List) { execute { val list = arrayListOf() sources.forEach { @@ -87,7 +87,7 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) } } - fun disableSelectExplore(sources: LinkedHashSet) { + fun disableSelectExplore(sources: List) { execute { val list = arrayListOf() sources.forEach { @@ -97,13 +97,13 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) } } - fun delSelection(sources: LinkedHashSet) { + fun delSelection(sources: List) { execute { App.db.bookSourceDao().delete(*sources.toTypedArray()) } } - fun exportSelection(sources: LinkedHashSet, file: File) { + fun exportSelection(sources: List, file: File) { execute { val json = GSON.toJson(sources) FileUtils.createFileIfNotExist(file, "exportBookSource.json") @@ -115,7 +115,7 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) } } - fun exportSelection(sources: LinkedHashSet, doc: DocumentFile) { + fun exportSelection(sources: List, doc: DocumentFile) { execute { val json = GSON.toJson(sources) doc.findFile("exportBookSource.json")?.delete() diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt index 13f270d6a..be9866ef2 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt @@ -204,7 +204,7 @@ class RssSourceActivity : VMBaseActivity(R.layout.activity_r private fun upGroupMenu() { groupMenu?.removeGroup(R.id.source_group) - groups.sortedWith(Collator.getInstance(java.util.Locale.CHINESE)) + groups.sortedWith(Collator.getInstance(Locale.CHINESE)) .map { groupMenu?.add(R.id.source_group, Menu.NONE, Menu.NONE, it) } diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt index 28ee9b48c..156dc1610 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt @@ -40,14 +40,14 @@ class RssSourceAdapter(context: Context, val callBack: CallBack) : callBack.upCountView() } - fun getSelection(): LinkedHashSet { - val selection = linkedSetOf() + fun getSelection(): List { + val selection = arrayListOf() getItems().forEach { if (selected.contains(it)) { selection.add(it) } } - return selection + return selection.sortedBy { it.customOrder } } override fun convert(holder: ItemViewHolder, item: RssSource, payloads: MutableList) { diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt index a506bad24..1ee781220 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt @@ -55,7 +55,7 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application) } } - fun enableSelection(sources: LinkedHashSet) { + fun enableSelection(sources: List) { execute { val list = arrayListOf() sources.forEach { @@ -65,7 +65,7 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application) } } - fun disableSelection(sources: LinkedHashSet) { + fun disableSelection(sources: List) { execute { val list = arrayListOf() sources.forEach { @@ -75,13 +75,13 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application) } } - fun delSelection(sources: LinkedHashSet) { + fun delSelection(sources: List) { execute { App.db.rssSourceDao().delete(*sources.toTypedArray()) } } - fun exportSelection(sources: LinkedHashSet, file: File) { + fun exportSelection(sources: List, file: File) { execute { val json = GSON.toJson(sources) FileUtils.createFileIfNotExist(file, "exportRssSource.json") @@ -93,7 +93,7 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application) } } - fun exportSelection(sources: LinkedHashSet, doc: DocumentFile) { + fun exportSelection(sources: List, doc: DocumentFile) { execute { val json = GSON.toJson(sources) doc.findFile("exportRssSource.json")?.delete() From 606324e943e530ec5132980e674e91c0f26d9ddc Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 10 May 2020 16:32:28 +0800 Subject: [PATCH 075/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/help/ImageLoader.kt | 5 ++- .../ui/book/info/edit/BookInfoEditActivity.kt | 31 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/help/ImageLoader.kt b/app/src/main/java/io/legado/app/help/ImageLoader.kt index 3d4272e9e..49b315a3f 100644 --- a/app/src/main/java/io/legado/app/help/ImageLoader.kt +++ b/app/src/main/java/io/legado/app/help/ImageLoader.kt @@ -7,6 +7,8 @@ import android.net.Uri import androidx.annotation.DrawableRes import com.bumptech.glide.Glide import com.bumptech.glide.RequestBuilder +import io.legado.app.utils.isAbsUrl +import io.legado.app.utils.isContentPath import java.io.File object ImageLoader { @@ -14,7 +16,8 @@ object ImageLoader { fun load(context: Context, path: String?): RequestBuilder { return when { path.isNullOrEmpty() -> Glide.with(context).load(path) - path.startsWith("http", true) -> Glide.with(context).load(path) + path.isAbsUrl() -> Glide.with(context).load(path) + path.isContentPath() -> Glide.with(context).load(Uri.parse(path)) else -> try { Glide.with(context).load(File(path)) } catch (e: Exception) { diff --git a/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt index 969b1ee45..e0b76ce1f 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt @@ -1,6 +1,7 @@ package io.legado.app.ui.book.info.edit import android.app.Activity +import android.content.Intent import android.os.Bundle import android.view.Menu import android.view.MenuItem @@ -16,6 +17,9 @@ import org.jetbrains.anko.sdk27.listeners.onClick class BookInfoEditActivity : VMBaseActivity(R.layout.activity_book_info_edit), ChangeCoverDialog.CallBack { + + private val resultSelectCover = 132 + override val viewModel: BookInfoEditViewModel get() = getViewModel(BookInfoEditViewModel::class.java) @@ -47,6 +51,13 @@ class BookInfoEditActivity : ChangeCoverDialog.show(supportFragmentManager, it.name, it.author) } } + tv_select_cover.onClick { + selectImage() + } + tv_refresh_cover.onClick { + tie_cover_url.setText(viewModel.book?.customCoverUrl) + upCover() + } } private fun upView(book: Book) { @@ -77,9 +88,29 @@ class BookInfoEditActivity : } } + private fun selectImage() { + val intent = Intent(Intent.ACTION_GET_CONTENT) + intent.addCategory(Intent.CATEGORY_OPENABLE) + intent.type = "image/*" + startActivityForResult(intent, resultSelectCover) + } + override fun coverChangeTo(coverUrl: String) { viewModel.book?.customCoverUrl = coverUrl tie_cover_url.setText(coverUrl) upCover() } + + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + super.onActivityResult(requestCode, resultCode, data) + when (requestCode) { + resultSelectCover -> { + if (resultCode == Activity.RESULT_OK) { + data?.data?.let { uri -> + coverChangeTo(uri.toString()) + } + } + } + } + } } \ No newline at end of file From 5ca20e06cf0d84ffe19a50654010d163871e4dd9 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 10 May 2020 16:41:10 +0800 Subject: [PATCH 076/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/ImageLoader.kt | 3 +++ .../main/java/io/legado/app/ui/widget/image/CoverImageView.kt | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/help/ImageLoader.kt b/app/src/main/java/io/legado/app/help/ImageLoader.kt index 49b315a3f..11f8dff21 100644 --- a/app/src/main/java/io/legado/app/help/ImageLoader.kt +++ b/app/src/main/java/io/legado/app/help/ImageLoader.kt @@ -13,6 +13,9 @@ import java.io.File object ImageLoader { + /** + * 自动判断path类型 + */ fun load(context: Context, path: String?): RequestBuilder { return when { path.isNullOrEmpty() -> Glide.with(context).load(path) 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 426391be4..e0268da7e 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 @@ -130,7 +130,7 @@ class CoverImageView : androidx.appcompat.widget.AppCompatImageView { fun load(path: String?, name: String?, author: String?) { setText(name, author) - ImageLoader.load(context, path)//Glide自动识别http://和file:// + ImageLoader.load(context, path)//Glide自动识别http://,content://和file:// .placeholder(R.drawable.image_cover_default) .error(R.drawable.image_cover_default) .listener(object : RequestListener { From 667cd533695ae7c05d3f33d85c06ae8f0d0ad236 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 10 May 2020 18:29:18 +0800 Subject: [PATCH 077/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/book/info/edit/BookInfoEditActivity.kt | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt index e0b76ce1f..f7ff39be4 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt @@ -9,7 +9,10 @@ import androidx.lifecycle.Observer import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.data.entities.Book +import io.legado.app.help.permission.Permissions +import io.legado.app.help.permission.PermissionsCompat import io.legado.app.ui.book.changecover.ChangeCoverDialog +import io.legado.app.utils.RealPathUtil import io.legado.app.utils.getViewModel import kotlinx.android.synthetic.main.activity_book_info_edit.* import org.jetbrains.anko.sdk27.listeners.onClick @@ -55,7 +58,7 @@ class BookInfoEditActivity : selectImage() } tv_refresh_cover.onClick { - tie_cover_url.setText(viewModel.book?.customCoverUrl) + viewModel.book?.customCoverUrl = tie_cover_url.text?.toString() upCover() } } @@ -107,7 +110,18 @@ class BookInfoEditActivity : resultSelectCover -> { if (resultCode == Activity.RESULT_OK) { data?.data?.let { uri -> - coverChangeTo(uri.toString()) + RealPathUtil.getPath(this, uri)?.let { path -> + PermissionsCompat.Builder(this) + .addPermissions( + Permissions.READ_EXTERNAL_STORAGE, + Permissions.WRITE_EXTERNAL_STORAGE + ) + .rationale(R.string.get_storage_per) + .onGranted { + coverChangeTo(path) + } + .request() + } } } } From 34c6af9964c3e3fa90bbcc80b15c6e7e8e2dac69 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 10 May 2020 18:30:02 +0800 Subject: [PATCH 078/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index c7184b6c7..1b9ae3c09 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -6,6 +6,7 @@ **2020/05/10** * 添加识别rss分组中的频道信息,在菜单中可以切换频道 from yangyxd * 源管理添加置底,批量置顶,批量置地 +* 封面选择本地图片完成 **2020/05/04** * 优化txt文件目录解析 From ca0673c93e11d1ebd41049b76a53374caa236e9b Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 10 May 2020 18:51:26 +0800 Subject: [PATCH 079/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 75fdfb620..ec6d22bdb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -117,7 +117,7 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" //fireBase - implementation 'com.google.firebase:firebase-core:17.4.0' + implementation 'com.google.firebase:firebase-core:17.4.1' implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1' //androidX From b04442f3ec3201149678a7351826a78883467c2e Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 10 May 2020 18:56:41 +0800 Subject: [PATCH 080/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 3 +++ .../ui/book/info/edit/BookInfoEditActivity.kt | 16 +--------------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b33892324..6b2bafdd8 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -3,6 +3,9 @@ xmlns:tools="http://schemas.android.com/tools" package="io.legado.app"> + diff --git a/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt index f7ff39be4..70b945efe 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt @@ -9,10 +9,7 @@ import androidx.lifecycle.Observer import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.data.entities.Book -import io.legado.app.help.permission.Permissions -import io.legado.app.help.permission.PermissionsCompat import io.legado.app.ui.book.changecover.ChangeCoverDialog -import io.legado.app.utils.RealPathUtil import io.legado.app.utils.getViewModel import kotlinx.android.synthetic.main.activity_book_info_edit.* import org.jetbrains.anko.sdk27.listeners.onClick @@ -110,18 +107,7 @@ class BookInfoEditActivity : resultSelectCover -> { if (resultCode == Activity.RESULT_OK) { data?.data?.let { uri -> - RealPathUtil.getPath(this, uri)?.let { path -> - PermissionsCompat.Builder(this) - .addPermissions( - Permissions.READ_EXTERNAL_STORAGE, - Permissions.WRITE_EXTERNAL_STORAGE - ) - .rationale(R.string.get_storage_per) - .onGranted { - coverChangeTo(path) - } - .request() - } + coverChangeTo(uri.toString()) } } } From b57a63f2d2eaf729b94992e832f662413939e2c5 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 14 May 2020 13:16:05 +0800 Subject: [PATCH 081/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/help/SourceHelp.kt | 44 +++++++++++++++++++ .../rss/source/manage/RssSourceViewModel.kt | 9 ++-- 2 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/io/legado/app/help/SourceHelp.kt diff --git a/app/src/main/java/io/legado/app/help/SourceHelp.kt b/app/src/main/java/io/legado/app/help/SourceHelp.kt new file mode 100644 index 000000000..bfb1ce104 --- /dev/null +++ b/app/src/main/java/io/legado/app/help/SourceHelp.kt @@ -0,0 +1,44 @@ +package io.legado.app.help + +import android.os.Handler +import android.os.Looper +import io.legado.app.App +import io.legado.app.data.entities.BookSource +import io.legado.app.data.entities.RssSource +import io.legado.app.utils.splitNotBlank +import org.jetbrains.anko.toast + +object SourceHelp { + + private val handler = Handler(Looper.getMainLooper()) + private val list18Plus by lazy { + String(App.INSTANCE.assets.open("18PlusList.txt").readBytes()).splitNotBlank("\n") + } + + fun insertRssSource(vararg rssSources: RssSource) { + rssSources.forEach { rssSource -> + if (is18Plus(rssSource.sortUrl)) { + handler.post { + App.INSTANCE.toast("${rssSource.sourceName}是18+网址,禁止导入.") + } + } else { + App.db.rssSourceDao().insert(rssSource) + } + } + } + + fun insertBookSource(vararg bookSources: BookSource) { + App.db.bookSourceDao().insert(*bookSources) + } + + private fun is18Plus(url: String?): Boolean { + url ?: return false + list18Plus.forEach { + if (url.contains(it)) { + return true + } + } + return false + } + +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt index 1ee781220..a15cb2e77 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt @@ -9,6 +9,7 @@ import io.legado.app.App import io.legado.app.R import io.legado.app.base.BaseViewModel import io.legado.app.data.entities.RssSource +import io.legado.app.help.SourceHelp import io.legado.app.help.http.HttpHelper import io.legado.app.help.storage.Restore.jsonPath import io.legado.app.utils.* @@ -162,7 +163,7 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application) } if (null != content) { GSON.fromJsonArray(content)?.let { - App.db.rssSourceDao().insert(*it.toTypedArray()) + SourceHelp.insertRssSource(*it.toTypedArray()) } } }.onSuccess { @@ -184,7 +185,7 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application) } } else { GSON.fromJsonArray(text1)?.let { - App.db.rssSourceDao().insert(*it.toTypedArray()) + SourceHelp.insertRssSource(*it.toTypedArray()) count = 1 } } @@ -199,7 +200,7 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application) rssSources.add(it) } } - App.db.rssSourceDao().insert(*rssSources.toTypedArray()) + SourceHelp.insertRssSource(*rssSources.toTypedArray()) "导入${rssSources.size}条" } text1.isAbsUrl() -> { @@ -225,7 +226,7 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application) sources.add(source) } } - App.db.rssSourceDao().insert(*sources.toTypedArray()) + SourceHelp.insertRssSource(*sources.toTypedArray()) return sources.size } return 0 From e5ddce749d3147d7c8f48cd06fc051fa0a0b3e6b Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 14 May 2020 19:19:03 +0800 Subject: [PATCH 082/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 700c700fe..d32290ef4 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ node_modules/ /app/google /app/gradle.properties package-lock.json +18PlusList.txt From 66ed7e4882306543c28421f7d14680826d25cb82 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 14 May 2020 19:20:03 +0800 Subject: [PATCH 083/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +++ app/src/main/java/io/legado/app/help/SourceHelp.kt | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 1b9ae3c09..3bc3b2940 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/05/14** +* 导入订阅源是添加18+过滤 + **2020/05/10** * 添加识别rss分组中的频道信息,在菜单中可以切换频道 from yangyxd * 源管理添加置底,批量置顶,批量置地 diff --git a/app/src/main/java/io/legado/app/help/SourceHelp.kt b/app/src/main/java/io/legado/app/help/SourceHelp.kt index bfb1ce104..a995d07b9 100644 --- a/app/src/main/java/io/legado/app/help/SourceHelp.kt +++ b/app/src/main/java/io/legado/app/help/SourceHelp.kt @@ -11,8 +11,12 @@ import org.jetbrains.anko.toast object SourceHelp { private val handler = Handler(Looper.getMainLooper()) - private val list18Plus by lazy { - String(App.INSTANCE.assets.open("18PlusList.txt").readBytes()).splitNotBlank("\n") + private val list18Plus: Array by lazy { + try { + String(App.INSTANCE.assets.open("18PlusList.txt").readBytes()).splitNotBlank("\n") + } catch (e: Exception) { + arrayOf() + } } fun insertRssSource(vararg rssSources: RssSource) { From 5e606813bb10ce0fcc8aa1d980788380eebc0cbf Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 14 May 2020 19:23:38 +0800 Subject: [PATCH 084/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 3bc3b2940..143754017 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -4,7 +4,7 @@ * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 **2020/05/14** -* 导入订阅源是添加18+过滤 +* 导入订阅源时添加18+过滤 **2020/05/10** * 添加识别rss分组中的频道信息,在菜单中可以切换频道 from yangyxd From adc8ddc4f352b3ffa10eb8433c8f8d1c7f4ef014 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 14 May 2020 19:25:49 +0800 Subject: [PATCH 085/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 2 +- app/src/main/java/io/legado/app/help/SourceHelp.kt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 143754017..8570a3d5e 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -4,7 +4,7 @@ * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 **2020/05/14** -* 导入订阅源时添加18+过滤 +* 导入订阅源时添加18+过滤,刚添加这个功能屏蔽列表不全,会慢慢完善吧 **2020/05/10** * 添加识别rss分组中的频道信息,在菜单中可以切换频道 from yangyxd diff --git a/app/src/main/java/io/legado/app/help/SourceHelp.kt b/app/src/main/java/io/legado/app/help/SourceHelp.kt index a995d07b9..14f06c55c 100644 --- a/app/src/main/java/io/legado/app/help/SourceHelp.kt +++ b/app/src/main/java/io/legado/app/help/SourceHelp.kt @@ -37,6 +37,7 @@ object SourceHelp { private fun is18Plus(url: String?): Boolean { url ?: return false + if (AppConfig.isGooglePlay) return false list18Plus.forEach { if (url.contains(it)) { return true From d75748a57f2ed7a0f79ab36904898af905002082 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 14 May 2020 19:31:14 +0800 Subject: [PATCH 086/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/SourceHelp.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/SourceHelp.kt b/app/src/main/java/io/legado/app/help/SourceHelp.kt index 14f06c55c..cfc3f3b10 100644 --- a/app/src/main/java/io/legado/app/help/SourceHelp.kt +++ b/app/src/main/java/io/legado/app/help/SourceHelp.kt @@ -11,11 +11,11 @@ import org.jetbrains.anko.toast object SourceHelp { private val handler = Handler(Looper.getMainLooper()) - private val list18Plus: Array by lazy { + private val list18Plus by lazy { try { String(App.INSTANCE.assets.open("18PlusList.txt").readBytes()).splitNotBlank("\n") } catch (e: Exception) { - arrayOf() + arrayOf() } } From 931314f98424dd1ed297228b551c923a21eaa801 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 14 May 2020 19:54:35 +0800 Subject: [PATCH 087/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/SourceHelp.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/help/SourceHelp.kt b/app/src/main/java/io/legado/app/help/SourceHelp.kt index cfc3f3b10..db3020824 100644 --- a/app/src/main/java/io/legado/app/help/SourceHelp.kt +++ b/app/src/main/java/io/legado/app/help/SourceHelp.kt @@ -21,7 +21,7 @@ object SourceHelp { fun insertRssSource(vararg rssSources: RssSource) { rssSources.forEach { rssSource -> - if (is18Plus(rssSource.sortUrl)) { + if (is18Plus(rssSource.sourceUrl)) { handler.post { App.INSTANCE.toast("${rssSource.sourceName}是18+网址,禁止导入.") } From 36ce0cbf8bc8c4fd814487b5d04c2d629e0f9e0b Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 14 May 2020 20:00:02 +0800 Subject: [PATCH 088/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/SourceHelp.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/SourceHelp.kt b/app/src/main/java/io/legado/app/help/SourceHelp.kt index db3020824..4cd1ca831 100644 --- a/app/src/main/java/io/legado/app/help/SourceHelp.kt +++ b/app/src/main/java/io/legado/app/help/SourceHelp.kt @@ -13,9 +13,10 @@ object SourceHelp { private val handler = Handler(Looper.getMainLooper()) private val list18Plus by lazy { try { - String(App.INSTANCE.assets.open("18PlusList.txt").readBytes()).splitNotBlank("\n") + return@lazy String(App.INSTANCE.assets.open("18PlusList.txt").readBytes()) + .splitNotBlank("\n") } catch (e: Exception) { - arrayOf() + return@lazy arrayOf() } } From 97cb0258680af6d9c9a20aa47f3d485d073dec1c Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 14 May 2020 21:31:12 +0800 Subject: [PATCH 089/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 8570a3d5e..1b9ae3c09 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,9 +3,6 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 -**2020/05/14** -* 导入订阅源时添加18+过滤,刚添加这个功能屏蔽列表不全,会慢慢完善吧 - **2020/05/10** * 添加识别rss分组中的频道信息,在菜单中可以切换频道 from yangyxd * 源管理添加置底,批量置顶,批量置地 From 43b948a3aa152b5f2e71a415091bb8dbcdb50617 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 15 May 2020 10:22:14 +0800 Subject: [PATCH 090/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt | 1 + 1 file changed, 1 insertion(+) 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 dcd84634e..e8835130a 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 @@ -466,6 +466,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo if (getPrefBoolean("volumeKeyPageOnPlay") || BaseReadAloudService.pause ) { + page_view.pageDelegate?.isCancel = false page_view.pageDelegate?.keyTurnPage(direction) return true } From 3166cbd88b69ea42ee677edf8766e285a6e47b64 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 15 May 2020 16:57:48 +0800 Subject: [PATCH 091/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/rss/article/RssSortActivity.kt | 41 +------------------ app/src/main/res/menu/rss_articles.xml | 4 -- 2 files changed, 1 insertion(+), 44 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt index d7c7087d4..2d45bcd70 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt @@ -17,7 +17,6 @@ import io.legado.app.utils.gone import io.legado.app.utils.visible import kotlinx.android.synthetic.main.activity_rss_artivles.* import org.jetbrains.anko.startActivityForResult -import java.util.* class RssSortActivity : VMBaseActivity(R.layout.activity_rss_artivles) { @@ -26,8 +25,6 @@ class RssSortActivity : VMBaseActivity(R.layout.activity_rss_a private val editSource = 12319 private val fragments = linkedMapOf() private lateinit var adapter: TabFragmentPageAdapter - private val channels = LinkedHashMap() - private var groupMenu: Menu? = null override fun onActivityCreated(savedInstanceState: Bundle?) { adapter = TabFragmentPageAdapter(supportFragmentManager) @@ -37,7 +34,6 @@ class RssSortActivity : VMBaseActivity(R.layout.activity_rss_a title_bar.title = it }) viewModel.initData(intent) { - upChannelMenu() upFragments() } } @@ -47,12 +43,6 @@ class RssSortActivity : VMBaseActivity(R.layout.activity_rss_a return super.onCompatCreateOptionsMenu(menu) } - override fun onPrepareOptionsMenu(menu: Menu?): Boolean { - groupMenu = menu - upChannelMenu() - return super.onPrepareOptionsMenu(menu) - } - override fun onCompatOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { R.id.menu_edit_source -> viewModel.rssSource?.sourceUrl?.let { @@ -64,44 +54,15 @@ class RssSortActivity : VMBaseActivity(R.layout.activity_rss_a } } } - if (item.groupId == R.id.source_channel) { - val key = item.title.toString(); - val i = fragments.keys.indexOf(key) - if (i >= 0) - view_pager.currentItem = i - } return super.onCompatOptionsItemSelected(item) } - private fun upChannelMenu() { - // 加入频道列表 - groupMenu?.removeGroup(R.id.source_channel) - val sourceChannel = viewModel.rssSource?.sourceGroup - channels.clear() - sourceChannel?.split("\n\n")?.forEach { c -> - val d = c.split("::") - if (d.size > 1) { - channels[d[0]] = d[1] - val item = groupMenu?.add(R.id.source_channel, Menu.NONE, Menu.NONE, d[0]) - item?.isCheckable = true - val keys = fragments.keys - item?.isChecked = keys.indexOf(d[0]) == view_pager.currentItem - } - } - } - private fun upFragments() { fragments.clear() viewModel.rssSource?.sortUrls()?.forEach { fragments[it.key] = RssArticlesFragment.create(it.key, it.value) } - val sortUrlsSize = fragments.size - if (sortUrlsSize <= 1) { - channels.forEach { - fragments[it.key] = RssArticlesFragment.create(it.key, it.value) - } - } - if (sortUrlsSize == 1) { + if (fragments.size == 1) { tab_layout.gone() } else { tab_layout.visible() diff --git a/app/src/main/res/menu/rss_articles.xml b/app/src/main/res/menu/rss_articles.xml index 831b908a5..03d187bcd 100644 --- a/app/src/main/res/menu/rss_articles.xml +++ b/app/src/main/res/menu/rss_articles.xml @@ -12,8 +12,4 @@ android:title="@string/clear" app:showAsAction="never" /> - - - - \ No newline at end of file From 9222c4b73b943dba8f04a98a26e3e5b7f080863b Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 15 May 2020 17:45:53 +0800 Subject: [PATCH 092/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 - app/src/main/assets/18PlusList.txt | 2 ++ .../java/io/legado/app/help/SourceHelp.kt | 20 +++++++++++-------- 3 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 app/src/main/assets/18PlusList.txt diff --git a/.gitignore b/.gitignore index d32290ef4..700c700fe 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,3 @@ node_modules/ /app/google /app/gradle.properties package-lock.json -18PlusList.txt diff --git a/app/src/main/assets/18PlusList.txt b/app/src/main/assets/18PlusList.txt new file mode 100644 index 000000000..7776c3b14 --- /dev/null +++ b/app/src/main/assets/18PlusList.txt @@ -0,0 +1,2 @@ +OGN5dS5jb20= +c2cwMC54eXo= \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/help/SourceHelp.kt b/app/src/main/java/io/legado/app/help/SourceHelp.kt index 4cd1ca831..bdb883b10 100644 --- a/app/src/main/java/io/legado/app/help/SourceHelp.kt +++ b/app/src/main/java/io/legado/app/help/SourceHelp.kt @@ -3,8 +3,9 @@ package io.legado.app.help import android.os.Handler import android.os.Looper import io.legado.app.App -import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.RssSource +import io.legado.app.utils.EncoderUtils +import io.legado.app.utils.NetworkUtils import io.legado.app.utils.splitNotBlank import org.jetbrains.anko.toast @@ -32,17 +33,20 @@ object SourceHelp { } } - fun insertBookSource(vararg bookSources: BookSource) { - App.db.bookSourceDao().insert(*bookSources) - } - private fun is18Plus(url: String?): Boolean { url ?: return false if (AppConfig.isGooglePlay) return false - list18Plus.forEach { - if (url.contains(it)) { - return true + val baseUrl = NetworkUtils.getBaseUrl(url) + baseUrl ?: return false + try { + val host = baseUrl.split("//", ".") + val base64Url = EncoderUtils.base64Encode("${host[host.lastIndex - 1]}.${host.last()}") + list18Plus.forEach { + if (base64Url == it) { + return true + } } + } catch (e: Exception) { } return false } From 2b187b63954e6c2514a42d05d736d50ac93b2737 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 15 May 2020 18:03:59 +0800 Subject: [PATCH 093/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/storage/OldRule.kt | 4 +++- .../app/ui/book/source/manage/BookSourceViewModel.kt | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/storage/OldRule.kt b/app/src/main/java/io/legado/app/help/storage/OldRule.kt index f5919eb2c..b69b35526 100644 --- a/app/src/main/java/io/legado/app/help/storage/OldRule.kt +++ b/app/src/main/java/io/legado/app/help/storage/OldRule.kt @@ -20,7 +20,7 @@ object OldRule { } catch (e: Exception) { null } - runCatching { + try { if (sourceAny?.ruleToc == null) { source.apply { val jsonItem = jsonPath.parse(json.trim()) @@ -125,6 +125,8 @@ object OldRule { GSON.fromJsonObject(GSON.toJson(sourceAny.ruleContent)) } } + } catch (e: Exception) { + e.printStackTrace() } return source } diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt index 5077a71cf..c6dc63c8e 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt @@ -233,6 +233,7 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) else -> "格式不对" } }.onError { + it.printStackTrace() finally(it.localizedMessage ?: "") }.onSuccess { finally(it) @@ -240,7 +241,11 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) } private fun importSourceUrl(url: String): Int { - HttpHelper.simpleGet(url, "UTF-8")?.let { body -> + HttpHelper.simpleGet(url, "UTF-8").let { body -> + if (body == null) { + toast("访问网站失败") + return 0 + } val bookSources = mutableListOf() val items: List> = jsonPath.parse(body).read("$") for (item in items) { @@ -252,6 +257,5 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) App.db.bookSourceDao().insert(*bookSources.toTypedArray()) return bookSources.size } - return 0 } } \ No newline at end of file From 4ea0bc893742dc53feaddcf31bc37917ce2375a5 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 15 May 2020 18:11:18 +0800 Subject: [PATCH 094/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/http/HttpHelper.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 31064e268..173a450c1 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 @@ -43,7 +43,11 @@ object HttpHelper { val response = getApiService(baseUrl, encode) .get(url, mapOf()) .execute() - return response.body() + return if (response.body() != null) { + response.body() + } else { + response.errorBody().toString() + } } return null } From d23344f6af207e553487e2943203fa2f450c88f4 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 17 May 2020 18:13:50 +0800 Subject: [PATCH 095/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/ReadBookActivity.kt | 22 ++++++++++++++++++- .../page/delegate/HorizontalPageDelegate.kt | 4 ++-- .../book/read/page/delegate/PageDelegate.kt | 8 ++----- .../read/page/delegate/ScrollPageDelegate.kt | 4 ++-- 4 files changed, 27 insertions(+), 11 deletions(-) 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 e8835130a..6d39baa83 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 @@ -85,7 +85,9 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo private val mHandler = Handler() private val keepScreenRunnable: Runnable = Runnable { Help.keepScreenOn(window, false) } - + private val autoPageRunnable: Runnable = Runnable { autoPagePlus() } + private var autoPageProgress = 0 + private var isAutoPage = false private var screenTimeOut: Long = 0 private var timeBatteryReceiver: TimeBatteryReceiver? = null override val pageFactory: TextPageFactory get() = page_view.pageFactory @@ -558,7 +560,25 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo * 自动翻页 */ override fun autoPage() { + if (isAutoPage) { + isAutoPage = false + mHandler.removeCallbacks(autoPageRunnable) + page_view.upContent() + } else { + isAutoPage = true + autoPagePlus() + } + read_menu.setAutoPage(isAutoPage) + } + private fun autoPagePlus() { + mHandler.removeCallbacks(autoPageRunnable) + autoPageProgress++ + if (autoPageProgress >= 46) { + autoPageProgress = 0 + ReadBook.moveToNextPage() + } + mHandler.postDelayed(autoPageRunnable, 100) } /** diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/HorizontalPageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/HorizontalPageDelegate.kt index f8f9bec74..774f522be 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/HorizontalPageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/HorizontalPageDelegate.kt @@ -104,7 +104,7 @@ abstract class HorizontalPageDelegate(pageView: PageView) : PageDelegate(pageVie } override fun nextPageByAnim() { - super.nextPageByAnim() + abort() if (!hasNext()) return setDirection(Direction.NEXT) setTouchPoint(viewWidth.toFloat(), 0f) @@ -112,7 +112,7 @@ abstract class HorizontalPageDelegate(pageView: PageView) : PageDelegate(pageVie } override fun prevPageByAnim() { - super.prevPageByAnim() + abort() if (!hasPrev()) return setDirection(Direction.PREV) setTouchPoint(0f, 0f) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt index cd455b641..2f3bf9728 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt @@ -170,13 +170,9 @@ abstract class PageDelegate(protected val pageView: PageView) : open fun onScroll() {}//移动contentView, slidePage - open fun nextPageByAnim() { - abort() - } + abstract fun nextPageByAnim() - open fun prevPageByAnim() { - abort() - } + abstract fun prevPageByAnim() open fun keyTurnPage(direction: Direction) { if (isRunning) return diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt index 3fa333cbf..b00578ec2 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt @@ -79,12 +79,12 @@ class ScrollPageDelegate(pageView: PageView) : PageDelegate(pageView) { } override fun nextPageByAnim() { - super.nextPageByAnim() + abort() startScroll(0, 0, 0, -ChapterProvider.visibleHeight) } override fun prevPageByAnim() { - super.prevPageByAnim() + abort() startScroll(0, 0, 0, ChapterProvider.visibleHeight) } } \ No newline at end of file From d9437164871f5e9f1c17b359d161c1974614d86d Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 17 May 2020 18:55:26 +0800 Subject: [PATCH 096/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/book/read/ReadBookActivity.kt | 8 +++++--- .../java/io/legado/app/ui/book/read/ReadMenu.kt | 6 +++++- .../io/legado/app/ui/book/read/page/PageView.kt | 13 ++++++++++++- 3 files changed, 22 insertions(+), 5 deletions(-) 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 6d39baa83..886f7938f 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 @@ -86,8 +86,8 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo private val mHandler = Handler() private val keepScreenRunnable: Runnable = Runnable { Help.keepScreenOn(window, false) } private val autoPageRunnable: Runnable = Runnable { autoPagePlus() } - private var autoPageProgress = 0 - private var isAutoPage = false + override var autoPageProgress = 0 + override var isAutoPage = false private var screenTimeOut: Long = 0 private var timeBatteryReceiver: TimeBatteryReceiver? = null override val pageFactory: TextPageFactory get() = page_view.pageFactory @@ -574,9 +574,11 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo private fun autoPagePlus() { mHandler.removeCallbacks(autoPageRunnable) autoPageProgress++ - if (autoPageProgress >= 46) { + if (autoPageProgress >= 460) { autoPageProgress = 0 ReadBook.moveToNextPage() + } else { + page_view.invalidate() } mHandler.postDelayed(autoPageRunnable, 100) } 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 254d037ad..317af6aab 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 @@ -140,7 +140,11 @@ class ReadMenu : FrameLayout { }) //自动翻页 - fabAutoPage.onClick { callBack?.autoPage() } + fabAutoPage.onClick { + runMenuOut { + callBack?.autoPage() + } + } //替换 fabReplaceRule.onClick { callBack?.openReplaceRule() } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt index 3a996bfe9..3be9bf48c 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt @@ -3,6 +3,7 @@ package io.legado.app.ui.book.read.page import android.annotation.SuppressLint import android.content.Context import android.graphics.Canvas +import android.graphics.Rect import android.util.AttributeSet import android.view.MotionEvent import android.widget.FrameLayout @@ -11,6 +12,8 @@ import io.legado.app.service.help.ReadBook import io.legado.app.ui.book.read.page.delegate.* import io.legado.app.ui.book.read.page.entities.TextChapter import io.legado.app.utils.activity +import io.legado.app.utils.screenshot +import kotlinx.android.synthetic.main.activity_book_read.view.* class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, attrs), @@ -44,8 +47,14 @@ class PageView(context: Context, attrs: AttributeSet) : override fun dispatchDraw(canvas: Canvas) { super.dispatchDraw(canvas) - pageDelegate?.onDraw(canvas) + if (callBack.isAutoPage) { + nextPage.screenshot()?.let { + val rect = + Rect(0, 0, page_view.width, page_view.height * callBack.autoPageProgress / 460) + canvas.drawBitmap(it, rect, rect, null) + } + } } override fun computeScroll() { @@ -169,6 +178,8 @@ class PageView(context: Context, attrs: AttributeSet) : interface CallBack { val isInitFinish: Boolean + val isAutoPage: Boolean + val autoPageProgress: Int fun clickCenter() fun screenOffTimerStart() fun showTextActionMenu() From 528b0ac45b0209a3c6367e7a17b574bbc7cbd079 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 17 May 2020 19:07:39 +0800 Subject: [PATCH 097/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/book/read/ReadBookActivity.kt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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 886f7938f..f2830dc52 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 @@ -346,6 +346,10 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo toast(R.string.read_aloud_pause) return true } + if (isAutoPage) { + autoPageStop() + return true + } } } } @@ -561,9 +565,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo */ override fun autoPage() { if (isAutoPage) { - isAutoPage = false - mHandler.removeCallbacks(autoPageRunnable) - page_view.upContent() + autoPageStop() } else { isAutoPage = true autoPagePlus() @@ -571,6 +573,12 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo read_menu.setAutoPage(isAutoPage) } + private fun autoPageStop() { + isAutoPage = false + mHandler.removeCallbacks(autoPageRunnable) + page_view.upContent() + } + private fun autoPagePlus() { mHandler.removeCallbacks(autoPageRunnable) autoPageProgress++ From 873e61b4ee3eac00204c3d982c5c486bd98edfdd Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 17 May 2020 19:08:28 +0800 Subject: [PATCH 098/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 1b9ae3c09..dbec02060 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/05/17** +* 自动翻页功能完成 + **2020/05/10** * 添加识别rss分组中的频道信息,在菜单中可以切换频道 from yangyxd * 源管理添加置底,批量置顶,批量置地 From 7e111fc4aadcc228d66faa76236f74f110fbacb1 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 17 May 2020 19:21:09 +0800 Subject: [PATCH 099/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/book/read/page/PageView.kt | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt index 3be9bf48c..ff93f113a 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt @@ -3,11 +3,13 @@ package io.legado.app.ui.book.read.page import android.annotation.SuppressLint import android.content.Context import android.graphics.Canvas +import android.graphics.Paint import android.graphics.Rect import android.util.AttributeSet import android.view.MotionEvent import android.widget.FrameLayout import io.legado.app.help.ReadBookConfig +import io.legado.app.lib.theme.accentColor import io.legado.app.service.help.ReadBook import io.legado.app.ui.book.read.page.delegate.* import io.legado.app.ui.book.read.page.entities.TextChapter @@ -26,6 +28,12 @@ class PageView(context: Context, attrs: AttributeSet) : var prevPage: ContentView = ContentView(context) var curPage: ContentView = ContentView(context) var nextPage: ContentView = ContentView(context) + private val autoPageRect by lazy { Rect() } + private val autoPagePint by lazy { + Paint().apply { + color = context.accentColor + } + } init { addView(nextPage) @@ -50,9 +58,16 @@ class PageView(context: Context, attrs: AttributeSet) : pageDelegate?.onDraw(canvas) if (callBack.isAutoPage) { nextPage.screenshot()?.let { - val rect = - Rect(0, 0, page_view.width, page_view.height * callBack.autoPageProgress / 460) - canvas.drawBitmap(it, rect, rect, null) + val bottom = page_view.height * callBack.autoPageProgress / 460 + autoPageRect.set(0, 0, page_view.width, bottom) + canvas.drawBitmap(it, autoPageRect, autoPageRect, null) + canvas.drawRect( + 0f, + bottom.toFloat() - 1, + page_view.width.toFloat(), + bottom.toFloat(), + autoPagePint + ) } } } @@ -155,18 +170,18 @@ class PageView(context: Context, attrs: AttributeSet) : override val currentChapter: TextChapter? get() { - return if (callBack.isInitFinish) ReadBook.textChapter(0) else null - } + return if (callBack.isInitFinish) ReadBook.textChapter(0) else null + } override val nextChapter: TextChapter? get() { - return if (callBack.isInitFinish) ReadBook.textChapter(1) else null - } + return if (callBack.isInitFinish) ReadBook.textChapter(1) else null + } override val prevChapter: TextChapter? get() { - return if (callBack.isInitFinish) ReadBook.textChapter(-1) else null - } + return if (callBack.isInitFinish) ReadBook.textChapter(-1) else null + } override fun hasNextChapter(): Boolean { return ReadBook.durChapterIndex < ReadBook.chapterSize - 1 From eb1eac8fcd3f97fe413f5702fa636933891ba683 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 17 May 2020 21:21:07 +0800 Subject: [PATCH 100/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/ReadBookActivity.kt | 2 +- .../ui/replacerule/edit/ReplaceEditDialog.kt | 57 +++++++++++++++++-- 2 files changed, 53 insertions(+), 6 deletions(-) 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 f2830dc52..0c25c6086 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 @@ -584,7 +584,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo autoPageProgress++ if (autoPageProgress >= 460) { autoPageProgress = 0 - ReadBook.moveToNextPage() + page_view.fillPage(PageDelegate.Direction.NEXT) } else { page_view.invalidate() } diff --git a/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt b/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt index 73c64a0e1..83bdcd97b 100644 --- a/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt +++ b/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt @@ -1,26 +1,30 @@ package io.legado.app.ui.replacerule.edit +import android.graphics.Rect import android.os.Bundle import android.util.DisplayMetrics -import android.view.LayoutInflater -import android.view.MenuItem -import android.view.View -import android.view.ViewGroup +import android.view.* import android.view.ViewGroup.LayoutParams.WRAP_CONTENT +import android.widget.PopupWindow import androidx.appcompat.widget.Toolbar import androidx.fragment.app.DialogFragment import androidx.fragment.app.FragmentManager import androidx.lifecycle.Observer import io.legado.app.R +import io.legado.app.constant.AppConst import io.legado.app.constant.Theme import io.legado.app.data.entities.ReplaceRule +import io.legado.app.ui.widget.KeyboardToolPop import io.legado.app.utils.applyTint import io.legado.app.utils.getViewModel import io.legado.app.utils.toast import kotlinx.android.synthetic.main.dialog_replace_edit.* +import org.jetbrains.anko.displayMetrics +import kotlin.math.abs class ReplaceEditDialog : DialogFragment(), - Toolbar.OnMenuItemClickListener { + Toolbar.OnMenuItemClickListener, + KeyboardToolPop.CallBack { companion object { @@ -41,6 +45,8 @@ class ReplaceEditDialog : DialogFragment(), } private lateinit var viewModel: ReplaceEditViewModel + private var mSoftKeyboardTool: PopupWindow? = null + private var mIsSoftKeyBoardShowing = false override fun onStart() { super.onStart() @@ -60,6 +66,8 @@ class ReplaceEditDialog : DialogFragment(), override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + mSoftKeyboardTool = KeyboardToolPop(requireContext(), AppConst.keyboardToolChars, this) + view.viewTreeObserver.addOnGlobalLayoutListener(KeyboardOnGlobalChangeListener()) tool_bar.inflateMenu(R.menu.replace_edit) tool_bar.menu.applyTint(requireContext(), Theme.getTheme()) tool_bar.setOnMenuItemClickListener(this) @@ -111,6 +119,45 @@ class ReplaceEditDialog : DialogFragment(), val callBack get() = activity as? CallBack + override fun sendText(text: String) { + TODO("Not yet implemented") + } + + private fun showKeyboardTopPopupWindow() { + mSoftKeyboardTool?.let { + if (it.isShowing) return + view?.let { view -> + it.showAtLocation(view, Gravity.BOTTOM, 0, 0) + } + } + } + + private fun closePopupWindow() { + mSoftKeyboardTool?.dismiss() + } + + private inner class KeyboardOnGlobalChangeListener : ViewTreeObserver.OnGlobalLayoutListener { + override fun onGlobalLayout() { + activity?.let { + val rect = Rect() + // 获取当前页面窗口的显示范围 + dialog?.window?.decorView?.getWindowVisibleDisplayFrame(rect) + val screenHeight = it.displayMetrics.heightPixels + val keyboardHeight = screenHeight - rect.bottom // 输入法的高度 + val preShowing = mIsSoftKeyBoardShowing + if (abs(keyboardHeight) > screenHeight / 5) { + mIsSoftKeyBoardShowing = true // 超过屏幕五分之一则表示弹出了输入法 + showKeyboardTopPopupWindow() + } else { + mIsSoftKeyBoardShowing = false + if (preShowing) { + closePopupWindow() + } + } + } + } + } + interface CallBack { fun onReplaceRuleSave() } From 1415573eb1df6558a4ea2beb32eec269593fcaf6 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 17 May 2020 21:32:33 +0800 Subject: [PATCH 101/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt b/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt index 83bdcd97b..e55677d88 100644 --- a/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt +++ b/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt @@ -67,7 +67,7 @@ class ReplaceEditDialog : DialogFragment(), override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) mSoftKeyboardTool = KeyboardToolPop(requireContext(), AppConst.keyboardToolChars, this) - view.viewTreeObserver.addOnGlobalLayoutListener(KeyboardOnGlobalChangeListener()) + ll_content.viewTreeObserver.addOnGlobalLayoutListener(KeyboardOnGlobalChangeListener()) tool_bar.inflateMenu(R.menu.replace_edit) tool_bar.menu.applyTint(requireContext(), Theme.getTheme()) tool_bar.setOnMenuItemClickListener(this) @@ -120,7 +120,7 @@ class ReplaceEditDialog : DialogFragment(), val callBack get() = activity as? CallBack override fun sendText(text: String) { - TODO("Not yet implemented") + } private fun showKeyboardTopPopupWindow() { From 76dec07358d84d56f44f114fabea47a6da0c1bf4 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 17 May 2020 23:12:34 +0800 Subject: [PATCH 102/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/replacerule/edit/ReplaceEditDialog.kt | 77 ++++++++----------- 1 file changed, 34 insertions(+), 43 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt b/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt index e55677d88..49c04f4d5 100644 --- a/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt +++ b/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt @@ -1,10 +1,13 @@ package io.legado.app.ui.replacerule.edit -import android.graphics.Rect import android.os.Bundle -import android.util.DisplayMetrics -import android.view.* +import android.view.LayoutInflater +import android.view.MenuItem +import android.view.View +import android.view.ViewGroup +import android.view.ViewGroup.LayoutParams.MATCH_PARENT import android.view.ViewGroup.LayoutParams.WRAP_CONTENT +import android.widget.EditText import android.widget.PopupWindow import androidx.appcompat.widget.Toolbar import androidx.fragment.app.DialogFragment @@ -19,8 +22,7 @@ import io.legado.app.utils.applyTint import io.legado.app.utils.getViewModel import io.legado.app.utils.toast import kotlinx.android.synthetic.main.dialog_replace_edit.* -import org.jetbrains.anko.displayMetrics -import kotlin.math.abs +import org.jetbrains.anko.sdk27.listeners.onFocusChange class ReplaceEditDialog : DialogFragment(), Toolbar.OnMenuItemClickListener, @@ -45,14 +47,11 @@ class ReplaceEditDialog : DialogFragment(), } private lateinit var viewModel: ReplaceEditViewModel - private var mSoftKeyboardTool: PopupWindow? = null - private var mIsSoftKeyBoardShowing = false + private lateinit var mSoftKeyboardTool: PopupWindow override fun onStart() { super.onStart() - val dm = DisplayMetrics() - activity?.windowManager?.defaultDisplay?.getMetrics(dm) - dialog?.window?.setLayout((dm.widthPixels * 0.9).toInt(), WRAP_CONTENT) + dialog?.window?.setLayout(MATCH_PARENT, WRAP_CONTENT) } override fun onCreateView( @@ -67,7 +66,6 @@ class ReplaceEditDialog : DialogFragment(), override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) mSoftKeyboardTool = KeyboardToolPop(requireContext(), AppConst.keyboardToolChars, this) - ll_content.viewTreeObserver.addOnGlobalLayoutListener(KeyboardOnGlobalChangeListener()) tool_bar.inflateMenu(R.menu.replace_edit) tool_bar.menu.applyTint(requireContext(), Theme.getTheme()) tool_bar.setOnMenuItemClickListener(this) @@ -77,6 +75,14 @@ class ReplaceEditDialog : DialogFragment(), arguments?.let { viewModel.initData(it) } + et_replace_rule.onFocusChange { v, hasFocus -> + if (hasFocus) { + mSoftKeyboardTool.width = et_replace_rule.width + mSoftKeyboardTool.showAsDropDown(v) + } else { + mSoftKeyboardTool.dismiss() + } + } } override fun onMenuItemClick(item: MenuItem?): Boolean { @@ -119,42 +125,27 @@ class ReplaceEditDialog : DialogFragment(), val callBack get() = activity as? CallBack - override fun sendText(text: String) { - - } - - private fun showKeyboardTopPopupWindow() { - mSoftKeyboardTool?.let { - if (it.isShowing) return - view?.let { view -> - it.showAtLocation(view, Gravity.BOTTOM, 0, 0) + private fun insertText(text: String) { + if (text.isBlank()) return + val view = dialog?.window?.decorView?.findFocus() + if (view is EditText) { + val start = view.selectionStart + val end = view.selectionEnd + val edit = view.editableText//获取EditText的文字 + if (start < 0 || start >= edit.length) { + edit.append(text) + } else { + edit.replace(start, end, text)//光标所在位置插入文字 } } } - private fun closePopupWindow() { - mSoftKeyboardTool?.dismiss() - } - - private inner class KeyboardOnGlobalChangeListener : ViewTreeObserver.OnGlobalLayoutListener { - override fun onGlobalLayout() { - activity?.let { - val rect = Rect() - // 获取当前页面窗口的显示范围 - dialog?.window?.decorView?.getWindowVisibleDisplayFrame(rect) - val screenHeight = it.displayMetrics.heightPixels - val keyboardHeight = screenHeight - rect.bottom // 输入法的高度 - val preShowing = mIsSoftKeyBoardShowing - if (abs(keyboardHeight) > screenHeight / 5) { - mIsSoftKeyBoardShowing = true // 超过屏幕五分之一则表示弹出了输入法 - showKeyboardTopPopupWindow() - } else { - mIsSoftKeyBoardShowing = false - if (preShowing) { - closePopupWindow() - } - } - } + override fun sendText(text: String) { + if (text == AppConst.keyboardToolChars[0]) { + val view = dialog?.window?.decorView?.findFocus() + view?.clearFocus() + } else { + insertText(text) } } From d0a06f6336dea8e7870443fca956a9fcf1b226c4 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 17 May 2020 23:13:40 +0800 Subject: [PATCH 103/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index dbec02060..33ca18a3a 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -5,6 +5,7 @@ **2020/05/17** * 自动翻页功能完成 +* 替换规则输入时弹出辅助输入条 **2020/05/10** * 添加识别rss分组中的频道信息,在菜单中可以切换频道 from yangyxd From 0aaf7bfe9e394adcb0c0dcf57b5d41615a88b0c8 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 17 May 2020 23:14:48 +0800 Subject: [PATCH 104/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt b/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt index 49c04f4d5..eb5a1c997 100644 --- a/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt +++ b/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt @@ -77,7 +77,7 @@ class ReplaceEditDialog : DialogFragment(), } et_replace_rule.onFocusChange { v, hasFocus -> if (hasFocus) { - mSoftKeyboardTool.width = et_replace_rule.width + mSoftKeyboardTool.width = v.width mSoftKeyboardTool.showAsDropDown(v) } else { mSoftKeyboardTool.dismiss() From 5282914d6585e7b12eb90c7826eb3ca8f460bbe9 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 17 May 2020 23:19:14 +0800 Subject: [PATCH 105/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt b/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt index eb5a1c997..0027f3209 100644 --- a/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt +++ b/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt @@ -88,7 +88,7 @@ class ReplaceEditDialog : DialogFragment(), override fun onMenuItemClick(item: MenuItem?): Boolean { when (item?.itemId) { R.id.menu_save -> { - val rule = getReplaceRule(); + val rule = getReplaceRule() if (!rule.isValid()){ toast(R.string.replace_rule_invalid) } From 1398696a26e83ab269071f809f4cf3d0b4a9589e Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 18 May 2020 09:29:32 +0800 Subject: [PATCH 106/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/constant/AppConst.kt | 2 +- app/src/main/java/io/legado/app/help/http/HttpHelper.kt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/constant/AppConst.kt b/app/src/main/java/io/legado/app/constant/AppConst.kt index cf37e2b10..10ffccd1f 100644 --- a/app/src/main/java/io/legado/app/constant/AppConst.kt +++ b/app/src/main/java/io/legado/app/constant/AppConst.kt @@ -20,7 +20,7 @@ object AppConst { const val UA_NAME = "User-Agent" val userAgent: String by lazy { - "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36" + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36" } val SCRIPT_ENGINE: ScriptEngine by lazy { 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 173a450c1..dd480fbf5 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 @@ -1,5 +1,6 @@ package io.legado.app.help.http +import io.legado.app.constant.AppConst import io.legado.app.help.http.api.HttpGetApi import io.legado.app.utils.NetworkUtils import kotlinx.coroutines.suspendCancellableCoroutine @@ -94,6 +95,7 @@ object HttpHelper { return Interceptor { chain -> val request = chain.request() .newBuilder() + .addHeader(AppConst.UA_NAME, AppConst.userAgent) .addHeader("Keep-Alive", "300") .addHeader("Connection", "Keep-Alive") .addHeader("Cache-Control", "no-cache") From 6c28abcdcd7b57f40de92223ec9e6241805e2b7c Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 18 May 2020 09:31:34 +0800 Subject: [PATCH 107/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 33ca18a3a..533d8bdc1 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/05/18** +* 修复http://alanskycn.gitee.io/书源导入失败问题,被屏蔽UA了 + **2020/05/17** * 自动翻页功能完成 * 替换规则输入时弹出辅助输入条 From f39ac0a011e13556d62d734cb73265dd15d0876b Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 18 May 2020 12:11:17 +0800 Subject: [PATCH 108/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/service/help/ReadBook.kt | 4 ++-- .../main/java/io/legado/app/ui/book/read/ReadBookActivity.kt | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/help/ReadBook.kt b/app/src/main/java/io/legado/app/service/help/ReadBook.kt index b7338596c..4b196ec48 100644 --- a/app/src/main/java/io/legado/app/service/help/ReadBook.kt +++ b/app/src/main/java/io/legado/app/service/help/ReadBook.kt @@ -148,7 +148,7 @@ object ReadBook { } private fun curPageChanged() { - callBack?.upPageProgress() + callBack?.pageChanged() if (BaseReadAloudService.isRun) { readAloud(!BaseReadAloudService.pause) } @@ -344,7 +344,7 @@ object ReadBook { interface CallBack { fun upContent(relativePosition: Int = 0, resetPageOffset: Boolean = true) fun upView() - fun upPageProgress() + fun pageChanged() fun contentLoadFinish() } } \ 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 0c25c6086..6b267daa0 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 @@ -523,9 +523,10 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo } /** - * 更新进度条 + * 页面改变 */ - override fun upPageProgress() { + override fun pageChanged() { + autoPageProgress = 0 launch { seek_read_page.progress = ReadBook.durPageIndex } From c5d3d5a1ea69d4d274176d34451b3ddfe2fa077b Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 18 May 2020 19:43:37 +0800 Subject: [PATCH 109/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/data/AppDatabase.kt | 14 +++- .../io/legado/app/data/entities/RssSource.kt | 1 + .../io/legado/app/ui/main/my/MyFragment.kt | 10 ++- app/src/main/res/drawable/bg_img_border.xml | 13 ++++ .../main/res/layout/item_rss_article_1.xml | 64 +++++++++++++++++++ .../main/res/layout/item_rss_article_2.xml | 54 ++++++++++++++++ app/src/main/res/menu/rss_articles.xml | 5 ++ app/src/main/res/values-zh-rHK/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/pref_main.xml | 22 +++++-- 10 files changed, 175 insertions(+), 10 deletions(-) create mode 100644 app/src/main/res/drawable/bg_img_border.xml create mode 100644 app/src/main/res/layout/item_rss_article_1.xml create mode 100644 app/src/main/res/layout/item_rss_article_2.xml 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 d2256dd85..0bf73c868 100644 --- a/app/src/main/java/io/legado/app/data/AppDatabase.kt +++ b/app/src/main/java/io/legado/app/data/AppDatabase.kt @@ -19,7 +19,7 @@ import kotlinx.coroutines.launch ReplaceRule::class, SearchBook::class, SearchKeyword::class, Cookie::class, RssSource::class, Bookmark::class, RssArticle::class, RssReadRecord::class, RssStar::class, TxtTocRule::class], - version = 12, + version = 13, exportSchema = true ) abstract class AppDatabase : RoomDatabase() { @@ -31,7 +31,7 @@ abstract class AppDatabase : RoomDatabase() { fun createDatabase(context: Context): AppDatabase { return Room.databaseBuilder(context, AppDatabase::class.java, DATABASE_NAME) .fallbackToDestructiveMigration() - .addMigrations(migration_10_11, migration_11_12) + .addMigrations(migration_10_11, migration_11_12, migration_12_13) .addCallback(object : Callback() { override fun onDestructiveMigration(db: SupportSQLiteDatabase) { GlobalScope.launch { Restore.restoreDatabase(Backup.backupPath) } @@ -62,6 +62,16 @@ abstract class AppDatabase : RoomDatabase() { ) } } + + private val migration_12_13 = object : Migration(12, 13) { + override fun migrate(database: SupportSQLiteDatabase) { + database.execSQL( + """ + ALTER TABLE rssSources ADD articleStyle INTEGER NOT NULL DEFAULT 0 + """ + ) + } + } } abstract fun bookDao(): BookDao diff --git a/app/src/main/java/io/legado/app/data/entities/RssSource.kt b/app/src/main/java/io/legado/app/data/entities/RssSource.kt index a7948e6e7..e30707446 100644 --- a/app/src/main/java/io/legado/app/data/entities/RssSource.kt +++ b/app/src/main/java/io/legado/app/data/entities/RssSource.kt @@ -24,6 +24,7 @@ data class RssSource( var sourceGroup: String? = null, var enabled: Boolean = true, var sortUrl: String? = null, + var articleStyle: Int = 0, //列表规则 var ruleArticles: String? = null, var ruleNextPage: String? = null, diff --git a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt index d948923e8..88bb95afe 100644 --- a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt @@ -13,7 +13,7 @@ import io.legado.app.R import io.legado.app.base.BaseFragment import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey -import io.legado.app.help.channel +import io.legado.app.help.AppConfig import io.legado.app.lib.theme.ATH import io.legado.app.service.WebService import io.legado.app.ui.about.AboutActivity @@ -79,7 +79,13 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog. observeEvent(EventBus.WEB_SERVICE_STOP) { webServicePre?.isChecked = false } - if (requireContext().channel == "google") { + findPreference(PreferKey.themeMode)?.let { + it.setOnPreferenceChangeListener { _, _ -> + view?.post { App.INSTANCE.applyDayNight() } + true + } + } + if (AppConfig.isGooglePlay) { findPreference("aboutCategory") ?.removePreference(findPreference("donate")) } diff --git a/app/src/main/res/drawable/bg_img_border.xml b/app/src/main/res/drawable/bg_img_border.xml new file mode 100644 index 000000000..07783726c --- /dev/null +++ b/app/src/main/res/drawable/bg_img_border.xml @@ -0,0 +1,13 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_rss_article_1.xml b/app/src/main/res/layout/item_rss_article_1.xml new file mode 100644 index 000000000..9c46e1aaf --- /dev/null +++ b/app/src/main/res/layout/item_rss_article_1.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_rss_article_2.xml b/app/src/main/res/layout/item_rss_article_2.xml new file mode 100644 index 000000000..55eaa7aac --- /dev/null +++ b/app/src/main/res/layout/item_rss_article_2.xml @@ -0,0 +1,54 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/rss_articles.xml b/app/src/main/res/menu/rss_articles.xml index 03d187bcd..055efd8c7 100644 --- a/app/src/main/res/menu/rss_articles.xml +++ b/app/src/main/res/menu/rss_articles.xml @@ -12,4 +12,9 @@ android:title="@string/clear" app:showAsAction="never" /> + + \ No newline at end of file diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index b5ba53391..84b579b55 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -670,6 +670,7 @@ 點擊加入 信息 + 切換佈局 主色調 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f01493465..297a4c632 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -675,6 +675,7 @@ 信息 隐藏页眉 隐藏页脚 + 切换布局 主色调 diff --git a/app/src/main/res/xml/pref_main.xml b/app/src/main/res/xml/pref_main.xml index 4486f5276..ba6f0792b 100644 --- a/app/src/main/res/xml/pref_main.xml +++ b/app/src/main/res/xml/pref_main.xml @@ -20,14 +20,24 @@ android:icon="@drawable/ic_cfg_replace" app:iconSpaceReserved="false" /> - + + Date: Mon, 18 May 2020 19:50:13 +0800 Subject: [PATCH 110/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/xml/pref_main.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/res/xml/pref_main.xml b/app/src/main/res/xml/pref_main.xml index ba6f0792b..e25834b5f 100644 --- a/app/src/main/res/xml/pref_main.xml +++ b/app/src/main/res/xml/pref_main.xml @@ -48,6 +48,7 @@ app:iconSpaceReserved="false" /> @@ -77,6 +78,7 @@ Date: Mon, 18 May 2020 20:44:16 +0800 Subject: [PATCH 111/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/rss/article/RssArticlesAdapter.kt | 4 +- .../app/ui/rss/article/RssArticlesFragment.kt | 2 +- .../app/ui/rss/article/RssSortActivity.kt | 8 +++ .../app/ui/rss/article/RssSortViewModel.kt | 19 +++++++ app/src/main/res/drawable/bg_img_border.xml | 13 ----- .../main/res/layout/item_rss_article_2.xml | 54 ------------------- 6 files changed, 30 insertions(+), 70 deletions(-) delete mode 100644 app/src/main/res/drawable/bg_img_border.xml delete mode 100644 app/src/main/res/layout/item_rss_article_2.xml diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesAdapter.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesAdapter.kt index 00b296359..7b56df2aa 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesAdapter.kt @@ -18,8 +18,8 @@ import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.textColorResource -class RssArticlesAdapter(context: Context, val callBack: CallBack) : - SimpleRecyclerAdapter(context, R.layout.item_rss_article) { +class RssArticlesAdapter(context: Context, layoutId: Int, val callBack: CallBack) : + SimpleRecyclerAdapter(context, layoutId) { override fun convert(holder: ItemViewHolder, item: RssArticle, payloads: MutableList) { with(holder.itemView) { diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt index f7a1b6bb6..201675028 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt @@ -55,7 +55,7 @@ class RssArticlesFragment : VMBaseFragment(R.layout.fragme ATH.applyEdgeEffectColor(recycler_view) recycler_view.layoutManager = LinearLayoutManager(requireContext()) recycler_view.addItemDecoration(VerticalDivider(requireContext())) - adapter = RssArticlesAdapter(requireContext(), this) + adapter = RssArticlesAdapter(requireContext(), activityViewModel.layoutId, this) recycler_view.adapter = adapter loadMoreView = LoadMoreView(requireContext()) adapter.addFooterView(loadMoreView) diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt index 2d45bcd70..41fad7292 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt @@ -53,6 +53,10 @@ class RssSortActivity : VMBaseActivity(R.layout.activity_rss_a viewModel.clearArticles() } } + R.id.menu_switch_layout -> { + viewModel.switchLayout() + upFragments() + } } return super.onCompatOptionsItemSelected(item) } @@ -84,6 +88,10 @@ class RssSortActivity : VMBaseActivity(R.layout.activity_rss_a private inner class TabFragmentPageAdapter internal constructor(fm: FragmentManager) : FragmentStatePagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { + override fun getItemPosition(`object`: Any): Int { + return POSITION_NONE + } + override fun getPageTitle(position: Int): CharSequence? { return fragments.keys.elementAt(position) } diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssSortViewModel.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssSortViewModel.kt index 4b1149f2e..e65dd37f4 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssSortViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssSortViewModel.kt @@ -4,6 +4,7 @@ import android.app.Application import android.content.Intent import androidx.lifecycle.MutableLiveData import io.legado.app.App +import io.legado.app.R import io.legado.app.base.BaseViewModel import io.legado.app.data.entities.RssArticle import io.legado.app.data.entities.RssReadRecord @@ -15,6 +16,11 @@ class RssSortViewModel(application: Application) : BaseViewModel(application) { var rssSource: RssSource? = null val titleLiveData = MutableLiveData() var order = System.currentTimeMillis() + val layoutId + get() = when (rssSource?.articleStyle) { + 1 -> R.layout.item_rss_article_1 + else -> R.layout.item_rss_article + } fun initData(intent: Intent, finally: () -> Unit) { execute { @@ -32,6 +38,19 @@ class RssSortViewModel(application: Application) : BaseViewModel(application) { } } + fun switchLayout() { + rssSource?.let { + if (it.articleStyle < 1) { + it.articleStyle = it.articleStyle + 1 + } else { + it.articleStyle = 0 + } + execute { + App.db.rssSourceDao().update(it) + } + } + } + fun read(rssArticle: RssArticle) { execute { App.db.rssArticleDao().insertRecord(RssReadRecord(rssArticle.link)) diff --git a/app/src/main/res/drawable/bg_img_border.xml b/app/src/main/res/drawable/bg_img_border.xml deleted file mode 100644 index 07783726c..000000000 --- a/app/src/main/res/drawable/bg_img_border.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/item_rss_article_2.xml b/app/src/main/res/layout/item_rss_article_2.xml deleted file mode 100644 index 55eaa7aac..000000000 --- a/app/src/main/res/layout/item_rss_article_2.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - \ No newline at end of file From bf7a820d729c03be81627044507702ed10b8ae01 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 18 May 2020 20:48:41 +0800 Subject: [PATCH 112/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 533d8bdc1..df11ed5f9 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -5,6 +5,7 @@ **2020/05/18** * 修复http://alanskycn.gitee.io/书源导入失败问题,被屏蔽UA了 +* Rss列表添加样式切换 **2020/05/17** * 自动翻页功能完成 From e4e5fbf5495d3c3cf7abbf0ced3c8743bf9b2f72 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 19 May 2020 11:06:46 +0800 Subject: [PATCH 113/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/rss/article/RssArticlesFragment.kt | 7 ++- .../app/ui/rss/article/RssSortViewModel.kt | 4 +- app/src/main/res/drawable/bg_img_border.xml | 13 +++++ .../main/res/layout/item_rss_article_2.xml | 54 +++++++++++++++++++ 4 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 app/src/main/res/drawable/bg_img_border.xml create mode 100644 app/src/main/res/layout/item_rss_article_2.xml diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt index 201675028..22a62bb63 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt @@ -4,6 +4,7 @@ import android.os.Bundle import android.view.View import androidx.lifecycle.LiveData import androidx.lifecycle.Observer +import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import io.legado.app.App @@ -53,7 +54,11 @@ class RssArticlesFragment : VMBaseFragment(R.layout.fragme private fun initView() { ATH.applyEdgeEffectColor(recycler_view) - recycler_view.layoutManager = LinearLayoutManager(requireContext()) + recycler_view.layoutManager = if (activityViewModel.isGridLayout) { + GridLayoutManager(requireContext(), 2) + } else { + LinearLayoutManager(requireContext()) + } recycler_view.addItemDecoration(VerticalDivider(requireContext())) adapter = RssArticlesAdapter(requireContext(), activityViewModel.layoutId, this) recycler_view.adapter = adapter diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssSortViewModel.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssSortViewModel.kt index e65dd37f4..135064bce 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssSortViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssSortViewModel.kt @@ -16,9 +16,11 @@ class RssSortViewModel(application: Application) : BaseViewModel(application) { var rssSource: RssSource? = null val titleLiveData = MutableLiveData() var order = System.currentTimeMillis() + val isGridLayout get() = rssSource?.articleStyle == 2 val layoutId get() = when (rssSource?.articleStyle) { 1 -> R.layout.item_rss_article_1 + 2 -> R.layout.item_rss_article_2 else -> R.layout.item_rss_article } @@ -40,7 +42,7 @@ class RssSortViewModel(application: Application) : BaseViewModel(application) { fun switchLayout() { rssSource?.let { - if (it.articleStyle < 1) { + if (it.articleStyle < 2) { it.articleStyle = it.articleStyle + 1 } else { it.articleStyle = 0 diff --git a/app/src/main/res/drawable/bg_img_border.xml b/app/src/main/res/drawable/bg_img_border.xml new file mode 100644 index 000000000..07783726c --- /dev/null +++ b/app/src/main/res/drawable/bg_img_border.xml @@ -0,0 +1,13 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_rss_article_2.xml b/app/src/main/res/layout/item_rss_article_2.xml new file mode 100644 index 000000000..55eaa7aac --- /dev/null +++ b/app/src/main/res/layout/item_rss_article_2.xml @@ -0,0 +1,54 @@ + + + + + + + + + + \ No newline at end of file From 57543276b18de8e95e609813ebe1359547722473 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 19 May 2020 11:23:40 +0800 Subject: [PATCH 114/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/AppConfig.kt | 7 ++++++- .../java/io/legado/app/ui/config/ThemeConfigFragment.kt | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/help/AppConfig.kt b/app/src/main/java/io/legado/app/help/AppConfig.kt index 547322cce..f47ec213a 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -1,5 +1,6 @@ package io.legado.app.help +import android.annotation.SuppressLint import android.content.Context import android.content.pm.PackageManager import io.legado.app.App @@ -122,7 +123,11 @@ object AppConfig { } var elevation: Int - get() = App.INSTANCE.getPrefInt("elevation", -1) + @SuppressLint("PrivateResource") + get() = App.INSTANCE.getPrefInt( + "elevation", + App.INSTANCE.resources.getDimension(R.dimen.design_appbar_elevation).toInt() + ) set(value) { App.INSTANCE.putPrefInt("elevation", value) } 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 7b163b3e6..488fe3b05 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 @@ -1,5 +1,6 @@ package io.legado.app.ui.config +import android.annotation.SuppressLint import android.content.SharedPreferences import android.os.Build import android.os.Bundle @@ -115,6 +116,7 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar } + @SuppressLint("PrivateResource") override fun onPreferenceTreeClick(preference: Preference?): Boolean { when (preference?.key) { "defaultTheme" -> alert(title = "切换默认主题") { From 49406206e6a453e7eef3c92703007cc0849a76af Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 19 May 2020 11:24:58 +0800 Subject: [PATCH 115/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/http/HttpHelper.kt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) 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 dd480fbf5..af6dfa0b1 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 @@ -44,11 +44,7 @@ object HttpHelper { val response = getApiService(baseUrl, encode) .get(url, mapOf()) .execute() - return if (response.body() != null) { - response.body() - } else { - response.errorBody().toString() - } + return response.body() } return null } From c8df18aa4637aa04882354cd03bb331a46f467b2 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 19 May 2020 11:26:07 +0800 Subject: [PATCH 116/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/xml/pref_config_theme.xml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/app/src/main/res/xml/pref_config_theme.xml b/app/src/main/res/xml/pref_config_theme.xml index 5b4af51f5..94bef734c 100644 --- a/app/src/main/res/xml/pref_config_theme.xml +++ b/app/src/main/res/xml/pref_config_theme.xml @@ -12,15 +12,6 @@ app:icons="@array/icons" app:iconSpaceReserved="false" /> - - Date: Tue, 19 May 2020 13:08:33 +0800 Subject: [PATCH 117/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/rss/article/RssArticlesFragment.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt index 22a62bb63..840bc623c 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt @@ -57,9 +57,10 @@ class RssArticlesFragment : VMBaseFragment(R.layout.fragme recycler_view.layoutManager = if (activityViewModel.isGridLayout) { GridLayoutManager(requireContext(), 2) } else { + recycler_view.addItemDecoration(VerticalDivider(requireContext())) LinearLayoutManager(requireContext()) + } - recycler_view.addItemDecoration(VerticalDivider(requireContext())) adapter = RssArticlesAdapter(requireContext(), activityViewModel.layoutId, this) recycler_view.adapter = adapter loadMoreView = LoadMoreView(requireContext()) From a0a2cd94029eee4a225f28465641cf8bb1bb0b94 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 19 May 2020 13:14:38 +0800 Subject: [PATCH 118/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/rss/article/RssArticlesFragment.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt index 840bc623c..0b116a854 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt @@ -55,6 +55,7 @@ class RssArticlesFragment : VMBaseFragment(R.layout.fragme private fun initView() { ATH.applyEdgeEffectColor(recycler_view) recycler_view.layoutManager = if (activityViewModel.isGridLayout) { + recycler_view.setPadding(8, 0, 8, 0) GridLayoutManager(requireContext(), 2) } else { recycler_view.addItemDecoration(VerticalDivider(requireContext())) From e492e27fc23050eb0e48a9eba52af7c7ac7d624b Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 19 May 2020 14:39:13 +0800 Subject: [PATCH 119/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/config/ThemeConfigFragment.kt | 26 ++++++++++++++----- app/src/main/res/menu/theme_config.xml | 10 +++++++ 2 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 app/src/main/res/menu/theme_config.xml 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 488fe3b05..770b1830a 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 @@ -4,6 +4,9 @@ import android.annotation.SuppressLint import android.content.SharedPreferences import android.os.Build import android.os.Bundle +import android.view.Menu +import android.view.MenuInflater +import android.view.MenuItem import android.view.View import androidx.preference.Preference import androidx.preference.PreferenceFragmentCompat @@ -20,7 +23,6 @@ import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ColorUtils import io.legado.app.ui.widget.number.NumberPickerDialog import io.legado.app.ui.widget.prefs.IconListPreference -import io.legado.app.ui.widget.prefs.NameListPreference import io.legado.app.utils.* @@ -35,18 +37,13 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar preferenceScreen.removePreference(it) } } - findPreference(PreferKey.themeMode)?.let { - it.setOnPreferenceChangeListener { _, _ -> - view?.post { App.INSTANCE.applyDayNight() } - true - } - } upPreferenceSummary("barElevation", AppConfig.elevation.toString()) } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) ATH.applyEdgeEffectColor(listView) + setHasOptionsMenu(true) } override fun onResume() { @@ -59,6 +56,21 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar super.onPause() } + override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { + super.onCreateOptionsMenu(menu, inflater) + inflater.inflate(R.menu.theme_config, menu) + } + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + when (item.itemId) { + R.id.menu_theme_mode -> { + AppConfig.isNightTheme = !AppConfig.isNightTheme + App.INSTANCE.applyDayNight() + } + } + return super.onOptionsItemSelected(item) + } + override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { sharedPreferences ?: return when (key) { diff --git a/app/src/main/res/menu/theme_config.xml b/app/src/main/res/menu/theme_config.xml new file mode 100644 index 000000000..5033089ac --- /dev/null +++ b/app/src/main/res/menu/theme_config.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file From 5f5cb39793091be9285dea5adb1f63029c0af374 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 19 May 2020 14:41:52 +0800 Subject: [PATCH 120/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/AppConfig.kt | 13 ------------- .../java/io/legado/app/utils/ContextExtensions.kt | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/AppConfig.kt b/app/src/main/java/io/legado/app/help/AppConfig.kt index f47ec213a..79353351c 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -2,7 +2,6 @@ package io.legado.app.help import android.annotation.SuppressLint import android.content.Context -import android.content.pm.PackageManager import io.legado.app.App import io.legado.app.R import io.legado.app.constant.PreferKey @@ -139,15 +138,3 @@ object AppConfig { val isGooglePlay: Boolean get() = App.INSTANCE.channel == "google" } -val Context.channel: String - get() { - try { - val pm = packageManager - val appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA); - return appInfo.metaData.getString("channel") ?: "" - } catch (e: Exception) { - e.printStackTrace(); - } - return "" - } - 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 bc3f6f9fa..7a9d1e275 100644 --- a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt @@ -3,6 +3,7 @@ package io.legado.app.utils import android.annotation.SuppressLint import android.content.* +import android.content.pm.PackageManager import android.content.res.ColorStateList import android.content.res.Configuration import android.graphics.Bitmap @@ -178,4 +179,16 @@ fun Context.openUrl(uri: Uri) { toast(e.localizedMessage ?: "open url error") } } -} \ No newline at end of file +} + +val Context.channel: String + get() { + try { + val pm = packageManager + val appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA); + return appInfo.metaData.getString("channel") ?: "" + } catch (e: Exception) { + e.printStackTrace(); + } + return "" + } From 5c1ab9d01799da7db08f0bec2d3292c8d3276a78 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 19 May 2020 21:26:32 +0800 Subject: [PATCH 121/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/rss/article/RssArticlesAdapter.kt | 15 +++++++++++---- .../app/ui/rss/article/RssArticlesFragment.kt | 2 ++ app/src/main/res/drawable/image_rss_article.jpg | Bin 0 -> 15838 bytes app/src/main/res/layout/item_rss_article.xml | 1 + 4 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 app/src/main/res/drawable/image_rss_article.jpg diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesAdapter.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesAdapter.kt index 7b56df2aa..7d092aa61 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesAdapter.kt @@ -1,5 +1,6 @@ package io.legado.app.ui.rss.article +import android.annotation.SuppressLint import android.content.Context import android.graphics.drawable.Drawable import com.bumptech.glide.load.DataSource @@ -21,15 +22,19 @@ import org.jetbrains.anko.textColorResource class RssArticlesAdapter(context: Context, layoutId: Int, val callBack: CallBack) : SimpleRecyclerAdapter(context, layoutId) { + @SuppressLint("CheckResult") override fun convert(holder: ItemViewHolder, item: RssArticle, payloads: MutableList) { with(holder.itemView) { tv_title.text = item.title tv_pub_date.text = item.pubDate - if (item.image.isNullOrBlank()) { + if (item.image.isNullOrBlank() && !callBack.isGridLayout) { image_view.gone() } else { - ImageLoader.load(context, item.image) - .addListener(object : RequestListener { + val glide = ImageLoader.load(context, item.image) + if (callBack.isGridLayout) { + glide.placeholder(R.drawable.image_rss_article) + } else { + glide.addListener(object : RequestListener { override fun onLoadFailed( e: GlideException?, model: Any?, @@ -52,7 +57,8 @@ class RssArticlesAdapter(context: Context, layoutId: Int, val callBack: CallBack } }) - .into(image_view) + } + glide.into(image_view) } if (item.read) { tv_title.textColorResource = R.color.tv_text_summary @@ -71,6 +77,7 @@ class RssArticlesAdapter(context: Context, layoutId: Int, val callBack: CallBack } interface CallBack { + val isGridLayout: Boolean fun readRss(rssArticle: RssArticle) } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt index 0b116a854..f2329cb84 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt @@ -43,6 +43,8 @@ class RssArticlesFragment : VMBaseFragment(R.layout.fragme lateinit var adapter: RssArticlesAdapter private lateinit var loadMoreView: LoadMoreView private var rssArticlesData: LiveData>? = null + override val isGridLayout: Boolean + get() = activityViewModel.isGridLayout override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { viewModel.init(arguments) diff --git a/app/src/main/res/drawable/image_rss_article.jpg b/app/src/main/res/drawable/image_rss_article.jpg new file mode 100644 index 0000000000000000000000000000000000000000..471b5650fbe8bd0e475848cdb2da78435b442625 GIT binary patch literal 15838 zcmb9BcTf}W_XZ4aLJ}YpDWOHg&`an96r={QKOylgZ5P-eu3Z&$-UI&YmrttpRKXy85~R2m}JI z(+=Ql3AhF@z+m(+C<8q`JtHFnoEgEw%*4dZ$H93HaRGTz-~y7LA0;9yjuMg<=I58V zBq=SgfWcrcimPf|R#cZ&!YKZ)6A&XKBQp~-FAEE=q9DJZ;{WG%Mh4g!K!>11IuJVm zW(U!+gU((9`~W~lo9zGQ`~PnsFdYO6qi3L9RbvCdU=ZE^H82!RPrC&KW~YO22r6jf zp`0#4K`}7J421AiLNPs;Qggp+F!wdL>5u#0Y0o16f8GASI;K7Qzn*E=MA-jtL@=$< zM*qKoLF`}-K{^G9HYZ+4F~|jRwg@oOfoKz@V+XW=zb57w)k@8~=^lGe+uW54Dn}r5 z-viPtqiwRKhd=CQ%9g5%3NhRvn+S$ov4`cw!Rp;|VoRP#UYcSGER%Q3v~=gU755#n z?BY}94Pg9__YzzGOI{Og_qf|YeCMJn+HXAc6f}5@9 z0XG{IU=V!3^9RDMpyywXML+;hpba#hoAw8gFD=3XX0$slyvTSz_V&_P-t0}B*ngJj z%0Z|P^I`Q9i{_WX;>+(oUv5(@sh39<$@tOXaID+R!EbUPrElKmx8?43{1-f~cgg5l z2Bho3`7zH+2WG!gm?FR*Kz-@Rr*!5L-p+&OFiE2-Z|ooeCb0HIU_JK|3zYbUE)bfI zmSPer$i`6Ma9#jp#*Q@tX=B-lE?DhRKpuc{a|{Bo)Xj70smYli3w+q)pFSbolp%nC zM@W(*F9oT0#nF)ZT*~gja19j7r)}AzpI}hruXCtl+=f4~Id+m*Y^4lES zXvRp}p>NUO8PT|<23qV9}^=J1=i_1OR}n96$9vq z(DUR-a^%13P)#+WKa6GVJTa0O8S7FF8C+(zT$H{hm88uKF=NMNfuKczGu(v%cJ3Ge zBw&CUnIhaCS~qMo)Lr%-ya!SI`|ccJow=yk2VDroRA=t+gPVX${`#2S`~_mk(mz^9cAla zL&I^}+9pH^XBFa6vUaOWxz!`?scw}l$|9$!C;2D`?CDajLnz9VkWB|kEz6}F<6eWrbB@|AZQKR-e0pcMHhgf3-Td)i9r2&$yx!$ zLCW|ck3j>o$X>>T@{v5I60@S%%iq$y3@`~&;pwb`9x|;lWg8B3x>MDG8%2!dT+YV| zVHj)(mYXKuPWqQ{^EJ3RIIBOA0M3ea&FW-yrL+`D03I|cf-o}-PlhZyw9OVc7KRKZ z^dTC>axWI?mdH?G8%zuZVKGEBnMHSjE(O9OU)erwZldrhS2FUxb${Tyrq_$1Ny&?a z0jC9wx7y}j`YkqWHY+ooH`fiiP4V2RR14B=R-V6T@~pYiVY=?t*z`GL?}BhyaT4F% zkmcjG-0qKeJoc13N|kQ4w}nuQG3~v0U(CBF1~TT&kL$!!D~&mZvSrmnMU$!n+i^3C z`S*CRqOT?WidbHeRWbMTy?Sg=rh97Pm$wuEr)<1N_yT5%dNOaUlmZZp3Ya20(U?G1YBmt=d1 zO=wi4l)h#R=RkU?bn@oCo{>XZ-;v@DSrK!%gqVpC6Z=f zR2lhyN9QOL0Zc)w$WE}?!NFVr0jbndE&l+^h*0K+N-W?cioE6_#t6`L089j@4q-t@ z;7r14&Q})g%BdFC|J3vfMB6I7b^XHR^hW1G@*&Y6bm?;fNa!%7UF$C95Jt?ytGTzC1ed)vX0Yq6fvhL0FuBkiy5 zIxuh&(`P($yB&&S-a{pW@djAC^b@3Hwt|6v25A{HxGMp?o(eTP+NT*BWeYYlfVl`o zvzhcbvKiU0WnEyE+>cM{HUGoS^>zENnrcb8Yyx#&vwNiepgtI-d`hV(d%pRJ@RJP78 zD@d5;F`tU5(Dugh^bnCQ+_{L{s#+DFD5ibbKEDx}O=p+E|aio-T>LuC7 z3J)5R)uf-=88COgc@-^QRu?9nP$_-m!!w0pcuA)2v%R@EI%jTXmUt0525>mE z|2FmNLs5Zxh|KqBh*V@YW`Osa$tW)Xu#UdVwE@8KUtj1GF0UlDu8!p^%vf_8^I7~7N*Jwfn*w(hAsyIQ!koE0!JSk_ z&zd|~c>{RY;cD^gNe=nxso1PXHAYjlzlGGcKd0WbK!9`zAZrm2mp-D>16+xEj?FTm%m&DIYKqV@)^KllP8F+~p8R*O= zJ1*U7mu~us>bZ1QGKwo0YfTk|3emiz0}I59{`{vi04k80cxOX1Wpvi9a>~U!NKa2{ zF*^fpE67?O9ox0}d~@OtbVSprT5NTni~LPiPr^OeX?tIHg*PPB*nBUEx0%xODx0)A zIy*FM1+7NRRp<=%g7aJ?E61QV%2v9q05Fh_u`z9dpruIJ!2@op?$?!tinBG#9DEDX zv*fe#+He=I>@J2@tdOc!mDf!$Z^BjHc4dnVkZ%8i2MI|XgNTWIU~esrME-(_7&Tu>X9_l>7Z>VfA6RejPIGugR^&3p^`NUtQmMI~34?(YS3{ z_54fNyLQWpe;Z?R99ItSZtvQ!JQT~vUtCFzzBnE|fz~j(EBUQb-}LQGE2JbQ&jnFF zs+(xJER4Id>p4`tYId<}gn&12r|sH8lx4F#~)yOB};Qyw!?z4&{ZW8{W&K73G5&D;Dzsg1&fG-M=sDal+Q zlBo0oWr%Kwe3==U4**N#ytRN}5P7Ja^YDaTAP;`Hy-fuGEQ*yZ26nG8BBFo>V{N=~ zH%_mybmYaw3AGUZld9R*MZam1`GUH%}{B8~3~;gLgmpEF7*H%zBEvDqFrMIkPyFDD$tlQCv}O-u`f7|TaKhyR zK0C(i!4+)1XDP=udrm{*^hxm7!} zJ2NEHrFD|hIeC7|eDizri9npyfpgLr!?5MJX=ZV|WjBZK2y_z1=(W{%b zYa`uS{XPoopWa3Gbu%jQRFnmo=s)dU%7B;yeJHJTNg+WZ0st{ffY=!ij^R&;I0DM@ zfIecHNDFN3)*#?0;HiWT0foij-0xJaGTBd(|{th#yw?q zxi4}vdK1*N*|}%Fq1hyT_WJAQSil;gqZvsY09O-fo{Fgx8b*x)su)YE%`SXe08ns{ zyf77Dq`5!rBTi5S>?A5*EMO(#B(Hpzyy>wB(BuG$$Wt<~hLqV)EK8adU z9n|k?DZWs3xq)a@yrKs7KkmI+`TVbX5u;&%KSSrR?d28jXIDpuc8f(Q?sLQJVNcZk zlm7Xlr$;i_pM^^9vy~xA$kWCPyql!p_1MwC0&7ueFTQs6mh3|hoLssD{JK~HyQ>4< zl0%38?t9-M^uEDt)SFu&p)_;xX5%Ju#tQ|-Y92m1*XNq>$cuPe0sxBGXkIw);~f;% z(1BP>t=Ur{10aC-B$qKpu2`DmziKwaO)m4UI37NGcJ$Kpa@9QfNwbzR4sj?-(=)7Hf$V)v z@V$HI!0r#kC!A<7_sC*GY~ex1L=N6$si^ZUck$$+N$=I}@0)%H^NZt?sa2+%Tu;V* zMs+hXo$VOh&A^_l7s6G(D_V6$^?I0lKb?H1;B~CnjKN_Zooj+NtnrXp$@*FHtOfsz z(E#EXFxUwt*J?4bH^cN|6+GeKGkGOYjwus^+{CX7=|fBB|3O6+PKu zXwj(sQACUATp8H79hTT5ubkW|B{`8Mtfy(a|M~C0ODFtKr|o6~!jhD=cGtz+d!>KF zcJ2Ney}C3bRw~lhlk+F2@lVT`pZEK>9b>P~m0t~+`24)MYD}C*>^CW^N9s!|CH2-y z(C5v)Goae*uhLBPEko(vf^Xj_Ly_O{UK<^QmU9s|yN-YFIk^5=`F?-2@6(O)le>4e zWOUlp=%tod=hJ?y@Sh$xD&3;=U6ftES9@YVSGxQBc}3Z?oYT^zutQ#l;sV^g55)rS z7^7AA!iKHbokaP6J1PI@N2U?~-aZ-ODSCqp6Z@f=9@}MnjLVpR{9it0L*b-y_nZCb za+uAbeEo#L8BpJNQEu& zao@D%uguA+;|2HVD|73mPisdqWj8XSw6y4DyI%h7J_8<3Tq?9YvC6l4fx}Q*d>(AB zriRC{P}blec9Zc`KXdyF$2>b#zx^!LGkwO!W>oEz?2Lo2nKpx?pisuJW6*ah@gopT zyr>?7qs6lT_zR>7P^;S>Bho}{LbN0kd{VIq$!m^}l=6gL--a(CWRdr)WChnC`B<|kx&Hg*Y z{drQDpl0yLZKk5xQ_)-G-^9&iRL{!)9K+o=dL|cM1*!dXx|JqInu`YCd6zFBS1VFfv=r&2 zkkog0sMnY#@JanB?Ct#k^MBlT(>f%*TJ-mqIn+&W?VOwe9VVFiU%bPwE@&wq38|G7 zq^Cq8fYHZotC>3dz5TPX>Tbo&@-%L}G-T9FZ`I*Htt<06hlO&s3LAH~ z>TZqfF1%y>YZvj&AnKso_MZQ@Cq6m+Z@OqQR=oR9M(6LPx!`(-SLWQsGQOn}!<-{g z5^`G7In?Fdzc1bnZM=M2xvakMO3%1Z>{8nZdLk|?;D&7Hl^fzw3nL@*4q?hCX*>UA z&fX1Y9{VmK_LgpGerYFgqL{z7M!ITR8Ecp$V#Yq!K)56D4(-tErj{A?esV_sCR*SB zDWW4n;!>ctiY1Q@G>efqiad=cfM`O+(6+4^?|Iv4QZJbsL7}4l5W9&`l&3d2A$dWx zRtjBiiR`o1N-#kLGihp--pxH8n7Ql^p92{dDekCHR~59mIv_ zUHKDz_vMQpA>W+jb{F{umBt{;7tf`dIR0>Rc%P=Fy|b7SULjA}$T$8W^--Ar``xbd z9UAisJ|E+B&e%Bs; zvh|9#Rw1c#@92NnlYE{Q*C){O@BQyP2f07a0D@QW&R@e1S>7kd;?y7iZWu*f`V+L} zI+$afiRQ2`J2v_#+Cizmm$IXFYezF%o#Zz;;_b8>5T6#cHMnsQaRw|=N4`3hx3*AD zH2Fg;HW(^@HJHL)X^GdIs0UdjcePzFY3Kp+Z!mE0(vfVnzG8A~FRJE!BjwkH=)X{| znrxAD3I-2+w1E=Io`MZ#tep&P1GI>o0pJM~or}Rb7VyEH0B%q?R1D!HsFCZy4?x8p zJr3f1?3r5XG*naN;Q#D= z+;5|wK?gz6;T!WK_kO#S=ag($9MnxcYut%PEf)^pa@My#lyCJ`Sik@G^siRq&s9Qy z{X4J9%IS}hO=~%O`DcJb-+ro-++^g>liSDtRKHL51uTRfyFEk%jg&a1vW9;R>&Nps zW{KepK?WAx4@R$2==IAaOP(w97Cz=m2B6;6x zCkfwX=p!4KpEK!CI~qW53f8vX>gP(S8YfxYJZzriV)pXwyTCYMnIrGNp{MIID0EvC zEx&Vt_aNHmxjJZ}qKwq?!qovmT^+&Op1Ax~chT7CrQz7EXsdq{mOFO?%!XdzA98yh zk0IV?-L^m3pIxT(n8QbqiO0+z>V2CB)J1fz6gl@X z!-&SM41<_mxpd0lJL4{u-wO6=a?QA)c;yjUe9R^UL&lr>t_*Mkh-y!@rp$F z^{P;LDWHgR8z+JV=os^=65cBWvEm5J7*W~FC?C<=;3rPfVlwVV6*7iYZiQN9nsH_Ot)Na!s$KT{(Xr(%zsJbSqn~ zB1yJ9waPvJ^8ott2c`9uIHaCvs5Z|xGnShxbE^xIW4H$EQxd(39`8hm!yPI0`<6d> zy#impST56YyddNcp{-0X=oZ{x``S;GCcN#TM$y%%XipL;T|?B6RMk*mQsb_88X zUHx<6UcudfS+%IsnK9n4U!$Ic$x(79kE8z(?0&UAedjBsuW40XpFI-Ecy2gQ% z)2fmRqB_FeBzwBo;%`lC9w-zQit>cUp5KH7dC%!mN~}t^ezGi4C;cxgzHwBkQGK^T zFaANy&s*$UF_Pv+_SwB15Ox`^PCm(r7<0x%a|?E>Bs!xK5`zZ=V~JT65soHH*{@ae zbx_eNW0tH~!wep#AmzZ>ZLfq1MH{n+tdHBrW6k_lCF#tvwbC-tz7d4K&1oww<8BpvB*(&q?l%})zdNTX zmeMI&tM?(;A3<+{*CQf%eg>vr*_4+GcOw0?q^p7rR*zO>zi`M;Fuaj*A3+q}TK2(z zzgVrMw;i?+?9pEtJ7KLKrZCU(>I_Kw?HCoUA5b~z*%q;{Zs%QnZAbrE*$c|yyQt_8 z>S-V4UrGgK!*(+jE%N-+Nx>~eEv4Uur1`NAhC4rxJ@ox5{MPE93%}V{}{Jw(fnhk%AHO6Z@&5ED8iT?`4_li{hG!;s8;uf+t zQif|SQMAW?kv{U6Yqf_=)MZtdmG1xcP!#5vz1+Dur?NK}u4|cED$6S~9w6Ku^&n!g zi<%c?>Wi+~_3FLf@w#jK#l6ajB!N3G_ftA$pSW)B{QUhpa_jp+?~-=LdfK~u;|S$6 z(rWk7;cu7Am5gmJ<2{!?C9Jd%98a^)Z%nENT`sZ_>nSJes47zvbI>%7jRz~Km}G<$ zojP~XVKe%Ul3f~)n(4=<^&|Z2H-}3k-Y8d;D4g>gLdbKCk^#UL$YmYRpyjy>xR8>> zU&o+tjByb>^qq9SG_R^YH@un68hu@Ge4xBzE%rS8jqy{Pd>4b&bfj++A;X+IA4~#M zTohU_d(Iks8FE0ThOMSJSi_!bwE*ov={=zQ9P0pQ)#3g0x<%94CZv97k~ulL z)=!=Ee)2qlEB*bPP#9vGe-M&ZL^+s?R?isPakaHPjZp3V^Mv)Kt-a;tAIo(ckp}AW z$(4ifB$PC7*|;Q7snP6D{{Ay_CF&mjN$K!gnqo%FducMJh*h~(>$rL@f|_!%MhA>`He0AiT}7dPH(-w4_*3w4LBv8)Qyb00_$JXlZJuS3XB8j0NGZk3QJ zB!bt{7d(4a5?eBBD5M-8A^o`FKZPh^{M*V>-dTg8y0Vq5xMQLGoKePc(@u`};Fa%K z3q-|nz}A4ow0p9-+0KU>*s4hr>Stn7=YW*luZb#n$i0Kq-FQ2T*e>cus-jOVY3-br z-DVCy$#_VuQPgJaZm1jd5~Al2xk`%g6z-bDDT}VK+#3I@m{xI>Gk&eTv$rbg(@%L^ zS!0vSwwsA!XCGP5!M%)hpLCrPK4-OMD6`-yy?mfR`Hq*EVX=T?t4Li#7S3Ha;D z{`os*m+YnW{U5`73G_C3+Re1oMMn9NtJkSq)!?<)3Ss9ilKDEJGVx3_=96s3A{d*w zMvrB&bKi=}zUa{xXF;&Sp5eG{Vb}ylF9|-$W zrM1wA+Fq0nB|k@)Dswf@(WtKSm1c~|mtu-DoaON2?RyNcy<#T(8PLgCDJg;5hh;2M zOFBnb?`?9X9(W_lw?a@t`IX}SwyF}g3YX*_h(Qd_msN+t=RJnR8rOt5YtE}(>J=?c-_Q|`G$J-F0x0Yg%D2yY+(_vEr z!*q+FR(hSOyftry{369=d~8g@94`+ngV=8mPh4bBA^H}Tt+UWPH3aV|G{Z2@ACU3b zXPTldb>OW!uWRz4u1gV=bkhooiEU6d{|Ks!2*sOtw>K320tIIO0t|iS{*?b4r9Tad zn)vs+-zF13CYLB}5R^ta_qX3v)bF0J#iQhVC1{)B_pm8LFPsSUJ>I9Z4~i(Ln7Y=T z9TPTknqe$dGL1J(S57Rl6F>im#zk16gSIv)2RrPxBPM^?0@6(AjRNJMuf3b1==9q5 z<==%2?sJXgv&hB^-1GF~?cU6R*(d*kp6|s*66@E_KYARpkCjvtDxZi=zWMcuuwqJd zi*jX4OwIL*0*D$7k?ew?iHe$jv;VuCjTb`|bw1 zrj7j3!(38d(bQa(Us>F*fA04%j@An(?-_`Nz2O(`da(suRZFQ& z%`UX0q>4HC>cEKfcd=pVYMbmsG1<0Mp;DU-R2#%%YMtxZ#w@G)^sWJAVpg{scPJ_PJZvrA3D7ipMOd#s4+YW+A~>xs;Bd!hVW(h!MFW{)a(oi*}E}@ zq9epyLt&G`V04sUZJv$*WT1vD4ace+)2Yfoaz^o9 zXf?}aNR$>-0e8znR)`5utQhghqlzlHQPm==Oa{8oSfo4OwdYc_#`w^+L|^9e)Khlb zaX8cF8PF{6(QNN`1_*-#6T=t7-a}p24LP|aEL<**4tYQ&sci;QyZveY&Bh5Ji6L9jI~S99~v5qaJUWr$oO@$K@-NBJK(QiPx=E5cO96aR(ri=A{ndw zVb*u#4KhII+>a4#C{HdNEDQ#^cZBfpK7u+?HNqlw3esEQyA+!So-7!gg&dfk@ks`>p2l}YtnUj zUWfk}YT|EW=<>Q$9$X#at+aRg_~6#%;T_!4Z!!9>A26S@hUuAuPDt_jpUM4Y&UsEt zd4G~cJ)6ajN7PP}mFJiPQye@zhQns6=cI1H>j^2S6d_VnD6F-G;sU@czgT)>)aPRBkA6EC9q4-ZR*3Sa5?Q(>F`09s7R;4TjLGB zOZP{W>)aft&Fypzh|~JFkjEUmO3|46_CJKoZD?mCSq986_FCOz)yFOSLo%$5z2gpb{V-Uhd`` zPOIkP$2DdQk-YTn3x^lm$&H@yR5cuO2!pTqR!L1>@WvZd%{VU?y23y1$D#vHtPj}K z-B<(`7pq*Vp2&g1&T-FCnz^!EDN*~-0q$RZP0Fb}x7#z18NK%;Yq5hXtVpEm_f3On zSOv!1cvZWmHv6ZqK;HU;279))ju$pR&A&&dUnW)c{jajKrn%pR}&MrjNtY`fe#^<|RTpEQBr1V3Jkj~t|0wYMjfovHw zm7Q0T<@c0_-`TS{hp)}&qB_d^-K905ck+^M4P-)0AO+7WFw3IR2T&H+W`Rf`QWb~u zy)uz{l0`FO2o_;URBTX3fhm4qgq8S%zU@ROaWl zm51FrmWE;x=oP0}KRvPQ9@#_gIU3v94hsic(^`9~RO_|j5BEkYA3F9R^M^NnUFvHc z3C|0V7Fw)T=4*I8d-)5#RTQ}k8`qaLNI_66=vs-9>F25#E5Jq)CJP8UtQo+yP=Z7a z3b9-c$#5H)?HILw`c&mTGDM&KUOJ@&twKyFLv#VlQ!K_Y_OYBff>(3Yi4y~c3~?IUiF|a<^U&)nLnKxLmX0Wa`T?F0;Pb;}ohtwFNB0Af4q%o< zLfG2Fzl8n~(bv=b{PsJu$Tv2>{WA1bddZri_XCwvFIQC@(dcqR{WkG-#`_?vVupFj z`BU}+RoCRc-(G!L4$6uYQ;~Ugyv}$_$55Jxo3UJf(0N^b8bm{dx|%I^GOQ@Cm0mA{ zF788Gdw@_Qi6&SbC=l^Qut;j!?6`@KOS+W5HdZ?D)?+lDx+^@3i})?*UawjXW?sI` zRCQ;x`VRTV5-9Ta0^Q<95yp3;*jT4I!*I!2rlpAK9`MTz++1Ip>^X;ZmC+H(G7y-8 zgT8{ypuiM@SVre;=m0uLRLZI?wl&BkZN@}e&Aqi^qu?E{bBu`}{qS%|ilA6@LxxRm z%a%FZn6M(^<8B*vvfelH{u*~=lWosvS6#6xskrNQeeZKP@dJx!K%={bo&LO_i9%v_ zQ;PFC?7PnzlMx)N2F_%Y#NCm|^U5I5VKL3`Ls7dLF6#l-#k7EeYqbSU`_jQD!@WOf2B z2;0TL!*@V0Z?12%AV?1J{Zd8E=Nlg^Fl1#$lPUb9C`iMjMYK$*SWlK$0P)fTGh~r+ z;ys`YDh3rZTa{pb&xHcGd06BVu>=Wsb`g46o1ZM|e~$P5Yh4>-#rAKo@U-g)yx0B; zL}Il(C64Nfj&ubhjgLU;vSSZR?r6dok2K*vT{@52*kp9zi!{iHMbJ*LClqUV0H#G^ zQ>=9ica~|zb1I$LvB8PE2@QhdicwN1d!cz58uT1G;L05C2*i2M0S&cd*rgJ9IgV}Z z(=pVK**LsHLAfQgx}@cuj5W%KCkoW7?A%bL7uzxuTkDB=hUD#5)qyWC#z!Y(K~bom`iQ4DA0J&ZluD$5>|VsbNy07k=5NM zqu1MH*nektvONLAH#vP79(l8{s` zR8f-n)KZ4sO%i&`-G-OYdp!}Gh?Al)NYi_8oUny#YFBdG92iiZ<69Vx$UeO1oX@#} zzJfEsQ%D^a4sfPKq(Q2hViAl8I0N!*aH0hO24P^q*jre;2Tycr?EF?;H_qGXX$x$- zdiRwK=jhN((TrY;4*%28Hva_a27TPMgh!M(b3SyIWoDgA<>ckDRhZ@WaAYEEh1lWm zY!~eDAk1Y*6|;QjW^RW-MZP|7ZG&O5-J$T~JD8MGq)_YiM>RA?74cN3Ni^GbG}~6Q z%m$nxg_J0gfdE%P^17;YCPt4^=1g(fZHBZ6*k zpI`KrF%F{UQpVmCb}y^()vF9-Ym2Ddp#?tl#Lqfe& z>?_m$yuIH(-8o5P9xo3CdcEnuAw}5r19j9u4-_Rp@@05wW-3f6irsd>+(?or1jiv_ zd9eWbF)Y^@n!KF|gvt|eI0@oWx<((A?lIz-8OJ(A87p)Sy$shNp9{&1TXx5EG;tr% z5u6EmbU2jjEUjpSu89d0qd}g(XpYa@eTa^?R$Elqv&pOE5aPG-R(SsNNT_Q|^dFwe ze6v`hsZmR|KvE@rxNU-TfwvxQoS-=Nx^_+bP|Y(k5U;!Zxd$0)5pc1|!;{G&jyVy) z0%Dd%g}_bfKyi}-N$7P$5y6?8C>=|Jmn1TPfvR+2$)dVNVQrx#JVRM*0h^ix5DH9j zOhYg*zmTbOOcBa;=R1+k?S`hhbxj1Ewh_Hij3a`O&E~~t!(9fgwz&o-Vs9vq-+a2W zlv*8Vvt|EUs5bU-)*aNK$i%46kW`~=^rd%+I5k6i93-;3@3jUZvOUf&fynYI0A3%wt7XYXoD4SML z&j}yL8ap}H;Ndk4o|04ASO5T|;Km?U^_U+S!?%#{lFsk52fbc(#@N{4q*2zbRg8Ct zZ){eH!ag{{CT->+qujY@oi9QpfX+9FN>S-SRSR{!8?EMXW=mQ}e3OeRe#PYWWNPv$Vj?F!S@}?V;*;8birLI9TyW2_A60QM+4pfXtX? z+|Rw)k*Y(UzQULQ>E-2IE)f}M%6b-odP8WcTjIhIDO4c}ym1suD`G^oR1?F2Xkd~k zf}~k;S}hBhwibX53cd5af8X7^=?}<<0nv=Q*iKYI7{)*@gPt|lZo>k2h)RK8hj6YU zS;ZnuQ(_WZK+2C<3fDZ(ft6ha-<37+Xt^Xbglav->V^LJ;9bZA=xOk+$4^RA2}`t^ z`pKsg=VsUk%imT-v@eyt4sCJU4pdq1P%^QcgMNhg@tRn0I?AW$i28A}7r_n4<0eln z^RtWOpLOkWC1r4_;I4p*vc0kqx#lhO9;{?(7_h)O_W%=H6U)m0CQ6`abu2&$(SmEV zdFnN#Mobc51BBw`QDXXR*Bf^!`$Jl@Cquo}|qAh)g1cP75@c{dD5s+cVa zCU1()qE)Xr$j`b?>F6IZ36s?SmvdFZ)cj+#dl38SsG0k}+dGHNaVxq{=kG~JWk2*+ z)4l*VsN(ewCBIX|dgfkpcFRVjI%NJ)#0;4KUXxYwO-gvgYp#v(;$ll|s?Y(^jE@JD zXu|?EW1tlyYzrRIPz$pp0D9{w2o!)=j>V+x;Z`7LLuav3t{7C-OOY*3oDPO1#=;=2c~tcCJD+#cXko{LQESc6qrJycBm6Jys@W?Gs-pTx%GIzu zZw@O#H%e-;Wrerm5_da~aomNb@x0EKT{oM_6a~VY(q(TqBiq}E=6Oats#1y^QDGcE z_{2%X=2I{=1?i5+Wq}gFq_ygVPPCK}y$hB(X2ERXs*yCo!_wv|&305k0Xk+u`4S=) z#H${KkSQ{X;h2w=@)_-y)dZC;k-iuybC_tv7Pmm10Tz%9=sdP+2&EF+u}o2(V_0zM zeuS$k17_e4EnvYWc`fVo9ADzgu=In#6>5cDB%n5sg$3W z`f=a5HSfRq$&v#7lStl>H$g>%Exa9JQg%D>7HkHcpHk*>i~{%;44H)6#_*qZFGnd_ zZBg=mE6T_toz1v&nI#uyF%#9Ub(PZ#ED%kq89ARSMS_?8&mnP2c*PT(uYhPAv<-Yf z$+yHFl_a4L)u@lN<`0|LWiJ2RL6F|WVaKu3Ru zWXbF1?XM%5>eKZu6*B6a4xptJU6lU|U3Aqn+G0xz8<4>L^$FLzPPF8NR1#y_70lOZ zv=N@mQ?N*qwkSI|;1zSds-&fSHqlv(Apt>wPtmqAj96v?(0nT|YfQ2yDheg2OT~L* zh*9$ljDGK-I4439-mr?EG9@NvAlJk@Vah{G^>I+fLdE1r;*7FYx$oMCv)p`}^X+xL z9phN!Qi;P%gy*#jw56o&1grzJaS*SI4c4f$%H*p?4U!a1Ln8_A5^V-BtV$=uUC zo}t?_;KrhBmjc@AviHik8WrR10Md^)V*z=>5L1Z6B-}L}W=KEVptdH^O0Gr00ZA0! zRbL2zoyK2h^+5jto^`<_$9q3=@!23YqsRH3a~}nJS)+8y^4DTCUqZR*{K_o2YX%g@ zH)tGQW(3EG^%yL-B8#Jaz&yfxr&W@44?ke>CPRt$PeX8C{cK>@~HXauEOQs zh~K)t-qz?66=~11otT$2v*1=K5Wb=~KGDPU(ER$>_!&A}w(Q!as${otNB)Sm^W}r6 zG2?b^E4)`skh7f&cOHl)VqQz3VV~>qX7~jNd9rE77gh#)9OD_ADbYZteYOI^o%6(* zF|bNpNrX4Vz!j-*LPG)8Yl&LbmT`~)Zr||BdVLho#RK~l1yG{36B;XBi!Tjehix@0 zzQj$=s$LW4xmtIFdH2pAkuD*df*Zwd1B=m&R(h}tMj>kvf*OBl^&`(0UkFr4*O(E0 z%+|duH2*1i65gOnSV=V~%T${Grxq0zadOwr6hBlo#J7<>bi`S4cYPvz?uoz6jzN8x za$VoZ^|fO$S8IG>|j`HIA|NnhtXi;pp@_lAA&1FO=Lz9iI(tCS*4 z+#W}_OLnQzMp%_s7}E7ag{74_$3b^3N?0y4g;NM)R9uO*%cQ{=$?HNCFf9zI=T@>4 zN<=y9#10!-8oGm>eZVQ!u1q*O4-V{13k_m~f`Ot&Sr)YZeCT_+;E(qI;ItIxFUU~! zeQDmRK0%)QrYP|>4977Ig!im5-lIj4pJ)Y^L$5T!>UGCqHZS(#FS&j*&A8dNL%rMn zLi%uKFi|m8_lV-~^u^)4YMq80Vc&DfM$xx>^S&_J@wCyNyFu=e>5d~$sNN;9K1)82 z8(Wxemb;n)VV}Ihre;nO&9e1`{cDa7QCtx`Ep6k;T;YV2o+=cKplv+NfvTrmbX zL>Y7_-j6R^!Ta`f79j&4Nu1$;`tfmbbw6SuE2A)}rlLs6m@;?R;{$fD187Nhi3cuS zUI=G1tm|D&6oWN~lHb!d*Epy11@eqURSD$%Rc#FU_e;K;Sv8TR0z43}Y5v~zFrPh0 z-6^4+(uW-#9uvFf%?_#XLxoRmj`hL8+8**#z{U z^X~6Zhd#BbWl!=)xbL`;?z?F!hjT6$C|fQ(wXi{y!4hfj7Gw7mUna(hl;q;!qtJO$ zB`QhOqF&H@3UmydlL~i;~FJ(T_7iq(C zXew--D3O@_w@%-#{ufba-KMXP%DdhEvtua2Cz^wBQcv From 3836c0479269823fbcab9ac9f8aa2a8229f9f895 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 19 May 2020 21:27:16 +0800 Subject: [PATCH 122/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/rss/article/RssArticlesAdapter.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesAdapter.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesAdapter.kt index 7d092aa61..049239a7b 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesAdapter.kt @@ -30,11 +30,11 @@ class RssArticlesAdapter(context: Context, layoutId: Int, val callBack: CallBack if (item.image.isNullOrBlank() && !callBack.isGridLayout) { image_view.gone() } else { - val glide = ImageLoader.load(context, item.image) + val imageLoader = ImageLoader.load(context, item.image) if (callBack.isGridLayout) { - glide.placeholder(R.drawable.image_rss_article) + imageLoader.placeholder(R.drawable.image_rss_article) } else { - glide.addListener(object : RequestListener { + imageLoader.addListener(object : RequestListener { override fun onLoadFailed( e: GlideException?, model: Any?, @@ -58,7 +58,7 @@ class RssArticlesAdapter(context: Context, layoutId: Int, val callBack: CallBack }) } - glide.into(image_view) + imageLoader.into(image_view) } if (item.read) { tv_title.textColorResource = R.color.tv_text_summary From 476e1b8ad48389e6cdb9340009a61c6108e2bcca Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 20 May 2020 09:59:03 +0800 Subject: [PATCH 123/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index df11ed5f9..1033764f8 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/05/20** +* Rss列表增加一种显示样式 + **2020/05/18** * 修复http://alanskycn.gitee.io/书源导入失败问题,被屏蔽UA了 * Rss列表添加样式切换 From e6ba8339d1c242c8dc31efbb49d7a78d0ed822f0 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 21 May 2020 10:30:42 +0800 Subject: [PATCH 124/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/rss/article/RssArticlesAdapter.kt | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesAdapter.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesAdapter.kt index 049239a7b..19fd6d0fb 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesAdapter.kt @@ -30,35 +30,35 @@ class RssArticlesAdapter(context: Context, layoutId: Int, val callBack: CallBack if (item.image.isNullOrBlank() && !callBack.isGridLayout) { image_view.gone() } else { - val imageLoader = ImageLoader.load(context, item.image) - if (callBack.isGridLayout) { - imageLoader.placeholder(R.drawable.image_rss_article) - } else { - imageLoader.addListener(object : RequestListener { - override fun onLoadFailed( - e: GlideException?, - model: Any?, - target: Target?, - isFirstResource: Boolean - ): Boolean { - image_view.gone() - return false - } + ImageLoader.load(context, item.image).apply { + if (callBack.isGridLayout) { + placeholder(R.drawable.image_rss_article) + } else { + addListener(object : RequestListener { + override fun onLoadFailed( + e: GlideException?, + model: Any?, + target: Target?, + isFirstResource: Boolean + ): Boolean { + image_view.gone() + return false + } - override fun onResourceReady( - resource: Drawable?, - model: Any?, - target: Target?, - dataSource: DataSource?, - isFirstResource: Boolean - ): Boolean { - image_view.visible() - return false - } + override fun onResourceReady( + resource: Drawable?, + model: Any?, + target: Target?, + dataSource: DataSource?, + isFirstResource: Boolean + ): Boolean { + image_view.visible() + return false + } - }) - } - imageLoader.into(image_view) + }) + } + }.into(image_view) } if (item.read) { tv_title.textColorResource = R.color.tv_text_summary From 049097af29909f09b1fc1fb9c861f34d317bbc76 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 21 May 2020 19:58:48 +0800 Subject: [PATCH 125/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/http/HttpHelper.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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 af6dfa0b1..a65423e78 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 @@ -42,7 +42,7 @@ object HttpHelper { fun simpleGet(url: String, encode: String? = null): String? { NetworkUtils.getBaseUrl(url)?.let { baseUrl -> val response = getApiService(baseUrl, encode) - .get(url, mapOf()) + .get(url, mapOf(Pair(AppConst.UA_NAME, AppConst.userAgent))) .execute() return response.body() } @@ -52,7 +52,7 @@ object HttpHelper { suspend fun simpleGetAsync(url: String, encode: String? = null): String? { NetworkUtils.getBaseUrl(url)?.let { baseUrl -> val response = getApiService(baseUrl, encode) - .getAsync(url, mapOf()) + .getAsync(url, mapOf(Pair(AppConst.UA_NAME, AppConst.userAgent))) return response.body() } return null @@ -62,7 +62,7 @@ object HttpHelper { NetworkUtils.getBaseUrl(url)?.let { baseUrl -> return getByteRetrofit(baseUrl) .create(HttpGetApi::class.java) - .getMapByteAsync(url, mapOf(), mapOf()) + .getMapByteAsync(url, mapOf(), mapOf(Pair(AppConst.UA_NAME, AppConst.userAgent))) .body() } return null @@ -91,7 +91,6 @@ object HttpHelper { return Interceptor { chain -> val request = chain.request() .newBuilder() - .addHeader(AppConst.UA_NAME, AppConst.userAgent) .addHeader("Keep-Alive", "300") .addHeader("Connection", "Keep-Alive") .addHeader("Cache-Control", "no-cache") From 92d6012e9f4a17d2a637d071b6acec5260a497f3 Mon Sep 17 00:00:00 2001 From: Modificator Date: Fri, 22 May 2020 23:34:27 +0800 Subject: [PATCH 126/296] =?UTF-8?q?=E6=81=A2=E5=A4=8D=20E-Ink=20=E5=BC=80?= =?UTF-8?q?=E5=85=B3=EF=BC=8C=E8=B0=83=E6=95=B4=E4=B8=BB=E9=A2=98=20?= =?UTF-8?q?=E9=BB=91=E7=99=BD=E3=80=81A=20=E5=B1=8F=E9=BB=91=E5=BA=95?= =?UTF-8?q?=E6=A0=8F=E9=A2=9C=E8=89=B2=EF=BC=8C=E4=B9=A6=E6=9E=B6=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=8E=BB=E9=99=A4=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 ++ .../main/java/io/legado/app/constant/PreferKey.kt | 1 + .../io/legado/app/ui/config/ThemeConfigFragment.kt | 4 +++- .../app/ui/main/bookshelf/books/BooksFragment.kt | 2 ++ .../java/io/legado/app/ui/main/my/MyFragment.kt | 3 +++ app/src/main/res/layout/fragment_books.xml | 2 +- app/src/main/res/xml/pref_main.xml | 14 +++++++------- 7 files changed, 19 insertions(+), 9 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ec6d22bdb..24cbf4510 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -193,6 +193,8 @@ dependencies { //转换繁体 implementation 'com.hankcs:hanlp:portable-1.7.7' + //E-Ink + implementation 'fadeapp.widgets:scrollless-recyclerView:1.0.2' } apply plugin: 'com.google.gms.google-services' 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 8913956d3..175180a33 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -43,4 +43,5 @@ object PreferKey { const val readStyleSelect = "readStyleSelect" const val systemTypefaces = "system_typefaces" const val readBodyToLh = "readBodyToLh" + const val einkMode = "isEInkMode" } \ No newline at end of file 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 770b1830a..6416040c3 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 @@ -156,18 +156,20 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar putPrefInt("colorPrimary", getCompatColor(R.color.white)) putPrefInt("colorAccent", getCompatColor(R.color.black)) putPrefInt("colorBackground", getCompatColor(R.color.white)) + putPrefInt("colorBottomBackground", getCompatColor(R.color.white)) AppConfig.isNightTheme = false } 4 -> { putPrefInt("colorPrimaryNight", getCompatColor(R.color.black)) putPrefInt( "colorAccentNight", - getCompatColor(R.color.md_grey_600) + getCompatColor(R.color.md_grey_500) ) putPrefInt( "colorBackgroundNight", getCompatColor(R.color.black) ) + putPrefInt("colorBottomBackgroundNight", getCompatColor(R.color.black)) AppConfig.isNightTheme = true } } diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt index ab8984752..29a8e1d9a 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt @@ -16,6 +16,7 @@ import io.legado.app.constant.BookType import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey import io.legado.app.data.entities.Book +import io.legado.app.help.AppConfig import io.legado.app.help.IntentDataHelp import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.accentColor @@ -76,6 +77,7 @@ class BooksFragment : BaseFragment(R.layout.fragment_books), rv_bookshelf.layoutManager = GridLayoutManager(context, bookshelfLayout + 2) booksAdapter = BooksAdapterGrid(requireContext(), this) } + rv_bookshelf.isEnableScroll = !AppConfig.isEInkMode rv_bookshelf.adapter = booksAdapter booksAdapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() { override fun onItemRangeInserted(positionStart: Int, itemCount: Int) { diff --git a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt index 88bb95afe..dab9eb544 100644 --- a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt @@ -121,6 +121,9 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog. } } "recordLog" -> LogUtils.upLevel() + PreferKey.einkMode -> { + postEvent(EventBus.RECREATE, "") + } } } diff --git a/app/src/main/res/layout/fragment_books.xml b/app/src/main/res/layout/fragment_books.xml index 30f8ce74c..e049610e2 100644 --- a/app/src/main/res/layout/fragment_books.xml +++ b/app/src/main/res/layout/fragment_books.xml @@ -4,7 +4,7 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - diff --git a/app/src/main/res/xml/pref_main.xml b/app/src/main/res/xml/pref_main.xml index e25834b5f..72a02e97a 100644 --- a/app/src/main/res/xml/pref_main.xml +++ b/app/src/main/res/xml/pref_main.xml @@ -30,13 +30,13 @@ android:icon="@drawable/ic_cfg_theme" app:iconSpaceReserved="false" /> - + Date: Sat, 23 May 2020 11:54:33 +0800 Subject: [PATCH 127/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/18PlusList.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/assets/18PlusList.txt b/app/src/main/assets/18PlusList.txt index 7776c3b14..b60f64d5e 100644 --- a/app/src/main/assets/18PlusList.txt +++ b/app/src/main/assets/18PlusList.txt @@ -1,2 +1,3 @@ OGN5dS5jb20= -c2cwMC54eXo= \ No newline at end of file +c2cwMC54eXo= +dGhpcyBpcyBhIGV4YW1wbGU= \ No newline at end of file From e7c50cf12560b594a9ba457f55466430af4801c1 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 23 May 2020 20:16:29 +0800 Subject: [PATCH 128/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/widget/prefs/PreferenceCategory.kt | 10 +- .../app/ui/widget/prefs/SwitchPreference.kt | 2 +- .../res/layout/view_preference_category.xml | 1 + app/src/main/res/xml/pref_config_read.xml | 157 +++++++++--------- 4 files changed, 88 insertions(+), 82 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/widget/prefs/PreferenceCategory.kt b/app/src/main/java/io/legado/app/ui/widget/prefs/PreferenceCategory.kt index 9cf6c2bfd..c150dbe56 100644 --- a/app/src/main/java/io/legado/app/ui/widget/prefs/PreferenceCategory.kt +++ b/app/src/main/java/io/legado/app/ui/widget/prefs/PreferenceCategory.kt @@ -12,7 +12,6 @@ import io.legado.app.help.AppConfig import io.legado.app.lib.theme.ColorUtils import io.legado.app.lib.theme.accentColor import io.legado.app.lib.theme.backgroundColor -import io.legado.app.utils.getCompatColor class PreferenceCategory(context: Context, attrs: AttributeSet) : PreferenceCategory(context, attrs) { @@ -28,12 +27,9 @@ class PreferenceCategory(context: Context, attrs: AttributeSet) : PreferenceCate val view = it.findViewById(R.id.preference_title) if (view is TextView) { // && !view.isInEditMode view.text = title - if (view.isInEditMode) { - view.setTextColor(context.getCompatColor(R.color.colorAccent)) - } else { - view.setBackgroundColor(context.backgroundColor) - view.setTextColor(context.accentColor) - } + if (view.isInEditMode) return + view.setBackgroundColor(context.backgroundColor) + view.setTextColor(context.accentColor) view.isVisible = title != null && title.isNotEmpty() val da = it.findViewById(R.id.preference_divider_above) diff --git a/app/src/main/java/io/legado/app/ui/widget/prefs/SwitchPreference.kt b/app/src/main/java/io/legado/app/ui/widget/prefs/SwitchPreference.kt index 2f6becfc2..41038169f 100644 --- a/app/src/main/java/io/legado/app/ui/widget/prefs/SwitchPreference.kt +++ b/app/src/main/java/io/legado/app/ui/widget/prefs/SwitchPreference.kt @@ -26,7 +26,7 @@ class SwitchPreference(context: Context, attrs: AttributeSet) : widgetLayoutResource, R.id.switchWidget ) - if (v is SwitchCompat) { + if (v is SwitchCompat && !v.isInEditMode) { ATH.setTint(v, context.accentColor) } super.onBindViewHolder(holder) diff --git a/app/src/main/res/layout/view_preference_category.xml b/app/src/main/res/layout/view_preference_category.xml index 72cf9b5ca..6bdc58c5a 100644 --- a/app/src/main/res/layout/view_preference_category.xml +++ b/app/src/main/res/layout/view_preference_category.xml @@ -19,6 +19,7 @@ android:paddingLeft="16dp" android:layout_width="match_parent" android:layout_height="wrap_content" + android:textColor="@color/colorAccent" tools:ignore="RtlHardcoded,RtlSymmetry" /> - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From d72b63b99a9161aac315838a2a2f0ce4518f49eb Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 23 May 2020 20:19:47 +0800 Subject: [PATCH 129/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/xml/pref_config_read.xml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/app/src/main/res/xml/pref_config_read.xml b/app/src/main/res/xml/pref_config_read.xml index 4f9a5b80f..377fef241 100644 --- a/app/src/main/res/xml/pref_config_read.xml +++ b/app/src/main/res/xml/pref_config_read.xml @@ -2,12 +2,6 @@ - - - - - \ No newline at end of file From 204ebe072fdcd28764b94e610b5b619110814ff3 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 23 May 2020 20:24:02 +0800 Subject: [PATCH 130/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/book/read/config/TipConfigDialog.kt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt index 2635b70b2..65bcfc7b6 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt @@ -25,12 +25,10 @@ class TipConfigDialog : BaseDialogFragment() { Help.upSystemUiVisibility(it) it.windowManager?.defaultDisplay?.getMetrics(dm) } - dialog?.window?.let { - val attr = it.attributes - attr.dimAmount = 0.0f - it.attributes = attr - it.setLayout((dm.widthPixels * 0.9).toInt(), ViewGroup.LayoutParams.WRAP_CONTENT) - } + dialog?.window?.setLayout( + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT + ) } override fun onCreateView( From 910646e599ce505b09846b9e8a0e3b40d1480ed2 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 23 May 2020 21:10:11 +0800 Subject: [PATCH 131/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/constant/PreferKey.kt | 1 + .../java/io/legado/app/help/ReadBookConfig.kt | 1 + .../ui/book/read/config/MoreConfigDialog.kt | 3 + .../app/ui/book/read/page/ChapterProvider.kt | 8 ++ app/src/main/res/values-zh-rHK/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/pref_config_read.xml | 132 +++++++++--------- 7 files changed, 84 insertions(+), 63 deletions(-) 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 8913956d3..6542640c8 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -43,4 +43,5 @@ object PreferKey { const val readStyleSelect = "readStyleSelect" const val systemTypefaces = "system_typefaces" const val readBodyToLh = "readBodyToLh" + const val textFullJustify = "textFullJustify" } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index ff4180081..6bc3bd5af 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -127,6 +127,7 @@ object ReadBookConfig { } var isScroll = pageAnim == 3 val clickTurnPage get() = App.INSTANCE.getPrefBoolean(PreferKey.clickTurnPage, true) + val textFullJustify get() = App.INSTANCE.getPrefBoolean(PreferKey.textFullJustify, true) var bodyIndentCount = App.INSTANCE.getPrefInt(PreferKey.bodyIndent, 2) set(value) { field = value diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt index 5d8ec5d82..7033b82d0 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt @@ -111,6 +111,9 @@ class MoreConfigDialog : DialogFragment() { Help.setOrientation(it) } } + PreferKey.textFullJustify -> { + postEvent(EventBus.UP_CONFIG, true) + } } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index e0cee0b5c..b988ba782 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt @@ -161,6 +161,10 @@ object ChapterProvider { desiredWidth: Float ) { var x = 0f + if (!ReadBookConfig.textFullJustify) { + addCharsToLineLast(textLine, words, textPaint, x) + return + } val bodyIndent = ReadBookConfig.bodyIndent val icw = StaticLayout.getDesiredWidth(bodyIndent, textPaint) / bodyIndent.length bodyIndent.toStringArray().forEach { @@ -186,6 +190,10 @@ object ChapterProvider { desiredWidth: Float, startX: Float ) { + if (!ReadBookConfig.textFullJustify) { + addCharsToLineLast(textLine, words, textPaint, startX) + return + } val gapCount: Int = words.length - 1 val d = (visibleWidth - desiredWidth) / gapCount var x = startX diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 84b579b55..edcfe8a08 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -691,4 +691,5 @@ 隱藏頁脚 自動換源 置底 + 文字兩端對齊 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 297a4c632..124663532 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -693,5 +693,6 @@ 夜间,背景色 夜间,底栏色 自动换源 + 文字两端对齐 diff --git a/app/src/main/res/xml/pref_config_read.xml b/app/src/main/res/xml/pref_config_read.xml index 377fef241..3b1e81f3c 100644 --- a/app/src/main/res/xml/pref_config_read.xml +++ b/app/src/main/res/xml/pref_config_read.xml @@ -2,79 +2,85 @@ - + - + - + - + - + - + - + - + - + - + - + - + + + \ No newline at end of file From 1f6c2777dc58432bea5b3cd1502b419977e4fcfb Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 23 May 2020 21:13:42 +0800 Subject: [PATCH 132/296] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=96=87?= =?UTF-8?q?=E5=AD=97=E4=B8=A4=E7=AB=AF=E5=AF=B9=E9=BD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 1033764f8..1d532a929 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/05/23** +* 添加文字两端对齐配置 + **2020/05/20** * Rss列表增加一种显示样式 From 1c6ffda67704197a3913cbdd64cd2f11795dd4a6 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 23 May 2020 21:45:53 +0800 Subject: [PATCH 133/296] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=96=87?= =?UTF-8?q?=E5=AD=97=E4=B8=A4=E7=AB=AF=E5=AF=B9=E9=BD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/ui/book/read/ReadBookActivity.kt | 2 ++ app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) 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 6b267daa0..dd2e765c5 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 @@ -569,6 +569,8 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo autoPageStop() } else { isAutoPage = true + page_view.upContent() + page_view.upContent(1) autoPagePlus() } read_menu.setAutoPage(isAutoPage) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt index ff93f113a..049553663 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt @@ -118,9 +118,10 @@ class PageView(context: Context, attrs: AttributeSet) : } override fun upContent(relativePosition: Int, resetPageOffset: Boolean) { - if (ReadBookConfig.isScroll) { + if (ReadBookConfig.isScroll && !callBack.isAutoPage) { curPage.setContent(pageFactory.currentPage, resetPageOffset) } else { + curPage.resetPageOffset() when (relativePosition) { -1 -> prevPage.setContent(pageFactory.prevPage) 1 -> nextPage.setContent(pageFactory.nextPage) From 1bd70306210ac352aff0ed8387bd0dc7b6ef2301 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 24 May 2020 08:55:23 +0800 Subject: [PATCH 134/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/18PlusList.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/assets/18PlusList.txt b/app/src/main/assets/18PlusList.txt index b60f64d5e..dd800e91b 100644 --- a/app/src/main/assets/18PlusList.txt +++ b/app/src/main/assets/18PlusList.txt @@ -1,3 +1,3 @@ OGN5dS5jb20= c2cwMC54eXo= -dGhpcyBpcyBhIGV4YW1wbGU= \ No newline at end of file +aXRyYWZmaWNuZXQuY29t \ No newline at end of file From 065cd6ee49dd4ace709e9284a4cabfa9fc1a459a Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 24 May 2020 19:45:59 +0800 Subject: [PATCH 135/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/constant/PreferKey.kt | 1 + .../java/io/legado/app/help/ReadBookConfig.kt | 5 + .../app/ui/book/read/ReadBookActivity.kt | 17 +- .../app/ui/book/read/config/AutoReadDialog.kt | 97 +++++++++ app/src/main/res/layout/dialog_auto_read.xml | 198 ++++++++++++++++++ app/src/main/res/layout/dialog_read_aloud.xml | 2 +- app/src/main/res/values-zh-rHK/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 8 files changed, 316 insertions(+), 6 deletions(-) create mode 100644 app/src/main/java/io/legado/app/ui/book/read/config/AutoReadDialog.kt create mode 100644 app/src/main/res/layout/dialog_auto_read.xml 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 6542640c8..4387f8b2a 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -44,4 +44,5 @@ object PreferKey { const val systemTypefaces = "system_typefaces" const val readBodyToLh = "readBodyToLh" const val textFullJustify = "textFullJustify" + const val autoReadSpeed = "autoReadSpeed" } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index 6bc3bd5af..cbc9fbd77 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -103,6 +103,11 @@ object ReadBookConfig { } //配置写入读取 + var autoReadSpeed + get() = App.INSTANCE.getPrefInt(PreferKey.autoReadSpeed, 46) + set(value) { + App.INSTANCE.putPrefInt(PreferKey.autoReadSpeed, value) + } var styleSelect = App.INSTANCE.getPrefInt(PreferKey.readStyleSelect) set(value) { field = value 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 dd2e765c5..3027b34c9 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 @@ -69,6 +69,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo ReadAloudDialog.CallBack, ChangeSourceDialog.CallBack, ReadBook.CallBack, + AutoReadDialog.CallBack, TocRegexDialog.CallBack, ReplaceEditDialog.CallBack, ColorPickerDialogListener { @@ -547,10 +548,16 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo } override fun clickCenter() { - if (BaseReadAloudService.isRun) { - showReadAloudDialog() - } else { - read_menu.runMenuIn() + when { + BaseReadAloudService.isRun -> { + showReadAloudDialog() + } + isAutoPage -> { + AutoReadDialog().show(supportFragmentManager, "autoRead") + } + else -> { + read_menu.runMenuIn() + } } } @@ -576,7 +583,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo read_menu.setAutoPage(isAutoPage) } - private fun autoPageStop() { + override fun autoPageStop() { isAutoPage = false mHandler.removeCallbacks(autoPageRunnable) page_view.upContent() diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/AutoReadDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/AutoReadDialog.kt new file mode 100644 index 000000000..37364721f --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/book/read/config/AutoReadDialog.kt @@ -0,0 +1,97 @@ +package io.legado.app.ui.book.read.config + +import android.os.Bundle +import android.util.DisplayMetrics +import android.view.Gravity +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.SeekBar +import io.legado.app.R +import io.legado.app.base.BaseDialogFragment +import io.legado.app.help.ReadBookConfig +import io.legado.app.lib.theme.bottomBackground +import io.legado.app.service.BaseReadAloudService +import io.legado.app.service.help.ReadAloud +import io.legado.app.ui.book.read.Help +import kotlinx.android.synthetic.main.dialog_auto_read.* +import org.jetbrains.anko.sdk27.listeners.onClick + +class AutoReadDialog : BaseDialogFragment() { + var callBack: CallBack? = null + + override fun onStart() { + super.onStart() + val dm = DisplayMetrics() + activity?.let { + Help.upSystemUiVisibility(it) + it.windowManager?.defaultDisplay?.getMetrics(dm) + } + dialog?.window?.let { + it.setBackgroundDrawableResource(R.color.background) + it.decorView.setPadding(0, 0, 0, 0) + val attr = it.attributes + attr.dimAmount = 0.0f + attr.gravity = Gravity.BOTTOM + it.attributes = attr + it.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) + } + } + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + callBack = activity as? CallBack + return inflater.inflate(R.layout.dialog_auto_read, container) + } + + override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { + root_view.setBackgroundColor(requireContext().bottomBackground) + initOnChange() + initData() + initEvent() + } + + private fun initData() { + seek_auto_read.progress = ReadBookConfig.autoReadSpeed + } + + private fun initOnChange() { + seek_auto_read.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener { + override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) { + } + + override fun onStartTrackingTouch(seekBar: SeekBar?) = Unit + + override fun onStopTrackingTouch(seekBar: SeekBar?) { + ReadBookConfig.autoReadSpeed = seek_auto_read.progress + upTtsSpeechRate() + } + }) + } + + private fun initEvent() { + ll_main_menu.onClick { callBack?.showMenuBar(); dismiss() } + ll_setting.onClick { + ReadAloudConfigDialog().show(childFragmentManager, "readAloudConfigDialog") + } + ll_catalog.onClick { callBack?.openChapterList() } + ll_auto_page_stop.onClick { callBack?.autoPageStop() } + } + + private fun upTtsSpeechRate() { + ReadAloud.upTtsSpeechRate(requireContext()) + if (!BaseReadAloudService.pause) { + ReadAloud.pause(requireContext()) + ReadAloud.resume(requireContext()) + } + } + + interface CallBack { + fun showMenuBar() + fun openChapterList() + fun autoPageStop() + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_auto_read.xml b/app/src/main/res/layout/dialog_auto_read.xml new file mode 100644 index 000000000..420bfe61f --- /dev/null +++ b/app/src/main/res/layout/dialog_auto_read.xml @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_read_aloud.xml b/app/src/main/res/layout/dialog_read_aloud.xml index 504865171..422c1932b 100644 --- a/app/src/main/res/layout/dialog_read_aloud.xml +++ b/app/src/main/res/layout/dialog_read_aloud.xml @@ -273,7 +273,7 @@ android:layout_height="50dp" android:background="?android:attr/selectableItemBackgroundBorderless" android:clickable="true" - android:contentDescription="@string/interface_setting" + android:contentDescription="@string/to_backstage" android:focusable="true" android:orientation="vertical" android:paddingBottom="7dp"> diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index edcfe8a08..90d34f2c3 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -692,4 +692,5 @@ 自動換源 置底 文字兩端對齊 + 自動翻頁速度 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 124663532..457c42de7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -694,5 +694,6 @@ 夜间,底栏色 自动换源 文字两端对齐 + 自动翻页速度 From 869e13e26ac26026b90466e80e2a9cb074aa994b Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 24 May 2020 19:49:22 +0800 Subject: [PATCH 136/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/ReadBookConfig.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index cbc9fbd77..ab248287d 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -103,10 +103,10 @@ object ReadBookConfig { } //配置写入读取 - var autoReadSpeed - get() = App.INSTANCE.getPrefInt(PreferKey.autoReadSpeed, 46) + var autoReadSpeed = App.INSTANCE.getPrefInt(PreferKey.autoReadSpeed, 46) set(value) { App.INSTANCE.putPrefInt(PreferKey.autoReadSpeed, value) + field = value } var styleSelect = App.INSTANCE.getPrefInt(PreferKey.readStyleSelect) set(value) { From 7ce476c35e627c4b6ac1a69eff2a34bad9b9c754 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 24 May 2020 19:54:57 +0800 Subject: [PATCH 137/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/ReadBookConfig.kt | 2 +- app/src/main/java/io/legado/app/help/storage/Restore.kt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index ab248287d..d19f03139 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -105,8 +105,8 @@ object ReadBookConfig { //配置写入读取 var autoReadSpeed = App.INSTANCE.getPrefInt(PreferKey.autoReadSpeed, 46) set(value) { - App.INSTANCE.putPrefInt(PreferKey.autoReadSpeed, value) field = value + App.INSTANCE.putPrefInt(PreferKey.autoReadSpeed, value) } var styleSelect = App.INSTANCE.getPrefInt(PreferKey.readStyleSelect) set(value) { diff --git a/app/src/main/java/io/legado/app/help/storage/Restore.kt b/app/src/main/java/io/legado/app/help/storage/Restore.kt index f174a6f5e..c92f408bd 100644 --- a/app/src/main/java/io/legado/app/help/storage/Restore.kt +++ b/app/src/main/java/io/legado/app/help/storage/Restore.kt @@ -126,6 +126,7 @@ object Restore { hideStatusBar = App.INSTANCE.getPrefBoolean(PreferKey.hideStatusBar) hideNavigationBar = App.INSTANCE.getPrefBoolean(PreferKey.hideNavigationBar) bodyIndentCount = App.INSTANCE.getPrefInt(PreferKey.bodyIndent, 2) + autoReadSpeed = App.INSTANCE.getPrefInt(PreferKey.autoReadSpeed, 46) } ChapterProvider.upStyle() ReadBook.loadContent(resetPageOffset = false) From 2a237e27737375e02638f09f3abdfab215a54a5a Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 24 May 2020 20:03:30 +0800 Subject: [PATCH 138/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/ui/book/read/ReadBookActivity.kt | 2 +- app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt | 3 ++- app/src/main/res/layout/dialog_auto_read.xml | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) 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 3027b34c9..51917239f 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 @@ -592,7 +592,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo private fun autoPagePlus() { mHandler.removeCallbacks(autoPageRunnable) autoPageProgress++ - if (autoPageProgress >= 460) { + if (autoPageProgress >= ReadBookConfig.autoReadSpeed * 10) { autoPageProgress = 0 page_view.fillPage(PageDelegate.Direction.NEXT) } else { diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt index 049553663..7b881006a 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt @@ -58,7 +58,8 @@ class PageView(context: Context, attrs: AttributeSet) : pageDelegate?.onDraw(canvas) if (callBack.isAutoPage) { nextPage.screenshot()?.let { - val bottom = page_view.height * callBack.autoPageProgress / 460 + val bottom = + page_view.height * callBack.autoPageProgress / (ReadBookConfig.autoReadSpeed * 10) autoPageRect.set(0, 0, page_view.width, bottom) canvas.drawBitmap(it, autoPageRect, autoPageRect, null) canvas.drawRect( diff --git a/app/src/main/res/layout/dialog_auto_read.xml b/app/src/main/res/layout/dialog_auto_read.xml index 420bfe61f..c444d66bb 100644 --- a/app/src/main/res/layout/dialog_auto_read.xml +++ b/app/src/main/res/layout/dialog_auto_read.xml @@ -42,7 +42,9 @@ android:layout_height="wrap_content" android:layout_marginStart="15dp" android:layout_marginEnd="15dp" - android:max="45" /> + android:min="10" + android:max="100" + tools:ignore="UnusedAttribute" /> From 9e8f562de7dda81897895ced77168dcf4357bd3a Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 24 May 2020 20:25:15 +0800 Subject: [PATCH 139/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/read/config/AutoReadDialog.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/AutoReadDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/AutoReadDialog.kt index 37364721f..d465c7b7f 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/AutoReadDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/AutoReadDialog.kt @@ -78,7 +78,10 @@ class AutoReadDialog : BaseDialogFragment() { ReadAloudConfigDialog().show(childFragmentManager, "readAloudConfigDialog") } ll_catalog.onClick { callBack?.openChapterList() } - ll_auto_page_stop.onClick { callBack?.autoPageStop() } + ll_auto_page_stop.onClick { + callBack?.autoPageStop() + dismiss() + } } private fun upTtsSpeechRate() { From a2c86950d771446128f82b97e671542424dc08b5 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 24 May 2020 20:27:01 +0800 Subject: [PATCH 140/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 1d532a929..6c40150d9 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/05/24** +* 添加自动翻页速度调节 + **2020/05/23** * 添加文字两端对齐配置 From 34a5dc1f3ff05a77e817b5b175976979ea21fd1f Mon Sep 17 00:00:00 2001 From: 383bjz82bu <383bjz82bu@fd.com> Date: Wed, 27 May 2020 01:31:27 +0800 Subject: [PATCH 141/296] =?UTF-8?q?=E5=95=8A=E5=93=88=EF=BC=8C=E6=89=80?= =?UTF-8?q?=E6=9C=89=E7=9A=84=20RecyclerView=20=E9=83=BD=E7=BB=99=E5=8A=A0?= =?UTF-8?q?=E4=B8=8A=E4=BA=86=E5=8A=A8=E7=94=BB=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/book/arrange/ArrangeBookActivity.kt | 2 ++ .../io/legado/app/ui/book/changecover/ChangeCoverDialog.kt | 2 ++ .../legado/app/ui/book/changesource/ChangeSourceDialog.kt | 2 ++ .../java/io/legado/app/ui/book/download/DownloadActivity.kt | 2 ++ .../io/legado/app/ui/book/explore/ExploreShowActivity.kt | 2 ++ .../java/io/legado/app/ui/book/group/GroupManageDialog.kt | 1 + .../java/io/legado/app/ui/book/group/GroupSelectDialog.kt | 2 ++ .../java/io/legado/app/ui/book/local/ImportBookActivity.kt | 1 + .../main/java/io/legado/app/ui/book/read/TextActionMenu.kt | 2 ++ .../io/legado/app/ui/book/read/config/BgTextConfigDialog.kt | 2 ++ .../io/legado/app/ui/book/read/config/TocRegexDialog.kt | 2 ++ .../java/io/legado/app/ui/book/search/SearchActivity.kt | 4 ++++ .../app/ui/book/source/debug/BookSourceDebugActivity.kt | 2 ++ .../app/ui/book/source/edit/BookSourceEditActivity.kt | 2 ++ .../legado/app/ui/book/source/manage/BookSourceActivity.kt | 2 ++ .../legado/app/ui/book/source/manage/GroupManageDialog.kt | 2 ++ .../java/io/legado/app/ui/filechooser/FileChooserDialog.kt | 3 +++ .../java/io/legado/app/ui/main/explore/ExploreFragment.kt | 2 ++ app/src/main/java/io/legado/app/ui/main/rss/RssFragment.kt | 2 ++ .../java/io/legado/app/ui/replacerule/GroupManageDialog.kt | 2 ++ .../io/legado/app/ui/replacerule/ReplaceRuleActivity.kt | 2 ++ .../app/ui/rss/source/debug/RssSourceDebugActivity.kt | 2 ++ .../legado/app/ui/rss/source/edit/RssSourceEditActivity.kt | 2 ++ .../io/legado/app/ui/rss/source/manage/GroupManageDialog.kt | 2 ++ .../io/legado/app/ui/rss/source/manage/RssSourceActivity.kt | 2 ++ .../main/java/io/legado/app/ui/widget/KeyboardToolPop.kt | 2 ++ .../java/io/legado/app/ui/widget/font/FontSelectDialog.kt | 1 + .../io/legado/app/ui/widget/prefs/IconListPreference.kt | 2 ++ .../io/legado/app/ui/widget/recycler/RefreshRecyclerView.kt | 2 ++ .../ui/widget/recycler/scroller/FastScrollRecyclerView.kt | 6 ++++-- app/src/main/res/layout/activity_arrange_book.xml | 2 +- app/src/main/res/layout/activity_book_search.xml | 6 +++--- app/src/main/res/layout/activity_book_source_edit.xml | 2 +- app/src/main/res/layout/activity_download.xml | 2 +- app/src/main/res/layout/activity_explore_show.xml | 2 +- app/src/main/res/layout/activity_import_book.xml | 2 +- app/src/main/res/layout/activity_replace_rule.xml | 2 +- app/src/main/res/layout/activity_rss_source_edit.xml | 2 +- app/src/main/res/layout/activity_source_debug.xml | 2 +- app/src/main/res/layout/dialog_book_group_picker.xml | 2 +- app/src/main/res/layout/dialog_change_cover.xml | 2 +- app/src/main/res/layout/dialog_change_source.xml | 2 +- app/src/main/res/layout/dialog_file_chooser.xml | 4 ++-- app/src/main/res/layout/dialog_font_select.xml | 2 +- app/src/main/res/layout/dialog_read_bg_text.xml | 2 +- app/src/main/res/layout/dialog_recycler_view.xml | 2 +- app/src/main/res/layout/dialog_toc_regex.xml | 2 +- app/src/main/res/layout/fragment_find_book.xml | 2 +- app/src/main/res/layout/fragment_rss.xml | 2 +- app/src/main/res/layout/popup_action_menu.xml | 4 ++-- app/src/main/res/layout/popup_keyboard_tool.xml | 2 +- app/src/main/res/layout/view_refresh_recycler.xml | 2 +- 52 files changed, 88 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt index 491922cb1..2d93dfdee 100644 --- a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt @@ -15,6 +15,7 @@ import io.legado.app.constant.AppConst import io.legado.app.constant.PreferKey import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookGroup +import io.legado.app.help.AppConfig import io.legado.app.help.ItemTouchCallback import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.noButton @@ -65,6 +66,7 @@ class ArrangeBookActivity : VMBaseActivity(R.layout.activi private fun initView() { ATH.applyEdgeEffectColor(recycler_view) + recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(this) recycler_view.addItemDecoration(VerticalDivider(this)) adapter = ArrangeBookAdapter(this, this) diff --git a/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt b/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt index 85df58172..0df08af73 100644 --- a/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt @@ -14,6 +14,7 @@ import androidx.recyclerview.widget.GridLayoutManager import io.legado.app.R import io.legado.app.base.BaseDialogFragment import io.legado.app.constant.Theme +import io.legado.app.help.AppConfig import io.legado.app.utils.applyTint import io.legado.app.utils.getViewModel import kotlinx.android.synthetic.main.dialog_change_source.* @@ -73,6 +74,7 @@ class ChangeCoverDialog : BaseDialogFragment(), } private fun initView() { + recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = GridLayoutManager(requireContext(), 3) adapter = CoverAdapter(requireContext(), this) recycler_view.adapter = adapter diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt index 09fa066ec..09e1cdb74 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt @@ -19,6 +19,7 @@ import io.legado.app.constant.PreferKey import io.legado.app.constant.Theme import io.legado.app.data.entities.Book import io.legado.app.data.entities.SearchBook +import io.legado.app.help.AppConfig import io.legado.app.ui.widget.recycler.VerticalDivider import io.legado.app.utils.applyTint import io.legado.app.utils.getPrefBoolean @@ -92,6 +93,7 @@ class ChangeSourceDialog : BaseDialogFragment(), private fun initRecyclerView() { adapter = ChangeSourceAdapter(requireContext(), this) + recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(context) recycler_view.addItemDecoration(VerticalDivider(requireContext())) recycler_view.adapter = adapter diff --git a/app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt b/app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt index b0f860527..83bf7487e 100644 --- a/app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt @@ -16,6 +16,7 @@ import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter +import io.legado.app.help.AppConfig import io.legado.app.help.BookHelp import io.legado.app.service.help.Download import io.legado.app.ui.filechooser.FileChooserDialog @@ -74,6 +75,7 @@ class DownloadActivity : VMBaseActivity(R.layout.activity_dow } private fun initRecyclerView() { + recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(this) adapter = DownloadAdapter(this, this) recycler_view.adapter = adapter 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 04bf86188..38eeffaf6 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 @@ -8,6 +8,7 @@ import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.data.entities.Book import io.legado.app.data.entities.SearchBook +import io.legado.app.help.AppConfig import io.legado.app.ui.book.info.BookInfoActivity import io.legado.app.ui.widget.recycler.LoadMoreView import io.legado.app.ui.widget.recycler.VerticalDivider @@ -32,6 +33,7 @@ class ExploreShowActivity : VMBaseActivity(R.layout.activi } private fun initRecyclerView() { + recycler_view.isEnableScroll = !AppConfig.isEInkMode adapter = ExploreShowAdapter(this, this) recycler_view.layoutManager = LinearLayoutManager(this) recycler_view.addItemDecoration(VerticalDivider(this)) diff --git a/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt b/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt index a5d719b57..cfe8f4278 100644 --- a/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt @@ -71,6 +71,7 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener { private fun initData() { adapter = GroupAdapter(requireContext()) + recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(requireContext()) recycler_view.addItemDecoration(VerticalDivider(requireContext())) recycler_view.adapter = adapter diff --git a/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt b/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt index 9440a7c46..1976c8b2e 100644 --- a/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt @@ -22,6 +22,7 @@ import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.constant.Theme import io.legado.app.data.entities.BookGroup +import io.legado.app.help.AppConfig import io.legado.app.help.ItemTouchCallback import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.customView @@ -96,6 +97,7 @@ class GroupSelectDialog : DialogFragment(), Toolbar.OnMenuItemClickListener { tool_bar.setOnMenuItemClickListener(this) tool_bar.menu.setGroupVisible(R.id.menu_groups, false) adapter = GroupAdapter(requireContext()) + recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(requireContext()) recycler_view.addItemDecoration(VerticalDivider(requireContext())) recycler_view.adapter = adapter diff --git a/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt index 3ce47ee99..eb3943200 100644 --- a/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt @@ -62,6 +62,7 @@ class ImportBookActivity : VMBaseActivity(R.layout.activity } private fun initView() { + recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(this) adapter = ImportBookAdapter(this, this) recycler_view.adapter = adapter diff --git a/app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt b/app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt index 5c8d1d214..673942b5c 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt @@ -20,6 +20,7 @@ import androidx.core.view.isVisible import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter +import io.legado.app.help.AppConfig import io.legado.app.service.BaseReadAloudService import io.legado.app.utils.gone import io.legado.app.utils.isAbsUrl @@ -61,6 +62,7 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac } private fun initRecyclerView() = with(contentView) { + recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.adapter = adapter recycler_view_more.adapter = adapter SupportMenuInflater(context).inflate(R.menu.content_select_action, menu) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt index 73f85dce0..5e7bd17eb 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt @@ -22,6 +22,7 @@ import io.legado.app.base.BaseDialogFragment import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.constant.EventBus +import io.legado.app.help.AppConfig import io.legado.app.help.ImageLoader import io.legado.app.help.ReadBookConfig import io.legado.app.help.permission.Permissions @@ -83,6 +84,7 @@ class BgTextConfigDialog : BaseDialogFragment() { private fun initData() = with(ReadBookConfig.durConfig) { sw_dark_status_icon.isChecked = statusIconDark() adapter = BgAdapter(requireContext()) + recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(requireContext(), RecyclerView.HORIZONTAL, false) recycler_view.adapter = adapter diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt index 300a507ea..f60f4e1e8 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt @@ -23,6 +23,7 @@ import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.constant.Theme import io.legado.app.data.entities.TxtTocRule +import io.legado.app.help.AppConfig import io.legado.app.help.ItemTouchCallback import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.cancelButton @@ -77,6 +78,7 @@ class TocRegexDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { private fun initView() { adapter = TocRegexAdapter(requireContext()) + recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(requireContext()) recycler_view.addItemDecoration(VerticalDivider(requireContext())) recycler_view.adapter = adapter diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt index e81545adc..8b8fd82ad 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt @@ -19,6 +19,7 @@ import io.legado.app.constant.PreferKey import io.legado.app.data.entities.Book import io.legado.app.data.entities.SearchBook import io.legado.app.data.entities.SearchKeyword +import io.legado.app.help.AppConfig import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.primaryTextColor import io.legado.app.ui.book.info.BookInfoActivity @@ -136,6 +137,9 @@ class SearchActivity : VMBaseActivity(R.layout.activity_book_se ATH.applyEdgeEffectColor(recycler_view) ATH.applyEdgeEffectColor(rv_bookshelf_search) ATH.applyEdgeEffectColor(rv_history_key) + recycler_view.isEnableScroll = !AppConfig.isEInkMode + rv_bookshelf_search.isEnableScroll = !AppConfig.isEInkMode + rv_history_key.isEnableScroll = !AppConfig.isEInkMode bookAdapter = BookAdapter(this, this) rv_bookshelf_search.layoutManager = FlexboxLayoutManager(this) rv_bookshelf_search.adapter = bookAdapter diff --git a/app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugActivity.kt index 75ac065e0..27ca73b26 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugActivity.kt @@ -8,6 +8,7 @@ import androidx.appcompat.widget.SearchView import androidx.recyclerview.widget.LinearLayoutManager import io.legado.app.R import io.legado.app.base.VMBaseActivity +import io.legado.app.help.AppConfig import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.accentColor import io.legado.app.ui.qrcode.QrCodeActivity @@ -44,6 +45,7 @@ class BookSourceDebugActivity : private fun initRecyclerView() { ATH.applyEdgeEffectColor(recycler_view) adapter = BookSourceDebugAdapter(this) + recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(this) recycler_view.adapter = adapter rotate_loading.loadingColor = accentColor diff --git a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt index 71ee36149..1a12bdac7 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt @@ -21,6 +21,7 @@ import io.legado.app.base.VMBaseActivity import io.legado.app.constant.AppConst import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.rule.* +import io.legado.app.help.AppConfig import io.legado.app.lib.dialogs.alert import io.legado.app.lib.theme.ATH import io.legado.app.ui.book.source.debug.BookSourceDebugActivity @@ -120,6 +121,7 @@ class BookSourceEditActivity : ATH.applyEdgeEffectColor(recycler_view) mSoftKeyboardTool = KeyboardToolPop(this, AppConst.keyboardToolChars, this) window.decorView.viewTreeObserver.addOnGlobalLayoutListener(KeyboardOnGlobalChangeListener()) + recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(this) recycler_view.adapter = adapter tab_layout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener { diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt index a765f3b4f..2b4a588c4 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt @@ -20,6 +20,7 @@ import io.legado.app.App import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.data.entities.BookSource +import io.legado.app.help.AppConfig import io.legado.app.help.ItemTouchCallback import io.legado.app.lib.dialogs.* import io.legado.app.lib.theme.ATH @@ -123,6 +124,7 @@ class BookSourceActivity : VMBaseActivity(R.layout.activity private fun initRecyclerView() { ATH.applyEdgeEffectColor(recycler_view) + recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(this) recycler_view.addItemDecoration(VerticalDivider(this)) adapter = BookSourceAdapter(this, this) diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/GroupManageDialog.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/GroupManageDialog.kt index d4a466948..523109569 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/GroupManageDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/GroupManageDialog.kt @@ -18,6 +18,7 @@ import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.constant.Theme +import io.legado.app.help.AppConfig import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.customView import io.legado.app.lib.dialogs.noButton @@ -63,6 +64,7 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener { tool_bar.menu.applyTint(requireContext(), Theme.getTheme()) tool_bar.setOnMenuItemClickListener(this) adapter = GroupAdapter(requireContext()) + recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(requireContext()) recycler_view.addItemDecoration(VerticalDivider(requireContext())) recycler_view.adapter = adapter diff --git a/app/src/main/java/io/legado/app/ui/filechooser/FileChooserDialog.kt b/app/src/main/java/io/legado/app/ui/filechooser/FileChooserDialog.kt index f1e6a7bc9..c3f6092bd 100644 --- a/app/src/main/java/io/legado/app/ui/filechooser/FileChooserDialog.kt +++ b/app/src/main/java/io/legado/app/ui/filechooser/FileChooserDialog.kt @@ -13,6 +13,7 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import io.legado.app.R import io.legado.app.constant.Theme +import io.legado.app.help.AppConfig import io.legado.app.ui.filechooser.adapter.FileAdapter import io.legado.app.ui.filechooser.adapter.PathAdapter import io.legado.app.ui.widget.recycler.VerticalDivider @@ -137,10 +138,12 @@ class FileChooserDialog : DialogFragment(), fileAdapter = FileAdapter(requireContext(), this) pathAdapter = PathAdapter(requireContext(), this) + rv_file.isEnableScroll = !AppConfig.isEInkMode rv_file.addItemDecoration(VerticalDivider(requireContext())) rv_file.layoutManager = LinearLayoutManager(activity) rv_file.adapter = fileAdapter + rv_path.isEnableScroll = !AppConfig.isEInkMode rv_path.layoutManager = LinearLayoutManager(activity, RecyclerView.HORIZONTAL, false) rv_path.adapter = pathAdapter diff --git a/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt b/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt index c8f93fc64..72d2abb78 100644 --- a/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt @@ -15,6 +15,7 @@ import io.legado.app.App import io.legado.app.R import io.legado.app.base.VMBaseFragment import io.legado.app.data.entities.BookSource +import io.legado.app.help.AppConfig import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.primaryTextColor import io.legado.app.ui.book.explore.ExploreShowActivity @@ -75,6 +76,7 @@ class ExploreFragment : VMBaseFragment(R.layout.fragment_find_ private fun initRecyclerView() { ATH.applyEdgeEffectColor(rv_find) + rv_find.isEnableScroll = !AppConfig.isEInkMode linearLayoutManager = LinearLayoutManager(context) rv_find.layoutManager = linearLayoutManager adapter = ExploreAdapter(requireContext(), this, this) diff --git a/app/src/main/java/io/legado/app/ui/main/rss/RssFragment.kt b/app/src/main/java/io/legado/app/ui/main/rss/RssFragment.kt index 334ce9e64..2a2f90dc1 100644 --- a/app/src/main/java/io/legado/app/ui/main/rss/RssFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/rss/RssFragment.kt @@ -10,6 +10,7 @@ import io.legado.app.App import io.legado.app.R import io.legado.app.base.VMBaseFragment import io.legado.app.data.entities.RssSource +import io.legado.app.help.AppConfig import io.legado.app.lib.theme.ATH import io.legado.app.ui.main.MainViewModel import io.legado.app.ui.rss.article.RssSortActivity @@ -51,6 +52,7 @@ class RssFragment : VMBaseFragment(R.layout.fragment_rss), private fun initRecyclerView() { ATH.applyEdgeEffectColor(recycler_view) adapter = RssAdapter(requireContext(), this) + recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = GridLayoutManager(requireContext(), 4) recycler_view.adapter = adapter } diff --git a/app/src/main/java/io/legado/app/ui/replacerule/GroupManageDialog.kt b/app/src/main/java/io/legado/app/ui/replacerule/GroupManageDialog.kt index df39b9a1d..165df103b 100644 --- a/app/src/main/java/io/legado/app/ui/replacerule/GroupManageDialog.kt +++ b/app/src/main/java/io/legado/app/ui/replacerule/GroupManageDialog.kt @@ -18,6 +18,7 @@ import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.constant.Theme +import io.legado.app.help.AppConfig import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.customView import io.legado.app.lib.dialogs.noButton @@ -63,6 +64,7 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener { tool_bar.menu.applyTint(requireContext(), Theme.getTheme()) tool_bar.setOnMenuItemClickListener(this) adapter = GroupAdapter(requireContext()) + recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(requireContext()) recycler_view.addItemDecoration(VerticalDivider(requireContext())) recycler_view.adapter = adapter 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 1f9057e35..2e9139774 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 @@ -20,6 +20,7 @@ import io.legado.app.App import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.data.entities.ReplaceRule +import io.legado.app.help.AppConfig import io.legado.app.help.BookHelp import io.legado.app.help.ItemTouchCallback import io.legado.app.help.coroutine.Coroutine @@ -101,6 +102,7 @@ class ReplaceRuleActivity : VMBaseActivity(R.layout.activi private fun initRecyclerView() { ATH.applyEdgeEffectColor(recycler_view) + recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(this) adapter = ReplaceRuleAdapter(this, this) recycler_view.adapter = adapter diff --git a/app/src/main/java/io/legado/app/ui/rss/source/debug/RssSourceDebugActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/debug/RssSourceDebugActivity.kt index b97bae3ea..4ac48f0de 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/debug/RssSourceDebugActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/debug/RssSourceDebugActivity.kt @@ -4,6 +4,7 @@ import android.os.Bundle import androidx.recyclerview.widget.LinearLayoutManager import io.legado.app.R import io.legado.app.base.VMBaseActivity +import io.legado.app.help.AppConfig import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.accentColor import io.legado.app.utils.getViewModel @@ -40,6 +41,7 @@ class RssSourceDebugActivity : VMBaseActivity(R.layout.acti private fun initRecyclerView() { ATH.applyEdgeEffectColor(recycler_view) adapter = RssSourceDebugAdapter(this) + recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(this) recycler_view.adapter = adapter rotate_loading.loadingColor = accentColor diff --git a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt index bd070639a..79f38d9e2 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt @@ -18,6 +18,7 @@ import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.constant.AppConst import io.legado.app.data.entities.RssSource +import io.legado.app.help.AppConfig import io.legado.app.lib.dialogs.alert import io.legado.app.lib.theme.ATH import io.legado.app.ui.qrcode.QrCodeActivity @@ -119,6 +120,7 @@ class RssSourceEditActivity : ATH.applyEdgeEffectColor(recycler_view) mSoftKeyboardTool = KeyboardToolPop(this, AppConst.keyboardToolChars, this) window.decorView.viewTreeObserver.addOnGlobalLayoutListener(this) + recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(this) recycler_view.adapter = adapter } diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/GroupManageDialog.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/GroupManageDialog.kt index ce2313f5a..a0f23d4e4 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/GroupManageDialog.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/GroupManageDialog.kt @@ -18,6 +18,7 @@ import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.constant.Theme +import io.legado.app.help.AppConfig import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.customView import io.legado.app.lib.dialogs.noButton @@ -61,6 +62,7 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener { tool_bar.menu.applyTint(requireContext(), Theme.getTheme()) tool_bar.setOnMenuItemClickListener(this) adapter = GroupAdapter(requireContext()) + recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(requireContext()) recycler_view.addItemDecoration(VerticalDivider(requireContext())) recycler_view.adapter = adapter diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt index be9866ef2..81e1046c7 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt @@ -20,6 +20,7 @@ import io.legado.app.App import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.data.entities.RssSource +import io.legado.app.help.AppConfig import io.legado.app.help.ItemTouchCallback import io.legado.app.lib.dialogs.* import io.legado.app.lib.theme.ATH @@ -137,6 +138,7 @@ class RssSourceActivity : VMBaseActivity(R.layout.activity_r private fun initRecyclerView() { ATH.applyEdgeEffectColor(recycler_view) + recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(this) recycler_view.addItemDecoration(VerticalDivider(this)) adapter = RssSourceAdapter(this, this) diff --git a/app/src/main/java/io/legado/app/ui/widget/KeyboardToolPop.kt b/app/src/main/java/io/legado/app/ui/widget/KeyboardToolPop.kt index 56dff107c..76f30efff 100644 --- a/app/src/main/java/io/legado/app/ui/widget/KeyboardToolPop.kt +++ b/app/src/main/java/io/legado/app/ui/widget/KeyboardToolPop.kt @@ -10,6 +10,7 @@ import androidx.recyclerview.widget.RecyclerView import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter +import io.legado.app.help.AppConfig import kotlinx.android.synthetic.main.item_fillet_text.view.* import kotlinx.android.synthetic.main.popup_keyboard_tool.view.* import org.jetbrains.anko.sdk27.listeners.onClick @@ -34,6 +35,7 @@ class KeyboardToolPop( private fun initRecyclerView() = with(contentView) { val adapter = Adapter(context) + recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(context, RecyclerView.HORIZONTAL, false) recycler_view.adapter = adapter adapter.setItems(chars) diff --git a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt index 8157ed870..4f8dd67a9 100644 --- a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt +++ b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt @@ -64,6 +64,7 @@ class FontSelectDialog : BaseDialogFragment(), tool_bar.setTitle(R.string.select_font) tool_bar.inflateMenu(R.menu.font_select) tool_bar.setOnMenuItemClickListener(this) + recycler_view.isEnableScroll = !AppConfig.isEInkMode adapter = FontAdapter(requireContext(), this) recycler_view.layoutManager = LinearLayoutManager(context) recycler_view.adapter = adapter diff --git a/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt b/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt index fa8b4eeb7..f8eb233c0 100644 --- a/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt +++ b/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt @@ -18,6 +18,7 @@ import androidx.recyclerview.widget.LinearLayoutManager import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter +import io.legado.app.help.AppConfig import io.legado.app.utils.getCompatDrawable import kotlinx.android.synthetic.main.dialog_recycler_view.* import kotlinx.android.synthetic.main.item_icon_preference.view.* @@ -138,6 +139,7 @@ class IconListPreference(context: Context, attrs: AttributeSet) : ListPreference override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) tool_bar.setTitle(R.string.change_icon) + recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(requireContext()) val adapter = Adapter(requireContext()) recycler_view.adapter = adapter diff --git a/app/src/main/java/io/legado/app/ui/widget/recycler/RefreshRecyclerView.kt b/app/src/main/java/io/legado/app/ui/widget/recycler/RefreshRecyclerView.kt index 931a7d138..2cc3c40a8 100644 --- a/app/src/main/java/io/legado/app/ui/widget/recycler/RefreshRecyclerView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/recycler/RefreshRecyclerView.kt @@ -9,6 +9,7 @@ import android.view.View import android.widget.LinearLayout import androidx.recyclerview.widget.LinearLayoutManager import io.legado.app.R +import io.legado.app.help.AppConfig import kotlinx.android.synthetic.main.view_refresh_recycler.view.* @@ -22,6 +23,7 @@ class RefreshRecyclerView(context: Context?, attrs: AttributeSet?) : LinearLayou init { orientation = VERTICAL LayoutInflater.from(context).inflate(R.layout.view_refresh_recycler, this, true) + recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.setOnTouchListener(object : OnTouchListener { @SuppressLint("ClickableViewAccessibility") override fun onTouch(v: View?, event: MotionEvent?): Boolean { diff --git a/app/src/main/java/io/legado/app/ui/widget/recycler/scroller/FastScrollRecyclerView.kt b/app/src/main/java/io/legado/app/ui/widget/recycler/scroller/FastScrollRecyclerView.kt index 0a2ebf741..e835e4514 100644 --- a/app/src/main/java/io/legado/app/ui/widget/recycler/scroller/FastScrollRecyclerView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/recycler/scroller/FastScrollRecyclerView.kt @@ -5,9 +5,11 @@ import android.util.AttributeSet import android.view.ViewGroup import androidx.annotation.ColorInt import androidx.recyclerview.widget.RecyclerView +import fadeapp.widgets.ScrollLessRecyclerView import io.legado.app.R +import io.legado.app.help.AppConfig -class FastScrollRecyclerView : RecyclerView { +class FastScrollRecyclerView : ScrollLessRecyclerView { private var mFastScroller: FastScroller? = null @@ -189,7 +191,7 @@ class FastScrollRecyclerView : RecyclerView { private fun layout(context: Context, attrs: AttributeSet?) { mFastScroller = FastScroller(context, attrs) mFastScroller?.id = R.id.fast_scroller - + isEnableScroll = !AppConfig.isEInkMode } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_arrange_book.xml b/app/src/main/res/layout/activity_arrange_book.xml index 1be7bdb41..b93bb8dbe 100644 --- a/app/src/main/res/layout/activity_arrange_book.xml +++ b/app/src/main/res/layout/activity_arrange_book.xml @@ -11,7 +11,7 @@ android:layout_height="wrap_content" app:title="@string/arrange_bookshelf" /> - - @@ -56,7 +56,7 @@ android:text="@string/bookshelf" android:visibility="gone" /> - - diff --git a/app/src/main/res/layout/activity_book_source_edit.xml b/app/src/main/res/layout/activity_book_source_edit.xml index ab8104256..53f152e06 100644 --- a/app/src/main/res/layout/activity_book_source_edit.xml +++ b/app/src/main/res/layout/activity_book_source_edit.xml @@ -96,7 +96,7 @@ - diff --git a/app/src/main/res/layout/activity_download.xml b/app/src/main/res/layout/activity_download.xml index 2f7ebd6f2..fcbe9933d 100644 --- a/app/src/main/res/layout/activity_download.xml +++ b/app/src/main/res/layout/activity_download.xml @@ -11,7 +11,7 @@ android:layout_height="wrap_content" app:title="@string/download_offline" /> - diff --git a/app/src/main/res/layout/activity_explore_show.xml b/app/src/main/res/layout/activity_explore_show.xml index 9bfab0f58..17532f98b 100644 --- a/app/src/main/res/layout/activity_explore_show.xml +++ b/app/src/main/res/layout/activity_explore_show.xml @@ -22,7 +22,7 @@ app:layout_constraintTop_toBottomOf="@id/title_bar"> - diff --git a/app/src/main/res/layout/activity_import_book.xml b/app/src/main/res/layout/activity_import_book.xml index 38d0b4f55..99906f6d9 100644 --- a/app/src/main/res/layout/activity_import_book.xml +++ b/app/src/main/res/layout/activity_import_book.xml @@ -53,7 +53,7 @@ tools:ignore="UnusedAttribute" /> - - - diff --git a/app/src/main/res/layout/activity_source_debug.xml b/app/src/main/res/layout/activity_source_debug.xml index 1b79a6058..50fcfd2de 100644 --- a/app/src/main/res/layout/activity_source_debug.xml +++ b/app/src/main/res/layout/activity_source_debug.xml @@ -14,7 +14,7 @@ app:layout_constraintTop_toTopOf="parent" app:title="@string/debug_source" /> - - - diff --git a/app/src/main/res/layout/dialog_change_source.xml b/app/src/main/res/layout/dialog_change_source.xml index cc7486b05..464eef953 100644 --- a/app/src/main/res/layout/dialog_change_source.xml +++ b/app/src/main/res/layout/dialog_change_source.xml @@ -19,7 +19,7 @@ android:layout_width="match_parent" android:layout_height="2dp" /> - diff --git a/app/src/main/res/layout/dialog_file_chooser.xml b/app/src/main/res/layout/dialog_file_chooser.xml index ab5974114..14fb214a0 100644 --- a/app/src/main/res/layout/dialog_file_chooser.xml +++ b/app/src/main/res/layout/dialog_file_chooser.xml @@ -10,7 +10,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" /> - - diff --git a/app/src/main/res/layout/dialog_font_select.xml b/app/src/main/res/layout/dialog_font_select.xml index 1e9cf6b42..5d8242f58 100644 --- a/app/src/main/res/layout/dialog_font_select.xml +++ b/app/src/main/res/layout/dialog_font_select.xml @@ -10,7 +10,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" /> - diff --git a/app/src/main/res/layout/dialog_read_bg_text.xml b/app/src/main/res/layout/dialog_read_bg_text.xml index 6cea816cd..14e189c8b 100644 --- a/app/src/main/res/layout/dialog_read_bg_text.xml +++ b/app/src/main/res/layout/dialog_read_bg_text.xml @@ -79,7 +79,7 @@ android:layout_height="wrap_content" android:text="@string/bg_image" /> - diff --git a/app/src/main/res/layout/dialog_recycler_view.xml b/app/src/main/res/layout/dialog_recycler_view.xml index 5b1d900a9..15d1d5315 100644 --- a/app/src/main/res/layout/dialog_recycler_view.xml +++ b/app/src/main/res/layout/dialog_recycler_view.xml @@ -11,7 +11,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" /> - - - diff --git a/app/src/main/res/layout/fragment_rss.xml b/app/src/main/res/layout/fragment_rss.xml index f1469fbd7..35cb73229 100644 --- a/app/src/main/res/layout/fragment_rss.xml +++ b/app/src/main/res/layout/fragment_rss.xml @@ -12,7 +12,7 @@ app:attachToActivity="false" app:title="@string/rss" /> - diff --git a/app/src/main/res/layout/popup_action_menu.xml b/app/src/main/res/layout/popup_action_menu.xml index 0f6b6e0e5..0c5a6f754 100644 --- a/app/src/main/res/layout/popup_action_menu.xml +++ b/app/src/main/res/layout/popup_action_menu.xml @@ -13,7 +13,7 @@ android:orientation="horizontal" android:gravity="center_vertical"> - - - - From 2490538fd9239e021d477c2ab3016ce1c8044e16 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 27 May 2020 19:33:32 +0800 Subject: [PATCH 142/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/help/AdapterDataObserverHeader.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/AdapterDataObserverHeader.kt b/app/src/main/java/io/legado/app/help/AdapterDataObserverHeader.kt index 24f0c0f2b..1aeddeb95 100644 --- a/app/src/main/java/io/legado/app/help/AdapterDataObserverHeader.kt +++ b/app/src/main/java/io/legado/app/help/AdapterDataObserverHeader.kt @@ -3,8 +3,8 @@ package io.legado.app.help import androidx.recyclerview.widget.RecyclerView internal class AdapterDataObserverHeader( - var adapterDataObserver: RecyclerView.AdapterDataObserver, - var headerCount: Int + private var adapterDataObserver: RecyclerView.AdapterDataObserver, + private var headerCount: Int ) : RecyclerView.AdapterDataObserver() { override fun onChanged() { adapterDataObserver.onChanged() From 6d087c1027a9a66e33ec2122e5ba857036e54397 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 27 May 2020 22:58:34 +0800 Subject: [PATCH 143/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index ec6d22bdb..d284a31f2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -117,7 +117,7 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" //fireBase - implementation 'com.google.firebase:firebase-core:17.4.1' + implementation 'com.google.firebase:firebase-core:17.4.2' implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1' //androidX From 50c53858896a36fb3eb9a6073574ce2d1adf933c Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 30 May 2020 12:01:18 +0800 Subject: [PATCH 144/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 3 +- app/proguard-rules.pro | 81 +++++++++++------------- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 +- 4 files changed, 41 insertions(+), 49 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d284a31f2..33af4c2c3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -66,7 +66,6 @@ android { applicationIdSuffix '.debug' versionNameSuffix 'debug' minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } android.applicationVariants.all { variant -> variant.outputs.all { @@ -121,7 +120,7 @@ dependencies { implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1' //androidX - implementation 'androidx.core:core-ktx:1.2.0' + implementation 'androidx.core:core-ktx:1.3.0' implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.media:media:1.1.0' implementation 'androidx.preference:preference:1.1.1' diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 1e8ab731b..29f32c555 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -58,21 +58,20 @@ # 保留我们使用的四大组件,自定义的Application等等这些类不被混淆 # 因为这些子类都有可能被外部调用 -keep public class * extends android.app.Activity --keep public class * extends android.app.Appliction +-keep public class * extends android.app.Application -keep public class * extends android.app.Service -keep public class * extends android.content.BroadcastReceiver -keep public class * extends android.content.ContentProvider -keep public class * extends android.app.backup.BackupAgentHelper -keep public class * extends android.preference.Preference -keep public class * extends android.view.View --keep public class com.android.vending.licensing.ILicensingService # 保留androidx下的所有类及其内部类 --keep class androidx.** {*;} +-keep class androidx** {*;} # 保留继承的 --keep public class * extends androidx.** +-keep public class * extends androidx** # 保留R下面的资源 -keep class **.R$* {*;} @@ -105,6 +104,7 @@ # 保留Parcelable序列化类不被混淆 -keep class * implements android.os.Parcelable { + #noinspection ShrinkerUnresolvedReference public static final android.os.Parcelable$Creator *; } @@ -128,16 +128,11 @@ } # webView处理,项目中没有使用到webView忽略即可 --keepclassmembers class fqcn.of.javascript.interface.for.webview { - public *; -} --keepclassmembers class * extends android.webkit.webViewClient { +-keepclassmembers class * extends android.webkit.WebViewClient { + public void *(android.webkit.WebView, java.lang.String); public void *(android.webkit.WebView, java.lang.String, android.graphics.Bitmap); public boolean *(android.webkit.WebView, java.lang.String); } --keepclassmembers class * extends android.webkit.webViewClient { - public void *(android.webkit.webView, jav.lang.String); -} # 移除Log类打印各个等级日志的代码,打正式包的时候可以做为禁log使用,这里可以作为禁止log打印的功能使用 # 记得proguard-android.txt中一定不要加-dontoptimize才起作用 @@ -151,11 +146,11 @@ } # 保持js引擎调用的java类 --keep class **.analyzeRule.**{*;} +-keep class **.analyzeRule**{*;} # 保持web类 --keep class **.web.**{*;} +-keep class **.web**{*;} #数据类 --keep class **.data.**{*;} +-keep class **.data**{*;} -dontwarn rx.** @@ -170,55 +165,53 @@ -dontwarn org.conscrypt.** -dontwarn com.jeremyliao.liveeventbus.** --keep class com.jeremyliao.liveeventbus.** { *; } --keep class okhttp3.**{*;} --keep class okio.**{*;} --keep class com.hwangjr.rxbus.**{*;} --keep class org.conscrypt.**{*;} --keep class com.kunfei.bookshelf.widget.**{*;} --keep class com.kunfei.bookshelf.bean.**{*;} --keep class android.support.**{*;} --keep class me.grantland.widget.**{*;} --keep class de.hdodenhof.circleimageview.**{*;} --keep class tyrant.explosionfield.**{*;} --keep class tyrantgit.explosionfield.**{*;} --keep class freemarker.**{*;} +-keep class com.jeremyliao.liveeventbus** { *; } +-keep class okhttp3**{*;} +-keep class okio**{*;} +-keep class com.hwangjr.rxbus**{*;} +-keep class org.conscrypt**{*;} +-keep class android.support**{*;} +-keep class me.grantland.widget**{*;} +-keep class de.hdodenhof.circleimageview**{*;} +-keep class tyrant.explosionfield**{*;} +-keep class tyrantgit.explosionfield**{*;} +-keep class freemarker**{*;} -keep class com.gyf.barlibrary.* {*;} ##JSOUP --keep class org.jsoup.**{*;} --keep class **.xpath.**{*;} +-keep class org.jsoup**{*;} +-keep class **.xpath**{*;} --keep class org.slf4j.**{*;} +-keep class org.slf4j**{*;} -dontwarn org.slf4j.** --keep class org.codehaus.**{*;} +-keep class org.codehaus**{*;} -dontwarn org.codehaus.** --keep class com.jayway.**{*;} +-keep class com.jayway**{*;} -dontwarn com.jayway.** --keep class com.fasterxml.**{*;} +-keep class com.fasterxml**{*;} --keep class javax.swing..**{*;} +-keep class javax.swing**{*;} -dontwarn javax.swing.** --keep class java.awt.**{*;} +-keep class java.awt**{*;} -dontwarn java.awt.** --keep class sun.misc.**{*;} +-keep class sun.misc**{*;} -dontwarn sun.misc.** --keep class sun.reflect.**{*;} +-keep class sun.reflect**{*;} -dontwarn sun.reflect.** ## Rhino --keep class javax.script.** { *; } --keep class com.sun.script.javascript.** { *; } --keep class org.mozilla.javascript.** { *; } +-keep class javax.script** { *; } +-keep class com.sun.script.javascript** { *; } +-keep class org.mozilla.javascript** { *; } ###EPUB -dontwarn nl.siegmann.epublib.** -dontwarn org.xmlpull.** --keep class nl.siegmann.epublib.**{*;} --keep class javax.xml.**{*;} --keep class org.xmlpull.**{*;} +-keep class nl.siegmann.epublib**{*;} +-keep class javax.xml**{*;} +-keep class org.xmlpull**{*;} --keep class org.simpleframework.xml.**{*;} +-keep class org.simpleframework.xml**{*;} -dontwarn org.simpleframework.xml.** -keepclassmembers class * { diff --git a/build.gradle b/build.gradle index 21c80e3a6..051a1d77c 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ buildscript { maven { url 'https://plugins.gradle.org/m2/' } } dependencies { - classpath 'com.android.tools.build:gradle:3.6.3' + classpath 'com.android.tools.build:gradle:4.0.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'de.timfreiheit.resourceplaceholders:placeholders:0.3' classpath 'com.google.gms:google-services:4.3.3' diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 20b544410..372426236 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Feb 25 08:10:32 CST 2020 +#Sat May 30 10:00:31 CST 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip From 4d1cbda3793c6b1f993735dd09a6e0f779e70adf Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 30 May 2020 17:14:21 +0800 Subject: [PATCH 145/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/data/entities/BaseBook.kt | 2 +- .../java/io/legado/app/data/entities/Book.kt | 22 ++++++++----------- .../io/legado/app/data/entities/SearchBook.kt | 14 +++++------- 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/entities/BaseBook.kt b/app/src/main/java/io/legado/app/data/entities/BaseBook.kt index 62d322b6c..31346a50c 100644 --- a/app/src/main/java/io/legado/app/data/entities/BaseBook.kt +++ b/app/src/main/java/io/legado/app/data/entities/BaseBook.kt @@ -4,7 +4,7 @@ import io.legado.app.utils.splitNotBlank interface BaseBook { var bookUrl: String - var variableMap: HashMap? + val variableMap: HashMap var kind: String? var wordCount: String? 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 fd96d137b..1bb69ea81 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 @@ -71,15 +71,16 @@ data class Book( return bookUrl.hashCode() } - @Ignore + @delegate:Ignore @IgnoredOnParcel - override var variableMap: HashMap? = null - get() { - if (field == null) { - field = GSON.fromJsonObject>(variable) ?: HashMap() - } - return field - } + override val variableMap by lazy { + GSON.fromJsonObject>(variable) ?: HashMap() + } + + override fun putVariable(key: String, value: String) { + variableMap[key] = value + variable = GSON.toJson(variableMap) + } @Ignore @IgnoredOnParcel @@ -97,11 +98,6 @@ data class Book( fun getDisplayIntro() = if (customIntro.isNullOrEmpty()) intro else customIntro - override fun putVariable(key: String, value: String) { - variableMap?.put(key, value) - variable = GSON.toJson(variableMap) - } - fun fileCharset(): Charset { return charset(charset ?: "UTF-8") } diff --git a/app/src/main/java/io/legado/app/data/entities/SearchBook.kt b/app/src/main/java/io/legado/app/data/entities/SearchBook.kt index 27f666547..72cdb721d 100644 --- a/app/src/main/java/io/legado/app/data/entities/SearchBook.kt +++ b/app/src/main/java/io/legado/app/data/entities/SearchBook.kt @@ -63,18 +63,14 @@ data class SearchBook( return other.originOrder - this.originOrder } - @Ignore + @delegate:Ignore @IgnoredOnParcel - override var variableMap: HashMap? = null - get() { - if (field == null) { - field = GSON.fromJsonObject>(variable) ?: HashMap() - } - return field - } + override val variableMap by lazy { + GSON.fromJsonObject>(variable) ?: HashMap() + } override fun putVariable(key: String, value: String) { - variableMap?.put(key, value) + variableMap[key] = value variable = GSON.toJson(variableMap) } From f5733bbf3e42c1d8ffeee281e4a605d4602d195a Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 31 May 2020 08:07:34 +0800 Subject: [PATCH 146/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../book/source/manage/BookSourceActivity.kt | 39 ++++++++++++++---- app/src/main/res/menu/book_source.xml | 40 +++++++++++-------- app/src/main/res/values-zh-rHK/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 4 files changed, 57 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt index a765f3b4f..a7c1dbb2c 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt @@ -57,6 +57,7 @@ class BookSourceActivity : VMBaseActivity(R.layout.activity private var bookSourceLiveDate: LiveData>? = null private var groups = linkedSetOf() private var groupMenu: SubMenu? = null + private var sort = 0 override fun onActivityCreated(savedInstanceState: Bundle?) { initUriScheme() @@ -92,6 +93,22 @@ class BookSourceActivity : VMBaseActivity(R.layout.activity allowExtensions = arrayOf("txt", "json") ) R.id.menu_import_source_onLine -> showImportDialog() + R.id.menu_sort_manual -> { + item.isChecked = true + sort = 0 + } + R.id.menu_sort_auto -> { + item.isChecked = true + sort = 2 + } + R.id.menu_sort_pin_yin -> { + item.isChecked = true + sort = 3 + } + R.id.menu_sort_url -> { + item.isChecked = true + sort = 4 + } } if (item.groupId == R.id.source_group) { search_view.setQuery(item.title, true) @@ -104,14 +121,14 @@ class BookSourceActivity : VMBaseActivity(R.layout.activity when (it.path) { "/importonline" -> it.getQueryParameter("src")?.let { url -> Snackbar.make(title_bar, R.string.importing, Snackbar.LENGTH_INDEFINITE).show() - if (url.startsWith("http", false)){ + if (url.startsWith("http", false)) { viewModel.importSource(url) { msg -> title_bar.snackbar(msg) } - } - else{ - viewModel.importSourceFromFilePath(url){msg -> - title_bar.snackbar(msg)} + } else { + viewModel.importSourceFromFilePath(url) { msg -> + title_bar.snackbar(msg) + } } } else -> { @@ -148,10 +165,16 @@ class BookSourceActivity : VMBaseActivity(R.layout.activity } else { App.db.bookSourceDao().liveDataSearch("%$searchKey%") } - bookSourceLiveDate?.observe(this, Observer { + bookSourceLiveDate?.observe(this, Observer { data -> + val sourceList = when (sort) { + 1 -> data.sortedBy { it.weight } + 2 -> data.sortedBy { it.bookSourceName } + 3 -> data.sortedBy { it.bookSourceUrl } + else -> data + } val diffResult = DiffUtil - .calculateDiff(DiffCallBack(ArrayList(adapter.getItems()), it)) - adapter.setItems(it, diffResult) + .calculateDiff(DiffCallBack(ArrayList(adapter.getItems()), sourceList)) + adapter.setItems(sourceList, diffResult) upCountView() }) } diff --git a/app/src/main/res/menu/book_source.xml b/app/src/main/res/menu/book_source.xml index 649060e9f..a02fb146e 100644 --- a/app/src/main/res/menu/book_source.xml +++ b/app/src/main/res/menu/book_source.xml @@ -23,22 +23,30 @@ - - - - - - + android:checkableBehavior="single"> + + + + + + + + + + diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 90d34f2c3..7cb27fd34 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -693,4 +693,5 @@ 置底 文字兩端對齊 自動翻頁速度 + 地址排序 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 457c42de7..bcf8f247a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -695,5 +695,6 @@ 自动换源 文字两端对齐 自动翻页速度 + 地址排序 From 51469c9e0155db48ee63023d4fa4744775ee7b4f Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 31 May 2020 08:10:01 +0800 Subject: [PATCH 147/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/book/source/manage/BookSourceActivity.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt index a7c1dbb2c..425faba93 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt @@ -96,18 +96,22 @@ class BookSourceActivity : VMBaseActivity(R.layout.activity R.id.menu_sort_manual -> { item.isChecked = true sort = 0 + initLiveDataBookSource(search_view.query?.toString()) } R.id.menu_sort_auto -> { item.isChecked = true sort = 2 + initLiveDataBookSource(search_view.query?.toString()) } R.id.menu_sort_pin_yin -> { item.isChecked = true sort = 3 + initLiveDataBookSource(search_view.query?.toString()) } R.id.menu_sort_url -> { item.isChecked = true sort = 4 + initLiveDataBookSource(search_view.query?.toString()) } } if (item.groupId == R.id.source_group) { From 71a4b7d6b273710ad86e883deb2b8269297e4577 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 31 May 2020 08:30:31 +0800 Subject: [PATCH 148/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/book/source/manage/BookSourceActivity.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt index 425faba93..f73477916 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt @@ -75,6 +75,8 @@ class BookSourceActivity : VMBaseActivity(R.layout.activity override fun onPrepareOptionsMenu(menu: Menu?): Boolean { groupMenu = menu?.findItem(R.id.menu_group)?.subMenu + groupMenu?.findItem(R.id.action_sort)?.subMenu + ?.setGroupCheckable(R.id.menu_group_sort, true, true) upGroupMenu() return super.onPrepareOptionsMenu(menu) } From 54e2e6071f7df59389a62b2fcb75efe2004d6cb8 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 31 May 2020 08:39:41 +0800 Subject: [PATCH 149/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 6c40150d9..1e274ee15 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,10 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/05/31** +* 更新到android studio 4.0 +* 书源排序添加按url + **2020/05/24** * 添加自动翻页速度调节 From 16f8fc0ca360aba597a55b373f95ff7c6e87e0b1 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 31 May 2020 10:23:06 +0800 Subject: [PATCH 150/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/service/BaseReadAloudService.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt b/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt index 6dee23a92..7531b21bb 100644 --- a/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt @@ -323,7 +323,6 @@ abstract class BaseReadAloudService : BaseService(), ) builder.setStyle( androidx.media.app.NotificationCompat.MediaStyle() - .setMediaSession(mediaSessionCompat.sessionToken) .setShowActionsInCompactView(0, 1, 2) ) builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC) From 46c28fc38c8191fc1168edd3f292e059978df4a6 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 31 May 2020 10:26:14 +0800 Subject: [PATCH 151/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 1e274ee15..bb1c7beaa 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -6,6 +6,7 @@ **2020/05/31** * 更新到android studio 4.0 * 书源排序添加按url +* 去除朗读通知的进度条 **2020/05/24** * 添加自动翻页速度调节 From f12f82e54e949af1aed60104c3a079ce1c772951 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 31 May 2020 20:16:29 +0800 Subject: [PATCH 152/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 +- app/src/main/assets/updateLog.md | 1 + app/src/main/java/io/legado/app/data/entities/Book.kt | 1 + app/src/main/java/io/legado/app/data/entities/SearchBook.kt | 2 ++ app/src/main/java/io/legado/app/utils/GsonExtensions.kt | 2 -- 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 33af4c2c3..a5068f755 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -56,7 +56,7 @@ android { signingConfig signingConfigs.myConfig } applicationIdSuffix '.release' - minifyEnabled true + minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } debug { diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index bb1c7beaa..51a0e2beb 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -7,6 +7,7 @@ * 更新到android studio 4.0 * 书源排序添加按url * 去除朗读通知的进度条 +* 修复恢复问题,暂时去除混淆 **2020/05/24** * 添加自动翻页速度调节 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 1bb69ea81..2889f1c99 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 @@ -71,6 +71,7 @@ data class Book( return bookUrl.hashCode() } + @delegate:Transient @delegate:Ignore @IgnoredOnParcel override val variableMap by lazy { diff --git a/app/src/main/java/io/legado/app/data/entities/SearchBook.kt b/app/src/main/java/io/legado/app/data/entities/SearchBook.kt index 72cdb721d..eb7ea0c10 100644 --- a/app/src/main/java/io/legado/app/data/entities/SearchBook.kt +++ b/app/src/main/java/io/legado/app/data/entities/SearchBook.kt @@ -63,6 +63,7 @@ data class SearchBook( return other.originOrder - this.originOrder } + @delegate:Transient @delegate:Ignore @IgnoredOnParcel override val variableMap by lazy { @@ -74,6 +75,7 @@ data class SearchBook( variable = GSON.toJson(variableMap) } + @delegate:Transient @delegate:Ignore @IgnoredOnParcel val origins: LinkedHashSet by lazy { linkedSetOf(origin) } diff --git a/app/src/main/java/io/legado/app/utils/GsonExtensions.kt b/app/src/main/java/io/legado/app/utils/GsonExtensions.kt index 773cd8030..32870d7b2 100644 --- a/app/src/main/java/io/legado/app/utils/GsonExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/GsonExtensions.kt @@ -22,7 +22,6 @@ val GSON: Gson by lazy { inline fun genericType(): Type = object : TypeToken() {}.type -@Throws(JsonSyntaxException::class) inline fun Gson.fromJsonObject(json: String?): T? {//可转成任意类型 return attempt { val result: T? = fromJson(json, genericType()) @@ -30,7 +29,6 @@ inline fun Gson.fromJsonObject(json: String?): T? {//可转成任意 }.value } -@Throws(JsonSyntaxException::class) inline fun Gson.fromJsonArray(json: String?): List? { return attempt { val result: List? = fromJson(json, ParameterizedTypeImpl(T::class.java)) From ecde68d63896196c53a0d0dba722924381ad1a43 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 31 May 2020 20:55:49 +0800 Subject: [PATCH 153/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/http/CookieStore.kt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/http/CookieStore.kt b/app/src/main/java/io/legado/app/help/http/CookieStore.kt index d82a4b175..42634ede1 100644 --- a/app/src/main/java/io/legado/app/help/http/CookieStore.kt +++ b/app/src/main/java/io/legado/app/help/http/CookieStore.kt @@ -39,10 +39,6 @@ object CookieStore { App.db.cookieDao().delete(url) } - fun clearCookies() { - - } - private fun cookieToMap(cookie: String): MutableMap { val cookieMap = mutableMapOf() if (cookie.isBlank()) { From 45a0341648f59dc094cc5be304e4b6df33fa8ea8 Mon Sep 17 00:00:00 2001 From: david082321 <7046617+david082321@users.noreply.github.com> Date: Tue, 2 Jun 2020 14:03:41 +0800 Subject: [PATCH 154/296] Create arrays.xml --- app/src/main/res/values-zh-rTW/arrays.xml | 109 ++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 app/src/main/res/values-zh-rTW/arrays.xml diff --git a/app/src/main/res/values-zh-rTW/arrays.xml b/app/src/main/res/values-zh-rTW/arrays.xml new file mode 100644 index 000000000..84dc2f886 --- /dev/null +++ b/app/src/main/res/values-zh-rTW/arrays.xml @@ -0,0 +1,109 @@ + + + + @string/book_type_text + @string/book_type_audio + + + + 度小美 + 度小宇 + 度逍遙 + 度丫丫 + 度小嬌 + 度米朵 + 度博文 + 度小童 + 度小萌 + 百度騷男 + 百度評書 + 百度主持 + + + + @string/indent_0 + @string/indent_1 + @string/indent_2 + @string/indent_3 + @string/indent_4 + + + + .txt + .json + .xml + + + + @string/jf_convert_o + @string/jf_convert_j + @string/jf_convert_f + + + + 跟隨系統 + 亮色主題 + 暗色主題 + + + + 自動 + 黑色 + 白色 + 跟隨背景 + + + + 預設 + 1分鐘 + 2分鐘 + 3分鐘 + 常亮 + + + + @string/default_path + @string/sys_folder_picker + @string/app_folder_picker + + + + @string/screen_unspecified + @string/screen_portrait + @string/screen_landscape + @string/screen_sensor + + + + iconMain + icon1 + icon2 + icon3 + icon4 + icon5 + icon6 + + + + 關閉 + 繁體轉簡體 + 簡體轉繁體 + + + + 系統預設字體 + 系統襯線字體 + 系統等寬字體 + + + + + 標題 + 時間 + 電量 + 頁數 + 進度 + 頁數及進度 + + + From b3e2de23234bf4bd82993a9f4d48ab21d9c60b20 Mon Sep 17 00:00:00 2001 From: david082321 <7046617+david082321@users.noreply.github.com> Date: Tue, 2 Jun 2020 14:09:27 +0800 Subject: [PATCH 155/296] Create strings.xml --- app/src/main/res/values-zh-rTW/strings.xml | 700 +++++++++++++++++++++ 1 file changed, 700 insertions(+) create mode 100644 app/src/main/res/values-zh-rTW/strings.xml diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml new file mode 100644 index 000000000..00bf07e51 --- /dev/null +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -0,0 +1,700 @@ + + + 閱讀 + 閱讀·搜尋 + 閱讀需要存取記憶卡權限,請前往“設定”—“應用權限”—打開所需權限 + + + Home + 復原 + 匯入閱讀資料 + 建立子資料夾 + 建立legado資料夾作為備份資料夾 + 備份路徑 + 匯入舊版資料 + 匯入Github資料 + 淨化取代 + Send + + 提示 + 取消 + 確定 + 去設定 + 無法跳轉至設定介面 + + 點擊重試 + 正在載入 + 提醒 + 編輯 + 刪除 + 取代 + 取代淨化 + 配置取代淨化規則 + 暫無 + 啟用 + 取代淨化-搜尋 + 書架 + 收藏夾 + 收藏 + 已收藏 + 未收藏 + 訂閱 + 全部 + 最近閱讀 + 最後閱讀 + 更新日誌 + 書架還空著,先去添加吧! + 搜尋 + 下載 + 列表 + 網格三列 + 網格四列 + 網格五列 + 網格六列 + 書架布局 + 檢視 + 書城 + 添加本機 + 書源 + 書源管理 + 建立/匯入/編輯/管理書源 + 設定 + 主題設定 + 與介面/顏色相關的一些設定 + 其它設定 + 與功能相關的一些設定 + 關於 + 捐贈 + 退出 + 尚未儲存,是否繼續編輯 + 閱讀樣式設定 + 版本 + 本機 + 搜尋 + 來源: %s + 最近: %s + 書名 + 最新: %s + 是否將《%s》放入書架? + 共%s個Text文件 + 載入中… + 重試 + Web 服務 + 啟用Web服務 + web編輯書源 + http://%1$s:%2$d + 離線下載 + 離線下載 + 下載選擇的章節到本機 + 換源 + + \u3000\u3000這是一款使用Kotlin全新開發的開源的閱讀軟體,歡迎您的加入。關注公眾號[開源閱讀]! + + + 閱讀3.0下載網址:\nhttps://play.google.com/store/apps/details?id=io.legado.app + + Version %s + 自動重新整理 + 打開軟體時自動更新書籍 + 自動下載最新章節 + 更新書籍時自動下載最新章節 + 備份與復原 + WebDav設定 + WebDav設定/匯入舊版本資料 + 備份 + 復原 + 備份請給與儲存權限 + 復原請給與儲存權限 + 確認 + 取消 + 確認備份嗎? + 新備份會取代原有備份。\n備份資料夾YueDu + 確認復原嗎? + 復原書架會覆蓋現有書架。 + 備份成功 + 備份失敗 + 正在復原 + 復原成功 + 復原失敗 + 螢幕方向 + 跟隨感測器 + 橫向 + 豎向 + 跟隨系統 + 免責聲明 + 共%d章 + 介面 + 亮度 + 目錄 + 下一章 + 上一章 + 隱藏狀態欄 + 閱讀介面隱藏狀態欄 + 朗讀 + 正在朗讀 + 點擊打開閱讀介面 + 播放 + 正在播放 + 點擊打開播放介面 + 播放暫停 + 返回 + 重新整理 + 開始 + 停止 + 暫停 + 繼續 + 定時 + 朗讀暫停 + 正在朗讀(還剩%d分鐘) + 閱讀介面隱藏虛擬按鍵 + 隱藏導航欄 + 導航欄顏色 + GitHub + 評分 + 發送郵件 + 無法打開 + 分享失敗 + 無章節 + 添加網址 + 添加書籍網址 + 背景 + 作者 + 作者: %s + 朗讀停止 + 清除快取 + 成功清理快取 + 儲存 + 編輯源 + 編輯書源 + 禁用書源 + 建立書源 + 建立訂閱源 + 添加書籍 + 掃描 + 複製源 + 貼上源 + 源規則說明 + 檢查更新 + 掃描二維碼 + 掃描本機圖片 + 規則說明 + 分享 + 軟體分享 + 跟隨系統 + 添加 + 匯入書源 + 本機匯入 + 網路匯入 + 取代淨化 + 取代規則編輯 + 取代規則 + 取代為 + 封面 + + 音量鍵翻頁 + 點擊翻頁 + 點擊總是翻下一頁 + 翻頁動畫 + 螢幕超時 + 返回 + 選單 + 調節 + 滾動條 + 清除快取會刪除所有已儲存章節,是否確認刪除? + 書源共享 + 取代規則名稱 + 取代規則為空或者不滿足正規表示式要求 + 選擇操作 + 全選 + 全選(%1$d/%2$d) + 取消(%1$d/%2$d) + 深色模式 + 啟動頁 + 開始下載 + 取消下載 + 暫無任務 + 已下載 %1$d/%2$d + 匯入選擇書籍 + 更新和搜尋執行緒數,太多會卡頓 + 切換圖示 + 刪除書籍 + 開始閱讀 + 載入資料中… + 載入失敗,點擊重試 + 內容簡介 + 簡介:%s + 打開外部書籍 + 來源: %s + 本機匯入 + 匯入線上規則 + 檢查更新間隔 + 按閱讀時間 + 按更新時間 + 按書名 + 手動排序 + 閱讀方式 + 排版 + 刪除所選 + 是否確認刪除? + 預設字體 + 發現 + 發現管理 + 沒有內容,去書源裡自訂吧! + 刪除所有 + 搜尋歷史 + 清除 + 正文顯示標題 + 書源同步 + 無最新章節訊息 + 顯示時間和電量 + 顯示分隔線 + 深色狀態欄圖示 + 內容 + 複製內容 + 一鍵快取 + 這是一段測試文字\n\u3000\u3000只是讓你看看效果的 + 文字顏色和背景(長按自訂) + 沉浸式狀態欄 + 還剩%d章未下載 + 沒有選擇 + 長按輸入顏色值 + 載入中… + 追更區 + 養肥區 + 書籤 + 添加書籤 + 刪除 + 載入超時 + 關注:%s + 已複製 + 整理書架 + 這將會刪除所有書籍,請謹慎操作。 + 搜尋書源 + 搜尋訂閱源 + 搜尋(共%d個書源) + 目錄(%d) + 加粗 + 字體 + 文字 + 軟體首頁 + + + + + 邊距 + 上邊距 + 下邊距 + 左邊距 + 右邊距 + 校驗書源 + 校驗所選 + 進度 %1$d/%2$d + 請安裝並選擇中文TTS! + TTS初始化失敗! + 簡繁轉換 + 關閉 + 簡轉繁 + 繁轉簡 + 翻頁模式 + %1$d 項 + 記憶卡: + 加入書架 + 加入書架(%1$d) + 成功添加%1$d本書 + 請將字體檔案放到SD根目錄Fonts資料夾下重新選擇 + 預設字體 + 選擇字體 + 字號 + 行距 + 段距 + 置頂 + 置底 + 自動展開發現 + 預設展開第一組發現 + 目前執行緒數 %s + 朗讀語速 + 自動翻頁 + 停止自動翻頁 + 自動翻頁間隔 + 書籍訊息 + 書籍訊息編輯 + 預設打開書架 + 自動跳轉最近閱讀 + 取代範圍,選填書名或者源名 + 分組 + 內容快取路徑 + 清理快取 + 系統檔案選擇器 + 新版本 + 下載更新 + 朗讀時音量鍵翻頁 + Tip邊距跟隨邊距調整 + 允許更新 + 禁止更新 + 反選 + 搜尋書名、作者 + 書名、作者、URL + 常見問題 + 顯示所有發現 + 關閉則只顯示勾選源的發現 + 更新目錄 + Txt目錄正則 + 設定編碼 + 倒序-順序 + 排序 + 智慧排序 + 手動排序 + 拼音排序 + 滾動到頂部 + 滾動到底部 + 已讀: %s + 追更 + 養肥 + 完結 + 所有書籍 + 追更書籍 + 養肥書籍 + 完結書籍 + 本機書籍 + 狀態欄顏色透明 + 導航欄變色 + 導航欄根據夜間模式變化 + 放入書架 + 繼續閱讀 + 封面地址 + 覆蓋 + 滑動 + 模擬 + 滾動 + 無動畫 + 此書源使用了進階功能,請到捐贈裡點擊支付寶紅包搜尋碼領取紅包開啟。 + 後台更新換源最新章節 + 開啟則會在軟體打開1分鐘後開始更新 + 書架ToolBar自動隱藏 + 滾動書架時ToolBar自動隱藏與顯示 + 登入 + 登入%s + 成功 + 目前源沒有配置登入地址 + + + 源名稱(sourceName) + 源URL(sourceUrl) + 源分組(sourceGroup) + 分類Url + 登入URL(loginUrl) + 搜尋地址(url) + 發現地址規則(url) + 書籍列表規則(bookList) + 書名規則(name) + 詳情頁url規則(bookUrl) + 作者規則(author) + 分類規則(kind) + 簡介規則(intro) + 封面規則(coverUrl) + 最新章節規則(lastChapter) + 字數規則(wordCount) + 書籍URL正則(bookUrlPattern) + 預處理規則(bookInfoInit) + 目錄URL規則(tocUrl) + 目錄下一頁規則(nextTocUrl) + 目錄列表規則(chapterList) + 章節名稱規則(ChapterName) + 章節URL規則(chapterUrl) + VIP標識(isVip) + 更新時間(ChapterInfo) + 正文規則(content) + 正文下一頁URL規則(nextContentUrl) + webJs + 資源正則(sourceRegex) + + 圖示(sourceIcon) + 列表規則(ruleArticles) + 列表下一頁規則(ruleArticles) + 標題規則(ruleTitle) + guid規則(ruleGuid) + 時間規則(rulePubDate) + 類別規則(ruleCategories) + 描述規則(ruleDescription) + 圖片url規則(ruleImage) + 內容規則(ruleContent) + 樣式(style) + 連結規則(ruleLink) + + + + 沒有書源 + 書籍訊息獲取失敗 + 內容獲取失敗 + 目錄獲取失敗 + 瀏覽網站失敗:%s + 文件讀取失敗 + 載入目錄失敗 + 獲取資料失敗! + 載入失敗\n%s + 沒有網路 + 網路連接超時 + 資料解析失敗 + + + 請求頭(header) + 除錯源 + 二維碼匯入 + 掃描二維碼 + 選中時點擊可彈出選單 + 主題 + 主題模式 + 選擇主題模式 + 預設主題 + 復原主題為預設配色 + 加入QQ群 + 獲取背景圖片需儲存權限 + 輸入書源網址 + 刪除文件 + 刪除文件成功 + 確定刪除文件嗎? + 手機目錄 + 智慧匯入 + 發現 + 切換顯示樣式 + 匯入本機書籍需儲存權限 + 夜間模式 + E-Ink 模式 + 電子墨水屏模式 + 本軟體需要儲存權限來儲存備份書籍訊息 + 再按一次退出程式 + 匯入本機書籍需儲存權限 + 網路連接不可用 + + + 確認 + 是否確認刪除? + 是否刪除全部書籍? + 是否同時刪除已下載的書籍目錄? + 掃描二維碼需相機權限 + 朗讀正在執行,不能自動翻頁 + 輸入編碼 + TXT目錄規則 + 打開外部書籍需獲取儲存權限 + 未獲取到書名 + 輸入取代規則網址 + 搜尋列表獲取成功%d + 書源名稱和URL不能為空 + 圖庫 + 領支付寶紅包 + 沒有獲取到更新地址 + 正在打開首頁,成功自動返回主介面 + 登入成功後請點擊右上角圖示進行首頁訪問測試 + + + 使用正規表示式 + 縮排 + 無縮排 + 一字元縮排 + 二字元縮排 + 三字元縮排 + 四字元縮排 + 選擇資料夾 + 選擇文件 + 沒有發現,可以在書源裡添加。 + 復原預設 + 自訂快取路徑需要儲存權限 + 黑色 + 文章內容為空 + 正在換源請等待… + 目錄列表為空 + 字距 + + 基本 + 搜尋 + 發現 + 詳情 + 目錄 + 正文 + + E-Ink 模式 + 去除動畫,最佳化電紙書使用體驗 + Web服務 + web埠 + 目前埠 %s + 二維碼分享 + 字串分享 + wifi分享 + 請給於儲存權限 + 減速 + 加速 + 上一個 + 下一個 + 音樂 + 音訊 + 啟用 + 啟用JS + 載入BaseUrl + 全部書源 + 輸入不能為空 + 清空發現快取 + 編輯發現 + 切換軟體顯示在桌面的圖示 + 幫助 + 我的 + 閱讀 + %d%% + %d分鐘 + 自動亮度%s + 按頁朗讀 + 線上朗讀 + 背景圖片 + 背景顏色 + 文字顏色 + 選擇圖片 + 分組管理 + 分組選擇 + 編輯分組 + 移入分組 + 添加分組 + 建立取代 + 分組 + 分組: %s + 目錄: %s + 啟用發現 + 禁用發現 + 啟用所選 + 禁用所選 + 匯出所選 + 匯出 + 載入目錄 + TTS + WebDav 密碼 + 輸入你的WebDav授權密碼 + 輸入你的伺服器地址 + WebDav 伺服器地址 + WebDav 帳號 + 輸入你的WebDav帳號 + 訂閱源 + 編輯訂閱源 + 篩選 + 篩選發現 + 目前位置: + 精準搜尋 + 正在啟動服務 + + 文件選擇 + 資料夾選擇 + 我是有底線的 + Uri轉Path失敗 + 重新整理封面 + 封面換源 + 選擇本機圖片 + 類型: + 文字 + 音訊 + 後台 + 正在匯入 + 正在匯出 + 自訂翻頁按鍵 + 上一頁按鍵 + 下一頁按鍵 + 先將書籍加入書架 + 未分組 + 上一句 + 下一句 + 其它目錄 + 文字太多,生成二維碼失敗 + 分享RSS源 + 分享書源 + 自動切換夜間模式 + 夜間模式跟隨系統 + 上級 + 線上朗讀音色 + (%1$d/%2$d) + 顯示訂閱 + 服務已停止 + 正在啟動服務\n具體訊息查看通知欄 + 預設路徑 + 系統資料夾選擇器 + 自帶選擇器\n(Android10以上因權限限制可能無法使用) + Android10以上因權限限制可能無法讀寫文件 + 長按文字在操作選單中顯示閱讀·搜尋 + 文字操作顯示搜尋 + 記錄日誌 + 中文簡繁體轉換 + 圖示為向量圖示,Android8.0以前不支援 + 朗讀設定 + 主介面 + 長按選擇文字 + 頁首 + 正文 + 頁尾 + 文字選擇結束位置 + 文字選擇開始位置 + 共用布局 + 瀏覽器 + 匯入預設規則 + 名稱 + 正則 + 更多選單 + + + 系統內建字體樣式 + 刪除來源文件 + 預設一 + 預設二 + 預設三 + 標題 + 靠左 + 居中 + 隱藏 + 加入分組 + 儲存圖片 + 沒有預設路徑 + 設定分組 + 查看目錄 + 導航欄陰影 + 目前陰影大小(elevation): %s + 預設 + 主選單 + 點擊授予權限 + 閱讀需要存取記憶卡權限,請點擊下方的"授予權限"按鈕,或前往“設定”—“應用權限”—打開所需權限。如果授予權限後仍然不正常,請點擊右上角的“選擇資料夾”,使用系統資料夾選擇器。 + 全文朗讀中不能朗讀選中文字 + 擴展到瀏海 + 更新目錄中 + 全程響應耳機按鍵 + 即使退出軟體也響應耳機按鍵 + 開發人員 + 聯繫我們 + 開源許可 + 其它 + 開源閱讀 + 關注公眾號 + 微信 + 您的支援是我更新的動力 + 公眾號[開源閱讀] + 正在自動換源 + 點擊加入 + + 訊息 + 隱藏頁首 + 隱藏頁尾 + 切換布局 + + + 主色調 + 強調色 + 背景色 + 底部操作欄顏色 + 白天 + 白天,主色調 + 白天,強調色 + 白天,背景色 + 白天,底欄色 + 夜間 + 夜間,主色調 + 夜間,強調色 + 夜間,背景色 + 夜間,底欄色 + 自動換源 + 文字兩端對齊 + 自動翻頁速度 + 地址排序 + + From 9e074a7990144ce6955759ebd62601cb41f77065 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 3 Jun 2020 08:55:35 +0800 Subject: [PATCH 156/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 51a0e2beb..b18fec509 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/06/03** +* zh-TW translation by david082321 + **2020/05/31** * 更新到android studio 4.0 * 书源排序添加按url From 1d292eb97adb11bbdff452fa40eaf5e8ab3226b5 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 3 Jun 2020 20:58:59 +0800 Subject: [PATCH 157/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + .../io/legado/app/service/AudioPlayService.kt | 24 +++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index b18fec509..12e2cee93 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -5,6 +5,7 @@ **2020/06/03** * zh-TW translation by david082321 +* 修复音频播放时播放速度调节会再下一章失效的bug **2020/05/31** * 更新到android studio 4.0 diff --git a/app/src/main/java/io/legado/app/service/AudioPlayService.kt b/app/src/main/java/io/legado/app/service/AudioPlayService.kt index 986e7c4ed..0efe85374 100644 --- a/app/src/main/java/io/legado/app/service/AudioPlayService.kt +++ b/app/src/main/java/io/legado/app/service/AudioPlayService.kt @@ -63,6 +63,7 @@ class AudioPlayService : BaseService(), private val dsRunnable: Runnable = Runnable { doDs() } private var mpRunnable: Runnable = Runnable { upPlayProgress() } private var bookChapter: BookChapter? = null + private var playSpeed: Float = 1f override fun onCreate() { super.onCreate() @@ -95,7 +96,12 @@ class AudioPlayService : BaseService(), IntentAction.adjustSpeed -> upSpeed(intent.getFloatExtra("adjust", 1f)) IntentAction.addTimer -> addTimer() IntentAction.setTimer -> setTimer(intent.getIntExtra("minute", 0)) - IntentAction.adjustProgress -> adjustProgress(intent.getIntExtra("position", position)) + IntentAction.adjustProgress -> adjustProgress( + intent.getIntExtra( + "position", + position + ) + ) else -> stopSelf() } } @@ -174,12 +180,12 @@ class AudioPlayService : BaseService(), private fun upSpeed(adjust: Float) { kotlin.runCatching { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - with(mediaPlayer) { - if (isPlaying) { - playbackParams = playbackParams.apply { speed += adjust } - } - postEvent(EventBus.AUDIO_SPEED, playbackParams.speed) + playSpeed += adjust + if (mediaPlayer.isPlaying) { + mediaPlayer.playbackParams = + mediaPlayer.playbackParams.apply { speed = playSpeed } } + postEvent(EventBus.AUDIO_SPEED, playSpeed) } } } @@ -189,7 +195,11 @@ class AudioPlayService : BaseService(), */ override fun onPrepared(mp: MediaPlayer?) { if (pause) return - mediaPlayer.start() + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + mediaPlayer.playbackParams = mediaPlayer.playbackParams.apply { speed = playSpeed } + } else { + mediaPlayer.start() + } mediaPlayer.seekTo(position) postEvent(EventBus.AUDIO_SIZE, mediaPlayer.duration) bookChapter?.let { From dc6efbb51414ab25ac7b50dc0d6baa85a0f148e6 Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 4 Jun 2020 21:32:08 +0800 Subject: [PATCH 158/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8D=E5=B4=A9?= =?UTF-8?q?=E6=BA=83bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/config/FileAssociationViewModel.kt | 105 ++++++++++-------- 1 file changed, 56 insertions(+), 49 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/config/FileAssociationViewModel.kt b/app/src/main/java/io/legado/app/ui/config/FileAssociationViewModel.kt index 02aab3668..4f897c791 100644 --- a/app/src/main/java/io/legado/app/ui/config/FileAssociationViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/config/FileAssociationViewModel.kt @@ -13,66 +13,73 @@ import io.legado.app.utils.readText import java.io.File class FileAssociationViewModel(application: Application) : BaseViewModel(application) { + fun dispatchIndent(uri: Uri): Intent? { - val url: String - //如果是普通的url,需要根据返回的内容判断是什么 - if (uri.scheme == "file" || uri.scheme == "content") { - val content = if (uri.scheme == "file") { - val file = File(uri.path.toString()) - if (file.exists()) { - file.readText() + try { + val url: String + //如果是普通的url,需要根据返回的内容判断是什么 + if (uri.scheme == "file" || uri.scheme == "content") { + val content = if (uri.scheme == "file") { + val file = File(uri.path.toString()) + if (file.exists()) { + file.readText() + } else { + null + } } else { - null + DocumentFile.fromSingleUri(context, uri)?.readText(context) } - } else { - DocumentFile.fromSingleUri(context, uri)?.readText(context) - } - var scheme = "" - if (content != null) { - if (content.isJsonObject() || content.isJsonArray()) { - //暂时根据文件内容判断属于什么 - when { - content.contains("bookSourceUrl") -> { - scheme = "booksource" - } - content.contains("sourceUrl") -> { - scheme = "rsssource" - } - content.contains("pattern") -> { - scheme = "replace" + var scheme = "" + if (content != null) { + if (content.isJsonObject() || content.isJsonArray()) { + //暂时根据文件内容判断属于什么 + when { + content.contains("bookSourceUrl") -> { + scheme = "booksource" + } + content.contains("sourceUrl") -> { + scheme = "rsssource" + } + content.contains("pattern") -> { + scheme = "replace" + } } } - } - if (TextUtils.isEmpty(scheme)) { - execute { - if (uri.scheme == "content"){ - LocalBook.importFile(uri.toString()) - }else{ - LocalBook.importFile(uri.path.toString()) + if (TextUtils.isEmpty(scheme)) { + execute { + if (uri.scheme == "content") { + LocalBook.importFile(uri.toString()) + } else { + LocalBook.importFile(uri.path.toString()) + } + toast("添加本地文件成功${uri.path}") } - toast("添加本地文件成功${uri.path}") + return null } + } else { + toast("文件不存在") return null } + // content模式下,需要传递完整的路径,方便后续解析 + url = if (uri.scheme == "content") { + "yuedu://${scheme}/importonline?src=$uri" + } else { + "yuedu://${scheme}/importonline?src=${uri.path}" + } + + } else if (uri.scheme == "yuedu") { + url = uri.toString() } else { - toast("文件不存在") - return null - } - // content模式下,需要传递完整的路径,方便后续解析 - url = if (uri.scheme == "content"){ - "yuedu://${scheme}/importonline?src=$uri" - }else{ - "yuedu://${scheme}/importonline?src=${uri.path}" + url = "yuedu://booksource/importonline?src=${uri.path}" } - - } else if (uri.scheme == "yuedu") { - url = uri.toString() - } else { - url = "yuedu://booksource/importonline?src=${uri.path}" + val data = Uri.parse(url) + val newIndent = Intent(Intent.ACTION_VIEW) + newIndent.data = data + return newIndent + } catch (e: Exception) { + e.printStackTrace() + toast(e.localizedMessage) + return null } - val data = Uri.parse(url) - val newIndent = Intent(Intent.ACTION_VIEW) - newIndent.data = data - return newIndent } } \ No newline at end of file From b02c81f89da9bab0822fc25398a3cb66cb22521f Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 4 Jun 2020 21:40:24 +0800 Subject: [PATCH 159/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8D=E5=B4=A9?= =?UTF-8?q?=E6=BA=83bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/data/entities/BookSource.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 1cb9a0269..9be459696 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 @@ -179,7 +179,7 @@ data class BookSource( class Converters { @TypeConverter - fun exploreRuleToString(exploreRule: ExploreRule?): String { + fun exploreRuleToString(exploreRule: ExploreRule?): String? { return GSON.toJson(exploreRule) } @@ -189,7 +189,7 @@ data class BookSource( } @TypeConverter - fun searchRuleToString(searchRule: SearchRule): String { + fun searchRuleToString(searchRule: SearchRule?): String? { return GSON.toJson(searchRule) } @@ -199,7 +199,7 @@ data class BookSource( } @TypeConverter - fun bookInfoRuleToString(bookInfoRule: BookInfoRule): String { + fun bookInfoRuleToString(bookInfoRule: BookInfoRule?): String? { return GSON.toJson(bookInfoRule) } @@ -209,7 +209,7 @@ data class BookSource( } @TypeConverter - fun tocRuleToString(tocRule: TocRule): String { + fun tocRuleToString(tocRule: TocRule?): String? { return GSON.toJson(tocRule) } @@ -219,7 +219,7 @@ data class BookSource( } @TypeConverter - fun contentRuleToString(contentRule: ContentRule): String { + fun contentRuleToString(contentRule: ContentRule?): String? { return GSON.toJson(contentRule) } From 2a3d8f3402ce21aa00ccaf892d8d527517e6911b Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 4 Jun 2020 21:44:34 +0800 Subject: [PATCH 160/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8D=E5=B4=A9?= =?UTF-8?q?=E6=BA=83bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/service/AudioPlayService.kt | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/AudioPlayService.kt b/app/src/main/java/io/legado/app/service/AudioPlayService.kt index 0efe85374..d28ca568c 100644 --- a/app/src/main/java/io/legado/app/service/AudioPlayService.kt +++ b/app/src/main/java/io/legado/app/service/AudioPlayService.kt @@ -146,14 +146,18 @@ class AudioPlayService : BaseService(), if (url.contains(".m3u8", false)) { stopSelf() } else { - AudioPlayService.pause = pause - handler.removeCallbacks(mpRunnable) - position = mediaPlayer.currentPosition - mediaPlayer.pause() - upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PAUSED) - AudioPlay.status = Status.PAUSE - postEvent(EventBus.AUDIO_STATE, Status.PAUSE) - upNotification() + try { + AudioPlayService.pause = pause + handler.removeCallbacks(mpRunnable) + position = mediaPlayer.currentPosition + mediaPlayer.pause() + upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PAUSED) + AudioPlay.status = Status.PAUSE + postEvent(EventBus.AUDIO_STATE, Status.PAUSE) + upNotification() + } catch (e: Exception) { + e.printStackTrace() + } } } From f26546be22a79f9c9b502edb420af4765e153339 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 6 Jun 2020 16:43:06 +0800 Subject: [PATCH 161/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/ReadBookViewModel.kt | 3 + .../main/bookshelf/books/BooksDiffCallBack.kt | 57 ++++++++----------- 2 files changed, 27 insertions(+), 33 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt index a4755213d..93322a998 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt @@ -82,6 +82,9 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { ReadBook.callBack?.upContent(resetPageOffset = false) } } + if (ReadBook.inBookshelf) { + ReadBook.saveRead() + } } } diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksDiffCallBack.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksDiffCallBack.kt index 27954c634..130847312 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksDiffCallBack.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksDiffCallBack.kt @@ -16,54 +16,45 @@ class BooksDiffCallBack(private val oldItems: List, private val newItems: } override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { - return oldItems[oldItemPosition].bookUrl == newItems[newItemPosition].bookUrl + val oldItem = oldItems[oldItemPosition] + val newItem = newItems[newItemPosition] + return oldItem.name == newItem.name + && oldItem.author == newItem.author } override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { val oldItem = oldItems[oldItemPosition] val newItem = newItems[newItemPosition] - if (oldItem.name != newItem.name) - return false - if (oldItem.author != newItem.author) - return false - if (oldItem.durChapterTitle != newItem.durChapterTitle) - return false - if (oldItem.latestChapterTitle != newItem.latestChapterTitle) - return false - if (oldItem.lastCheckCount != newItem.lastCheckCount) - return false - if (oldItem.getDisplayCover() != newItem.getDisplayCover()) - return false - if (oldItem.getUnreadChapterNum() != newItem.getUnreadChapterNum()) - return false - return true + return when { + oldItem.durChapterTime != newItem.durChapterTime -> false + oldItem.name != newItem.name -> false + oldItem.author != newItem.author -> false + oldItem.durChapterTitle != newItem.durChapterTitle -> false + oldItem.latestChapterTitle != newItem.latestChapterTitle -> false + oldItem.lastCheckCount != newItem.lastCheckCount -> false + oldItem.getDisplayCover() != newItem.getDisplayCover() -> false + oldItem.getUnreadChapterNum() != newItem.getUnreadChapterNum() -> false + else -> true + } } override fun getChangePayload(oldItemPosition: Int, newItemPosition: Int): Any? { val oldItem = oldItems[oldItemPosition] val newItem = newItems[newItemPosition] val bundle = bundleOf() - if (oldItem.name != newItem.name) - bundle.putString("name", null) - if (oldItem.author != newItem.author) - bundle.putString("author", null) - if (oldItem.durChapterTitle != newItem.durChapterTitle) - bundle.putString("dur", null) - if (oldItem.latestChapterTitle != newItem.latestChapterTitle) - bundle.putString("last", null) - if (oldItem.getDisplayCover() != newItem.getDisplayCover()) - bundle.putString("cover", null) - if (oldItem.lastCheckCount != newItem.lastCheckCount) - bundle.putString("refresh", null) - if (oldItem.getUnreadChapterNum() != newItem.getUnreadChapterNum() + if (oldItem.name != newItem.name) bundle.putString("name", null) + if (oldItem.author != newItem.author) bundle.putString("author", null) + if (oldItem.durChapterTitle != newItem.durChapterTitle) bundle.putString("dur", null) + if (oldItem.latestChapterTitle != newItem.latestChapterTitle) bundle.putString("last", null) + if (oldItem.getDisplayCover() != newItem.getDisplayCover()) bundle.putString("cover", null) + if (oldItem.lastCheckCount != newItem.lastCheckCount) bundle.putString("refresh", null) + if (oldItem.durChapterTime != newItem.durChapterTime + || oldItem.getUnreadChapterNum() != newItem.getUnreadChapterNum() || oldItem.lastCheckCount != newItem.lastCheckCount ) { bundle.putString("refresh", null) } - - if (bundle.isEmpty) { - return null - } + if (bundle.isEmpty) return null return bundle } From ef2d49eb5826180c7fb3fc999c07792733f05f8f Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 6 Jun 2020 16:54:33 +0800 Subject: [PATCH 162/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/service/help/ReadBook.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/io/legado/app/service/help/ReadBook.kt b/app/src/main/java/io/legado/app/service/help/ReadBook.kt index 4b196ec48..54e128199 100644 --- a/app/src/main/java/io/legado/app/service/help/ReadBook.kt +++ b/app/src/main/java/io/legado/app/service/help/ReadBook.kt @@ -333,6 +333,7 @@ object ReadBook { book.durChapterTime = System.currentTimeMillis() book.durChapterIndex = durChapterIndex book.durChapterPos = durPageIndex + book.lastCheckCount = 0 App.db.bookChapterDao().getChapter(book.bookUrl, durChapterIndex)?.let { book.durChapterTitle = it.title } From fcf8028a597ed23a9c27df4cfb86bce8bca47303 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 6 Jun 2020 17:07:57 +0800 Subject: [PATCH 163/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/main/bookshelf/books/BooksDiffCallBack.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksDiffCallBack.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksDiffCallBack.kt index 130847312..0756daca5 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksDiffCallBack.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksDiffCallBack.kt @@ -47,8 +47,8 @@ class BooksDiffCallBack(private val oldItems: List, private val newItems: if (oldItem.durChapterTitle != newItem.durChapterTitle) bundle.putString("dur", null) if (oldItem.latestChapterTitle != newItem.latestChapterTitle) bundle.putString("last", null) if (oldItem.getDisplayCover() != newItem.getDisplayCover()) bundle.putString("cover", null) - if (oldItem.lastCheckCount != newItem.lastCheckCount) bundle.putString("refresh", null) - if (oldItem.durChapterTime != newItem.durChapterTime + if (oldItem.lastCheckCount != newItem.lastCheckCount + || oldItem.durChapterTime != newItem.durChapterTime || oldItem.getUnreadChapterNum() != newItem.getUnreadChapterNum() || oldItem.lastCheckCount != newItem.lastCheckCount ) { From 68aa9ab82cbeef0ed81587878cfe564d69910711 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 6 Jun 2020 17:35:30 +0800 Subject: [PATCH 164/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/bookshelf/books/BooksAdapterList.kt | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt index 755f55f20..783a1f14d 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt @@ -2,6 +2,7 @@ package io.legado.app.ui.main.bookshelf.books import android.content.Context import android.os.Bundle +import android.view.View import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.constant.BookType @@ -25,14 +26,7 @@ class BooksAdapterList(context: Context, private val callBack: CallBack) : tv_read.text = item.durChapterTitle tv_last.text = item.latestChapterTitle iv_cover.load(item.getDisplayCover(), item.name, item.author) - if (item.origin != BookType.local && callBack.isUpdate(item.bookUrl)) { - bv_unread.invisible() - rl_loading.show() - } else { - rl_loading.hide() - bv_unread.setBadgeCount(item.getUnreadChapterNum()) - bv_unread.setHighlight(item.lastCheckCount > 0) - } + upRefresh(this, item) } else { bundle.keySet().map { when (it) { @@ -41,20 +35,24 @@ class BooksAdapterList(context: Context, private val callBack: CallBack) : "dur" -> tv_read.text = item.durChapterTitle "last" -> tv_last.text = item.latestChapterTitle "cover" -> iv_cover.load(item.getDisplayCover(), item.name, item.author) - "refresh" -> if (item.origin != BookType.local && callBack.isUpdate(item.bookUrl)) { - bv_unread.invisible() - rl_loading.show() - } else { - rl_loading.hide() - bv_unread.setBadgeCount(item.getUnreadChapterNum()) - bv_unread.setHighlight(item.lastCheckCount > 0) - } + "refresh" -> upRefresh(this, item) } } } } } + private fun upRefresh(itemView: View, item: Book) = with(itemView) { + if (item.origin != BookType.local && callBack.isUpdate(item.bookUrl)) { + bv_unread.invisible() + rl_loading.show() + } else { + rl_loading.hide() + bv_unread.setBadgeCount(item.getUnreadChapterNum()) + bv_unread.setHighlight(item.lastCheckCount > 0) + } + } + override fun registerListener(holder: ItemViewHolder) { holder.itemView.apply { onClick { From 2845e799cc5a975d124a5b25b43bb99b3425a1aa Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 6 Jun 2020 18:49:22 +0800 Subject: [PATCH 165/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/service/AudioPlayService.kt | 1 - .../legado/app/service/TTSReadAloudService.kt | 27 ++++++++++--------- .../main/bookshelf/books/BooksAdapterList.kt | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/AudioPlayService.kt b/app/src/main/java/io/legado/app/service/AudioPlayService.kt index d28ca568c..fa56e85d0 100644 --- a/app/src/main/java/io/legado/app/service/AudioPlayService.kt +++ b/app/src/main/java/io/legado/app/service/AudioPlayService.kt @@ -520,7 +520,6 @@ class AudioPlayService : BaseService(), ) builder.setStyle( androidx.media.app.NotificationCompat.MediaStyle() - .setMediaSession(mediaSessionCompat?.sessionToken) .setShowActionsInCompactView(0, 1, 2) ) builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC) diff --git a/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt b/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt index 0517ca2fc..1e6fcc2dd 100644 --- a/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt @@ -42,9 +42,7 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener private fun initTts() { ttsInitFinish = false - textToSpeech = TextToSpeech(this, this).apply { - setOnUtteranceProgressListener(ttsUtteranceListener) - } + textToSpeech = TextToSpeech(this, this) } override fun onDestroy() { @@ -55,6 +53,7 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener override fun onInit(status: Int) { if (status == TextToSpeech.SUCCESS) { textToSpeech?.let { + it.setOnUtteranceProgressListener(ttsUtteranceListener) it.language = Locale.CHINA ttsInitFinish = true play() @@ -69,16 +68,20 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener @Synchronized override fun play() { if (contentList.isNotEmpty() && ttsInitFinish && requestFocus()) { - MediaHelp.playSilentSound(this) super.play() - textToSpeech?.stop() - for (i in nowSpeak until contentList.size) { - textToSpeech?.speak( - contentList[i], - TextToSpeech.QUEUE_ADD, - null, - AppConst.APP_TAG + i - ) + execute { + MediaHelp.playSilentSound(this@TTSReadAloudService) + textToSpeech?.let { + it.stop() + for (i in nowSpeak until contentList.size) { + it.speak( + contentList[i], + TextToSpeech.QUEUE_ADD, + null, + AppConst.APP_TAG + i + ) + } + } } } } diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt index 783a1f14d..7ed9a7d99 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt @@ -48,8 +48,8 @@ class BooksAdapterList(context: Context, private val callBack: CallBack) : rl_loading.show() } else { rl_loading.hide() - bv_unread.setBadgeCount(item.getUnreadChapterNum()) bv_unread.setHighlight(item.lastCheckCount > 0) + bv_unread.setBadgeCount(item.getUnreadChapterNum()) } } From d28d87bfaafa35754b8adcac323038edb2ce82f0 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 6 Jun 2020 20:35:11 +0800 Subject: [PATCH 166/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 +- .../java/io/legado/app/ui/book/read/ReadBookViewModel.kt | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index a5068f755..3d910061e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -116,7 +116,7 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" //fireBase - implementation 'com.google.firebase:firebase-core:17.4.2' + implementation 'com.google.firebase:firebase-core:17.4.3' implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1' //androidX diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt index 93322a998..b9b27b507 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt @@ -59,9 +59,6 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { } ReadBook.loadContent(resetPageOffset = true) } - if (ReadBook.inBookshelf) { - ReadBook.saveRead() - } } else { isInitFinish = true ReadBook.titleDate.postValue(book.name) @@ -82,9 +79,9 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { ReadBook.callBack?.upContent(resetPageOffset = false) } } - if (ReadBook.inBookshelf) { - ReadBook.saveRead() - } + } + if (ReadBook.inBookshelf) { + ReadBook.saveRead() } } From fccdf41ea8802ffc54668e6afa5db791db04b3b2 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 6 Jun 2020 20:36:22 +0800 Subject: [PATCH 167/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/read/ReadBookViewModel.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt index b9b27b507..0c9cc80d0 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt @@ -35,6 +35,10 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { } ?: App.db.bookDao().lastReadBook?.let { initBook(it) } + }.onFinally { + if (ReadBook.inBookshelf) { + ReadBook.saveRead() + } } } @@ -80,9 +84,6 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { } } } - if (ReadBook.inBookshelf) { - ReadBook.saveRead() - } } private fun loadBookInfo( From 3075b4b3e64b768d6b33b479c231da56c259131e Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 6 Jun 2020 20:48:03 +0800 Subject: [PATCH 168/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/book/search/DiffCallBack.kt | 62 ++++++------------- 1 file changed, 19 insertions(+), 43 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt b/app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt index b03e54fb7..4125489b8 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt @@ -18,64 +18,40 @@ class DiffCallBack(private val oldItems: List, private val newItems: override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { val oldItem = oldItems[oldItemPosition] val newItem = newItems[newItemPosition] - if (oldItem.name != newItem.name) { - return false + return when { + oldItem.name != newItem.name -> false + oldItem.author != newItem.author -> false + else -> true } - if (oldItem.author != newItem.author) { - return false - } - return true } override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { val oldItem = oldItems[oldItemPosition] val newItem = newItems[newItemPosition] - if (oldItem.origins.size != newItem.origins.size) { - return false - } - if (oldItem.coverUrl != newItem.coverUrl) { - return false - } - if (oldItem.kind != newItem.kind) { - return false - } - if (oldItem.latestChapterTitle != newItem.latestChapterTitle) { - return false + return when { + oldItem.origins.size != newItem.origins.size -> false + oldItem.coverUrl != newItem.coverUrl -> false + oldItem.kind != newItem.kind -> false + oldItem.latestChapterTitle != newItem.latestChapterTitle -> false + oldItem.intro != newItem.intro -> false + else -> true } - if (oldItem.intro != newItem.intro) { - return false - } - return true } override fun getChangePayload(oldItemPosition: Int, newItemPosition: Int): Any? { val payload = Bundle() val newItem = newItems[newItemPosition] val oldItem = oldItems[oldItemPosition] - if (oldItem.name != newItem.name) { - payload.putString("name", newItem.name) - } - if (oldItem.author != newItem.author) { - payload.putString("author", newItem.author) - } - if (oldItem.origins.size != newItem.origins.size) { + if (oldItem.name != newItem.name) payload.putString("name", newItem.name) + if (oldItem.author != newItem.author) payload.putString("author", newItem.author) + if (oldItem.origins.size != newItem.origins.size) payload.putInt("origins", newItem.origins.size) - } - if (oldItem.coverUrl != newItem.coverUrl) { - payload.putString("cover", newItem.coverUrl) - } - if (oldItem.kind != newItem.kind) { - payload.putString("kind", newItem.kind) - } - if (oldItem.latestChapterTitle != newItem.latestChapterTitle) { + if (oldItem.coverUrl != newItem.coverUrl) payload.putString("cover", newItem.coverUrl) + if (oldItem.kind != newItem.kind) payload.putString("kind", newItem.kind) + if (oldItem.latestChapterTitle != newItem.latestChapterTitle) payload.putString("last", newItem.latestChapterTitle) - } - if (oldItem.intro != newItem.intro) { - payload.putString("intro", newItem.intro) - } - if (payload.isEmpty) { - return null - } + if (oldItem.intro != newItem.intro) payload.putString("intro", newItem.intro) + if (payload.isEmpty) return null return payload } } \ No newline at end of file From ebb1e2dd339b65ff2d2785cdf481b733948841da Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 6 Jun 2020 20:49:16 +0800 Subject: [PATCH 169/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/book/changesource/DiffCallBack.kt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/DiffCallBack.kt b/app/src/main/java/io/legado/app/ui/book/changesource/DiffCallBack.kt index b0a8f19ef..142ab24c2 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/DiffCallBack.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/DiffCallBack.kt @@ -24,13 +24,11 @@ class DiffCallBack(private val oldItems: List, private val newItems: override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { val oldItem = oldItems[oldItemPosition] val newItem = newItems[newItemPosition] - if (oldItem.originName != newItem.originName) { - return false - } - if (oldItem.latestChapterTitle != newItem.latestChapterTitle) { - return false + return when { + oldItem.originName != newItem.originName -> false + oldItem.latestChapterTitle != newItem.latestChapterTitle -> false + else -> true } - return true } override fun getChangePayload(oldItemPosition: Int, newItemPosition: Int): Any? { From 57e3595601eaed86d8da8cb59fd636c4c7ac6eef Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 6 Jun 2020 20:55:51 +0800 Subject: [PATCH 170/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/main/bookshelf/books/BooksFragment.kt | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt index ab8984752..137aaf184 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt @@ -7,7 +7,6 @@ import androidx.lifecycle.Observer import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.LinearLayoutManager -import androidx.recyclerview.widget.RecyclerView import io.legado.app.App import io.legado.app.R import io.legado.app.base.BaseFragment @@ -28,7 +27,6 @@ import io.legado.app.utils.getViewModelOfActivity import io.legado.app.utils.observeEvent import kotlinx.android.synthetic.main.fragment_books.* import org.jetbrains.anko.startActivity -import kotlin.math.max class BooksFragment : BaseFragment(R.layout.fragment_books), @@ -77,23 +75,6 @@ class BooksFragment : BaseFragment(R.layout.fragment_books), booksAdapter = BooksAdapterGrid(requireContext(), this) } rv_bookshelf.adapter = booksAdapter - booksAdapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() { - override fun onItemRangeInserted(positionStart: Int, itemCount: Int) { - val layoutManager = rv_bookshelf.layoutManager - if (positionStart == 0 && layoutManager is LinearLayoutManager) { - val scrollTo = layoutManager.findFirstVisibleItemPosition() - itemCount - rv_bookshelf.scrollToPosition(max(0, scrollTo)) - } - } - - override fun onItemRangeMoved(fromPosition: Int, toPosition: Int, itemCount: Int) { - val layoutManager = rv_bookshelf.layoutManager - if (toPosition == 0 && layoutManager is LinearLayoutManager) { - val scrollTo = layoutManager.findFirstVisibleItemPosition() - itemCount - rv_bookshelf.scrollToPosition(max(0, scrollTo)) - } - } - }) } private fun upRecyclerData() { From 73a087522f250a7fb527e94cab8c482305857890 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 6 Jun 2020 20:57:53 +0800 Subject: [PATCH 171/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 12e2cee93..225b7ecda 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/06/06** +* 修复一些bug,包括从阅读界面退出后还是显示红色更新的bug + **2020/06/03** * zh-TW translation by david082321 * 修复音频播放时播放速度调节会再下一章失效的bug From 3a5cc4b44f0071b5c68850c7aa67352df1d65da6 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 6 Jun 2020 21:07:16 +0800 Subject: [PATCH 172/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 3d910061e..f23046bbb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -196,8 +196,8 @@ dependencies { apply plugin: 'com.google.gms.google-services' -afterEvaluate { - for (Task task : project.tasks.matching { it.name.startsWith('crashlyticsUploadDeobs') }) { - task.enabled = false - } -} \ No newline at end of file +//afterEvaluate { +// for (Task task : project.tasks.matching { it.name.startsWith('crashlyticsUploadDeobs') }) { +// task.enabled = false +// } +//} \ No newline at end of file From 7ee7dd08c5d581392958033bd17cef7be8553140 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 7 Jun 2020 11:30:35 +0800 Subject: [PATCH 173/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=B9=A6?= =?UTF-8?q?=E6=BA=90=E6=A0=A1=E9=AA=8C,=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=85=B3=E9=94=AE=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/service/CheckSourceService.kt | 19 ++---- .../io/legado/app/service/help/CheckSource.kt | 61 +++++++++++++------ .../book/source/manage/BookSourceActivity.kt | 24 +++++++- 3 files changed, 70 insertions(+), 34 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/CheckSourceService.kt b/app/src/main/java/io/legado/app/service/CheckSourceService.kt index 896e7bb75..e6cbb5966 100644 --- a/app/src/main/java/io/legado/app/service/CheckSourceService.kt +++ b/app/src/main/java/io/legado/app/service/CheckSourceService.kt @@ -7,13 +7,11 @@ import io.legado.app.R import io.legado.app.base.BaseService import io.legado.app.constant.AppConst import io.legado.app.constant.IntentAction -import io.legado.app.data.entities.BookSource import io.legado.app.help.AppConfig import io.legado.app.help.IntentHelp import io.legado.app.help.coroutine.CompositeCoroutine -import io.legado.app.model.WebBook +import io.legado.app.service.help.CheckSource import io.legado.app.ui.book.source.manage.BookSourceActivity -import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.asCoroutineDispatcher import org.jetbrains.anko.toast import java.util.concurrent.Executors @@ -80,24 +78,15 @@ class CheckSourceService : BaseService() { if (source.searchUrl.isNullOrEmpty()) { onNext(sourceUrl) } else { - check(source) + CheckSource(source).check(this, searchPool) { + onNext(it) + } } } ?: onNext(sourceUrl) } } } - private fun check(source: BookSource) { - val webBook = WebBook(source) - tasks.add(webBook.searchBook("我的", scope = this, context = searchPool) - .onError(IO) { - source.addGroup("失效") - App.db.bookSourceDao().update(source) - }.onFinally(IO) { - onNext(source.bookSourceUrl) - }) - } - private fun onNext(sourceUrl: String) { synchronized(this) { check() diff --git a/app/src/main/java/io/legado/app/service/help/CheckSource.kt b/app/src/main/java/io/legado/app/service/help/CheckSource.kt index b0a33953b..45ad0329a 100644 --- a/app/src/main/java/io/legado/app/service/help/CheckSource.kt +++ b/app/src/main/java/io/legado/app/service/help/CheckSource.kt @@ -2,34 +2,59 @@ package io.legado.app.service.help import android.content.Context import android.content.Intent +import io.legado.app.App import io.legado.app.R import io.legado.app.constant.IntentAction import io.legado.app.data.entities.BookSource +import io.legado.app.help.coroutine.Coroutine +import io.legado.app.model.WebBook import io.legado.app.service.CheckSourceService +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers import org.jetbrains.anko.toast +import kotlin.coroutines.CoroutineContext -object CheckSource { +class CheckSource(val source: BookSource) { - fun start(context: Context, sources: List) { - if (sources.isEmpty()) { - context.toast(R.string.non_select) - return - } - val selectedIds: ArrayList = arrayListOf() - sources.map { - selectedIds.add(it.bookSourceUrl) + companion object { + var keyword = "我的" + + fun start(context: Context, sources: List) { + if (sources.isEmpty()) { + context.toast(R.string.non_select) + return + } + val selectedIds: ArrayList = arrayListOf() + sources.map { + selectedIds.add(it.bookSourceUrl) + } + Intent(context, CheckSourceService::class.java).let { + it.action = IntentAction.start + it.putExtra("selectIds", selectedIds) + context.startService(it) + } } - Intent(context, CheckSourceService::class.java).let { - it.action = IntentAction.start - it.putExtra("selectIds", selectedIds) - context.startService(it) + + fun stop(context: Context) { + Intent(context, CheckSourceService::class.java).let { + it.action = IntentAction.stop + context.startService(it) + } } } - fun stop(context: Context) { - Intent(context, CheckSourceService::class.java).let { - it.action = IntentAction.stop - context.startService(it) - } + fun check( + scope: CoroutineScope, + context: CoroutineContext, + onNext: (sourceUrl: String) -> Unit + ): Coroutine<*> { + val webBook = WebBook(source) + return webBook.searchBook(keyword, scope = scope, context = context) + .onError(Dispatchers.IO) { + source.addGroup("失效") + App.db.bookSourceDao().update(source) + }.onFinally(Dispatchers.IO) { + onNext(source.bookSourceUrl) + } } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt index f73477916..c10140de6 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt @@ -231,13 +231,35 @@ class BookSourceActivity : VMBaseActivity(R.layout.activity R.id.menu_enable_explore -> viewModel.enableSelectExplore(adapter.getSelection()) R.id.menu_disable_explore -> viewModel.disableSelectExplore(adapter.getSelection()) R.id.menu_export_selection -> FilePicker.selectFolder(this, exportRequestCode) - R.id.menu_check_source -> CheckSource.start(this, adapter.getSelection()) + R.id.menu_check_source -> checkSource() R.id.menu_top_sel -> viewModel.topSource(*adapter.getSelection().toTypedArray()) R.id.menu_bottom_sel -> viewModel.bottomSource(*adapter.getSelection().toTypedArray()) } return true } + @SuppressLint("InflateParams") + private fun checkSource() { + alert(titleResource = R.string.search_book_key) { + var editText: AutoCompleteTextView? = null + customView { + layoutInflater.inflate(R.layout.dialog_edit_text, null).apply { + editText = edit_view + edit_view.setText(CheckSource.keyword) + } + } + okButton { + editText?.text?.toString()?.let { + if (it.isNotEmpty()) { + CheckSource.keyword = it + } + } + CheckSource.start(this@BookSourceActivity, adapter.getSelection()) + } + noButton { } + }.show().applyTint() + } + private fun upGroupMenu() { groupMenu?.removeGroup(R.id.source_group) groups.sortedWith(Collator.getInstance(java.util.Locale.CHINESE)) From b9f87c3887de67092786f58cd9f92cfed953ede4 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 7 Jun 2020 17:07:57 +0800 Subject: [PATCH 174/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/bookshelf/books/BooksAdapterGrid.kt | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterGrid.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterGrid.kt index 1438c4507..be725abe9 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterGrid.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterGrid.kt @@ -2,6 +2,7 @@ package io.legado.app.ui.main.bookshelf.books import android.content.Context import android.os.Bundle +import android.view.View import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.constant.BookType @@ -22,33 +23,30 @@ class BooksAdapterGrid(context: Context, private val callBack: CallBack) : ATH.applyBackgroundTint(this) tv_name.text = item.name iv_cover.load(item.getDisplayCover(), item.name, item.author) - if (item.origin != BookType.local && callBack.isUpdate(item.bookUrl)) { - bv_unread.invisible() - rl_loading.show() - } else { - rl_loading.hide() - bv_unread.setBadgeCount(item.getUnreadChapterNum()) - bv_unread.setHighlight(item.lastCheckCount > 0) - } + upRefresh(this, item) } else { bundle.keySet().map { when (it) { "name" -> tv_name.text = item.name "cover" -> iv_cover.load(item.getDisplayCover(), item.name, item.author) - "refresh" -> if (item.origin != BookType.local && callBack.isUpdate(item.bookUrl)) { - bv_unread.invisible() - rl_loading.show() - } else { - rl_loading.hide() - bv_unread.setBadgeCount(item.getUnreadChapterNum()) - bv_unread.setHighlight(item.lastCheckCount > 0) - } + "refresh" -> upRefresh(this, item) } } } } } + private fun upRefresh(itemView: View, item: Book) = with(itemView) { + if (item.origin != BookType.local && callBack.isUpdate(item.bookUrl)) { + bv_unread.invisible() + rl_loading.show() + } else { + rl_loading.hide() + bv_unread.setBadgeCount(item.getUnreadChapterNum()) + bv_unread.setHighlight(item.lastCheckCount > 0) + } + } + override fun registerListener(holder: ItemViewHolder) { holder.itemView.apply { onClick { From 027e74ddea49374ca07a38e13e6d827a044d3c29 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 7 Jun 2020 17:13:31 +0800 Subject: [PATCH 175/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/service/HttpReadAloudService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt b/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt index 7796ffce0..de9807e84 100644 --- a/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt @@ -204,7 +204,7 @@ class HttpReadAloudService : BaseReadAloudService(), } else { nextChapter() } - }, 1000) + }, 100) return true } From ae5011de7b3dd2e6bd05ea6b13b3ef9bdd37f71c Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 7 Jun 2020 17:32:22 +0800 Subject: [PATCH 176/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/service/HttpReadAloudService.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt b/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt index de9807e84..4c29f84ae 100644 --- a/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt @@ -76,7 +76,9 @@ class HttpReadAloudService : BaseReadAloudService(), val file = getSpeakFile(index) file.writeBytes(bytes) if (index == nowSpeak) { - playAudio(FileInputStream(file).fd) + @Suppress("BlockingMethodInNonBlockingContext") + val fis = FileInputStream(file) + playAudio(fis.fd) } } } else { From 15462dd8da5f8ec09145d88a945d16bac32f7c1b Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 7 Jun 2020 17:34:23 +0800 Subject: [PATCH 177/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 225b7ecda..ad20e9284 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/06/07** +* 优化书源检测,自定义搜索关键词 + **2020/06/06** * 修复一些bug,包括从阅读界面退出后还是显示红色更新的bug From bac6d7d808967c44e240f4f7ef9f99eff05a6cc4 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 7 Jun 2020 18:04:27 +0800 Subject: [PATCH 178/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/service/help/ReadBook.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/service/help/ReadBook.kt b/app/src/main/java/io/legado/app/service/help/ReadBook.kt index 54e128199..4b196ec48 100644 --- a/app/src/main/java/io/legado/app/service/help/ReadBook.kt +++ b/app/src/main/java/io/legado/app/service/help/ReadBook.kt @@ -333,7 +333,6 @@ object ReadBook { book.durChapterTime = System.currentTimeMillis() book.durChapterIndex = durChapterIndex book.durChapterPos = durPageIndex - book.lastCheckCount = 0 App.db.bookChapterDao().getChapter(book.bookUrl, durChapterIndex)?.let { book.durChapterTitle = it.title } From 95f8b577169938ca5141042a1a1835c47a33d06a Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 7 Jun 2020 18:22:35 +0800 Subject: [PATCH 179/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt | 1 + 1 file changed, 1 insertion(+) 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 51917239f..a88af1b3b 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 @@ -132,6 +132,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo override fun onPause() { super.onPause() + ReadBook.saveRead() timeBatteryReceiver?.let { unregisterReceiver(it) timeBatteryReceiver = null From ae75aff5af2737a23f32d6b7b9d01d6f751b34ab Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 7 Jun 2020 21:37:26 +0800 Subject: [PATCH 180/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/data/entities/BookSource.kt | 13 +++++++++---- .../java/io/legado/app/service/help/CheckSource.kt | 3 +++ .../ui/book/source/manage/BookSourceViewModel.kt | 5 +---- 3 files changed, 13 insertions(+), 8 deletions(-) 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 9be459696..62026ef7b 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,6 +1,7 @@ package io.legado.app.data.entities import android.os.Parcelable +import android.text.TextUtils import androidx.room.* import io.legado.app.App import io.legado.app.constant.AppConst @@ -8,10 +9,7 @@ import io.legado.app.constant.AppConst.userAgent import io.legado.app.constant.BookType import io.legado.app.data.entities.rule.* import io.legado.app.help.JsExtensions -import io.legado.app.utils.ACache -import io.legado.app.utils.GSON -import io.legado.app.utils.fromJsonObject -import io.legado.app.utils.getPrefString +import io.legado.app.utils.* import kotlinx.android.parcel.Parcelize import java.util.* import javax.script.SimpleBindings @@ -105,6 +103,13 @@ data class BookSource( } } + fun removeGroup(group: String) { + bookSourceGroup?.splitNotBlank(",")?.toHashSet()?.let { + it.remove(group) + bookSourceGroup = TextUtils.join(",", it) + } + } + fun getExploreKinds(): ArrayList? { val exploreKinds = arrayListOf() exploreUrl?.let { diff --git a/app/src/main/java/io/legado/app/service/help/CheckSource.kt b/app/src/main/java/io/legado/app/service/help/CheckSource.kt index 45ad0329a..5d8c6876b 100644 --- a/app/src/main/java/io/legado/app/service/help/CheckSource.kt +++ b/app/src/main/java/io/legado/app/service/help/CheckSource.kt @@ -53,6 +53,9 @@ class CheckSource(val source: BookSource) { .onError(Dispatchers.IO) { source.addGroup("失效") App.db.bookSourceDao().update(source) + }.onSuccess(Dispatchers.IO) { + source.removeGroup("失效") + App.db.bookSourceDao().update(source) }.onFinally(Dispatchers.IO) { onNext(source.bookSourceUrl) } diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt index c6dc63c8e..c0e255783 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt @@ -158,10 +158,7 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) execute { val sources = App.db.bookSourceDao().getByGroup(group) sources.map { source -> - source.bookSourceGroup?.splitNotBlank(",")?.toHashSet()?.let { - it.remove(group) - source.bookSourceGroup = TextUtils.join(",", it) - } + source.removeGroup(group) } App.db.bookSourceDao().update(*sources.toTypedArray()) } From e61c1742f0a0aa24ec86d12aeb2f93e58e7a251d Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 7 Jun 2020 21:39:44 +0800 Subject: [PATCH 181/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index ad20e9284..8de8fa6bf 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -5,6 +5,7 @@ **2020/06/07** * 优化书源检测,自定义搜索关键词 +* 失效书源如果校验为有效会去掉失效标志 **2020/06/06** * 修复一些bug,包括从阅读界面退出后还是显示红色更新的bug From a1d6179ee9c2c0382491a69b20448aa551f996a5 Mon Sep 17 00:00:00 2001 From: gedoor Date: Mon, 8 Jun 2020 22:33:17 +0800 Subject: [PATCH 182/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/proguard-rules.pro | 63 +++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 29f32c555..4dd43b6b5 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -68,10 +68,10 @@ # 保留androidx下的所有类及其内部类 --keep class androidx** {*;} +-keep class androidx.** {*;} # 保留继承的 --keep public class * extends androidx** +-keep public class * extends androidx.** # 保留R下面的资源 -keep class **.R$* {*;} @@ -104,7 +104,6 @@ # 保留Parcelable序列化类不被混淆 -keep class * implements android.os.Parcelable { - #noinspection ShrinkerUnresolvedReference public static final android.os.Parcelable$Creator *; } @@ -146,11 +145,11 @@ } # 保持js引擎调用的java类 --keep class **.analyzeRule**{*;} +-keep class **.analyzeRule.**{*;} # 保持web类 --keep class **.web**{*;} +-keep class **.web.**{*;} #数据类 --keep class **.data**{*;} +-keep class **.data.**{*;} -dontwarn rx.** @@ -165,49 +164,49 @@ -dontwarn org.conscrypt.** -dontwarn com.jeremyliao.liveeventbus.** --keep class com.jeremyliao.liveeventbus** { *; } --keep class okhttp3**{*;} --keep class okio**{*;} --keep class com.hwangjr.rxbus**{*;} --keep class org.conscrypt**{*;} --keep class android.support**{*;} --keep class me.grantland.widget**{*;} --keep class de.hdodenhof.circleimageview**{*;} --keep class tyrant.explosionfield**{*;} --keep class tyrantgit.explosionfield**{*;} --keep class freemarker**{*;} --keep class com.gyf.barlibrary.* {*;} +-keep class com.jeremyliao.liveeventbus.** { *; } +-keep class okhttp3.**{*;} +-keep class okio.**{*;} +-keep class com.hwangjr.rxbus.**{*;} +-keep class org.conscrypt.**{*;} +-keep class android.support.**{*;} +-keep class me.grantland.widget.**{*;} +-keep class de.hdodenhof.circleimageview.**{*;} +-keep class tyrant.explosionfield.**{*;} +-keep class tyrantgit.explosionfield.**{*;} +-keep class freemarker.**{*;} +-keep class com.gyf.barlibrary.** {*;} ##JSOUP --keep class org.jsoup**{*;} --keep class **.xpath**{*;} +-keep class org.jsoup.**{*;} +-keep class **.xpath.**{*;} --keep class org.slf4j**{*;} +-keep class org.slf4j.**{*;} -dontwarn org.slf4j.** --keep class org.codehaus**{*;} +-keep class org.codehaus.**{*;} -dontwarn org.codehaus.** --keep class com.jayway**{*;} +-keep class com.jayway.**{*;} -dontwarn com.jayway.** --keep class com.fasterxml**{*;} +-keep class com.fasterxml.**{*;} --keep class javax.swing**{*;} +-keep class javax.swing.**{*;} -dontwarn javax.swing.** --keep class java.awt**{*;} +-keep class java.awt.**{*;} -dontwarn java.awt.** --keep class sun.misc**{*;} +-keep class sun.misc.**{*;} -dontwarn sun.misc.** --keep class sun.reflect**{*;} +-keep class sun.reflect.**{*;} -dontwarn sun.reflect.** ## Rhino --keep class javax.script** { *; } --keep class com.sun.script.javascript** { *; } --keep class org.mozilla.javascript** { *; } +-keep class javax.script.** { *; } +-keep class com.sun.script.javascript.** { *; } +-keep class org.mozilla.javascript.** { *; } ###EPUB -dontwarn nl.siegmann.epublib.** -dontwarn org.xmlpull.** --keep class nl.siegmann.epublib**{*;} +-keep class nl.siegmann.epublib.**{*;} -keep class javax.xml**{*;} -keep class org.xmlpull**{*;} From 1987adc2664f64f96695b72cb67787a079055507 Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 9 Jun 2020 17:12:27 +0800 Subject: [PATCH 183/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8D=E4=BB=8E?= =?UTF-8?q?=E5=8F=91=E7=8E=B0=E7=95=8C=E9=9D=A2=E6=89=93=E5=BC=80=E5=B7=B2?= =?UTF-8?q?=E5=9C=A8=E4=B9=A6=E6=9E=B6=E7=9A=84=E4=B9=A6=E6=97=B6,?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=AF=B9=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +++ .../app/ui/book/explore/ExploreShowActivity.kt | 3 ++- .../legado/app/ui/book/info/BookInfoViewModel.kt | 14 +++++++------- .../io/legado/app/ui/book/read/ReadBookActivity.kt | 5 ++++- .../io/legado/app/ui/book/search/SearchActivity.kt | 8 ++++++-- .../app/ui/main/bookshelf/books/BooksFragment.kt | 5 ++++- 6 files changed, 26 insertions(+), 12 deletions(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 8de8fa6bf..78968466d 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/06/09** +* 修复从发现界面打开已在书架的书时,显示不对的问题 + **2020/06/07** * 优化书源检测,自定义搜索关键词 * 失效书源如果校验为有效会去掉失效标志 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 04bf86188..dbba6b63e 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 @@ -72,7 +72,8 @@ class ExploreShowActivity : VMBaseActivity(R.layout.activi override fun showBookInfo(book: Book) { startActivity( - Pair("bookUrl", book.bookUrl) + Pair("name", book.name), + Pair("author", book.author) ) } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt index 47dc6c33f..60b40e089 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt @@ -22,13 +22,13 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) { fun initData(intent: Intent) { execute { - intent.getStringExtra("bookUrl")?.let { - App.db.bookDao().getBook(it)?.let { book -> - inBookshelf = true - setBook(book) - } ?: App.db.searchBookDao().getSearchBook(it)?.toBook()?.let { book -> - setBook(book) - } + val name = intent.getStringExtra("name") ?: "" + val author = intent.getStringExtra("author") ?: "" + App.db.bookDao().getBook(name, author)?.let { book -> + inBookshelf = true + setBook(book) + } ?: App.db.searchBookDao().getFirstByNameAuthor(name, author)?.toBook()?.let { book -> + setBook(book) } } } 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 a88af1b3b..1ea8ec8f6 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 @@ -242,7 +242,10 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo onReplaceRuleSave() } R.id.menu_book_info -> ReadBook.book?.let { - startActivity(Pair("bookUrl", it.bookUrl)) + startActivity( + Pair("name", it.name), + Pair("author", it.author) + ) } R.id.menu_toc_regex -> TocRegexDialog.show( supportFragmentManager, diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt index e81545adc..6daa679cc 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt @@ -317,7 +317,10 @@ class SearchActivity : VMBaseActivity(R.layout.activity_book_se override fun showBookInfo(name: String, author: String) { viewModel.getSearchBook(name, author) { searchBook -> searchBook?.let { - startActivity(Pair("bookUrl", it.bookUrl)) + startActivity( + Pair("name", it.name), + Pair("author", it.author) + ) } } } @@ -327,7 +330,8 @@ class SearchActivity : VMBaseActivity(R.layout.activity_book_se */ override fun showBookInfo(book: Book) { startActivity( - Pair("bookUrl", book.bookUrl) + Pair("name", book.name), + Pair("author", book.author) ) } diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt index 137aaf184..a1390dc94 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt @@ -111,7 +111,10 @@ class BooksFragment : BaseFragment(R.layout.fragment_books), } override fun openBookInfo(book: Book) { - context?.startActivity(Pair("bookUrl", book.bookUrl)) + context?.startActivity( + Pair("name", book.name), + Pair("author", book.author) + ) } override fun isUpdate(bookUrl: String): Boolean { From 0d082915f808e3774d0efb301ef861aa0256e052 Mon Sep 17 00:00:00 2001 From: Hingbong Date: Wed, 10 Jun 2020 00:21:41 +0800 Subject: [PATCH 184/296] =?UTF-8?q?feat:=20=E5=AD=97=E4=BD=93=E7=9A=84?= =?UTF-8?q?=E7=B2=97=E7=BB=86=E9=80=89=E6=8B=A9=E5=A2=9E=E5=8A=A0=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E9=80=89=E6=8B=A9=E7=BB=86=E4=BD=93(Android=20O?= =?UTF-8?q?=E7=94=9F=E6=95=88)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 +- .../java/io/legado/app/help/ReadBookConfig.kt | 4 +- .../io/legado/app/service/help/ReadBook.kt | 7 +++ .../ui/book/read/config/ReadStyleDialog.kt | 5 +- .../read/config/TextFontWeightConverter.kt | 55 +++++++++++++++++++ .../app/ui/book/read/page/ChapterProvider.kt | 30 +++++++--- .../app/ui/book/read/page/ContentView.kt | 6 +- .../res/layout/dialog_read_book_style.xml | 5 +- app/src/main/res/values-zh-rHK/arrays.xml | 5 ++ app/src/main/res/values-zh-rHK/strings.xml | 1 + app/src/main/res/values-zh-rTW/arrays.xml | 5 ++ app/src/main/res/values-zh-rTW/strings.xml | 1 + app/src/main/res/values/arrays.xml | 6 ++ app/src/main/res/values/strings.xml | 1 + 14 files changed, 111 insertions(+), 22 deletions(-) create mode 100644 app/src/main/java/io/legado/app/ui/book/read/config/TextFontWeightConverter.kt diff --git a/app/build.gradle b/app/build.gradle index f23046bbb..dfd2b732e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -153,7 +153,7 @@ dependencies { implementation 'com.jeremyliao:live-event-bus-x:1.5.7' //协程 - def coroutines_version = '1.3.3' + def coroutines_version = '1.3.7' implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version" diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index d19f03139..daf17da51 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -147,7 +147,7 @@ object ReadBookConfig { private val config get() = if (shareLayout) getConfig(5) else durConfig - var textBold: Boolean + var textBold: Int get() = config.textBold set(value) { config.textBold = value @@ -294,7 +294,7 @@ object ReadBookConfig { private var darkStatusIconNight: Boolean = false,//晚上是否暗色状态栏 private var textColor: String = "#3E3D3B",//白天文字颜色 private var textColorNight: String = "#ADADAD",//夜间文字颜色 - var textBold: Boolean = false,//是否粗体字 + var textBold: Int = 0,//是否粗体字 0:正常, 1:粗体, 2:细体 var textSize: Int = 20,//文字大小 var letterSpacing: Float = 0.5f,//字间距 var lineSpacingExtra: Int = 12,//行间距 diff --git a/app/src/main/java/io/legado/app/service/help/ReadBook.kt b/app/src/main/java/io/legado/app/service/help/ReadBook.kt index 4b196ec48..d008ad7e9 100644 --- a/app/src/main/java/io/legado/app/service/help/ReadBook.kt +++ b/app/src/main/java/io/legado/app/service/help/ReadBook.kt @@ -1,11 +1,13 @@ package io.legado.app.service.help import androidx.lifecycle.MutableLiveData +import com.hankcs.hanlp.HanLP import io.legado.app.App import io.legado.app.R import io.legado.app.constant.BookType import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter +import io.legado.app.help.AppConfig import io.legado.app.help.BookHelp import io.legado.app.help.IntentDataHelp import io.legado.app.help.coroutine.Coroutine @@ -292,6 +294,11 @@ object ReadBook { ) { Coroutine.async { if (chapter.index in durChapterIndex - 1..durChapterIndex + 1) { + chapter.title = when (AppConfig.chineseConverterType) { + 1 -> HanLP.convertToSimplifiedChinese(chapter.title) + 2 -> HanLP.convertToTraditionalChinese(chapter.title) + else -> chapter.title + } val contents = BookHelp.disposeContent( chapter.title, book!!.name, diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt index 19cad6738..38e96af50 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt @@ -103,9 +103,7 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { tv_title_mode.onClick { showTitleConfig() } - tv_text_bold.onClick { - ReadBookConfig.textBold = !ReadBookConfig.textBold - tv_text_bold.isSelected = ReadBookConfig.textBold + text_font_weight_converter.onChanged { postEvent(EventBus.UP_CONFIG, true) } tv_text_font.onClick { @@ -215,7 +213,6 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { private fun upStyle() { ReadBookConfig.let { - tv_text_bold.isSelected = it.textBold dsb_text_size.progress = it.textSize - 5 dsb_text_letter_spacing.progress = (it.letterSpacing * 100).toInt() + 50 dsb_line_size.progress = it.lineSpacingExtra diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/TextFontWeightConverter.kt b/app/src/main/java/io/legado/app/ui/book/read/config/TextFontWeightConverter.kt new file mode 100644 index 000000000..12f5243fa --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/book/read/config/TextFontWeightConverter.kt @@ -0,0 +1,55 @@ +package io.legado.app.ui.book.read.config + +import android.content.Context +import android.text.Spannable +import android.text.SpannableString +import android.text.style.ForegroundColorSpan +import android.util.AttributeSet +import io.legado.app.R +import io.legado.app.help.AppConfig +import io.legado.app.help.ReadBookConfig +import io.legado.app.lib.dialogs.alert +import io.legado.app.lib.theme.accentColor +import io.legado.app.ui.widget.text.StrokeTextView +import org.jetbrains.anko.sdk27.listeners.onClick + +class TextFontWeightConverter(context: Context, attrs: AttributeSet?) : StrokeTextView(context, attrs) { + + private val spannableString = SpannableString("中/粗/细") + private var enabledSpan: ForegroundColorSpan = ForegroundColorSpan(context.accentColor) + private var onChanged: (() -> Unit)? = null + + init { + text = spannableString + if (!isInEditMode) { + upUi(ReadBookConfig.textBold) + } + onClick { + selectType() + } + } + + private fun upUi(type: Int) { + spannableString.removeSpan(enabledSpan) + when (type) { + 0 -> spannableString.setSpan(enabledSpan, 0, 1, Spannable.SPAN_INCLUSIVE_EXCLUSIVE) + 1 -> spannableString.setSpan(enabledSpan, 2, 3, Spannable.SPAN_INCLUSIVE_EXCLUSIVE) + 2 -> spannableString.setSpan(enabledSpan, 4, 5, Spannable.SPAN_INCLUSIVE_EXCLUSIVE) + } + text = spannableString + } + + private fun selectType() { + context.alert(titleResource = R.string.text_font_weight_converter) { + items(context.resources.getStringArray(R.array.text_font_weight).toList()) { _, i -> + ReadBookConfig.textBold = i + upUi(i) + onChanged?.invoke() + } + }.show() + } + + fun onChanged(unit: () -> Unit) { + onChanged = unit + } +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index b988ba782..15f3ac23c 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt @@ -6,6 +6,7 @@ import android.text.Layout import android.text.StaticLayout import android.text.TextPaint import android.text.TextUtils +import com.hankcs.hanlp.HanLP import io.legado.app.App import io.legado.app.constant.PreferKey import io.legado.app.data.entities.BookChapter @@ -78,6 +79,7 @@ object ChapterProvider { item.title = bookChapter.title item.upLinesPosition() } + return TextChapter( bookChapter.index, bookChapter.title, @@ -270,23 +272,37 @@ object ChapterProvider { App.INSTANCE.removePref(PreferKey.readBookFont) Typeface.SANS_SERIF } + // 字体统一处理 + val bold = Typeface.create(typeface, Typeface.BOLD) + val normal = Typeface.create(typeface, Typeface.NORMAL) + val (titleFont, textFont) = when (ReadBookConfig.textBold) { + 1 -> { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) + Pair(Typeface.create(typeface, 900, false), bold) + else + Pair(bold, bold) + } + 2 -> { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) + Pair(normal, Typeface.create(typeface, 300, false)) + else + Pair(normal, normal) + } + else -> Pair(bold, normal) + } + //标题 titlePaint = TextPaint() titlePaint.color = ReadBookConfig.durConfig.textColor() titlePaint.letterSpacing = ReadBookConfig.letterSpacing - titlePaint.typeface = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - Typeface.create(typeface, if (ReadBookConfig.textBold) 900 else 700, false) - } else { - Typeface.create(typeface, Typeface.BOLD) - } + titlePaint.typeface = titleFont titlePaint.textSize = with(ReadBookConfig) { textSize + titleSize }.sp.toFloat() titlePaint.isAntiAlias = true //正文 contentPaint = TextPaint() contentPaint.color = ReadBookConfig.durConfig.textColor() contentPaint.letterSpacing = ReadBookConfig.letterSpacing - val style = if (ReadBookConfig.textBold) Typeface.BOLD else Typeface.NORMAL - contentPaint.typeface = Typeface.create(typeface, style) + contentPaint.typeface = textFont contentPaint.textSize = ReadBookConfig.textSize.sp.toFloat() contentPaint.isAntiAlias = true //间距 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 8058c0a04..8cf679114 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 @@ -207,11 +207,7 @@ class ContentView(context: Context) : FrameLayout(context) { @SuppressLint("SetTextI18n") fun setProgress(textPage: TextPage) = textPage.apply { - val title = when (AppConfig.chineseConverterType) { - 1 -> HanLP.convertToSimplifiedChinese(textPage.title) - 2 -> HanLP.convertToTraditionalChinese(textPage.title) - else -> textPage.title - } + val title = textPage.title tvTitle?.text = title tvPage?.text = "${index.plus(1)}/$pageSize" tvTotalProgress?.text = readProgress diff --git a/app/src/main/res/layout/dialog_read_book_style.xml b/app/src/main/res/layout/dialog_read_book_style.xml index 9436e0f0a..b57705513 100644 --- a/app/src/main/res/layout/dialog_read_book_style.xml +++ b/app/src/main/res/layout/dialog_read_book_style.xml @@ -37,15 +37,14 @@ android:layout_height="wrap_content" android:layout_weight="1" /> - diff --git a/app/src/main/res/values-zh-rHK/arrays.xml b/app/src/main/res/values-zh-rHK/arrays.xml index ebe6c25dd..b99ad1992 100644 --- a/app/src/main/res/values-zh-rHK/arrays.xml +++ b/app/src/main/res/values-zh-rHK/arrays.xml @@ -49,4 +49,9 @@ 系統等寬字體 + + 正常 + 粗體 + 細體 + \ No newline at end of file diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 7cb27fd34..c439e23af 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -694,4 +694,5 @@ 文字兩端對齊 自動翻頁速度 地址排序 + 文章字體轉換 diff --git a/app/src/main/res/values-zh-rTW/arrays.xml b/app/src/main/res/values-zh-rTW/arrays.xml index 84dc2f886..4efd0c56f 100644 --- a/app/src/main/res/values-zh-rTW/arrays.xml +++ b/app/src/main/res/values-zh-rTW/arrays.xml @@ -106,4 +106,9 @@ 頁數及進度 + + 正常 + 粗體 + 細體 + diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 00bf07e51..50bb909ce 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -696,5 +696,6 @@ 文字兩端對齊 自動翻頁速度 地址排序 + 文章字體轉換 diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index b1046096f..e8a99ff2a 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -106,4 +106,10 @@ 页数及进度 + + 正常 + 粗体 + 细体 + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bcf8f247a..b234284fa 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -676,6 +676,7 @@ 隐藏页眉 隐藏页脚 切换布局 + 文章字重切换 主色调 From 41b5e27f0fbbaf435cba874e601d3c679257b9f5 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 10 Jun 2020 17:58:15 +0800 Subject: [PATCH 185/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/service/TTSReadAloudService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt b/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt index 1e6fcc2dd..2d4b8bbde 100644 --- a/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt @@ -72,7 +72,7 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener execute { MediaHelp.playSilentSound(this@TTSReadAloudService) textToSpeech?.let { - it.stop() + it.speak("", TextToSpeech.QUEUE_FLUSH, null, null) for (i in nowSpeak until contentList.size) { it.speak( contentList[i], From 8166670dcd02014a2d2912653c43c6d317e61a7e Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 10 Jun 2020 17:58:47 +0800 Subject: [PATCH 186/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 78968466d..deec586fc 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/06/10** +* 正文字体的粗细选择增加可以选择细体(Android O生效) + **2020/06/09** * 修复从发现界面打开已在书架的书时,显示不对的问题 From e7b90f0e312369fff37378fa777691238e868e78 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 10 Jun 2020 18:18:24 +0800 Subject: [PATCH 187/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/readConfig.json | 20 +++++-------------- .../java/io/legado/app/help/ReadBookConfig.kt | 4 ++-- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/app/src/main/assets/readConfig.json b/app/src/main/assets/readConfig.json index c26c81554..301a75705 100644 --- a/app/src/main/assets/readConfig.json +++ b/app/src/main/assets/readConfig.json @@ -7,9 +7,7 @@ "bgType": 0, "bgTypeNight": 0, "darkStatusIcon": true, - "textSize": 24, - "letterSpacing": 0, - "lineSpacingExtra": 10 + "darkStatusIconNight": false }, { "bgStr": "#DDC090", @@ -19,9 +17,7 @@ "bgType": 0, "bgTypeNight": 0, "darkStatusIcon": true, - "textSize": 24, - "letterSpacing": 0, - "lineSpacingExtra": 10 + "darkStatusIconNight": false }, { "bgStr": "#C2D8AA", @@ -31,9 +27,7 @@ "bgType": 0, "bgTypeNight": 0, "darkStatusIcon": false, - "textSize": 24, - "letterSpacing": 0, - "lineSpacingExtra": 10 + "darkStatusIconNight": false }, { "bgStr": "#DBB8E2", @@ -43,9 +37,7 @@ "bgType": 0, "bgTypeNight": 0, "darkStatusIcon": false, - "textSize": 24, - "letterSpacing": 0, - "lineSpacingExtra": 10 + "darkStatusIconNight": false }, { "bgStr": "#ABCEE0", @@ -55,8 +47,6 @@ "bgType": 0, "bgTypeNight": 0, "darkStatusIcon": false, - "textSize": 24, - "letterSpacing": 0, - "lineSpacingExtra": 10 + "darkStatusIconNight": false } ] \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index daf17da51..fcfd622ed 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -296,9 +296,9 @@ object ReadBookConfig { private var textColorNight: String = "#ADADAD",//夜间文字颜色 var textBold: Int = 0,//是否粗体字 0:正常, 1:粗体, 2:细体 var textSize: Int = 20,//文字大小 - var letterSpacing: Float = 0.5f,//字间距 + var letterSpacing: Float = 0.1f,//字间距 var lineSpacingExtra: Int = 12,//行间距 - var paragraphSpacing: Int = 12,//段距 + var paragraphSpacing: Int = 4,//段距 var titleMode: Int = 0,//标题居中 var titleSize: Int = 0, var titleTopSpacing: Int = 0, From 595edcb60da695b4d0440c9e5c7757da4a2bb140 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 10 Jun 2020 20:25:29 +0800 Subject: [PATCH 188/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/proguard-rules.pro | 2 + .../java/io/legado/app/help/ReadBookConfig.kt | 1 + .../io/legado/app/utils/GsonExtensions.kt | 41 ++++++++++-- app/src/main/res/values-zh-rHK/strings.xml | 6 ++ app/src/main/res/values-zh-rTW/strings.xml | 6 +- app/src/main/res/values/strings.xml | 9 ++- app/src/main/res/xml/pref_config_backup.xml | 66 ++++++++++--------- 7 files changed, 89 insertions(+), 42 deletions(-) diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 4dd43b6b5..b22ef10c7 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -164,6 +164,8 @@ -dontwarn org.conscrypt.** -dontwarn com.jeremyliao.liveeventbus.** +-keep class com.google.gson.** { *; } +-keep class com.ke.gson.** { *; } -keep class com.jeremyliao.liveeventbus.** { *; } -keep class okhttp3.**{*;} -keep class okio.**{*;} diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index fcfd622ed..9828bb3a1 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -59,6 +59,7 @@ object ReadBookConfig { val json = configFile.readText() return GSON.fromJsonArray(json) } catch (e: Exception) { + e.printStackTrace() } } return null diff --git a/app/src/main/java/io/legado/app/utils/GsonExtensions.kt b/app/src/main/java/io/legado/app/utils/GsonExtensions.kt index 32870d7b2..b29b4e2b4 100644 --- a/app/src/main/java/io/legado/app/utils/GsonExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/GsonExtensions.kt @@ -15,6 +15,7 @@ val GSON: Gson by lazy { object : TypeToken?>() {}.type, MapDeserializerDoubleAsIntFix() ) + .registerTypeAdapter(Int::class.java, IntJsonDeserializer()) .disableHtmlEscaping() .setPrettyPrinting() .create() @@ -44,6 +45,32 @@ class ParameterizedTypeImpl(private val clazz: Class<*>) : ParameterizedType { override fun getActualTypeArguments(): Array = arrayOf(clazz) } +/** + * int类型转化失败时跳过 + */ +class IntJsonDeserializer : JsonDeserializer { + + override fun deserialize( + json: JsonElement, + typeOfT: Type?, + context: JsonDeserializationContext? + ): Int? { + return when { + json.isJsonPrimitive -> { + val prim = json.asJsonPrimitive + if (prim.isNumber) { + prim.asNumber.toInt() + } else { + null + } + } + else -> null + } + } + +} + + /** * 修复Int变为Double的问题 */ @@ -60,20 +87,20 @@ class MapDeserializerDoubleAsIntFix : return read(jsonElement) as? Map } - fun read(`in`: JsonElement): Any? { + fun read(json: JsonElement): Any? { when { - `in`.isJsonArray -> { + json.isJsonArray -> { val list: MutableList = ArrayList() - val arr = `in`.asJsonArray + val arr = json.asJsonArray for (anArr in arr) { list.add(read(anArr)) } return list } - `in`.isJsonObject -> { + json.isJsonObject -> { val map: MutableMap = LinkedTreeMap() - val obj = `in`.asJsonObject + val obj = json.asJsonObject val entitySet = obj.entrySet() for ((key, value) in entitySet) { @@ -81,8 +108,8 @@ class MapDeserializerDoubleAsIntFix : } return map } - `in`.isJsonPrimitive -> { - val prim = `in`.asJsonPrimitive + json.isJsonPrimitive -> { + val prim = json.asJsonPrimitive when { prim.isBoolean -> { return prim.asBoolean diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index c439e23af..9dbf733dd 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -695,4 +695,10 @@ 自動翻頁速度 地址排序 文章字體轉換 + 請選擇備份路徑 + 其它 + legado-top + 本地和WebDav壹起備份 + 優先從WebDav恢復,失敗時從本地恢復 + 選擇舊版備份文件夾 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 50bb909ce..8023644cf 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -664,7 +664,7 @@ 聯繫我們 開源許可 其它 - 開源閱讀 + legado-top 關注公眾號 微信 您的支援是我更新的動力 @@ -697,5 +697,9 @@ 自動翻頁速度 地址排序 文章字體轉換 + 請選擇備份路徑 + 本地和WebDav壹起備份 + 優先從WebDav恢復,失敗時從本地恢復 + 選擇舊版備份文件夾 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b234284fa..2d49fd471 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -11,6 +11,7 @@ 创建子文件夹 创建legado文件夹作为备份文件夹 备份路径 + 请选择备份路径 导入旧版数据 导入Github数据 净化替换 @@ -663,8 +664,8 @@ 开发人员 联系我们 开源许可 - 其它 - 开源阅读 + 其它 + 开源阅读 关注公众号 微信 您的支持是我更新的动力 @@ -697,5 +698,7 @@ 文字两端对齐 自动翻页速度 地址排序 - + 本地和WebDav一起备份 + 优先从WebDav恢复,失败时从本地恢复 + 选择旧版备份文件夹 diff --git a/app/src/main/res/xml/pref_config_backup.xml b/app/src/main/res/xml/pref_config_backup.xml index 515da6622..784089b69 100644 --- a/app/src/main/res/xml/pref_config_backup.xml +++ b/app/src/main/res/xml/pref_config_backup.xml @@ -4,64 +4,68 @@ + app:iconSpaceReserved="false" + app:layout="@layout/view_preference_category"> + android:key="webDavCreateDir" + android:defaultValue="true" + android:title="@string/mkdirs" + android:summary="@string/mkdirs_description" + app:allowDividerAbove="false" + app:allowDividerBelow="false" + app:iconSpaceReserved="false" /> + app:iconSpaceReserved="false" + app:layout="@layout/view_preference_category"> + android:key="backupUri" + android:title="@string/backup_path" + android:summary="@string/select_backup_path" + app:iconSpaceReserved="false" /> + android:key="web_dav_backup" + android:title="@string/backup" + android:summary="@string/backup_summary" + app:iconSpaceReserved="false" /> + android:key="web_dav_restore" + android:title="@string/restore" + android:summary="@string/restore_summary" + app:iconSpaceReserved="false" /> + android:key="import_old" + android:title="@string/menu_import_old_version" + android:summary="@string/import_old_summary" + app:iconSpaceReserved="false" /> From bad15423924bc9c2c5b9196d366e019235f001f2 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 10 Jun 2020 20:30:30 +0800 Subject: [PATCH 189/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index deec586fc..87949f387 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -4,7 +4,7 @@ * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 **2020/06/10** -* 正文字体的粗细选择增加可以选择细体(Android O生效) +* 正文字体的粗细选择增加可以选择细体(Android O生效) by hingbong **2020/06/09** * 修复从发现界面打开已在书架的书时,显示不对的问题 From e1ee0a17e2c1f24f5a57d35c0e1dde9e53be583b Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 10 Jun 2020 20:39:54 +0800 Subject: [PATCH 190/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/ui/book/read/ReadBookActivity.kt | 3 +++ 1 file changed, 3 insertions(+) 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 1ea8ec8f6..d5880a728 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 @@ -523,6 +523,9 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo seek_read_page.progress = ReadBook.durPageIndex tv_pre.isEnabled = ReadBook.durChapterIndex != 0 tv_next.isEnabled = ReadBook.durChapterIndex != ReadBook.chapterSize - 1 + } ?: let { + tv_chapter_name.gone() + tv_chapter_url.gone() } } } From 64be7259f61a4392b2d47362c96975f3a06cc795 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 10 Jun 2020 20:49:34 +0800 Subject: [PATCH 191/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/main/bookshelf/books/BooksFragment.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt index a1390dc94..a7b714bed 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt @@ -7,6 +7,7 @@ import androidx.lifecycle.Observer import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView import io.legado.app.App import io.legado.app.R import io.legado.app.base.BaseFragment @@ -27,6 +28,7 @@ import io.legado.app.utils.getViewModelOfActivity import io.legado.app.utils.observeEvent import kotlinx.android.synthetic.main.fragment_books.* import org.jetbrains.anko.startActivity +import kotlin.math.max class BooksFragment : BaseFragment(R.layout.fragment_books), @@ -75,6 +77,23 @@ class BooksFragment : BaseFragment(R.layout.fragment_books), booksAdapter = BooksAdapterGrid(requireContext(), this) } rv_bookshelf.adapter = booksAdapter + booksAdapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() { + override fun onItemRangeInserted(positionStart: Int, itemCount: Int) { + val layoutManager = rv_bookshelf.layoutManager + if (positionStart == 0 && layoutManager is LinearLayoutManager) { + val scrollTo = layoutManager.findFirstVisibleItemPosition() - itemCount + rv_bookshelf.scrollToPosition(max(0, scrollTo)) + } + } + + override fun onItemRangeMoved(fromPosition: Int, toPosition: Int, itemCount: Int) { + val layoutManager = rv_bookshelf.layoutManager + if (toPosition == 0 && layoutManager is LinearLayoutManager) { + val scrollTo = layoutManager.findFirstVisibleItemPosition() - itemCount + rv_bookshelf.scrollToPosition(max(0, scrollTo)) + } + } + }) } private fun upRecyclerData() { From c493fb894d4412593c7a107cd09621a862da1308 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 10 Jun 2020 21:05:02 +0800 Subject: [PATCH 192/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt index 60b40e089..53b7366b9 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt @@ -12,6 +12,7 @@ import io.legado.app.help.BookHelp import io.legado.app.model.WebBook import io.legado.app.model.localBook.AnalyzeTxtFile import io.legado.app.model.localBook.LocalBook +import io.legado.app.service.help.ReadBook import kotlinx.coroutines.Dispatchers.IO class BookInfoViewModel(application: Application) : BaseViewModel(application) { @@ -178,6 +179,9 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) { book.durChapterTitle = it.durChapterTitle } App.db.bookDao().insert(book) + if (ReadBook.book?.name == book.name && ReadBook.book?.author == book.author) { + ReadBook.book = book + } } }.onSuccess { success?.invoke() From 2bf9a57963404f99d04c097ea24fb6a7d835e516 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 10 Jun 2020 21:07:10 +0800 Subject: [PATCH 193/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 87949f387..e97a87dd8 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -5,6 +5,7 @@ **2020/06/10** * 正文字体的粗细选择增加可以选择细体(Android O生效) by hingbong +* 修复bug **2020/06/09** * 修复从发现界面打开已在书架的书时,显示不对的问题 From 249544d2b11a7ae231f509f807dee5b53244eb8e Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 10 Jun 2020 21:10:31 +0800 Subject: [PATCH 194/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/service/help/ReadBook.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/help/ReadBook.kt b/app/src/main/java/io/legado/app/service/help/ReadBook.kt index d008ad7e9..ef15098b0 100644 --- a/app/src/main/java/io/legado/app/service/help/ReadBook.kt +++ b/app/src/main/java/io/legado/app/service/help/ReadBook.kt @@ -40,7 +40,6 @@ object ReadBook { fun resetData(book: Book) { this.book = book - titleDate.postValue(book.name) durChapterIndex = book.durChapterIndex durPageIndex = book.durChapterPos isLocalBook = book.origin == BookType.local @@ -48,11 +47,11 @@ object ReadBook { prevTextChapter = null curTextChapter = null nextTextChapter = null + titleDate.postValue(book.name) upWebBook(book) } - fun upWebBook(book: Book?) { - book ?: return + fun upWebBook(book: Book) { webBook = if (book.origin == BookType.local) { null } else { From 7e8d22b2b7482def47205f7935fbbd4891fc296a Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 10 Jun 2020 21:19:16 +0800 Subject: [PATCH 195/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt index 0c9cc80d0..e6d6b57e3 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt @@ -65,6 +65,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { } } else { isInitFinish = true + ReadBook.book!!.group = book.group ReadBook.titleDate.postValue(book.name) ReadBook.upWebBook(book) if (!book.isLocalBook() && ReadBook.webBook == null) { From 0d79a57577b150a1942736f2f116f78a1aef9652 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 10 Jun 2020 22:30:50 +0800 Subject: [PATCH 196/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/ui/about/AboutFragment.kt | 1 + app/src/main/res/xml/about.xml | 6 ++++++ 2 files changed, 7 insertions(+) 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 3b56737cf..e44666349 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 @@ -47,6 +47,7 @@ class AboutFragment : PreferenceFragmentCompat() { "update_log" -> showUpdateLog() "check_update" -> openUrl(R.string.latest_release_url) "mail" -> sendMail() + "sourceRuleSummary" -> openUrl(R.string.source_rule_url) "git" -> openUrl(R.string.this_github_url) "home_page" -> openUrl(R.string.home_page_url) "license" -> requireContext().openUrl(licenseUrl) diff --git a/app/src/main/res/xml/about.xml b/app/src/main/res/xml/about.xml index 3c607cd9d..a5c5922e6 100644 --- a/app/src/main/res/xml/about.xml +++ b/app/src/main/res/xml/about.xml @@ -51,6 +51,12 @@ android:summary="@string/this_github_url" app:iconSpaceReserved="false" /> + + Date: Wed, 10 Jun 2020 22:33:51 +0800 Subject: [PATCH 197/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/values/pref_key_value.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values/pref_key_value.xml b/app/src/main/res/values/pref_key_value.xml index 017bfe798..a2a2611cb 100644 --- a/app/src/main/res/values/pref_key_value.xml +++ b/app/src/main/res/values/pref_key_value.xml @@ -13,7 +13,7 @@ checkUpdate 开源阅读 - https://gitee.com/alanskycn/yuedu/blob/master/Rule/README.md + https://celeter.github.io/ https://github.com/gedoor/legado https://github.com/gedoor/legado/graphs/contributors https://gedoor.github.io/MyBookshelf/disclaimer.html From 90ac85517d24d5b1dcbefef36b012f8a288603fa Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 11 Jun 2020 21:55:03 +0800 Subject: [PATCH 198/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/main/MainActivity.kt | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) 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 181ec0330..8664d2eab 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 @@ -26,13 +26,14 @@ import io.legado.app.ui.main.rss.RssFragment import io.legado.app.ui.widget.dialog.TextDialog import io.legado.app.utils.* import kotlinx.android.synthetic.main.activity_main.* +import org.jetbrains.anko.toast class MainActivity : VMBaseActivity(R.layout.activity_main), BottomNavigationView.OnNavigationItemSelectedListener, ViewPager.OnPageChangeListener by ViewPager.SimpleOnPageChangeListener() { override val viewModel: MainViewModel get() = getViewModel(MainViewModel::class.java) - + private var exitTime: Long = 0 private var pagePosition = 0 private val fragmentId = arrayOf(0, 1, 2, 3) private val fragmentMap = mapOf( @@ -105,8 +106,14 @@ class MainActivity : VMBaseActivity(R.layout.activity_main), return true } if (!BaseReadAloudService.pause) { - moveTaskToBack(true) - return true + if (System.currentTimeMillis() - exitTime > 2000) { + toast(R.string.double_click_exit) + exitTime = System.currentTimeMillis() + } else { + moveTaskToBack(true) + return true + } + return false } } } @@ -121,6 +128,15 @@ class MainActivity : VMBaseActivity(R.layout.activity_main), } } + override fun finish() { + if (System.currentTimeMillis() - exitTime > 2000) { + toast(R.string.double_click_exit) + exitTime = System.currentTimeMillis() + } else { + super.finish() + } + } + override fun onDestroy() { super.onDestroy() ReadAloud.stop(this) From 2bb4698b5e791aa9e4ce67ad7ebc23bef7f1dae7 Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 12 Jun 2020 20:50:40 +0800 Subject: [PATCH 199/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index e97a87dd8..073675caf 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/06/12** +* 修复分组变化的bug + **2020/06/10** * 正文字体的粗细选择增加可以选择细体(Android O生效) by hingbong * 修复bug From eb163896ce722d0e177402d0a9080ef2a07eddd2 Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 12 Jun 2020 22:23:14 +0800 Subject: [PATCH 200/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/book/changesource/ChangeSourceAdapter.kt | 1 - .../book/changesource/ChangeSourceViewModel.kt | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt index 3a148a2c2..12e63a907 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt @@ -60,7 +60,6 @@ class ChangeSourceAdapter(context: Context, val callBack: CallBack) : when (it.itemId) { R.id.menu_disable_book_source -> { callBack.disableSource(searchBook) - removeItem(searchBook) } } true diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt index e5adf9e85..1b29f0e01 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt @@ -2,6 +2,7 @@ package io.legado.app.ui.book.changesource import android.app.Application import android.os.Bundle +import android.os.Handler import androidx.lifecycle.MutableLiveData import io.legado.app.App import io.legado.app.R @@ -22,6 +23,7 @@ import java.util.concurrent.Executors class ChangeSourceViewModel(application: Application) : BaseViewModel(application) { private var searchPool = Executors.newFixedThreadPool(AppConfig.threadCount).asCoroutineDispatcher() + val handler = Handler() val searchStateData = MutableLiveData() val searchBooksLiveData = MutableLiveData>() var name: String = "" @@ -29,6 +31,9 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio private var task: Coroutine<*>? = null private var screenKey: String = "" private val searchBooks = hashSetOf() + private var postTime = 0L + private val sendRunnable = Runnable { upAdapter() } + fun initData(arguments: Bundle?) { arguments?.let { bundle -> @@ -55,9 +60,16 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio } } + @Synchronized private fun upAdapter() { - val books = searchBooks.toList() - searchBooksLiveData.postValue(books.sortedBy { it.originOrder }) + if (System.currentTimeMillis() > postTime + 500) { + postTime = System.currentTimeMillis() + handler.removeCallbacks(sendRunnable) + val books = searchBooks.toList() + searchBooksLiveData.postValue(books.sortedBy { it.originOrder }) + } else { + handler.postDelayed(sendRunnable, 500) + } } private fun searchFinish(searchBook: SearchBook) { @@ -172,6 +184,7 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio App.db.bookSourceDao().update(source) } searchBooks.remove(searchBook) + upAdapter() } } From 59335a00c8777e1bb0975b2425b8b5a1fa546986 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 13 Jun 2020 16:11:27 +0800 Subject: [PATCH 201/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../changesource/ChangeSourceViewModel.kt | 2 +- .../app/ui/book/search/SearchActivity.kt | 15 ++++-------- .../app/ui/book/search/SearchViewModel.kt | 23 +++++++++++++++---- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt index 1b29f0e01..605822af8 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt @@ -63,8 +63,8 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio @Synchronized private fun upAdapter() { if (System.currentTimeMillis() > postTime + 500) { - postTime = System.currentTimeMillis() handler.removeCallbacks(sendRunnable) + postTime = System.currentTimeMillis() val books = searchBooks.toList() searchBooksLiveData.postValue(books.sortedBy { it.originOrder }) } else { diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt index 6daa679cc..e7e0d691c 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt @@ -52,7 +52,6 @@ class SearchActivity : VMBaseActivity(R.layout.activity_book_se private var menu: Menu? = null private var precisionSearchMenuItem: MenuItem? = null private var groups = linkedSetOf() - private var refreshTime = System.currentTimeMillis() override fun onActivityCreated(savedInstanceState: Bundle?) { initRecyclerView() @@ -181,14 +180,13 @@ class SearchActivity : VMBaseActivity(R.layout.activity_book_se upGroupMenu() }) viewModel.searchBookLiveData.observe(this, Observer { - upSearchItems(it, false) + upSearchItems(it) }) viewModel.isSearchLiveData.observe(this, Observer { if (it) { startSearch() } else { searchFinally() - upSearchItems(viewModel.searchBooks, true) } }) } @@ -284,14 +282,11 @@ class SearchActivity : VMBaseActivity(R.layout.activity_book_se * 更新搜索结果 */ @Synchronized - private fun upSearchItems(items: List, isMandatoryUpdate: Boolean) { + private fun upSearchItems(items: List) { val searchItems = ArrayList(items) - if (isMandatoryUpdate || System.currentTimeMillis() - refreshTime > 500) { - refreshTime = System.currentTimeMillis() - val diffResult = - DiffUtil.calculateDiff(DiffCallBack(adapter.getItems(), searchItems)) - adapter.setItems(searchItems, diffResult) - } + val diffResult = + DiffUtil.calculateDiff(DiffCallBack(adapter.getItems(), searchItems)) + adapter.setItems(searchItems, diffResult) } /** diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt index ccfc5dd15..5e7f60026 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt @@ -1,6 +1,7 @@ package io.legado.app.ui.book.search import android.app.Application +import android.os.Handler import androidx.lifecycle.MutableLiveData import io.legado.app.App import io.legado.app.base.BaseViewModel @@ -12,15 +13,18 @@ import io.legado.app.utils.getPrefBoolean import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.isActive -class SearchViewModel(application: Application) : BaseViewModel(application) - , SearchBookModel.CallBack { +class SearchViewModel(application: Application) : BaseViewModel(application), + SearchBookModel.CallBack { + val handler = Handler() private val searchBookModel = SearchBookModel(this, this) var isSearchLiveData = MutableLiveData() var searchBookLiveData = MutableLiveData>() var searchKey: String = "" var isLoading = false - var searchBooks = arrayListOf() + private var searchBooks = arrayListOf() private var searchID = 0L + private var postTime = 0L + private val sendRunnable = Runnable { upAdapter() } /** * 开始搜索 @@ -36,6 +40,17 @@ class SearchViewModel(application: Application) : BaseViewModel(application) searchBookModel.search(searchID, searchKey) } + @Synchronized + private fun upAdapter() { + if (System.currentTimeMillis() > postTime + 500) { + handler.removeCallbacks(sendRunnable) + postTime = System.currentTimeMillis() + searchBookLiveData.postValue(searchBooks) + } else { + handler.postDelayed(sendRunnable, 500) + } + } + override fun onSearchStart() { isSearchLiveData.postValue(true) } @@ -151,7 +166,7 @@ class SearchViewModel(application: Application) : BaseViewModel(application) }) if (!scope.isActive) return searchBooks = copyDataS - searchBookLiveData.postValue(copyDataS) + upAdapter() } } From e3aa9263e69dd1f85baa552a437bfc5a10623d4a Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 13 Jun 2020 16:46:12 +0800 Subject: [PATCH 202/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/book/changesource/ChangeSourceViewModel.kt | 5 +++-- .../java/io/legado/app/ui/book/search/SearchViewModel.kt | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt index 605822af8..da58200c5 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt @@ -62,13 +62,14 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio @Synchronized private fun upAdapter() { - if (System.currentTimeMillis() > postTime + 500) { + if (System.currentTimeMillis() >= postTime + 500) { handler.removeCallbacks(sendRunnable) postTime = System.currentTimeMillis() val books = searchBooks.toList() searchBooksLiveData.postValue(books.sortedBy { it.originOrder }) } else { - handler.postDelayed(sendRunnable, 500) + handler.removeCallbacks(sendRunnable) + handler.postDelayed(sendRunnable, 500 - System.currentTimeMillis() + postTime) } } diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt index 5e7f60026..318937697 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt @@ -42,12 +42,13 @@ class SearchViewModel(application: Application) : BaseViewModel(application), @Synchronized private fun upAdapter() { - if (System.currentTimeMillis() > postTime + 500) { + if (System.currentTimeMillis() >= postTime + 500) { handler.removeCallbacks(sendRunnable) postTime = System.currentTimeMillis() searchBookLiveData.postValue(searchBooks) } else { - handler.postDelayed(sendRunnable, 500) + handler.removeCallbacks(sendRunnable) + handler.postDelayed(sendRunnable, 500 - System.currentTimeMillis() + postTime) } } From 00f6dcf6d198ab34d14f8a9302ace30259a4256c Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 13 Jun 2020 16:47:01 +0800 Subject: [PATCH 203/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/search/SearchActivity.kt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt index e7e0d691c..3d12157d5 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt @@ -8,7 +8,6 @@ import android.view.View.VISIBLE import androidx.appcompat.widget.SearchView import androidx.lifecycle.LiveData import androidx.lifecycle.Observer -import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.google.android.flexbox.FlexboxLayoutManager @@ -283,10 +282,7 @@ class SearchActivity : VMBaseActivity(R.layout.activity_book_se */ @Synchronized private fun upSearchItems(items: List) { - val searchItems = ArrayList(items) - val diffResult = - DiffUtil.calculateDiff(DiffCallBack(adapter.getItems(), searchItems)) - adapter.setItems(searchItems, diffResult) + adapter.setItems(items) } /** From 542def704b2dec660516e8aebea7c0ffb8ff717f Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 13 Jun 2020 17:52:50 +0800 Subject: [PATCH 204/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 073675caf..020f74ce3 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/06/13** +* 优化搜索 + **2020/06/12** * 修复分组变化的bug From f3aeba29bf22519c5fdbe80dad46aa9e93e26ae5 Mon Sep 17 00:00:00 2001 From: 383bjz82bu <383bjz82bu@fd.com> Date: Sat, 13 Jun 2020 17:27:13 +0000 Subject: [PATCH 205/296] --- .../main/java/io/legado/app/help/AppConfig.kt | 2 +- .../java/io/legado/app/help/ReadBookConfig.kt | 15 ++++++- .../io/legado/app/ui/about/AboutFragment.kt | 4 +- .../io/legado/app/ui/about/DonateFragment.kt | 4 +- .../io/legado/app/ui/book/read/ReadMenu.kt | 8 ++-- .../ui/book/read/config/MoreConfigDialog.kt | 4 +- .../book/read/config/ReadAloudConfigDialog.kt | 4 +- .../app/ui/config/BackupConfigFragment.kt | 4 +- .../app/ui/config/OtherConfigFragment.kt | 3 +- .../app/ui/config/ThemeConfigFragment.kt | 3 +- .../io/legado/app/ui/main/my/MyFragment.kt | 5 ++- .../legado/app/utils/AnimationUtilsSupport.kt | 17 ++++++++ .../app/utils/PreferenceFragmentSupport.kt | 41 +++++++++++++++++++ 13 files changed, 92 insertions(+), 22 deletions(-) create mode 100644 app/src/main/java/io/legado/app/utils/AnimationUtilsSupport.kt create mode 100644 app/src/main/java/io/legado/app/utils/PreferenceFragmentSupport.kt diff --git a/app/src/main/java/io/legado/app/help/AppConfig.kt b/app/src/main/java/io/legado/app/help/AppConfig.kt index 79353351c..fef825c70 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -81,7 +81,7 @@ object AppConfig { get() = App.INSTANCE.getPrefString(PreferKey.ttsSpeechPer) ?: "0" val isEInkMode: Boolean - get() = App.INSTANCE.getPrefBoolean("isEInkMode") + get() = App.INSTANCE.getPrefBoolean(PreferKey.einkMode) val clickAllNext: Boolean get() = App.INSTANCE.getPrefBoolean(PreferKey.clickAllNext, false) diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index 9828bb3a1..abb739682 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -26,12 +26,25 @@ object ReadBookConfig { val json = String(App.INSTANCE.assets.open(readConfigFileName).readBytes()) GSON.fromJsonArray(json)!! } - val durConfig get() = getConfig(styleSelect) + val durConfig get() = + if (AppConfig.isEInkMode) + einkConfig + else + getConfig(styleSelect) + var bg: Drawable? = null var bgMeanColor: Int = 0 + val einkConfig:Config init { upConfig() + einkConfig = Config( + bgStr = "#FFFFFF", + bgStrNight = "#FFFFFF", + textColor = "#000000", + textColorNight = "#000000", + darkStatusIconNight = true + ) } @Synchronized 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 e44666349..17c7eb4e6 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 @@ -6,16 +6,16 @@ import android.os.Bundle import android.view.View import androidx.annotation.StringRes import androidx.preference.Preference -import androidx.preference.PreferenceFragmentCompat import io.legado.app.App import io.legado.app.R import io.legado.app.lib.dialogs.alert import io.legado.app.ui.widget.dialog.TextDialog +import io.legado.app.utils.PreferenceFragmentSupport import io.legado.app.utils.openUrl import io.legado.app.utils.sendToClip import io.legado.app.utils.toast -class AboutFragment : PreferenceFragmentCompat() { +class AboutFragment : PreferenceFragmentSupport() { private val licenseUrl = "https://github.com/gedoor/legado/blob/master/LICENSE" private val disclaimerUrl = "https://gedoor.github.io/MyBookshelf/disclaimer.html" diff --git a/app/src/main/java/io/legado/app/ui/about/DonateFragment.kt b/app/src/main/java/io/legado/app/ui/about/DonateFragment.kt index b716c8f05..6223b5865 100644 --- a/app/src/main/java/io/legado/app/ui/about/DonateFragment.kt +++ b/app/src/main/java/io/legado/app/ui/about/DonateFragment.kt @@ -5,14 +5,14 @@ import android.content.Intent import android.os.Bundle import android.view.View import androidx.preference.Preference -import androidx.preference.PreferenceFragmentCompat import io.legado.app.R import io.legado.app.utils.ACache +import io.legado.app.utils.PreferenceFragmentSupport import io.legado.app.utils.openUrl import io.legado.app.utils.sendToClip import org.jetbrains.anko.longToast -class DonateFragment : PreferenceFragmentCompat() { +class DonateFragment : PreferenceFragmentSupport() { private val zfbHbRwmUrl = "https://gitee.com/gekunfei/Donate/raw/master/zfbhbrwm.png" private val zfbSkRwmUrl = "https://gitee.com/gekunfei/Donate/raw/master/zfbskrwm.jpg" 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 317af6aab..36793bed1 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 @@ -194,8 +194,8 @@ class ReadMenu : FrameLayout { } private fun initAnimation() { - menuTopIn = AnimationUtils.loadAnimation(context, R.anim.anim_readbook_top_in) - menuBottomIn = AnimationUtils.loadAnimation(context, R.anim.anim_readbook_bottom_in) + menuTopIn = AnimationUtilsSupport.loadAnimation(context, R.anim.anim_readbook_top_in) + menuBottomIn = AnimationUtilsSupport.loadAnimation(context, R.anim.anim_readbook_bottom_in) menuTopIn.setAnimationListener(object : Animation.AnimationListener { override fun onAnimationStart(animation: Animation) { callBack?.upSystemUiVisibility() @@ -217,8 +217,8 @@ class ReadMenu : FrameLayout { }) //隐藏菜单 - menuTopOut = AnimationUtils.loadAnimation(context, R.anim.anim_readbook_top_out) - menuBottomOut = AnimationUtils.loadAnimation(context, R.anim.anim_readbook_bottom_out) + menuTopOut = AnimationUtilsSupport.loadAnimation(context, R.anim.anim_readbook_top_out) + menuBottomOut = AnimationUtilsSupport.loadAnimation(context, R.anim.anim_readbook_bottom_out) menuTopOut.setAnimationListener(object : Animation.AnimationListener { override fun onAnimationStart(animation: Animation) { vw_menu_bg.setOnClickListener(null) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt index 7033b82d0..cf1558087 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt @@ -10,7 +10,6 @@ import android.view.ViewGroup import android.widget.LinearLayout import androidx.fragment.app.DialogFragment import androidx.preference.Preference -import androidx.preference.PreferenceFragmentCompat import io.legado.app.R import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey @@ -18,6 +17,7 @@ import io.legado.app.help.ReadBookConfig import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.bottomBackground import io.legado.app.ui.book.read.Help +import io.legado.app.utils.PreferenceFragmentSupport import io.legado.app.utils.dp import io.legado.app.utils.getPrefBoolean import io.legado.app.utils.postEvent @@ -64,7 +64,7 @@ class MoreConfigDialog : DialogFragment() { .commit() } - class ReadPreferenceFragment : PreferenceFragmentCompat(), + class ReadPreferenceFragment : PreferenceFragmentSupport(), SharedPreferences.OnSharedPreferenceChangeListener { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudConfigDialog.kt index cdb10159e..dd5eadf9c 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudConfigDialog.kt @@ -10,7 +10,6 @@ import android.widget.LinearLayout import androidx.fragment.app.DialogFragment import androidx.preference.ListPreference import androidx.preference.Preference -import androidx.preference.PreferenceFragmentCompat import io.legado.app.R import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey @@ -20,6 +19,7 @@ import io.legado.app.lib.theme.backgroundColor import io.legado.app.service.BaseReadAloudService import io.legado.app.service.help.ReadAloud import io.legado.app.ui.book.read.Help +import io.legado.app.utils.PreferenceFragmentSupport import io.legado.app.utils.postEvent class ReadAloudConfigDialog : DialogFragment() { @@ -59,7 +59,7 @@ class ReadAloudConfigDialog : DialogFragment() { .commit() } - class ReadAloudPreferenceFragment : PreferenceFragmentCompat(), + class ReadAloudPreferenceFragment : PreferenceFragmentSupport(), SharedPreferences.OnSharedPreferenceChangeListener { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { diff --git a/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt index 9df96e3f2..7ff39a7b3 100644 --- a/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt @@ -8,15 +8,15 @@ import android.view.View import androidx.preference.EditTextPreference import androidx.preference.ListPreference import androidx.preference.Preference -import androidx.preference.PreferenceFragmentCompat import io.legado.app.R import io.legado.app.constant.PreferKey import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.accentColor import io.legado.app.ui.filechooser.FileChooserDialog +import io.legado.app.utils.PreferenceFragmentSupport import io.legado.app.utils.getPrefString -class BackupConfigFragment : PreferenceFragmentCompat(), +class BackupConfigFragment : PreferenceFragmentSupport(), SharedPreferences.OnSharedPreferenceChangeListener, FileChooserDialog.CallBack { diff --git a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt index f23fee053..07a70b110 100644 --- a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt @@ -7,7 +7,6 @@ import android.os.Bundle import android.view.View import androidx.preference.ListPreference import androidx.preference.Preference -import androidx.preference.PreferenceFragmentCompat import io.legado.app.App import io.legado.app.R import io.legado.app.constant.EventBus @@ -21,7 +20,7 @@ import io.legado.app.ui.widget.number.NumberPickerDialog import io.legado.app.utils.* -class OtherConfigFragment : PreferenceFragmentCompat(), +class OtherConfigFragment : PreferenceFragmentSupport(), SharedPreferences.OnSharedPreferenceChangeListener { private val packageManager = App.INSTANCE.packageManager 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 6416040c3..774dd07e0 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 @@ -9,7 +9,6 @@ import android.view.MenuInflater import android.view.MenuItem import android.view.View import androidx.preference.Preference -import androidx.preference.PreferenceFragmentCompat import io.legado.app.App import io.legado.app.R import io.legado.app.constant.EventBus @@ -26,7 +25,7 @@ import io.legado.app.ui.widget.prefs.IconListPreference import io.legado.app.utils.* -class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedPreferenceChangeListener { +class ThemeConfigFragment : PreferenceFragmentSupport(), SharedPreferences.OnSharedPreferenceChangeListener { val items = arrayListOf("极简", "曜夜", "经典", "黑白", "A屏黑") diff --git a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt index dab9eb544..de219c0aa 100644 --- a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt @@ -7,13 +7,13 @@ import android.view.Menu import android.view.MenuItem import android.view.View import androidx.preference.Preference -import androidx.preference.PreferenceFragmentCompat import io.legado.app.App import io.legado.app.R import io.legado.app.base.BaseFragment import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey import io.legado.app.help.AppConfig +import io.legado.app.help.ReadBookConfig import io.legado.app.lib.theme.ATH import io.legado.app.service.WebService import io.legado.app.ui.about.AboutActivity @@ -65,7 +65,7 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog. BackupRestoreUi.onActivityResult(requestCode, resultCode, data) } - class PreferenceFragment : PreferenceFragmentCompat(), + class PreferenceFragment : PreferenceFragmentSupport(), SharedPreferences.OnSharedPreferenceChangeListener { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { @@ -123,6 +123,7 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog. "recordLog" -> LogUtils.upLevel() PreferKey.einkMode -> { postEvent(EventBus.RECREATE, "") + ReadBookConfig.pageAnim = 4 } } } diff --git a/app/src/main/java/io/legado/app/utils/AnimationUtilsSupport.kt b/app/src/main/java/io/legado/app/utils/AnimationUtilsSupport.kt new file mode 100644 index 000000000..1400b11f2 --- /dev/null +++ b/app/src/main/java/io/legado/app/utils/AnimationUtilsSupport.kt @@ -0,0 +1,17 @@ +package io.legado.app.utils + +import android.content.Context +import android.view.animation.Animation +import android.view.animation.AnimationUtils +import androidx.annotation.AnimRes +import io.legado.app.help.AppConfig + +object AnimationUtilsSupport { + fun loadAnimation(context: Context, @AnimRes id: Int): Animation { + val animation = AnimationUtils.loadAnimation(context, id) + if (AppConfig.isEInkMode) { + animation.duration = 0 + } + return animation + } +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/utils/PreferenceFragmentSupport.kt b/app/src/main/java/io/legado/app/utils/PreferenceFragmentSupport.kt new file mode 100644 index 000000000..23848fb52 --- /dev/null +++ b/app/src/main/java/io/legado/app/utils/PreferenceFragmentSupport.kt @@ -0,0 +1,41 @@ +package io.legado.app.utils + +import android.content.pm.PackageManager +import android.os.Bundle +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.core.view.setPadding +import androidx.preference.PreferenceFragmentCompat +import androidx.preference.PreferenceRecyclerViewAccessibilityDelegate +import androidx.recyclerview.widget.RecyclerView +import fadeapp.widgets.ScrollLessRecyclerView +import io.legado.app.R +import io.legado.app.help.AppConfig + +abstract class PreferenceFragmentSupport : PreferenceFragmentCompat(){ + + override fun onCreateRecyclerView( + inflater: LayoutInflater, + parent: ViewGroup, + savedInstanceState: Bundle? + ): RecyclerView { + + if (context?.packageManager?.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)==true) { + val recyclerView: RecyclerView?= parent.findViewById(R.id.recycler_view) + if (recyclerView != null) { + return recyclerView + } + } + val recyclerView = ScrollLessRecyclerView(inflater.context,null,R.attr.preferenceFragmentListStyle) + recyclerView.id = R.id.recycler_view + recyclerView.setPadding(0) + recyclerView.clipToPadding = false + recyclerView.isEnableScroll = !AppConfig.isEInkMode + recyclerView.layoutManager = onCreateLayoutManager() + recyclerView.setAccessibilityDelegateCompat( + PreferenceRecyclerViewAccessibilityDelegate(recyclerView) + ) + + return recyclerView + } +} \ No newline at end of file From 1d768c150a546929f39b58821a5132b2c33d9d1a Mon Sep 17 00:00:00 2001 From: 383bjz82bu <383bjz82bu@fd.com> Date: Sat, 13 Jun 2020 17:35:45 +0000 Subject: [PATCH 206/296] reset edit .gitignore --- .gitignore | 8 -------- .../java/io/legado/app/ui/main/my/MyFragment.kt | 13 +++++++++++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index e9f1bfd7b..700c700fe 100644 --- a/.gitignore +++ b/.gitignore @@ -13,11 +13,3 @@ node_modules/ /app/google /app/gradle.properties package-lock.json - -*__gen.go -*__ignore.go -*.swp -*.swo -~i_* -ig_* -zzzig_* diff --git a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt index de219c0aa..da6dde167 100644 --- a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt @@ -122,8 +122,17 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog. } "recordLog" -> LogUtils.upLevel() PreferKey.einkMode -> { - postEvent(EventBus.RECREATE, "") - ReadBookConfig.pageAnim = 4 + //既然是 E-Ink 模式,为什么不一步到位呢 + if (AppConfig.isEInkMode) { + ReadBookConfig.pageAnim = 4 + putPrefInt("colorPrimary", getCompatColor(R.color.white)) + putPrefInt("colorAccent", getCompatColor(R.color.black)) + putPrefInt("colorBackground", getCompatColor(R.color.white)) + putPrefInt("colorBottomBackground", getCompatColor(R.color.white)) + AppConfig.isNightTheme = false + App.INSTANCE.applyDayNight() + postEvent(EventBus.RECREATE, "") + } } } } From ec89b8425eede0fae48bc9347491a47dae1dd1d5 Mon Sep 17 00:00:00 2001 From: fisher Date: Sun, 14 Jun 2020 15:50:15 +0800 Subject: [PATCH 207/296] =?UTF-8?q?update=20=20special=20title=20like=20?= =?UTF-8?q?=20xxx(=E4=B8=80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/txtTocRule.json | 213 ++++++++++++++-------------- 1 file changed, 109 insertions(+), 104 deletions(-) diff --git a/app/src/main/assets/txtTocRule.json b/app/src/main/assets/txtTocRule.json index 46fb3d4cc..2cdd34372 100644 --- a/app/src/main/assets/txtTocRule.json +++ b/app/src/main/assets/txtTocRule.json @@ -1,104 +1,109 @@ -[ - { - "enable": true, - "name": "目录", - "rule": "^[  \\t]{0,4}(?:序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|篇(?!张))).{0,30}$", - "serialNumber": -17 - }, - { - "enable": false, - "name": "目录(去空白)", - "rule": "(?<=[ \\s])(?:序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|篇(?!张))).{0,30}$", - "serialNumber": -16 - }, - { - "enable": false, - "name": "目录(匹配简介)", - "rule": "(?<=[ \\s])(?:(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|回(?![合来事去])|场(?![和合比电是])|篇(?!张))).{0,30}$", - "serialNumber": -15 - }, - { - "enable": false, - "name": "目录(古典、轻小说备用)", - "rule": "^[  \\t]{0,4}(?:序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|回(?![合来事去])|场(?![和合比电是])|篇(?!张))).{0,30}$", - "serialNumber": -14 - }, - { - "enable": false, - "name": "数字(纯数字标题)", - "rule": "(?<=[ \\s])\\d+[  \\t]{0,4}$", - "serialNumber": -13 - }, - { - "enable": true, - "name": "数字 分隔符 标题名称", - "rule": "^[  \\t]{0,4}\\d{1,5}[,., 、_—\\-].{1,30}$", - "serialNumber": -12 - }, - { - "enable": true, - "name": "大写数字 分隔符 标题名称", - "rule": "^[  \\t]{0,4}[零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}[ 、_—\\-].{1,30}$", - "serialNumber": -11 - }, - { - "enable": true, - "name": "正文 标题/序号", - "rule": "^[  \\t]{0,4}正文[  ]{1,4}.{0,20}$", - "serialNumber": -10 - }, - { - "enable": true, - "name": "Chapter/Section/Part/Episode 序号 标题", - "rule": "^[  \\t]{0,4}(?:[Cc]hapter|[Ss]ection|[Pp]art|PART|[Ee]pisode|(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外)\\s{0,4}\\d{1,4}.{0,30}$", - "serialNumber": -9 - }, - { - "enable": false, - "name": "Chapter(去简介)", - "rule": "^[  \\t]{0,4}(?:[Cc]hapter|[Ss]ection|[Pp]art|PART|[Ee]pisode)\\s{0,4}\\d{1,4}.{0,30}$", - "serialNumber": -8 - }, - { - "enable": true, - "name": "特殊符号 序号 标题", - "rule": "(?<=[\\s ])[【〔〖「『〈[\\[](?:第|[Cc]hapter)[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,10}[章节].{0,20}$", - "serialNumber": -7 - }, - { - "enable": false, - "name": "特殊符号 标题(成对)", - "rule": "(?<=[\\s ]{0,4})(?:[\\[〈「『〖〔《(【\\(].{1,30}[\\)】)》〕〗』」〉\\]]?|(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外)[  ]{0,4}$", - "serialNumber": -6 - }, - { - "enable":true, - "name": "特殊符号 标题(单个)", - "rule": "(?<=[\\s ]{0,4})(?:[☆★✦✧].{1,30}|(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外)[  ]{0,4}$", - "serialNumber": -5 - }, - { - "enable": true, - "name": "章/卷 序号 标题", - "rule": "^[ \\t ]{0,4}(?:(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|[卷章][\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8})[  ]{0,4}.{0,30}$", - "serialNumber": -4 - }, - { - "enable":false, - "name": "顶格标题", - "rule": "^\\S.{1,20}$", - "serialNumber": -3 - }, - { - "enable":false, - "name": "双标题(前向)", - "rule": "(?m)(?<=[ \\t ]{0,4})第[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}章.{0,30}$(?=[\\s ]{0,8}第[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}章)", - "serialNumber": -2 - }, - { - "enable":false, - "name": "双标题(后向)", - "rule": "(?m)(?<=[ \\t ]{0,4}第[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}章.{0,30}$[\\s ]{0,8})第[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}章.{0,30}$", - "serialNumber": -1 - } -] +[{ + "enable": true, + "name": "目录", + "rule": "^[  \\t]{0,4}(?:序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|篇(?!张))).{0,30}$", + "serialNumber": -18 +}, +{ + "enable": false, + "name": "目录(去空白)", + "rule": "(?<=[ \\s])(?:序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|篇(?!张))).{0,30}$", + "serialNumber": -17 +}, +{ + "enable": false, + "name": "目录(匹配简介)", + "rule": "(?<=[ \\s])(?:(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|回(?![合来事去])|场(?![和合比电是])|篇(?!张))).{0,30}$", + "serialNumber": -16 +}, +{ + "enable": false, + "name": "目录(古典、轻小说备用)", + "rule": "^[  \\t]{0,4}(?:序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|回(?![合来事去])|场(?![和合比电是])|篇(?!张))).{0,30}$", + "serialNumber": -15 +}, +{ + "enable": false, + "name": "数字(纯数字标题)", + "rule": "(?<=[ \\s])\\d+[  \\t]{0,4}$", + "serialNumber": -14 +}, +{ + "enable": true, + "name": "数字 分隔符 标题名称", + "rule": "^[  \\t]{0,4}\\d{1,5}[,., 、_—\\-].{1,30}$", + "serialNumber": -13 +}, +{ + "enable": true, + "name": "大写数字 分隔符 标题名称", + "rule": "^[  \\t]{0,4}[零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}[ 、_—\\-].{1,30}$", + "serialNumber": -12 +}, +{ + "enable": true, + "name": "正文 标题/序号", + "rule": "^[  \\t]{0,4}正文[  ]{1,4}.{0,20}$", + "serialNumber": -11 +}, +{ + "enable": true, + "name": "Chapter/Section/Part/Episode 序号 标题", + "rule": "^[  \\t]{0,4}(?:[Cc]hapter|[Ss]ection|[Pp]art|PART|[Ee]pisode|(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外)\\s{0,4}\\d{1,4}.{0,30}$", + "serialNumber": -10 +}, +{ + "enable": false, + "name": "Chapter(去简介)", + "rule": "^[  \\t]{0,4}(?:[Cc]hapter|[Ss]ection|[Pp]art|PART|[Ee]pisode)\\s{0,4}\\d{1,4}.{0,30}$", + "serialNumber": -9 +}, +{ + "enable": true, + "name": "特殊符号 序号 标题", + "rule": "(?<=[\\s ])[【〔〖「『〈[\\[](?:第|[Cc]hapter)[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,10}[章节].{0,20}$", + "serialNumber": -8 +}, +{ + "enable": false, + "name": "特殊符号 标题(成对)", + "rule": "(?<=[\\s ]{0,4})(?:[\\[〈「『〖〔《(【\\(].{1,30}[\\)】)》〕〗』」〉\\]]?|(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外)[  ]{0,4}$", + "serialNumber": -7 +}, +{ + "enable": true, + "name": "特殊符号 标题(单个)", + "rule": "(?<=[\\s ]{0,4})(?:[☆★✦✧].{1,30}|(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外)[  ]{0,4}$", + "serialNumber": -6 +}, +{ + "enable": true, + "name": "章/卷 序号 标题", + "rule": "^[ \\t ]{0,4}(?:(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|[卷章][\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8})[  ]{0,4}.{0,30}$", + "serialNumber": -5 +}, +{ + "enable": false, + "name": "顶格标题", + "rule": "^\\S.{1,20}$", + "serialNumber": -4 +}, +{ + "enable": false, + "name": "双标题(前向)", + "rule": "(?m)(?<=[ \\t ]{0,4})第[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}章.{0,30}$(?=[\\s ]{0,8}第[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}章)", + "serialNumber": -3 +}, +{ + "enable": false, + "name": "双标题(后向)", + "rule": "(?m)(?<=[ \\t ]{0,4}第[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}章.{0,30}$[\\s ]{0,8})第[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}章.{0,30}$", + "serialNumber": -2 +}, +{ + "enable": true, + "name": "标题 特殊符号 序号", + "rule": "^.{1,20}[((][零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}[))]$", + "serialNumber": -1 +} +] \ No newline at end of file From 630e781bca7758bd9ed39a7c84d910ac5c35e378 Mon Sep 17 00:00:00 2001 From: 52fisher <32198215+52fisher@users.noreply.github.com> Date: Sun, 14 Jun 2020 17:09:34 +0800 Subject: [PATCH 208/296] =?UTF-8?q?=20update=20special=20title=20like=20xx?= =?UTF-8?q?xx(=E4=B8=80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/txtTocRule.json | 41 +++++++++++++++++------------ 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/app/src/main/assets/txtTocRule.json b/app/src/main/assets/txtTocRule.json index aa5408b4c..db07f99e1 100644 --- a/app/src/main/assets/txtTocRule.json +++ b/app/src/main/assets/txtTocRule.json @@ -4,118 +4,125 @@ "enable": true, "name": "目录", "rule": "^[  \\t]{0,4}(?:序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|篇(?!张))).{0,30}$", - "serialNumber": -17 + "serialNumber": -21 }, { "id": -2, "enable": false, "name": "目录(去空白)", "rule": "(?<=[ \\s])(?:序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|篇(?!张))).{0,30}$", - "serialNumber": -16 + "serialNumber": -20 }, { "id": -3, "enable": false, "name": "目录(匹配简介)", "rule": "(?<=[ \\s])(?:(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|回(?![合来事去])|场(?![和合比电是])|篇(?!张))).{0,30}$", - "serialNumber": -15 + "serialNumber": -19 }, { "id": -4, "enable": false, "name": "目录(古典、轻小说备用)", "rule": "^[  \\t]{0,4}(?:序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|回(?![合来事去])|场(?![和合比电是])|篇(?!张))).{0,30}$", - "serialNumber": -14 + "serialNumber": -18 }, { "id": -5, "enable": false, "name": "数字(纯数字标题)", "rule": "(?<=[ \\s])\\d+[  \\t]{0,4}$", - "serialNumber": -13 + "serialNumber": -17 }, { "id": -6, "enable": true, "name": "数字 分隔符 标题名称", "rule": "^[  \\t]{0,4}\\d{1,5}[,., 、_—\\-].{1,30}$", - "serialNumber": -12 + "serialNumber": -16 }, { "id": -7, "enable": true, "name": "大写数字 分隔符 标题名称", "rule": "^[  \\t]{0,4}[零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}[ 、_—\\-].{1,30}$", - "serialNumber": -11 + "serialNumber": -15 }, { "id": -8, "enable": true, "name": "正文 标题/序号", "rule": "^[  \\t]{0,4}正文[  ]{1,4}.{0,20}$", - "serialNumber": -10 + "serialNumber": -14 }, { "id": -9, "enable": true, "name": "Chapter/Section/Part/Episode 序号 标题", "rule": "^[  \\t]{0,4}(?:[Cc]hapter|[Ss]ection|[Pp]art|PART|[Ee]pisode|(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外)\\s{0,4}\\d{1,4}.{0,30}$", - "serialNumber": -9 + "serialNumber": -13 }, { "id": -10, "enable": false, "name": "Chapter(去简介)", "rule": "^[  \\t]{0,4}(?:[Cc]hapter|[Ss]ection|[Pp]art|PART|[Ee]pisode)\\s{0,4}\\d{1,4}.{0,30}$", - "serialNumber": -8 + "serialNumber": -12 }, { "id": -11, "enable": true, "name": "特殊符号 序号 标题", "rule": "(?<=[\\s ])[【〔〖「『〈[\\[](?:第|[Cc]hapter)[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,10}[章节].{0,20}$", - "serialNumber": -7 + "serialNumber": -11 }, { "id": -12, "enable": false, "name": "特殊符号 标题(成对)", "rule": "(?<=[\\s ]{0,4})(?:[\\[〈「『〖〔《(【\\(].{1,30}[\\)】)》〕〗』」〉\\]]?|(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外)[  ]{0,4}$", - "serialNumber": -6 + "serialNumber": -10 }, { "id": -13, "enable":true, "name": "特殊符号 标题(单个)", "rule": "(?<=[\\s ]{0,4})(?:[☆★✦✧].{1,30}|(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外)[  ]{0,4}$", - "serialNumber": -5 + "serialNumber": -9 }, { "id": -14, "enable": true, "name": "章/卷 序号 标题", "rule": "^[ \\t ]{0,4}(?:(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|[卷章][\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8})[  ]{0,4}.{0,30}$", - "serialNumber": -4 + "serialNumber": -8 }, { "id": -15, "enable":false, "name": "顶格标题", "rule": "^\\S.{1,20}$", - "serialNumber": -3 + "serialNumber": -7 }, { "id": -16, "enable":false, "name": "双标题(前向)", "rule": "(?m)(?<=[ \\t ]{0,4})第[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}章.{0,30}$(?=[\\s ]{0,8}第[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}章)", - "serialNumber": -2 + "serialNumber": -6 }, { "id": -17, "enable":false, "name": "双标题(后向)", "rule": "(?m)(?<=[ \\t ]{0,4}第[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}章.{0,30}$[\\s ]{0,8})第[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}章.{0,30}$", - "serialNumber": -1 + "serialNumber": -5 + }, + { + "id":"-18", + "enable": true, + "name": "标题 特殊符号 序号", + "rule": "^.{1,20}[((][\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}[))]$", + "serialNumber": -4 } ] From 0ee6317f921f37daee7c6d26649edeb316a0922a Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 14 Jun 2020 17:42:43 +0800 Subject: [PATCH 209/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/model/localBook/AnalyzeTxtFile.kt | 14 ++++++++------ .../app/ui/book/read/config/TocRegexViewModel.kt | 6 ++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/localBook/AnalyzeTxtFile.kt b/app/src/main/java/io/legado/app/model/localBook/AnalyzeTxtFile.kt index 15e8597c2..f9cfb846c 100644 --- a/app/src/main/java/io/legado/app/model/localBook/AnalyzeTxtFile.kt +++ b/app/src/main/java/io/legado/app/model/localBook/AnalyzeTxtFile.kt @@ -278,18 +278,20 @@ class AnalyzeTxtFile { } private fun getTocRules(): List { - val rules = App.db.txtTocRule().all + val rules = App.db.txtTocRule().enabled if (rules.isEmpty()) { - return getDefaultRules() + return getDefaultEnabledRules() } return rules } - fun getDefaultRules(): List { + fun getDefaultEnabledRules(): List { App.INSTANCE.assets.open("txtTocRule.json").readBytes().let { byteArray -> - GSON.fromJsonArray(String(byteArray))?.let { - App.db.txtTocRule().insert(*it.toTypedArray()) - return it + GSON.fromJsonArray(String(byteArray))?.let { txtTocRules -> + App.db.txtTocRule().insert(*txtTocRules.toTypedArray()) + return txtTocRules.filter { + it.enable + } } } return emptyList() diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexViewModel.kt index e94649684..140a781e4 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexViewModel.kt @@ -22,10 +22,8 @@ class TocRegexViewModel(application: Application) : BaseViewModel(application) { fun importDefault() { execute { - AnalyzeTxtFile.getDefaultRules().let { - App.db.txtTocRule().deleteDefault() - App.db.txtTocRule().insert(*it.toTypedArray()) - } + App.db.txtTocRule().deleteDefault() + AnalyzeTxtFile.getDefaultEnabledRules() } } From 3716e67b409d226d5808a67782e0e20225372035 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 14 Jun 2020 19:29:10 +0800 Subject: [PATCH 210/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/ui/book/info/BookInfoActivity.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt index e0b6f275a..0e887fad4 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt @@ -86,6 +86,9 @@ class BookInfoActivity : R.id.menu_refresh -> { upLoading(true) viewModel.bookData.value?.let { + if (it.isLocalBook()) { + it.tocUrl = "" + } viewModel.loadBookInfo(it) } } From c6d6d27cf3ef9034909f4db58492b467ed8de79c Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 14 Jun 2020 20:14:32 +0800 Subject: [PATCH 211/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 4 ++++ app/src/main/res/menu/book_source.xml | 8 ++++++++ app/src/main/res/values-zh-rHK/strings.xml | 2 ++ app/src/main/res/values-zh-rTW/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 2 ++ 5 files changed, 18 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 020f74ce3..a6b4b27c1 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,10 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/06/14** +* 修复txt文件目录识别 +* 书源分组添加已启用已禁用 + **2020/06/13** * 优化搜索 diff --git a/app/src/main/res/menu/book_source.xml b/app/src/main/res/menu/book_source.xml index a02fb146e..4ae595bb7 100644 --- a/app/src/main/res/menu/book_source.xml +++ b/app/src/main/res/menu/book_source.xml @@ -52,6 +52,14 @@
+ + + + diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 9dbf733dd..ab23bb16c 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -701,4 +701,6 @@ 本地和WebDav壹起備份 優先從WebDav恢復,失敗時從本地恢復 選擇舊版備份文件夾 + 已啓用 + 已禁用 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 8023644cf..681068185 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -701,5 +701,7 @@ 本地和WebDav壹起備份 優先從WebDav恢復,失敗時從本地恢復 選擇舊版備份文件夾 + 已啓用 + 已禁用 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2d49fd471..b32c7ffbd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -701,4 +701,6 @@ 本地和WebDav一起备份 优先从WebDav恢复,失败时从本地恢复 选择旧版备份文件夹 + 已启用 + 已禁用 From da565413189b427b098ffbb55e40beb24656906e Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 14 Jun 2020 20:56:48 +0800 Subject: [PATCH 212/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/data/dao/BookSourceDao.kt | 6 +++++ .../book/source/manage/BookSourceActivity.kt | 23 +++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) 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 55d5ada4c..0c0b8e49a 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 @@ -14,6 +14,12 @@ interface BookSourceDao { @Query("select * from book_sources where bookSourceName like :searchKey or bookSourceGroup like :searchKey or bookSourceUrl like :searchKey order by customOrder asc") fun liveDataSearch(searchKey: String = ""): LiveData> + @Query("select * from book_sources where enabled = 1 order by customOrder asc") + fun liveDataEnabled(): LiveData> + + @Query("select * from book_sources where enabled = 0 order by customOrder asc") + fun liveDataDisabled(): LiveData> + @Query("select * from book_sources where enabledExplore = 1 and trim(exploreUrl) <> '' order by customOrder asc") fun liveExplore(): LiveData> diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt index c10140de6..d5feb380c 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt @@ -115,6 +115,12 @@ class BookSourceActivity : VMBaseActivity(R.layout.activity sort = 4 initLiveDataBookSource(search_view.query?.toString()) } + R.id.menu_enabled_group -> { + search_view.setQuery(getString(R.string.enabled), true) + } + R.id.menu_disabled_group -> { + search_view.setQuery(getString(R.string.disabled), true) + } } if (item.groupId == R.id.source_group) { search_view.setQuery(item.title, true) @@ -166,10 +172,19 @@ class BookSourceActivity : VMBaseActivity(R.layout.activity private fun initLiveDataBookSource(searchKey: String? = null) { bookSourceLiveDate?.removeObservers(this) - bookSourceLiveDate = if (searchKey.isNullOrEmpty()) { - App.db.bookSourceDao().liveDataAll() - } else { - App.db.bookSourceDao().liveDataSearch("%$searchKey%") + bookSourceLiveDate = when { + searchKey.isNullOrEmpty() -> { + App.db.bookSourceDao().liveDataAll() + } + searchKey == getString(R.string.enabled) -> { + App.db.bookSourceDao().liveDataEnabled() + } + searchKey == getString(R.string.disabled) -> { + App.db.bookSourceDao().liveDataDisabled() + } + else -> { + App.db.bookSourceDao().liveDataSearch("%$searchKey%") + } } bookSourceLiveDate?.observe(this, Observer { data -> val sourceList = when (sort) { From c7649434ced28693af6574f23e8d04181e8d107d Mon Sep 17 00:00:00 2001 From: 52fisher <32198215+52fisher@users.noreply.github.com> Date: Sun, 14 Jun 2020 22:20:38 +0800 Subject: [PATCH 213/296] =?UTF-8?q?Update=20title=20special=20chars=20like?= =?UTF-8?q?=20xxxx(=E4=B8=80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/txtTocRule.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/assets/txtTocRule.json b/app/src/main/assets/txtTocRule.json index db07f99e1..fdb0f6f21 100644 --- a/app/src/main/assets/txtTocRule.json +++ b/app/src/main/assets/txtTocRule.json @@ -122,7 +122,7 @@ "id":"-18", "enable": true, "name": "标题 特殊符号 序号", - "rule": "^.{1,20}[((][\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}[))]$", + "rule": "^.{1,20}[((][\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}[))][  \t]{0,4}$", "serialNumber": -4 } ] From 529e4d50be99ee2df29e11d1aa9dc6ea92d5b7e4 Mon Sep 17 00:00:00 2001 From: gedoor Date: Mon, 15 Jun 2020 21:15:14 +0800 Subject: [PATCH 214/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt b/app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt index c02450091..e2586e3e0 100644 --- a/app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt @@ -19,7 +19,7 @@ interface SearchBookDao { @Query("select * from searchBooks where bookUrl = :bookUrl") fun getSearchBook(bookUrl: String): SearchBook? - @Query("select * from searchBooks where name = :name and author = :author and origin in (select bookSourceUrl from book_sources where enabled = 1) order by originOrder limit 1") + @Query("select * from searchBooks where name = :name and author = :author and origin in (select bookSourceUrl from book_sources) order by originOrder limit 1") fun getFirstByNameAuthor(name: String, author: String): SearchBook? @Query( From 0c2a677e14162d4c58db232dcdfcc559b4fb7a04 Mon Sep 17 00:00:00 2001 From: gedoor Date: Mon, 15 Jun 2020 22:57:38 +0800 Subject: [PATCH 215/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index a6b4b27c1..562e97c02 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,10 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/06/15** +* 添加 E-Ink 模式 by Modificator +* 修复发现打开书时可能的错误 + **2020/06/14** * 修复txt文件目录识别 * 书源分组添加已启用已禁用 From f1fd69ca4f818599f5c6042c0b6c0b3a03f188b5 Mon Sep 17 00:00:00 2001 From: Modificator Date: Mon, 15 Jun 2020 23:48:37 +0800 Subject: [PATCH 216/296] =?UTF-8?q?=E4=BF=9D=E5=AD=98=E6=89=93=E5=BC=80=20?= =?UTF-8?q?E-Ink=20=E6=A8=A1=E5=BC=8F=E5=89=8D=E7=9A=84=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E3=80=81=E7=BF=BB=E9=A1=B5=E5=8A=A8=E7=94=BB=EF=BC=8C=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E5=90=8E=E6=81=A2=E5=A4=8D=E4=B9=8B=E5=89=8D=E7=9A=84?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/main/my/MyFragment.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt index da6dde167..724b084c4 100644 --- a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt @@ -15,6 +15,7 @@ import io.legado.app.constant.PreferKey import io.legado.app.help.AppConfig import io.legado.app.help.ReadBookConfig import io.legado.app.lib.theme.ATH +import io.legado.app.lib.theme.ThemeStore import io.legado.app.service.WebService import io.legado.app.ui.about.AboutActivity import io.legado.app.ui.about.DonateActivity @@ -124,6 +125,15 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog. PreferKey.einkMode -> { //既然是 E-Ink 模式,为什么不一步到位呢 if (AppConfig.isEInkMode) { + //保存开启前的设置 + putPrefInt("lastReadBookPageAnim", ReadBookConfig.pageAnim) + putPrefInt("lastColorPrimary", ThemeStore.primaryColor(requireContext())) + putPrefInt("lastColorAccent", ThemeStore.accentColor(requireContext())) + putPrefInt("lastColorBackground", ThemeStore.backgroundColor(requireContext())) + putPrefInt("lastColorBottomBackground", ThemeStore.bottomBackground(requireContext())) + putPrefBoolean("lastIsNightTheme", AppConfig.isNightTheme) + + //设置 E-Ink 模式配置 ReadBookConfig.pageAnim = 4 putPrefInt("colorPrimary", getCompatColor(R.color.white)) putPrefInt("colorAccent", getCompatColor(R.color.black)) @@ -132,6 +142,15 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog. AppConfig.isNightTheme = false App.INSTANCE.applyDayNight() postEvent(EventBus.RECREATE, "") + } else { + ReadBookConfig.pageAnim = getPrefInt("lastReadBookPageAnim") + putPrefInt("colorPrimary", getPrefInt("lastColorPrimary")) + putPrefInt("colorAccent", getPrefInt("lastColorAccent")) + putPrefInt("colorBackground", getPrefInt("lastColorBackground")) + putPrefInt("colorBottomBackground", getPrefInt("lastColorBottomBackground")) + AppConfig.isNightTheme = getPrefBoolean("lastIsNightTheme") + App.INSTANCE.applyDayNight() + postEvent(EventBus.RECREATE, "") } } } From 5b0323d49258ac4d05edc39518f227eaf6ea4609 Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 16 Jun 2020 19:52:54 +0800 Subject: [PATCH 217/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8D=E6=81=A2?= =?UTF-8?q?=E5=A4=8D=E6=97=B6=E9=9C=80=E8=A6=81=E9=80=80=E5=87=BA=E9=87=8D?= =?UTF-8?q?=E8=BF=9B=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/main/MainActivity.kt | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) 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 8664d2eab..d604465a1 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 @@ -105,16 +105,17 @@ class MainActivity : VMBaseActivity(R.layout.activity_main), view_pager_main.currentItem = 0 return true } - if (!BaseReadAloudService.pause) { - if (System.currentTimeMillis() - exitTime > 2000) { - toast(R.string.double_click_exit) - exitTime = System.currentTimeMillis() + if (System.currentTimeMillis() - exitTime > 2000) { + toast(R.string.double_click_exit) + exitTime = System.currentTimeMillis() + } else { + if (BaseReadAloudService.pause) { + finish() } else { moveTaskToBack(true) - return true } - return false } + return true } } } @@ -128,15 +129,6 @@ class MainActivity : VMBaseActivity(R.layout.activity_main), } } - override fun finish() { - if (System.currentTimeMillis() - exitTime > 2000) { - toast(R.string.double_click_exit) - exitTime = System.currentTimeMillis() - } else { - super.finish() - } - } - override fun onDestroy() { super.onDestroy() ReadAloud.stop(this) From b62490b7a278a208a7d9b05ba6c821e30699c6e8 Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 16 Jun 2020 20:06:24 +0800 Subject: [PATCH 218/296] =?UTF-8?q?feat:=20=E5=88=B7=E6=96=B0=E6=97=B6?= =?UTF-8?q?=E5=8F=AA=E5=88=B7=E6=96=B0=E5=BD=93=E5=89=8D=E4=B9=A6=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 4 ++++ app/src/main/java/io/legado/app/ui/main/MainViewModel.kt | 5 +++-- .../io/legado/app/ui/main/bookshelf/books/BooksFragment.kt | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 562e97c02..25114ef87 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,10 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/06/16** +* 刷新时只刷新当前书架 +* 修复恢复备份需要退出重进的问题 + **2020/06/15** * 添加 E-Ink 模式 by Modificator * 修复发现打开书时可能的错误 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 61c951ae5..4dcd3560d 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 @@ -4,6 +4,7 @@ import android.app.Application import io.legado.app.App import io.legado.app.base.BaseViewModel import io.legado.app.constant.EventBus +import io.legado.app.data.entities.Book import io.legado.app.data.entities.RssSource import io.legado.app.help.http.HttpHelper import io.legado.app.help.storage.Restore @@ -17,9 +18,9 @@ import kotlinx.coroutines.delay class MainViewModel(application: Application) : BaseViewModel(application) { val updateList = hashSetOf() - fun upChapterList() { + fun upChapterList(books: List) { execute { - App.db.bookDao().hasUpdateBooks.forEach { book -> + books.forEach { book -> if (!updateList.contains(book.bookUrl)) { App.db.bookSourceDao().getBookSource(book.origin)?.let { bookSource -> synchronized(this) { diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt index e061a510e..f9346c7ef 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt @@ -67,7 +67,7 @@ class BooksFragment : BaseFragment(R.layout.fragment_books), refresh_layout.setColorSchemeColors(accentColor) refresh_layout.setOnRefreshListener { refresh_layout.isRefreshing = false - activityViewModel.upChapterList() + activityViewModel.upChapterList(booksAdapter.getItems()) } val bookshelfLayout = getPrefInt(PreferKey.bookshelfLayout) if (bookshelfLayout == 0) { From 5499bfcf11ce07f1861fc7eb3ae8e34012b4e7cb Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 16 Jun 2020 20:09:50 +0800 Subject: [PATCH 219/296] =?UTF-8?q?feat:=20=E5=88=B7=E6=96=B0=E6=97=B6?= =?UTF-8?q?=E5=8F=AA=E5=88=B7=E6=96=B0=E5=BD=93=E5=89=8D=E4=B9=A6=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 25114ef87..0ff75ca65 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -6,6 +6,7 @@ **2020/06/16** * 刷新时只刷新当前书架 * 修复恢复备份需要退出重进的问题 +* 保存打开 E-Ink 模式前的主题、翻页动画,关闭后恢复之前的配置, 现在可以切着玩了 **2020/06/15** * 添加 E-Ink 模式 by Modificator From b1368280933550345e784807b39d0d93ce6cb0ee Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 16 Jun 2020 20:12:43 +0800 Subject: [PATCH 220/296] =?UTF-8?q?feat:=20=E5=88=B7=E6=96=B0=E6=97=B6?= =?UTF-8?q?=E5=8F=AA=E5=88=B7=E6=96=B0=E5=BD=93=E5=89=8D=E4=B9=A6=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/ReadBookConfig.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index abb739682..9288a1c76 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -34,7 +34,7 @@ object ReadBookConfig { var bg: Drawable? = null var bgMeanColor: Int = 0 - val einkConfig:Config + private val einkConfig: Config init { upConfig() From 5ab04dd0c23c5ae8ec7724783d0394aeed39b97d Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 16 Jun 2020 20:43:17 +0800 Subject: [PATCH 221/296] =?UTF-8?q?feat:=20=E5=88=B7=E6=96=B0=E6=97=B6?= =?UTF-8?q?=E5=8F=AA=E5=88=B7=E6=96=B0=E5=BD=93=E5=89=8D=E4=B9=A6=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/main/bookshelf/BookshelfFragment.kt | 13 +++++++++++-- .../app/ui/main/bookshelf/books/BooksFragment.kt | 8 ++++++-- app/src/main/res/menu/main_bookshelf.xml | 6 ++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt index f51bdc0a6..9c657dd99 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt @@ -31,6 +31,7 @@ import io.legado.app.ui.book.download.DownloadActivity import io.legado.app.ui.book.group.GroupManageDialog import io.legado.app.ui.book.local.ImportBookActivity import io.legado.app.ui.book.search.SearchActivity +import io.legado.app.ui.main.MainViewModel import io.legado.app.ui.main.bookshelf.books.BooksFragment import io.legado.app.ui.widget.text.AutoCompleteTextView import io.legado.app.utils.* @@ -52,11 +53,12 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b override val viewModel: BookshelfViewModel get() = getViewModel(BookshelfViewModel::class.java) - + private val activityViewModel: MainViewModel + get() = getViewModelOfActivity(MainViewModel::class.java) private var bookGroupLiveData: LiveData>? = null private var noGroupLiveData: LiveData? = null private val bookGroups = mutableListOf() - private val fragmentMap = hashMapOf() + private val fragmentMap = hashMapOf() private var showGroupNone = false override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { @@ -73,6 +75,13 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b super.onCompatOptionsItemSelected(item) when (item.itemId) { R.id.menu_search -> startActivity() + R.id.menu_update_toc -> { + val group = bookGroups[tab_layout.selectedTabPosition] + val fragment = fragmentMap[group.groupId] + fragment?.getBooks()?.let { + activityViewModel.upChapterList(it) + } + } R.id.menu_bookshelf_layout -> configBookshelf() R.id.menu_group_manage -> GroupManageDialog() .show(childFragmentManager, "groupManageDialog") diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt index f9346c7ef..c7395c4dd 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt @@ -46,14 +46,14 @@ class BooksFragment : BaseFragment(R.layout.fragment_books), } } - private lateinit var activityViewModel: MainViewModel + private val activityViewModel: MainViewModel + get() = getViewModelOfActivity(MainViewModel::class.java) private lateinit var booksAdapter: BaseBooksAdapter private var bookshelfLiveData: LiveData>? = null private var position = 0 private var groupId = -1 override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { - activityViewModel = getViewModelOfActivity(MainViewModel::class.java) arguments?.let { position = it.getInt("position", 0) groupId = it.getInt("groupId", -1) @@ -120,6 +120,10 @@ class BooksFragment : BaseFragment(R.layout.fragment_books), }) } + fun getBooks(): List { + return booksAdapter.getItems() + } + override fun open(book: Book) { when (book.type) { BookType.audio -> diff --git a/app/src/main/res/menu/main_bookshelf.xml b/app/src/main/res/menu/main_bookshelf.xml index 1c63a7629..628026f7c 100644 --- a/app/src/main/res/menu/main_bookshelf.xml +++ b/app/src/main/res/menu/main_bookshelf.xml @@ -8,6 +8,12 @@ android:title="@string/search" app:showAsAction="ifRoom" /> + + Date: Tue, 16 Jun 2020 20:47:35 +0800 Subject: [PATCH 222/296] =?UTF-8?q?feat:=20=E5=88=B7=E6=96=B0=E6=97=B6?= =?UTF-8?q?=E5=8F=AA=E5=88=B7=E6=96=B0=E5=BD=93=E5=89=8D=E4=B9=A6=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/ui/main/MainViewModel.kt | 6 ++++++ 1 file changed, 6 insertions(+) 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 4dcd3560d..fe22ce11e 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 @@ -18,6 +18,12 @@ import kotlinx.coroutines.delay class MainViewModel(application: Application) : BaseViewModel(application) { val updateList = hashSetOf() + fun upChapterList() { + execute { + upChapterList(App.db.bookDao().hasUpdateBooks) + } + } + fun upChapterList(books: List) { execute { books.forEach { book -> From d161a3400b311e7d79e32dfbe4c607e40686b1e0 Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 16 Jun 2020 21:36:28 +0800 Subject: [PATCH 223/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/about/AboutActivity.kt | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/about/AboutActivity.kt b/app/src/main/java/io/legado/app/ui/about/AboutActivity.kt index 1ce1202de..ca71714f1 100644 --- a/app/src/main/java/io/legado/app/ui/about/AboutActivity.kt +++ b/app/src/main/java/io/legado/app/ui/about/AboutActivity.kt @@ -24,15 +24,19 @@ class AboutActivity : BaseActivity(R.layout.activity_about) { .replace(R.id.fl_fragment, aboutFragment, fTag) .commit() tv_app_summary.post { - val span = ForegroundColorSpan(accentColor) - val spannableString = SpannableString(tv_app_summary.text) - val gzh = getString(R.string.legado_gzh) - val start = spannableString.indexOf(gzh) - spannableString.setSpan( - span, start, start + gzh.length, - Spannable.SPAN_EXCLUSIVE_EXCLUSIVE - ) - tv_app_summary.text = spannableString + try { + val span = ForegroundColorSpan(accentColor) + val spannableString = SpannableString(tv_app_summary.text) + val gzh = getString(R.string.legado_gzh) + val start = spannableString.indexOf(gzh) + spannableString.setSpan( + span, start, start + gzh.length, + Spannable.SPAN_EXCLUSIVE_EXCLUSIVE + ) + tv_app_summary.text = spannableString + } catch (e: Exception) { + e.printStackTrace() + } } } From bb9008e588da5a764a5bf222df0b686a81f5d6c3 Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 16 Jun 2020 21:43:25 +0800 Subject: [PATCH 224/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/values-zh-rHK/strings.xml | 2 +- app/src/main/res/values-zh-rTW/strings.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index ab23bb16c..cf1a34ace 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -88,7 +88,7 @@ 下載已選擇的章節到本地 換源 - \u3000\u3000這是一款使用 Kotlin 全新開發的開源的閲讀應用程式,歡迎你的加入。關注公眾號[开源阅读]! + \u3000\u3000這是一款使用 Kotlin 全新開發的開源的閲讀應用程式,歡迎你的加入。關注公眾號[legado-top]! 閲讀3.0下載地址:\nhttps://play.google.com/store/apps/details?id=io.legado.app diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 681068185..b02021f3d 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -88,7 +88,7 @@ 下載選擇的章節到本機 換源 - \u3000\u3000這是一款使用Kotlin全新開發的開源的閱讀軟體,歡迎您的加入。關注公眾號[開源閱讀]! + \u3000\u3000這是一款使用Kotlin全新開發的開源的閱讀軟體,歡迎您的加入。關注公眾號[legado-top]! 閱讀3.0下載網址:\nhttps://play.google.com/store/apps/details?id=io.legado.app From a0b1b3e6626dfaa3ffd4419e289cdc0d92f5d6a5 Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 16 Jun 2020 21:47:19 +0800 Subject: [PATCH 225/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/values-zh-rHK/strings.xml | 2 +- app/src/main/res/values-zh-rTW/strings.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index cf1a34ace..c499172ad 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -697,7 +697,7 @@ 文章字體轉換 請選擇備份路徑 其它 - legado-top + legado-top 本地和WebDav壹起備份 優先從WebDav恢復,失敗時從本地恢復 選擇舊版備份文件夾 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index b02021f3d..181cdddbd 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -663,8 +663,8 @@ 開發人員 聯繫我們 開源許可 - 其它 - legado-top + 其它 + legado-top 關注公眾號 微信 您的支援是我更新的動力 From 7f5ca68b29ecb07d13965fe47f6b2e8795139121 Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 16 Jun 2020 21:48:21 +0800 Subject: [PATCH 226/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 0ff75ca65..1cbc36801 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -7,6 +7,7 @@ * 刷新时只刷新当前书架 * 修复恢复备份需要退出重进的问题 * 保存打开 E-Ink 模式前的主题、翻页动画,关闭后恢复之前的配置, 现在可以切着玩了 +* 修复因繁体语言导致的崩溃bug **2020/06/15** * 添加 E-Ink 模式 by Modificator From bb61114ac759f448d5129bb2d16f2ef7fab519f4 Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 16 Jun 2020 22:01:50 +0800 Subject: [PATCH 227/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/ui/main/MainViewModel.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 fe22ce11e..b7392aaef 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 @@ -3,6 +3,7 @@ package io.legado.app.ui.main import android.app.Application import io.legado.app.App import io.legado.app.base.BaseViewModel +import io.legado.app.constant.BookType import io.legado.app.constant.EventBus import io.legado.app.data.entities.Book import io.legado.app.data.entities.RssSource @@ -26,7 +27,9 @@ class MainViewModel(application: Application) : BaseViewModel(application) { fun upChapterList(books: List) { execute { - books.forEach { book -> + books.filter { + it.origin != BookType.local && it.canUpdate + }.forEach { book -> if (!updateList.contains(book.bookUrl)) { App.db.bookSourceDao().getBookSource(book.origin)?.let { bookSource -> synchronized(this) { From e0add796c8e8a905c59f1736bacde2fca14eb242 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 17 Jun 2020 08:10:52 +0800 Subject: [PATCH 228/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt b/app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt index c849ae1de..94c883909 100644 --- a/app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt +++ b/app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt @@ -190,10 +190,11 @@ object BackupRestoreUi { AppConfig.backupPath = uri.toString() } } - oldDataRequestCode -> - if (resultCode == RESULT_OK) data?.data?.let { uri -> + oldDataRequestCode -> if (resultCode == RESULT_OK) { + data?.data?.let { uri -> ImportOldData.importUri(uri) } + } } } From a54062b9419029bb86b032adc5ce72e8a7d92c47 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 17 Jun 2020 20:47:58 +0800 Subject: [PATCH 229/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 265d741ee..1e827329c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -66,6 +66,7 @@ android { applicationIdSuffix '.debug' versionNameSuffix 'debug' minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } android.applicationVariants.all { variant -> variant.outputs.all { @@ -86,7 +87,7 @@ android { } compileOptions { // Flag to enable support for the new language APIs - //coreLibraryDesugaringEnabled true + coreLibraryDesugaringEnabled true // Sets Java compatibility to Java 8 sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -108,6 +109,7 @@ kapt { } dependencies { + coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.5' implementation fileTree(dir: 'libs', include: ['*.jar']) testImplementation 'junit:junit:4.13' androidTestImplementation 'androidx.test:runner:1.2.0' @@ -196,10 +198,4 @@ dependencies { implementation 'fadeapp.widgets:scrollless-recyclerView:1.0.2' } -apply plugin: 'com.google.gms.google-services' - -//afterEvaluate { -// for (Task task : project.tasks.matching { it.name.startsWith('crashlyticsUploadDeobs') }) { -// task.enabled = false -// } -//} \ No newline at end of file +apply plugin: 'com.google.gms.google-services' \ No newline at end of file From 65864b6fd0a419fb22ff44a90d26fdc4ce7ca6cd Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 17 Jun 2020 21:05:30 +0800 Subject: [PATCH 230/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/data/AppDatabase.kt | 1 + .../legado/app/help/storage/ImportOldData.kt | 143 +++++++----------- 2 files changed, 55 insertions(+), 89 deletions(-) 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 0bf73c868..16faf6cad 100644 --- a/app/src/main/java/io/legado/app/data/AppDatabase.kt +++ b/app/src/main/java/io/legado/app/data/AppDatabase.kt @@ -37,6 +37,7 @@ abstract class AppDatabase : RoomDatabase() { GlobalScope.launch { Restore.restoreDatabase(Backup.backupPath) } } }) + .allowMainThreadQueries() .build() } diff --git a/app/src/main/java/io/legado/app/help/storage/ImportOldData.kt b/app/src/main/java/io/legado/app/help/storage/ImportOldData.kt index 9882e4d4f..da769dbe2 100644 --- a/app/src/main/java/io/legado/app/help/storage/ImportOldData.kt +++ b/app/src/main/java/io/legado/app/help/storage/ImportOldData.kt @@ -6,113 +6,78 @@ import androidx.documentfile.provider.DocumentFile import io.legado.app.App import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.ReplaceRule -import io.legado.app.help.coroutine.Coroutine import io.legado.app.utils.DocumentUtils import io.legado.app.utils.FileUtils -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import kotlinx.coroutines.withContext import org.jetbrains.anko.toast import java.io.File object ImportOldData { fun import(context: Context, file: File) { - GlobalScope.launch(Dispatchers.IO) { - try {// 导入书架 - val shelfFile = - FileUtils.createFileIfNotExist(file, "myBookShelf.json") - val json = shelfFile.readText() - val importCount = importOldBookshelf(json) - withContext(Dispatchers.Main) { - context.toast("成功导入书籍${importCount}") - } - } catch (e: Exception) { - withContext(Dispatchers.Main) { - context.toast("导入书籍失败\n${e.localizedMessage}") - } - } + try {// 导入书架 + val shelfFile = + FileUtils.createFileIfNotExist(file, "myBookShelf.json") + val json = shelfFile.readText() + val importCount = importOldBookshelf(json) + context.toast("成功导入书籍${importCount}") + } catch (e: Exception) { + context.toast("导入书籍失败\n${e.localizedMessage}") + } - try {// Book source - val sourceFile = - FileUtils.getFile(file, "myBookSource.json") - val json = sourceFile.readText() - val importCount = importOldSource(json) - withContext(Dispatchers.Main) { - context.toast("成功导入书源${importCount}") - } - } catch (e: Exception) { - withContext(Dispatchers.Main) { - context.toast("导入源失败\n${e.localizedMessage}") - } - } + try {// Book source + val sourceFile = + FileUtils.getFile(file, "myBookSource.json") + val json = sourceFile.readText() + val importCount = importOldSource(json) + context.toast("成功导入书源${importCount}") + } catch (e: Exception) { + context.toast("导入源失败\n${e.localizedMessage}") + } - try {// Replace rules - val ruleFile = FileUtils.getFile(file, "myBookReplaceRule.json") - if (ruleFile.exists()) { - val json = ruleFile.readText() - val importCount = importOldReplaceRule(json) - withContext(Dispatchers.Main) { - context.toast("成功导入替换规则${importCount}") - } - } else { - withContext(Dispatchers.Main) { - context.toast("未找到替换规则") - } - } - } catch (e: Exception) { - withContext(Dispatchers.Main) { - context.toast("导入替换规则失败\n${e.localizedMessage}") - } + try {// Replace rules + val ruleFile = FileUtils.getFile(file, "myBookReplaceRule.json") + if (ruleFile.exists()) { + val json = ruleFile.readText() + val importCount = importOldReplaceRule(json) + context.toast("成功导入替换规则${importCount}") + } else { + context.toast("未找到替换规则") } + } catch (e: Exception) { + context.toast("导入替换规则失败\n${e.localizedMessage}") } } fun importUri(uri: Uri) { - Coroutine.async { - DocumentFile.fromTreeUri(App.INSTANCE, uri)?.listFiles()?.forEach { - when (it.name) { - "myBookShelf.json" -> - try { - DocumentUtils.readText(App.INSTANCE, it.uri)?.let { json -> - val importCount = importOldBookshelf(json) - withContext(Dispatchers.Main) { - App.INSTANCE.toast("成功导入书籍${importCount}") - } - } - } catch (e: java.lang.Exception) { - withContext(Dispatchers.Main) { - App.INSTANCE.toast("导入书籍失败\n${e.localizedMessage}") - } + DocumentFile.fromTreeUri(App.INSTANCE, uri)?.listFiles()?.forEach { + when (it.name) { + "myBookShelf.json" -> + try { + DocumentUtils.readText(App.INSTANCE, it.uri)?.let { json -> + val importCount = importOldBookshelf(json) + App.INSTANCE.toast("成功导入书籍${importCount}") } - "myBookSource.json" -> - try { - DocumentUtils.readText(App.INSTANCE, it.uri)?.let { json -> - val importCount = importOldSource(json) - withContext(Dispatchers.Main) { - App.INSTANCE.toast("成功导入书源${importCount}") - } - } - } catch (e: Exception) { - withContext(Dispatchers.Main) { - App.INSTANCE.toast("导入源失败\n${e.localizedMessage}") - } + } catch (e: java.lang.Exception) { + App.INSTANCE.toast("导入书籍失败\n${e.localizedMessage}") + } + "myBookSource.json" -> + try { + DocumentUtils.readText(App.INSTANCE, it.uri)?.let { json -> + val importCount = importOldSource(json) + App.INSTANCE.toast("成功导入书源${importCount}") } - "myBookReplaceRule.json" -> - try { - DocumentUtils.readText(App.INSTANCE, it.uri)?.let { json -> - val importCount = importOldReplaceRule(json) - withContext(Dispatchers.Main) { - App.INSTANCE.toast("成功导入替换规则${importCount}") - } - } - } catch (e: Exception) { - withContext(Dispatchers.Main) { - App.INSTANCE.toast("导入替换规则失败\n${e.localizedMessage}") - } + } catch (e: Exception) { + App.INSTANCE.toast("导入源失败\n${e.localizedMessage}") + } + "myBookReplaceRule.json" -> + try { + DocumentUtils.readText(App.INSTANCE, it.uri)?.let { json -> + val importCount = importOldReplaceRule(json) + App.INSTANCE.toast("成功导入替换规则${importCount}") } - } + } catch (e: Exception) { + App.INSTANCE.toast("导入替换规则失败\n${e.localizedMessage}") + } } } } From 5aeecdc801cd45a88bf347a00b7c013e754b5ffa Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 17 Jun 2020 21:10:41 +0800 Subject: [PATCH 231/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 1cbc36801..30242228b 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,10 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/06/17** +* 修复更新书架时更新禁止更新的问题 +* 修复导入旧版本数据问题 + **2020/06/16** * 刷新时只刷新当前书架 * 修复恢复备份需要退出重进的问题 From df09bf25b4759b62e767fbdc2a0bd12fa5724cef Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 18 Jun 2020 19:31:17 +0800 Subject: [PATCH 232/296] =?UTF-8?q?feat:=20fadeapp.widgets:scrollless-recy?= =?UTF-8?q?clerView=E5=AF=BC=E8=87=B4=E6=9C=89=E4=BA=9B=E6=89=8B=E6=9C=BA?= =?UTF-8?q?=E9=87=8D=E5=BD=B1,=E6=9A=82=E6=97=B6=E5=8E=BB=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 4 +- .../io/legado/app/ui/about/AboutFragment.kt | 4 +- .../io/legado/app/ui/about/DonateFragment.kt | 4 +- .../ui/book/arrange/ArrangeBookActivity.kt | 2 - .../ui/book/changecover/ChangeCoverDialog.kt | 2 - .../book/changesource/ChangeSourceDialog.kt | 2 - .../app/ui/book/download/DownloadActivity.kt | 2 - .../ui/book/explore/ExploreShowActivity.kt | 2 - .../app/ui/book/group/GroupManageDialog.kt | 1 - .../app/ui/book/group/GroupSelectDialog.kt | 2 - .../app/ui/book/local/ImportBookActivity.kt | 1 - .../legado/app/ui/book/read/TextActionMenu.kt | 2 - .../ui/book/read/config/BgTextConfigDialog.kt | 2 - .../ui/book/read/config/MoreConfigDialog.kt | 4 +- .../book/read/config/ReadAloudConfigDialog.kt | 4 +- .../app/ui/book/read/config/TocRegexDialog.kt | 2 - .../app/ui/book/search/SearchActivity.kt | 4 -- .../source/debug/BookSourceDebugActivity.kt | 2 - .../source/edit/BookSourceEditActivity.kt | 2 - .../book/source/manage/BookSourceActivity.kt | 2 - .../book/source/manage/GroupManageDialog.kt | 2 - .../app/ui/config/BackupConfigFragment.kt | 4 +- .../app/ui/config/OtherConfigFragment.kt | 3 +- .../app/ui/config/ThemeConfigFragment.kt | 4 +- .../app/ui/filechooser/FileChooserDialog.kt | 3 -- .../ui/main/bookshelf/books/BooksFragment.kt | 2 - .../app/ui/main/explore/ExploreFragment.kt | 2 - .../io/legado/app/ui/main/my/MyFragment.kt | 3 +- .../io/legado/app/ui/main/rss/RssFragment.kt | 2 - .../app/ui/replacerule/GroupManageDialog.kt | 2 - .../app/ui/replacerule/ReplaceRuleActivity.kt | 2 - .../source/debug/RssSourceDebugActivity.kt | 2 - .../rss/source/edit/RssSourceEditActivity.kt | 2 - .../ui/rss/source/manage/GroupManageDialog.kt | 2 - .../ui/rss/source/manage/RssSourceActivity.kt | 2 - .../legado/app/ui/widget/KeyboardToolPop.kt | 2 - .../app/ui/widget/font/FontSelectDialog.kt | 1 - .../app/ui/widget/prefs/IconListPreference.kt | 2 - .../ui/widget/recycler/RefreshRecyclerView.kt | 2 - .../scroller/FastScrollRecyclerView.kt | 5 +-- .../app/utils/PreferenceFragmentSupport.kt | 41 ------------------- .../main/res/layout/activity_arrange_book.xml | 2 +- .../main/res/layout/activity_book_search.xml | 10 ++--- .../res/layout/activity_book_source_edit.xml | 2 +- app/src/main/res/layout/activity_download.xml | 2 +- .../main/res/layout/activity_explore_show.xml | 2 +- .../main/res/layout/activity_import_book.xml | 2 +- .../main/res/layout/activity_replace_rule.xml | 2 +- .../res/layout/activity_rss_source_edit.xml | 2 +- .../main/res/layout/activity_source_debug.xml | 2 +- .../res/layout/dialog_book_group_picker.xml | 2 +- .../main/res/layout/dialog_change_cover.xml | 2 +- .../main/res/layout/dialog_change_source.xml | 2 +- .../main/res/layout/dialog_file_chooser.xml | 4 +- .../main/res/layout/dialog_font_select.xml | 2 +- .../main/res/layout/dialog_read_bg_text.xml | 2 +- .../main/res/layout/dialog_recycler_view.xml | 2 +- app/src/main/res/layout/dialog_toc_regex.xml | 2 +- app/src/main/res/layout/fragment_books.xml | 2 +- .../main/res/layout/fragment_find_book.xml | 2 +- app/src/main/res/layout/fragment_rss.xml | 2 +- app/src/main/res/layout/popup_action_menu.xml | 4 +- .../main/res/layout/popup_keyboard_tool.xml | 2 +- .../main/res/layout/view_refresh_recycler.xml | 2 +- 64 files changed, 49 insertions(+), 149 deletions(-) delete mode 100644 app/src/main/java/io/legado/app/utils/PreferenceFragmentSupport.kt diff --git a/app/build.gradle b/app/build.gradle index 1e827329c..7c6d6b445 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -194,8 +194,8 @@ dependencies { //转换繁体 implementation 'com.hankcs:hanlp:portable-1.7.7' - //E-Ink - implementation 'fadeapp.widgets:scrollless-recyclerView:1.0.2' + //E-Ink 有些手机会出现重影 + //implementation 'fadeapp.widgets:scrollless-recyclerView:1.0.2' } apply plugin: 'com.google.gms.google-services' \ No newline at end of file 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 17c7eb4e6..e44666349 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 @@ -6,16 +6,16 @@ import android.os.Bundle import android.view.View import androidx.annotation.StringRes import androidx.preference.Preference +import androidx.preference.PreferenceFragmentCompat import io.legado.app.App import io.legado.app.R import io.legado.app.lib.dialogs.alert import io.legado.app.ui.widget.dialog.TextDialog -import io.legado.app.utils.PreferenceFragmentSupport import io.legado.app.utils.openUrl import io.legado.app.utils.sendToClip import io.legado.app.utils.toast -class AboutFragment : PreferenceFragmentSupport() { +class AboutFragment : PreferenceFragmentCompat() { private val licenseUrl = "https://github.com/gedoor/legado/blob/master/LICENSE" private val disclaimerUrl = "https://gedoor.github.io/MyBookshelf/disclaimer.html" diff --git a/app/src/main/java/io/legado/app/ui/about/DonateFragment.kt b/app/src/main/java/io/legado/app/ui/about/DonateFragment.kt index 6223b5865..b716c8f05 100644 --- a/app/src/main/java/io/legado/app/ui/about/DonateFragment.kt +++ b/app/src/main/java/io/legado/app/ui/about/DonateFragment.kt @@ -5,14 +5,14 @@ import android.content.Intent import android.os.Bundle import android.view.View import androidx.preference.Preference +import androidx.preference.PreferenceFragmentCompat import io.legado.app.R import io.legado.app.utils.ACache -import io.legado.app.utils.PreferenceFragmentSupport import io.legado.app.utils.openUrl import io.legado.app.utils.sendToClip import org.jetbrains.anko.longToast -class DonateFragment : PreferenceFragmentSupport() { +class DonateFragment : PreferenceFragmentCompat() { private val zfbHbRwmUrl = "https://gitee.com/gekunfei/Donate/raw/master/zfbhbrwm.png" private val zfbSkRwmUrl = "https://gitee.com/gekunfei/Donate/raw/master/zfbskrwm.jpg" diff --git a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt index 2d93dfdee..491922cb1 100644 --- a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt @@ -15,7 +15,6 @@ import io.legado.app.constant.AppConst import io.legado.app.constant.PreferKey import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookGroup -import io.legado.app.help.AppConfig import io.legado.app.help.ItemTouchCallback import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.noButton @@ -66,7 +65,6 @@ class ArrangeBookActivity : VMBaseActivity(R.layout.activi private fun initView() { ATH.applyEdgeEffectColor(recycler_view) - recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(this) recycler_view.addItemDecoration(VerticalDivider(this)) adapter = ArrangeBookAdapter(this, this) diff --git a/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt b/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt index 0df08af73..85df58172 100644 --- a/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt @@ -14,7 +14,6 @@ import androidx.recyclerview.widget.GridLayoutManager import io.legado.app.R import io.legado.app.base.BaseDialogFragment import io.legado.app.constant.Theme -import io.legado.app.help.AppConfig import io.legado.app.utils.applyTint import io.legado.app.utils.getViewModel import kotlinx.android.synthetic.main.dialog_change_source.* @@ -74,7 +73,6 @@ class ChangeCoverDialog : BaseDialogFragment(), } private fun initView() { - recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = GridLayoutManager(requireContext(), 3) adapter = CoverAdapter(requireContext(), this) recycler_view.adapter = adapter diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt index 09e1cdb74..09fa066ec 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt @@ -19,7 +19,6 @@ import io.legado.app.constant.PreferKey import io.legado.app.constant.Theme import io.legado.app.data.entities.Book import io.legado.app.data.entities.SearchBook -import io.legado.app.help.AppConfig import io.legado.app.ui.widget.recycler.VerticalDivider import io.legado.app.utils.applyTint import io.legado.app.utils.getPrefBoolean @@ -93,7 +92,6 @@ class ChangeSourceDialog : BaseDialogFragment(), private fun initRecyclerView() { adapter = ChangeSourceAdapter(requireContext(), this) - recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(context) recycler_view.addItemDecoration(VerticalDivider(requireContext())) recycler_view.adapter = adapter diff --git a/app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt b/app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt index 83bf7487e..b0f860527 100644 --- a/app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt @@ -16,7 +16,6 @@ import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter -import io.legado.app.help.AppConfig import io.legado.app.help.BookHelp import io.legado.app.service.help.Download import io.legado.app.ui.filechooser.FileChooserDialog @@ -75,7 +74,6 @@ class DownloadActivity : VMBaseActivity(R.layout.activity_dow } private fun initRecyclerView() { - recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(this) adapter = DownloadAdapter(this, this) recycler_view.adapter = adapter 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 1d0fa4c80..dbba6b63e 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 @@ -8,7 +8,6 @@ import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.data.entities.Book import io.legado.app.data.entities.SearchBook -import io.legado.app.help.AppConfig import io.legado.app.ui.book.info.BookInfoActivity import io.legado.app.ui.widget.recycler.LoadMoreView import io.legado.app.ui.widget.recycler.VerticalDivider @@ -33,7 +32,6 @@ class ExploreShowActivity : VMBaseActivity(R.layout.activi } private fun initRecyclerView() { - recycler_view.isEnableScroll = !AppConfig.isEInkMode adapter = ExploreShowAdapter(this, this) recycler_view.layoutManager = LinearLayoutManager(this) recycler_view.addItemDecoration(VerticalDivider(this)) diff --git a/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt b/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt index cfe8f4278..a5d719b57 100644 --- a/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt @@ -71,7 +71,6 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener { private fun initData() { adapter = GroupAdapter(requireContext()) - recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(requireContext()) recycler_view.addItemDecoration(VerticalDivider(requireContext())) recycler_view.adapter = adapter diff --git a/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt b/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt index 1976c8b2e..9440a7c46 100644 --- a/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt @@ -22,7 +22,6 @@ import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.constant.Theme import io.legado.app.data.entities.BookGroup -import io.legado.app.help.AppConfig import io.legado.app.help.ItemTouchCallback import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.customView @@ -97,7 +96,6 @@ class GroupSelectDialog : DialogFragment(), Toolbar.OnMenuItemClickListener { tool_bar.setOnMenuItemClickListener(this) tool_bar.menu.setGroupVisible(R.id.menu_groups, false) adapter = GroupAdapter(requireContext()) - recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(requireContext()) recycler_view.addItemDecoration(VerticalDivider(requireContext())) recycler_view.adapter = adapter diff --git a/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt index eb3943200..3ce47ee99 100644 --- a/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt @@ -62,7 +62,6 @@ class ImportBookActivity : VMBaseActivity(R.layout.activity } private fun initView() { - recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(this) adapter = ImportBookAdapter(this, this) recycler_view.adapter = adapter diff --git a/app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt b/app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt index 673942b5c..5c8d1d214 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt @@ -20,7 +20,6 @@ import androidx.core.view.isVisible import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter -import io.legado.app.help.AppConfig import io.legado.app.service.BaseReadAloudService import io.legado.app.utils.gone import io.legado.app.utils.isAbsUrl @@ -62,7 +61,6 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac } private fun initRecyclerView() = with(contentView) { - recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.adapter = adapter recycler_view_more.adapter = adapter SupportMenuInflater(context).inflate(R.menu.content_select_action, menu) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt index 5e7bd17eb..73f85dce0 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt @@ -22,7 +22,6 @@ import io.legado.app.base.BaseDialogFragment import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.constant.EventBus -import io.legado.app.help.AppConfig import io.legado.app.help.ImageLoader import io.legado.app.help.ReadBookConfig import io.legado.app.help.permission.Permissions @@ -84,7 +83,6 @@ class BgTextConfigDialog : BaseDialogFragment() { private fun initData() = with(ReadBookConfig.durConfig) { sw_dark_status_icon.isChecked = statusIconDark() adapter = BgAdapter(requireContext()) - recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(requireContext(), RecyclerView.HORIZONTAL, false) recycler_view.adapter = adapter diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt index cf1558087..7033b82d0 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt @@ -10,6 +10,7 @@ import android.view.ViewGroup import android.widget.LinearLayout import androidx.fragment.app.DialogFragment import androidx.preference.Preference +import androidx.preference.PreferenceFragmentCompat import io.legado.app.R import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey @@ -17,7 +18,6 @@ import io.legado.app.help.ReadBookConfig import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.bottomBackground import io.legado.app.ui.book.read.Help -import io.legado.app.utils.PreferenceFragmentSupport import io.legado.app.utils.dp import io.legado.app.utils.getPrefBoolean import io.legado.app.utils.postEvent @@ -64,7 +64,7 @@ class MoreConfigDialog : DialogFragment() { .commit() } - class ReadPreferenceFragment : PreferenceFragmentSupport(), + class ReadPreferenceFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedPreferenceChangeListener { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudConfigDialog.kt index dd5eadf9c..cdb10159e 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudConfigDialog.kt @@ -10,6 +10,7 @@ import android.widget.LinearLayout import androidx.fragment.app.DialogFragment import androidx.preference.ListPreference import androidx.preference.Preference +import androidx.preference.PreferenceFragmentCompat import io.legado.app.R import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey @@ -19,7 +20,6 @@ import io.legado.app.lib.theme.backgroundColor import io.legado.app.service.BaseReadAloudService import io.legado.app.service.help.ReadAloud import io.legado.app.ui.book.read.Help -import io.legado.app.utils.PreferenceFragmentSupport import io.legado.app.utils.postEvent class ReadAloudConfigDialog : DialogFragment() { @@ -59,7 +59,7 @@ class ReadAloudConfigDialog : DialogFragment() { .commit() } - class ReadAloudPreferenceFragment : PreferenceFragmentSupport(), + class ReadAloudPreferenceFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedPreferenceChangeListener { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt index f60f4e1e8..300a507ea 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt @@ -23,7 +23,6 @@ import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.constant.Theme import io.legado.app.data.entities.TxtTocRule -import io.legado.app.help.AppConfig import io.legado.app.help.ItemTouchCallback import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.cancelButton @@ -78,7 +77,6 @@ class TocRegexDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { private fun initView() { adapter = TocRegexAdapter(requireContext()) - recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(requireContext()) recycler_view.addItemDecoration(VerticalDivider(requireContext())) recycler_view.adapter = adapter diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt index fe30270df..3d12157d5 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt @@ -18,7 +18,6 @@ import io.legado.app.constant.PreferKey import io.legado.app.data.entities.Book import io.legado.app.data.entities.SearchBook import io.legado.app.data.entities.SearchKeyword -import io.legado.app.help.AppConfig import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.primaryTextColor import io.legado.app.ui.book.info.BookInfoActivity @@ -135,9 +134,6 @@ class SearchActivity : VMBaseActivity(R.layout.activity_book_se ATH.applyEdgeEffectColor(recycler_view) ATH.applyEdgeEffectColor(rv_bookshelf_search) ATH.applyEdgeEffectColor(rv_history_key) - recycler_view.isEnableScroll = !AppConfig.isEInkMode - rv_bookshelf_search.isEnableScroll = !AppConfig.isEInkMode - rv_history_key.isEnableScroll = !AppConfig.isEInkMode bookAdapter = BookAdapter(this, this) rv_bookshelf_search.layoutManager = FlexboxLayoutManager(this) rv_bookshelf_search.adapter = bookAdapter diff --git a/app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugActivity.kt index 27ca73b26..75ac065e0 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugActivity.kt @@ -8,7 +8,6 @@ import androidx.appcompat.widget.SearchView import androidx.recyclerview.widget.LinearLayoutManager import io.legado.app.R import io.legado.app.base.VMBaseActivity -import io.legado.app.help.AppConfig import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.accentColor import io.legado.app.ui.qrcode.QrCodeActivity @@ -45,7 +44,6 @@ class BookSourceDebugActivity : private fun initRecyclerView() { ATH.applyEdgeEffectColor(recycler_view) adapter = BookSourceDebugAdapter(this) - recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(this) recycler_view.adapter = adapter rotate_loading.loadingColor = accentColor diff --git a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt index 1a12bdac7..71ee36149 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt @@ -21,7 +21,6 @@ import io.legado.app.base.VMBaseActivity import io.legado.app.constant.AppConst import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.rule.* -import io.legado.app.help.AppConfig import io.legado.app.lib.dialogs.alert import io.legado.app.lib.theme.ATH import io.legado.app.ui.book.source.debug.BookSourceDebugActivity @@ -121,7 +120,6 @@ class BookSourceEditActivity : ATH.applyEdgeEffectColor(recycler_view) mSoftKeyboardTool = KeyboardToolPop(this, AppConst.keyboardToolChars, this) window.decorView.viewTreeObserver.addOnGlobalLayoutListener(KeyboardOnGlobalChangeListener()) - recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(this) recycler_view.adapter = adapter tab_layout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener { diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt index 583d6864c..d5feb380c 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt @@ -20,7 +20,6 @@ import io.legado.app.App import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.data.entities.BookSource -import io.legado.app.help.AppConfig import io.legado.app.help.ItemTouchCallback import io.legado.app.lib.dialogs.* import io.legado.app.lib.theme.ATH @@ -153,7 +152,6 @@ class BookSourceActivity : VMBaseActivity(R.layout.activity private fun initRecyclerView() { ATH.applyEdgeEffectColor(recycler_view) - recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(this) recycler_view.addItemDecoration(VerticalDivider(this)) adapter = BookSourceAdapter(this, this) diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/GroupManageDialog.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/GroupManageDialog.kt index 523109569..d4a466948 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/GroupManageDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/GroupManageDialog.kt @@ -18,7 +18,6 @@ import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.constant.Theme -import io.legado.app.help.AppConfig import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.customView import io.legado.app.lib.dialogs.noButton @@ -64,7 +63,6 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener { tool_bar.menu.applyTint(requireContext(), Theme.getTheme()) tool_bar.setOnMenuItemClickListener(this) adapter = GroupAdapter(requireContext()) - recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(requireContext()) recycler_view.addItemDecoration(VerticalDivider(requireContext())) recycler_view.adapter = adapter diff --git a/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt index 7ff39a7b3..9df96e3f2 100644 --- a/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt @@ -8,15 +8,15 @@ import android.view.View import androidx.preference.EditTextPreference import androidx.preference.ListPreference import androidx.preference.Preference +import androidx.preference.PreferenceFragmentCompat import io.legado.app.R import io.legado.app.constant.PreferKey import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.accentColor import io.legado.app.ui.filechooser.FileChooserDialog -import io.legado.app.utils.PreferenceFragmentSupport import io.legado.app.utils.getPrefString -class BackupConfigFragment : PreferenceFragmentSupport(), +class BackupConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedPreferenceChangeListener, FileChooserDialog.CallBack { diff --git a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt index 07a70b110..f23fee053 100644 --- a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt @@ -7,6 +7,7 @@ import android.os.Bundle import android.view.View import androidx.preference.ListPreference import androidx.preference.Preference +import androidx.preference.PreferenceFragmentCompat import io.legado.app.App import io.legado.app.R import io.legado.app.constant.EventBus @@ -20,7 +21,7 @@ import io.legado.app.ui.widget.number.NumberPickerDialog import io.legado.app.utils.* -class OtherConfigFragment : PreferenceFragmentSupport(), +class OtherConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedPreferenceChangeListener { private val packageManager = App.INSTANCE.packageManager 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 774dd07e0..13d12c4b0 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 @@ -9,6 +9,7 @@ import android.view.MenuInflater import android.view.MenuItem import android.view.View import androidx.preference.Preference +import androidx.preference.PreferenceFragmentCompat import io.legado.app.App import io.legado.app.R import io.legado.app.constant.EventBus @@ -25,7 +26,8 @@ import io.legado.app.ui.widget.prefs.IconListPreference import io.legado.app.utils.* -class ThemeConfigFragment : PreferenceFragmentSupport(), SharedPreferences.OnSharedPreferenceChangeListener { +class ThemeConfigFragment : PreferenceFragmentCompat(), + SharedPreferences.OnSharedPreferenceChangeListener { val items = arrayListOf("极简", "曜夜", "经典", "黑白", "A屏黑") diff --git a/app/src/main/java/io/legado/app/ui/filechooser/FileChooserDialog.kt b/app/src/main/java/io/legado/app/ui/filechooser/FileChooserDialog.kt index c3f6092bd..f1e6a7bc9 100644 --- a/app/src/main/java/io/legado/app/ui/filechooser/FileChooserDialog.kt +++ b/app/src/main/java/io/legado/app/ui/filechooser/FileChooserDialog.kt @@ -13,7 +13,6 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import io.legado.app.R import io.legado.app.constant.Theme -import io.legado.app.help.AppConfig import io.legado.app.ui.filechooser.adapter.FileAdapter import io.legado.app.ui.filechooser.adapter.PathAdapter import io.legado.app.ui.widget.recycler.VerticalDivider @@ -138,12 +137,10 @@ class FileChooserDialog : DialogFragment(), fileAdapter = FileAdapter(requireContext(), this) pathAdapter = PathAdapter(requireContext(), this) - rv_file.isEnableScroll = !AppConfig.isEInkMode rv_file.addItemDecoration(VerticalDivider(requireContext())) rv_file.layoutManager = LinearLayoutManager(activity) rv_file.adapter = fileAdapter - rv_path.isEnableScroll = !AppConfig.isEInkMode rv_path.layoutManager = LinearLayoutManager(activity, RecyclerView.HORIZONTAL, false) rv_path.adapter = pathAdapter diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt index c7395c4dd..4d3d51663 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt @@ -16,7 +16,6 @@ import io.legado.app.constant.BookType import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey import io.legado.app.data.entities.Book -import io.legado.app.help.AppConfig import io.legado.app.help.IntentDataHelp import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.accentColor @@ -77,7 +76,6 @@ class BooksFragment : BaseFragment(R.layout.fragment_books), rv_bookshelf.layoutManager = GridLayoutManager(context, bookshelfLayout + 2) booksAdapter = BooksAdapterGrid(requireContext(), this) } - rv_bookshelf.isEnableScroll = !AppConfig.isEInkMode rv_bookshelf.adapter = booksAdapter booksAdapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() { override fun onItemRangeInserted(positionStart: Int, itemCount: Int) { diff --git a/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt b/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt index 72d2abb78..c8f93fc64 100644 --- a/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt @@ -15,7 +15,6 @@ import io.legado.app.App import io.legado.app.R import io.legado.app.base.VMBaseFragment import io.legado.app.data.entities.BookSource -import io.legado.app.help.AppConfig import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.primaryTextColor import io.legado.app.ui.book.explore.ExploreShowActivity @@ -76,7 +75,6 @@ class ExploreFragment : VMBaseFragment(R.layout.fragment_find_ private fun initRecyclerView() { ATH.applyEdgeEffectColor(rv_find) - rv_find.isEnableScroll = !AppConfig.isEInkMode linearLayoutManager = LinearLayoutManager(context) rv_find.layoutManager = linearLayoutManager adapter = ExploreAdapter(requireContext(), this, this) diff --git a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt index 724b084c4..0a59c49c1 100644 --- a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt @@ -7,6 +7,7 @@ import android.view.Menu import android.view.MenuItem import android.view.View import androidx.preference.Preference +import androidx.preference.PreferenceFragmentCompat import io.legado.app.App import io.legado.app.R import io.legado.app.base.BaseFragment @@ -66,7 +67,7 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog. BackupRestoreUi.onActivityResult(requestCode, resultCode, data) } - class PreferenceFragment : PreferenceFragmentSupport(), + class PreferenceFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedPreferenceChangeListener { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { diff --git a/app/src/main/java/io/legado/app/ui/main/rss/RssFragment.kt b/app/src/main/java/io/legado/app/ui/main/rss/RssFragment.kt index 2a2f90dc1..334ce9e64 100644 --- a/app/src/main/java/io/legado/app/ui/main/rss/RssFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/rss/RssFragment.kt @@ -10,7 +10,6 @@ import io.legado.app.App import io.legado.app.R import io.legado.app.base.VMBaseFragment import io.legado.app.data.entities.RssSource -import io.legado.app.help.AppConfig import io.legado.app.lib.theme.ATH import io.legado.app.ui.main.MainViewModel import io.legado.app.ui.rss.article.RssSortActivity @@ -52,7 +51,6 @@ class RssFragment : VMBaseFragment(R.layout.fragment_rss), private fun initRecyclerView() { ATH.applyEdgeEffectColor(recycler_view) adapter = RssAdapter(requireContext(), this) - recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = GridLayoutManager(requireContext(), 4) recycler_view.adapter = adapter } diff --git a/app/src/main/java/io/legado/app/ui/replacerule/GroupManageDialog.kt b/app/src/main/java/io/legado/app/ui/replacerule/GroupManageDialog.kt index 165df103b..df39b9a1d 100644 --- a/app/src/main/java/io/legado/app/ui/replacerule/GroupManageDialog.kt +++ b/app/src/main/java/io/legado/app/ui/replacerule/GroupManageDialog.kt @@ -18,7 +18,6 @@ import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.constant.Theme -import io.legado.app.help.AppConfig import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.customView import io.legado.app.lib.dialogs.noButton @@ -64,7 +63,6 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener { tool_bar.menu.applyTint(requireContext(), Theme.getTheme()) tool_bar.setOnMenuItemClickListener(this) adapter = GroupAdapter(requireContext()) - recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(requireContext()) recycler_view.addItemDecoration(VerticalDivider(requireContext())) recycler_view.adapter = adapter 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 2e9139774..1f9057e35 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 @@ -20,7 +20,6 @@ import io.legado.app.App import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.data.entities.ReplaceRule -import io.legado.app.help.AppConfig import io.legado.app.help.BookHelp import io.legado.app.help.ItemTouchCallback import io.legado.app.help.coroutine.Coroutine @@ -102,7 +101,6 @@ class ReplaceRuleActivity : VMBaseActivity(R.layout.activi private fun initRecyclerView() { ATH.applyEdgeEffectColor(recycler_view) - recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(this) adapter = ReplaceRuleAdapter(this, this) recycler_view.adapter = adapter diff --git a/app/src/main/java/io/legado/app/ui/rss/source/debug/RssSourceDebugActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/debug/RssSourceDebugActivity.kt index 4ac48f0de..b97bae3ea 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/debug/RssSourceDebugActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/debug/RssSourceDebugActivity.kt @@ -4,7 +4,6 @@ import android.os.Bundle import androidx.recyclerview.widget.LinearLayoutManager import io.legado.app.R import io.legado.app.base.VMBaseActivity -import io.legado.app.help.AppConfig import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.accentColor import io.legado.app.utils.getViewModel @@ -41,7 +40,6 @@ class RssSourceDebugActivity : VMBaseActivity(R.layout.acti private fun initRecyclerView() { ATH.applyEdgeEffectColor(recycler_view) adapter = RssSourceDebugAdapter(this) - recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(this) recycler_view.adapter = adapter rotate_loading.loadingColor = accentColor diff --git a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt index 79f38d9e2..bd070639a 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt @@ -18,7 +18,6 @@ import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.constant.AppConst import io.legado.app.data.entities.RssSource -import io.legado.app.help.AppConfig import io.legado.app.lib.dialogs.alert import io.legado.app.lib.theme.ATH import io.legado.app.ui.qrcode.QrCodeActivity @@ -120,7 +119,6 @@ class RssSourceEditActivity : ATH.applyEdgeEffectColor(recycler_view) mSoftKeyboardTool = KeyboardToolPop(this, AppConst.keyboardToolChars, this) window.decorView.viewTreeObserver.addOnGlobalLayoutListener(this) - recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(this) recycler_view.adapter = adapter } diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/GroupManageDialog.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/GroupManageDialog.kt index a0f23d4e4..ce2313f5a 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/GroupManageDialog.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/GroupManageDialog.kt @@ -18,7 +18,6 @@ import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.constant.Theme -import io.legado.app.help.AppConfig import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.customView import io.legado.app.lib.dialogs.noButton @@ -62,7 +61,6 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener { tool_bar.menu.applyTint(requireContext(), Theme.getTheme()) tool_bar.setOnMenuItemClickListener(this) adapter = GroupAdapter(requireContext()) - recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(requireContext()) recycler_view.addItemDecoration(VerticalDivider(requireContext())) recycler_view.adapter = adapter diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt index 81e1046c7..be9866ef2 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt @@ -20,7 +20,6 @@ import io.legado.app.App import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.data.entities.RssSource -import io.legado.app.help.AppConfig import io.legado.app.help.ItemTouchCallback import io.legado.app.lib.dialogs.* import io.legado.app.lib.theme.ATH @@ -138,7 +137,6 @@ class RssSourceActivity : VMBaseActivity(R.layout.activity_r private fun initRecyclerView() { ATH.applyEdgeEffectColor(recycler_view) - recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(this) recycler_view.addItemDecoration(VerticalDivider(this)) adapter = RssSourceAdapter(this, this) diff --git a/app/src/main/java/io/legado/app/ui/widget/KeyboardToolPop.kt b/app/src/main/java/io/legado/app/ui/widget/KeyboardToolPop.kt index 76f30efff..56dff107c 100644 --- a/app/src/main/java/io/legado/app/ui/widget/KeyboardToolPop.kt +++ b/app/src/main/java/io/legado/app/ui/widget/KeyboardToolPop.kt @@ -10,7 +10,6 @@ import androidx.recyclerview.widget.RecyclerView import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter -import io.legado.app.help.AppConfig import kotlinx.android.synthetic.main.item_fillet_text.view.* import kotlinx.android.synthetic.main.popup_keyboard_tool.view.* import org.jetbrains.anko.sdk27.listeners.onClick @@ -35,7 +34,6 @@ class KeyboardToolPop( private fun initRecyclerView() = with(contentView) { val adapter = Adapter(context) - recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(context, RecyclerView.HORIZONTAL, false) recycler_view.adapter = adapter adapter.setItems(chars) diff --git a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt index 4f8dd67a9..8157ed870 100644 --- a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt +++ b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt @@ -64,7 +64,6 @@ class FontSelectDialog : BaseDialogFragment(), tool_bar.setTitle(R.string.select_font) tool_bar.inflateMenu(R.menu.font_select) tool_bar.setOnMenuItemClickListener(this) - recycler_view.isEnableScroll = !AppConfig.isEInkMode adapter = FontAdapter(requireContext(), this) recycler_view.layoutManager = LinearLayoutManager(context) recycler_view.adapter = adapter diff --git a/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt b/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt index f8eb233c0..fa8b4eeb7 100644 --- a/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt +++ b/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt @@ -18,7 +18,6 @@ import androidx.recyclerview.widget.LinearLayoutManager import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter -import io.legado.app.help.AppConfig import io.legado.app.utils.getCompatDrawable import kotlinx.android.synthetic.main.dialog_recycler_view.* import kotlinx.android.synthetic.main.item_icon_preference.view.* @@ -139,7 +138,6 @@ class IconListPreference(context: Context, attrs: AttributeSet) : ListPreference override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) tool_bar.setTitle(R.string.change_icon) - recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.layoutManager = LinearLayoutManager(requireContext()) val adapter = Adapter(requireContext()) recycler_view.adapter = adapter diff --git a/app/src/main/java/io/legado/app/ui/widget/recycler/RefreshRecyclerView.kt b/app/src/main/java/io/legado/app/ui/widget/recycler/RefreshRecyclerView.kt index 2cc3c40a8..931a7d138 100644 --- a/app/src/main/java/io/legado/app/ui/widget/recycler/RefreshRecyclerView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/recycler/RefreshRecyclerView.kt @@ -9,7 +9,6 @@ import android.view.View import android.widget.LinearLayout import androidx.recyclerview.widget.LinearLayoutManager import io.legado.app.R -import io.legado.app.help.AppConfig import kotlinx.android.synthetic.main.view_refresh_recycler.view.* @@ -23,7 +22,6 @@ class RefreshRecyclerView(context: Context?, attrs: AttributeSet?) : LinearLayou init { orientation = VERTICAL LayoutInflater.from(context).inflate(R.layout.view_refresh_recycler, this, true) - recycler_view.isEnableScroll = !AppConfig.isEInkMode recycler_view.setOnTouchListener(object : OnTouchListener { @SuppressLint("ClickableViewAccessibility") override fun onTouch(v: View?, event: MotionEvent?): Boolean { diff --git a/app/src/main/java/io/legado/app/ui/widget/recycler/scroller/FastScrollRecyclerView.kt b/app/src/main/java/io/legado/app/ui/widget/recycler/scroller/FastScrollRecyclerView.kt index e835e4514..c2ebb8352 100644 --- a/app/src/main/java/io/legado/app/ui/widget/recycler/scroller/FastScrollRecyclerView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/recycler/scroller/FastScrollRecyclerView.kt @@ -5,11 +5,9 @@ import android.util.AttributeSet import android.view.ViewGroup import androidx.annotation.ColorInt import androidx.recyclerview.widget.RecyclerView -import fadeapp.widgets.ScrollLessRecyclerView import io.legado.app.R -import io.legado.app.help.AppConfig -class FastScrollRecyclerView : ScrollLessRecyclerView { +class FastScrollRecyclerView : RecyclerView { private var mFastScroller: FastScroller? = null @@ -191,7 +189,6 @@ class FastScrollRecyclerView : ScrollLessRecyclerView { private fun layout(context: Context, attrs: AttributeSet?) { mFastScroller = FastScroller(context, attrs) mFastScroller?.id = R.id.fast_scroller - isEnableScroll = !AppConfig.isEInkMode } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/utils/PreferenceFragmentSupport.kt b/app/src/main/java/io/legado/app/utils/PreferenceFragmentSupport.kt deleted file mode 100644 index 23848fb52..000000000 --- a/app/src/main/java/io/legado/app/utils/PreferenceFragmentSupport.kt +++ /dev/null @@ -1,41 +0,0 @@ -package io.legado.app.utils - -import android.content.pm.PackageManager -import android.os.Bundle -import android.view.LayoutInflater -import android.view.ViewGroup -import androidx.core.view.setPadding -import androidx.preference.PreferenceFragmentCompat -import androidx.preference.PreferenceRecyclerViewAccessibilityDelegate -import androidx.recyclerview.widget.RecyclerView -import fadeapp.widgets.ScrollLessRecyclerView -import io.legado.app.R -import io.legado.app.help.AppConfig - -abstract class PreferenceFragmentSupport : PreferenceFragmentCompat(){ - - override fun onCreateRecyclerView( - inflater: LayoutInflater, - parent: ViewGroup, - savedInstanceState: Bundle? - ): RecyclerView { - - if (context?.packageManager?.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)==true) { - val recyclerView: RecyclerView?= parent.findViewById(R.id.recycler_view) - if (recyclerView != null) { - return recyclerView - } - } - val recyclerView = ScrollLessRecyclerView(inflater.context,null,R.attr.preferenceFragmentListStyle) - recyclerView.id = R.id.recycler_view - recyclerView.setPadding(0) - recyclerView.clipToPadding = false - recyclerView.isEnableScroll = !AppConfig.isEInkMode - recyclerView.layoutManager = onCreateLayoutManager() - recyclerView.setAccessibilityDelegateCompat( - PreferenceRecyclerViewAccessibilityDelegate(recyclerView) - ) - - return recyclerView - } -} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_arrange_book.xml b/app/src/main/res/layout/activity_arrange_book.xml index b93bb8dbe..1be7bdb41 100644 --- a/app/src/main/res/layout/activity_arrange_book.xml +++ b/app/src/main/res/layout/activity_arrange_book.xml @@ -11,7 +11,7 @@ android:layout_height="wrap_content" app:title="@string/arrange_bookshelf" /> - - + android:layout_width="match_parent" + android:layout_height="match_parent" /> @@ -56,7 +56,7 @@ android:text="@string/bookshelf" android:visibility="gone" /> - - diff --git a/app/src/main/res/layout/activity_book_source_edit.xml b/app/src/main/res/layout/activity_book_source_edit.xml index 53f152e06..ab8104256 100644 --- a/app/src/main/res/layout/activity_book_source_edit.xml +++ b/app/src/main/res/layout/activity_book_source_edit.xml @@ -96,7 +96,7 @@ - diff --git a/app/src/main/res/layout/activity_download.xml b/app/src/main/res/layout/activity_download.xml index fcbe9933d..2f7ebd6f2 100644 --- a/app/src/main/res/layout/activity_download.xml +++ b/app/src/main/res/layout/activity_download.xml @@ -11,7 +11,7 @@ android:layout_height="wrap_content" app:title="@string/download_offline" /> - diff --git a/app/src/main/res/layout/activity_explore_show.xml b/app/src/main/res/layout/activity_explore_show.xml index 17532f98b..9bfab0f58 100644 --- a/app/src/main/res/layout/activity_explore_show.xml +++ b/app/src/main/res/layout/activity_explore_show.xml @@ -22,7 +22,7 @@ app:layout_constraintTop_toBottomOf="@id/title_bar"> - diff --git a/app/src/main/res/layout/activity_import_book.xml b/app/src/main/res/layout/activity_import_book.xml index 99906f6d9..38d0b4f55 100644 --- a/app/src/main/res/layout/activity_import_book.xml +++ b/app/src/main/res/layout/activity_import_book.xml @@ -53,7 +53,7 @@ tools:ignore="UnusedAttribute" /> - - - diff --git a/app/src/main/res/layout/activity_source_debug.xml b/app/src/main/res/layout/activity_source_debug.xml index 50fcfd2de..1b79a6058 100644 --- a/app/src/main/res/layout/activity_source_debug.xml +++ b/app/src/main/res/layout/activity_source_debug.xml @@ -14,7 +14,7 @@ app:layout_constraintTop_toTopOf="parent" app:title="@string/debug_source" /> - - - diff --git a/app/src/main/res/layout/dialog_change_source.xml b/app/src/main/res/layout/dialog_change_source.xml index 464eef953..cc7486b05 100644 --- a/app/src/main/res/layout/dialog_change_source.xml +++ b/app/src/main/res/layout/dialog_change_source.xml @@ -19,7 +19,7 @@ android:layout_width="match_parent" android:layout_height="2dp" /> - diff --git a/app/src/main/res/layout/dialog_file_chooser.xml b/app/src/main/res/layout/dialog_file_chooser.xml index 14fb214a0..ab5974114 100644 --- a/app/src/main/res/layout/dialog_file_chooser.xml +++ b/app/src/main/res/layout/dialog_file_chooser.xml @@ -10,7 +10,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" /> - - diff --git a/app/src/main/res/layout/dialog_font_select.xml b/app/src/main/res/layout/dialog_font_select.xml index 5d8242f58..1e9cf6b42 100644 --- a/app/src/main/res/layout/dialog_font_select.xml +++ b/app/src/main/res/layout/dialog_font_select.xml @@ -10,7 +10,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" /> - diff --git a/app/src/main/res/layout/dialog_read_bg_text.xml b/app/src/main/res/layout/dialog_read_bg_text.xml index 14e189c8b..6cea816cd 100644 --- a/app/src/main/res/layout/dialog_read_bg_text.xml +++ b/app/src/main/res/layout/dialog_read_bg_text.xml @@ -79,7 +79,7 @@ android:layout_height="wrap_content" android:text="@string/bg_image" /> - diff --git a/app/src/main/res/layout/dialog_recycler_view.xml b/app/src/main/res/layout/dialog_recycler_view.xml index 15d1d5315..5b1d900a9 100644 --- a/app/src/main/res/layout/dialog_recycler_view.xml +++ b/app/src/main/res/layout/dialog_recycler_view.xml @@ -11,7 +11,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" /> - - - diff --git a/app/src/main/res/layout/fragment_find_book.xml b/app/src/main/res/layout/fragment_find_book.xml index e7596b5b1..8609db403 100644 --- a/app/src/main/res/layout/fragment_find_book.xml +++ b/app/src/main/res/layout/fragment_find_book.xml @@ -14,7 +14,7 @@ app:layout_constraintTop_toTopOf="parent" app:title="@string/find" /> - diff --git a/app/src/main/res/layout/fragment_rss.xml b/app/src/main/res/layout/fragment_rss.xml index 35cb73229..f1469fbd7 100644 --- a/app/src/main/res/layout/fragment_rss.xml +++ b/app/src/main/res/layout/fragment_rss.xml @@ -12,7 +12,7 @@ app:attachToActivity="false" app:title="@string/rss" /> - diff --git a/app/src/main/res/layout/popup_action_menu.xml b/app/src/main/res/layout/popup_action_menu.xml index 0c5a6f754..0f6b6e0e5 100644 --- a/app/src/main/res/layout/popup_action_menu.xml +++ b/app/src/main/res/layout/popup_action_menu.xml @@ -13,7 +13,7 @@ android:orientation="horizontal" android:gravity="center_vertical"> - - - - From eb39fb4436cae96782e95339a5475644dea5fcda Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 18 Jun 2020 19:32:39 +0800 Subject: [PATCH 233/296] =?UTF-8?q?feat:=20fadeapp.widgets:scrollless-recy?= =?UTF-8?q?clerView=E5=AF=BC=E8=87=B4=E6=9C=89=E4=BA=9B=E6=89=8B=E6=9C=BA?= =?UTF-8?q?=E9=87=8D=E5=BD=B1,=E6=9A=82=E6=97=B6=E5=8E=BB=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 30242228b..d83467aa2 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/06/18** +* fadeapp.widgets:scrollless-recyclerView导致有些手机重影,暂时去除 + **2020/06/17** * 修复更新书架时更新禁止更新的问题 * 修复导入旧版本数据问题 From 5932e6e6a2813eeffe46a9bfa4f3d082050a3709 Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 18 Jun 2020 19:58:26 +0800 Subject: [PATCH 234/296] =?UTF-8?q?feat:=20=E4=B8=8B=E8=BD=BD=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E6=B7=BB=E5=8A=A0=E5=88=86=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/data/dao/BookDao.kt | 3 - .../app/ui/book/download/DownloadActivity.kt | 77 ++++++++++++++++--- .../ui/main/bookshelf/BookshelfFragment.kt | 5 +- app/src/main/res/menu/download.xml | 21 +++++ 4 files changed, 91 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/dao/BookDao.kt b/app/src/main/java/io/legado/app/data/dao/BookDao.kt index c91e01648..3dfaf21fa 100644 --- a/app/src/main/java/io/legado/app/data/dao/BookDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/BookDao.kt @@ -21,9 +21,6 @@ interface BookDao { @Query("SELECT bookUrl FROM books WHERE origin = '${BookType.local}'") fun observeLocalUri(): LiveData> - @Query("SELECT * FROM books WHERE origin <> '${BookType.local}' and type = 0") - fun observeDownload(): LiveData> - @Query("SELECT * FROM books WHERE (`group` & :group) > 0") fun observeByGroup(group: Int): LiveData> diff --git a/app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt b/app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt index b0f860527..6c8d63c26 100644 --- a/app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt @@ -12,10 +12,12 @@ import com.google.android.material.snackbar.Snackbar import io.legado.app.App import io.legado.app.R import io.legado.app.base.VMBaseActivity +import io.legado.app.constant.AppConst import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter +import io.legado.app.data.entities.BookGroup import io.legado.app.help.BookHelp import io.legado.app.service.help.Download import io.legado.app.ui.filechooser.FileChooserDialog @@ -35,24 +37,44 @@ class DownloadActivity : VMBaseActivity(R.layout.activity_dow private val exportRequestCode = 32 private val exportBookPathKey = "exportBookPath" lateinit var adapter: DownloadAdapter - private var bookshelfLiveData: LiveData>? = null + private var groupLiveData: LiveData>? = null + private var booksLiveData: LiveData>? = null private var menu: Menu? = null private var exportPosition = -1 + private val groupList: ArrayList = arrayListOf() + private var groupId: Int = -1 override val viewModel: DownloadViewModel get() = getViewModel(DownloadViewModel::class.java) override fun onActivityCreated(savedInstanceState: Bundle?) { + groupId = intent.getIntExtra("groupId", -1) + title_bar.subtitle = intent.getStringExtra("groupName") ?: getString(R.string.all) initRecyclerView() - initLiveData() + initGroupData() + initBookData() } override fun onCompatCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.download, menu) - this.menu = menu return super.onCompatCreateOptionsMenu(menu) } + override fun onPrepareOptionsMenu(menu: Menu?): Boolean { + this.menu = menu + upMenu() + return super.onPrepareOptionsMenu(menu) + } + + private fun upMenu() { + menu?.findItem(R.id.menu_book_group)?.subMenu?.let { subMenu -> + subMenu.removeGroup(R.id.menu_group) + groupList.forEach { bookGroup -> + subMenu.add(R.id.menu_group, bookGroup.groupId, Menu.NONE, bookGroup.groupName) + } + } + } + override fun onCompatOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { R.id.menu_download -> launch(IO) { @@ -69,6 +91,21 @@ class DownloadActivity : VMBaseActivity(R.layout.activity_dow Download.stop(this@DownloadActivity) } } + R.id.menu_no_group -> { + title_bar.subtitle = getString(R.string.no_group) + groupId = AppConst.bookGroupNone.groupId + initBookData() + } + R.id.menu_all -> { + title_bar.subtitle = item.title + groupId = AppConst.bookGroupAll.groupId + initBookData() + } + else -> if (item.groupId == R.id.menu_group) { + title_bar.subtitle = item.title + groupId = item.itemId + initBookData() + } } return super.onCompatOptionsItemSelected(item) } @@ -79,21 +116,39 @@ class DownloadActivity : VMBaseActivity(R.layout.activity_dow recycler_view.adapter = adapter } - private fun initLiveData() { - bookshelfLiveData?.removeObservers(this) - bookshelfLiveData = App.db.bookDao().observeDownload() - bookshelfLiveData?.observe(this, Observer { list -> + private fun initBookData() { + booksLiveData?.removeObservers(this) + booksLiveData = when (groupId) { + AppConst.bookGroupAll.groupId -> App.db.bookDao().observeAll() + AppConst.bookGroupNone.groupId -> App.db.bookDao().observeNoGroup() + else -> App.db.bookDao().observeByGroup(groupId) + } + booksLiveData?.observe(this, Observer { list -> + val booksDownload = list.filter { + !it.isLocalBook() && it.isTxt() + } val books = when (getPrefInt(PreferKey.bookshelfSort)) { - 1 -> list.sortedByDescending { it.latestChapterTime } - 2 -> list.sortedBy { it.name } - 3 -> list.sortedBy { it.order } - else -> list.sortedByDescending { it.durChapterTime } + 1 -> booksDownload.sortedByDescending { it.latestChapterTime } + 2 -> booksDownload.sortedBy { it.name } + 3 -> booksDownload.sortedBy { it.order } + else -> booksDownload.sortedByDescending { it.durChapterTime } } adapter.setItems(books) initCacheSize(books) }) } + private fun initGroupData() { + groupLiveData?.removeObservers(this) + groupLiveData = App.db.bookGroupDao().liveDataAll() + groupLiveData?.observe(this, Observer { + groupList.clear() + groupList.addAll(it) + adapter.notifyDataSetChanged() + upMenu() + }) + } + private fun initCacheSize(books: List) { launch(IO) { books.forEach { book -> diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt index 9c657dd99..341a45eb5 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt @@ -91,7 +91,10 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b Pair("groupId", selectedGroup.groupId), Pair("groupName", selectedGroup.groupName) ) - R.id.menu_download -> startActivity() + R.id.menu_download -> startActivity( + Pair("groupId", selectedGroup.groupId), + Pair("groupName", selectedGroup.groupName) + ) } } diff --git a/app/src/main/res/menu/download.xml b/app/src/main/res/menu/download.xml index 452269d37..6c5b7a8f3 100644 --- a/app/src/main/res/menu/download.xml +++ b/app/src/main/res/menu/download.xml @@ -8,4 +8,25 @@ android:icon="@drawable/ic_play_24dp" app:showAsAction="ifRoom" /> + + + + + + + + + + + + + \ No newline at end of file From 2d27682660a50c2fcc26a6762e9cc4d178d2c13a Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 18 Jun 2020 19:58:58 +0800 Subject: [PATCH 235/296] =?UTF-8?q?feat:=20=E4=B8=8B=E8=BD=BD=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E6=B7=BB=E5=8A=A0=E5=88=86=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index d83467aa2..1cf5d3438 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -5,6 +5,7 @@ **2020/06/18** * fadeapp.widgets:scrollless-recyclerView导致有些手机重影,暂时去除 +* 下载界面添加分组 **2020/06/17** * 修复更新书架时更新禁止更新的问题 From 0eb6ce8c062f8bb40fe867313c9dede1b30fa47b Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 18 Jun 2020 20:41:13 +0800 Subject: [PATCH 236/296] =?UTF-8?q?feat:=20=E4=B8=8B=E8=BD=BD=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E6=B7=BB=E5=8A=A0=E5=88=86=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/data/entities/Book.kt | 6 +++++- .../main/java/io/legado/app/model/localBook/LocalBook.kt | 2 +- .../java/io/legado/app/ui/book/download/DownloadActivity.kt | 2 +- .../java/io/legado/app/ui/book/read/ReadBookActivity.kt | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) 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 2889f1c99..104520ff3 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 @@ -56,10 +56,14 @@ data class Book( return origin == BookType.local } - fun isTxt(): Boolean { + fun isLocalTxt(): Boolean { return isLocalBook() && originName.endsWith(".txt", true) } + fun isOnLineTxt(): Boolean { + return !isLocalBook() && type == 0 + } + override fun equals(other: Any?): Boolean { if (other is Book) { return other.bookUrl == bookUrl diff --git a/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt b/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt index c5e7ffab5..9195c87a5 100644 --- a/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt +++ b/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt @@ -47,7 +47,7 @@ object LocalBook { fun deleteBook(book: Book, deleteOriginal: Boolean) { kotlin.runCatching { - if (book.isTxt()) { + if (book.isLocalTxt()) { val bookFile = FileUtils.getFile(AnalyzeTxtFile.cacheFolder, book.originName) bookFile.delete() } diff --git a/app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt b/app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt index 6c8d63c26..6889e1052 100644 --- a/app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt @@ -125,7 +125,7 @@ class DownloadActivity : VMBaseActivity(R.layout.activity_dow } booksLiveData?.observe(this, Observer { list -> val booksDownload = list.filter { - !it.isLocalBook() && it.isTxt() + it.isOnLineTxt() } val books = when (getPrefInt(PreferKey.bookshelfSort)) { 1 -> booksDownload.sortedByDescending { it.latestChapterTime } 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 d5880a728..dcfaa88ee 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 @@ -198,7 +198,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo when (item.groupId) { R.id.menu_group_on_line -> item.isVisible = onLine R.id.menu_group_local -> item.isVisible = !onLine - R.id.menu_group_text -> item.isVisible = book.isTxt() + R.id.menu_group_text -> item.isVisible = book.isLocalTxt() R.id.menu_group_login -> item.isVisible = !ReadBook.webBook?.bookSource?.loginUrl.isNullOrEmpty() else -> if (item.itemId == R.id.menu_enable_replace) { From bb0e4c6b984fab490c811ef1694a108512dbc6ad Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 18 Jun 2020 21:51:18 +0800 Subject: [PATCH 237/296] =?UTF-8?q?feat:=20=E4=B8=8B=E8=BD=BD=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E6=B7=BB=E5=8A=A0=E5=88=86=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/main/my/MyFragment.kt | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt index 0a59c49c1..122f787eb 100644 --- a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt @@ -145,10 +145,23 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog. postEvent(EventBus.RECREATE, "") } else { ReadBookConfig.pageAnim = getPrefInt("lastReadBookPageAnim") - putPrefInt("colorPrimary", getPrefInt("lastColorPrimary")) - putPrefInt("colorAccent", getPrefInt("lastColorAccent")) - putPrefInt("colorBackground", getPrefInt("lastColorBackground")) - putPrefInt("colorBottomBackground", getPrefInt("lastColorBottomBackground")) + if (getPrefBoolean("lastIsNightTheme")) { + putPrefInt("colorPrimaryNight", getPrefInt("lastColorPrimary")) + putPrefInt("colorAccentNight", getPrefInt("lastColorAccent")) + putPrefInt("colorBackgroundNight", getPrefInt("lastColorBackground")) + putPrefInt( + "colorBottomBackgroundNight", + getPrefInt("lastColorBottomBackground") + ) + } else { + putPrefInt("colorPrimary", getPrefInt("lastColorPrimary")) + putPrefInt("colorAccent", getPrefInt("lastColorAccent")) + putPrefInt("colorBackground", getPrefInt("lastColorBackground")) + putPrefInt( + "colorBottomBackground", + getPrefInt("lastColorBottomBackground") + ) + } AppConfig.isNightTheme = getPrefBoolean("lastIsNightTheme") App.INSTANCE.applyDayNight() postEvent(EventBus.RECREATE, "") From df6aca8760431e3d6067789a3cd7253c295701fe Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 18 Jun 2020 21:54:34 +0800 Subject: [PATCH 238/296] =?UTF-8?q?feat:=20=E4=B8=8B=E8=BD=BD=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E6=B7=BB=E5=8A=A0=E5=88=86=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/download/DownloadActivity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt b/app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt index 6889e1052..0097c33ac 100644 --- a/app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt @@ -79,7 +79,7 @@ class DownloadActivity : VMBaseActivity(R.layout.activity_dow when (item.itemId) { R.id.menu_download -> launch(IO) { if (adapter.downloadMap.isNullOrEmpty()) { - App.db.bookDao().webBooks.forEach { book -> + adapter.getItems().forEach { book -> Download.start( this@DownloadActivity, book.bookUrl, From c21c30ac3ef69fb87147fd8f96e33e76a5b08f8d Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 18 Jun 2020 21:58:56 +0800 Subject: [PATCH 239/296] =?UTF-8?q?feat:=20=E4=B8=8B=E8=BD=BD=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E6=B7=BB=E5=8A=A0=E5=88=86=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 1cf5d3438..64f30839c 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -6,6 +6,7 @@ **2020/06/18** * fadeapp.widgets:scrollless-recyclerView导致有些手机重影,暂时去除 * 下载界面添加分组 +* 修复eInk bug **2020/06/17** * 修复更新书架时更新禁止更新的问题 From 180f987097da88c0b7c2dce2d48442e8d7e6671f Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 18 Jun 2020 22:40:52 +0800 Subject: [PATCH 240/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8DEInk=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/App.kt | 17 +++--- .../java/io/legado/app/constant/PreferKey.kt | 21 ++++++- .../main/java/io/legado/app/help/AppConfig.kt | 2 +- .../io/legado/app/lib/theme/ThemeStore.kt | 9 +-- .../io/legado/app/ui/main/my/MyFragment.kt | 57 +++++++++---------- 5 files changed, 63 insertions(+), 43 deletions(-) diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt index 5c4c02964..dde82c946 100644 --- a/app/src/main/java/io/legado/app/App.kt +++ b/app/src/main/java/io/legado/app/App.kt @@ -12,6 +12,7 @@ import com.jeremyliao.liveeventbus.LiveEventBus 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.PreferKey import io.legado.app.data.AppDatabase import io.legado.app.help.ActivityHelp import io.legado.app.help.AppConfig @@ -71,24 +72,24 @@ class App : Application() { if (AppConfig.isNightTheme) { ThemeStore.editTheme(this) .primaryColor( - getPrefInt("colorPrimaryNight", getCompatColor(R.color.md_blue_grey_600)) + getPrefInt(PreferKey.cNPrimary, getCompatColor(R.color.md_blue_grey_600)) ).accentColor( - getPrefInt("colorAccentNight", getCompatColor(R.color.md_deep_orange_800)) + getPrefInt(PreferKey.cNAccent, getCompatColor(R.color.md_deep_orange_800)) ).backgroundColor( - getPrefInt("colorBackgroundNight", getCompatColor(R.color.shine_color)) + getPrefInt(PreferKey.cNBackground, getCompatColor(R.color.shine_color)) ).bottomBackground( - getPrefInt("colorBottomBackgroundNight", getCompatColor(R.color.md_grey_850)) + getPrefInt(PreferKey.cNBBackground, getCompatColor(R.color.md_grey_850)) ).apply() } else { ThemeStore.editTheme(this) .primaryColor( - getPrefInt("colorPrimary", getCompatColor(R.color.md_indigo_800)) + getPrefInt(PreferKey.cPrimary, getCompatColor(R.color.md_indigo_800)) ).accentColor( - getPrefInt("colorAccent", getCompatColor(R.color.md_red_600)) + getPrefInt(PreferKey.cAccent, getCompatColor(R.color.md_red_600)) ).backgroundColor( - getPrefInt("colorBackground", getCompatColor(R.color.md_grey_100)) + getPrefInt(PreferKey.cBackground, getCompatColor(R.color.md_grey_100)) ).bottomBackground( - getPrefInt("colorBottomBackground", getCompatColor(R.color.md_grey_200)) + getPrefInt(PreferKey.cBBackground, getCompatColor(R.color.md_grey_200)) ).apply() } } 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 e8f29712c..e4d8eafae 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -43,7 +43,26 @@ object PreferKey { const val readStyleSelect = "readStyleSelect" const val systemTypefaces = "system_typefaces" const val readBodyToLh = "readBodyToLh" - const val einkMode = "isEInkMode" + const val eInkMode = "isEInkMode" const val textFullJustify = "textFullJustify" const val autoReadSpeed = "autoReadSpeed" + + const val cPrimary = "colorPrimary" + const val cAccent = "colorAccent" + const val cBackground = "colorBackground" + const val cBBackground = "colorBottomBackground" + + const val cNPrimary = "colorPrimaryNight" + const val cNAccent = "colorAccentNight" + const val cNBackground = "colorBackgroundNight" + const val cNBBackground = "colorBottomBackgroundNight" + + const val cLPrimary = "lastColorPrimary" + const val cLAccent = "lastColorAccent" + const val cLBackground = "lastColorBackground" + const val cLBBackground = "lastColorBottomBackground" + + const val lastPageAnim = "lastPageAnim" + const val lastIsNight = "lastIsNightTheme" + const val lastThemeMode = "lastThemeMode" } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/help/AppConfig.kt b/app/src/main/java/io/legado/app/help/AppConfig.kt index fef825c70..2ebd8f47a 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -81,7 +81,7 @@ object AppConfig { get() = App.INSTANCE.getPrefString(PreferKey.ttsSpeechPer) ?: "0" val isEInkMode: Boolean - get() = App.INSTANCE.getPrefBoolean(PreferKey.einkMode) + get() = App.INSTANCE.getPrefBoolean(PreferKey.eInkMode) val clickAllNext: Boolean get() = App.INSTANCE.getPrefBoolean(PreferKey.clickAllNext, false) diff --git a/app/src/main/java/io/legado/app/lib/theme/ThemeStore.kt b/app/src/main/java/io/legado/app/lib/theme/ThemeStore.kt index 5b3997081..415938c22 100644 --- a/app/src/main/java/io/legado/app/lib/theme/ThemeStore.kt +++ b/app/src/main/java/io/legado/app/lib/theme/ThemeStore.kt @@ -9,6 +9,7 @@ import androidx.annotation.CheckResult import androidx.annotation.ColorInt import androidx.annotation.ColorRes import androidx.core.content.ContextCompat +import io.legado.app.App import io.legado.app.R /** @@ -194,7 +195,7 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { @CheckResult @ColorInt - fun primaryColor(context: Context): Int { + fun primaryColor(context: Context = App.INSTANCE): Int { return prefs(context).getInt( ThemeStorePrefKeys.KEY_PRIMARY_COLOR, ATHUtils.resolveColor(context, R.attr.colorPrimary, Color.parseColor("#455A64")) @@ -212,7 +213,7 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { @CheckResult @ColorInt - fun accentColor(context: Context): Int { + fun accentColor(context: Context = App.INSTANCE): Int { return prefs(context).getInt( ThemeStorePrefKeys.KEY_ACCENT_COLOR, ATHUtils.resolveColor(context, R.attr.colorAccent, Color.parseColor("#263238")) @@ -277,7 +278,7 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { @CheckResult @ColorInt - fun backgroundColor(context: Context): Int { + fun backgroundColor(context: Context = App.INSTANCE): Int { return prefs(context).getInt( ThemeStorePrefKeys.KEY_BACKGROUND_COLOR, ATHUtils.resolveColor(context, android.R.attr.colorBackground) @@ -294,7 +295,7 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { @CheckResult @ColorInt - fun bottomBackground(context: Context): Int { + fun bottomBackground(context: Context = App.INSTANCE): Int { return prefs(context).getInt( ThemeStorePrefKeys.KEY_BOTTOM_BACKGROUND, ATHUtils.resolveColor(context, android.R.attr.colorBackground) diff --git a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt index 122f787eb..1d20baeab 100644 --- a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt @@ -123,46 +123,45 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog. } } "recordLog" -> LogUtils.upLevel() - PreferKey.einkMode -> { + PreferKey.eInkMode -> { //既然是 E-Ink 模式,为什么不一步到位呢 if (AppConfig.isEInkMode) { //保存开启前的设置 - putPrefInt("lastReadBookPageAnim", ReadBookConfig.pageAnim) - putPrefInt("lastColorPrimary", ThemeStore.primaryColor(requireContext())) - putPrefInt("lastColorAccent", ThemeStore.accentColor(requireContext())) - putPrefInt("lastColorBackground", ThemeStore.backgroundColor(requireContext())) - putPrefInt("lastColorBottomBackground", ThemeStore.bottomBackground(requireContext())) - putPrefBoolean("lastIsNightTheme", AppConfig.isNightTheme) + putPrefInt(PreferKey.lastPageAnim, ReadBookConfig.pageAnim) + putPrefInt(PreferKey.cLPrimary, ThemeStore.primaryColor()) + putPrefInt(PreferKey.cLAccent, ThemeStore.accentColor()) + putPrefInt(PreferKey.cLBackground, ThemeStore.backgroundColor()) + putPrefInt(PreferKey.cLBBackground, ThemeStore.bottomBackground()) + putPrefBoolean(PreferKey.lastIsNight, AppConfig.isNightTheme) + putPrefString( + PreferKey.lastThemeMode, + getPrefString(PreferKey.themeMode) ?: "0" + ) //设置 E-Ink 模式配置 ReadBookConfig.pageAnim = 4 - putPrefInt("colorPrimary", getCompatColor(R.color.white)) - putPrefInt("colorAccent", getCompatColor(R.color.black)) - putPrefInt("colorBackground", getCompatColor(R.color.white)) - putPrefInt("colorBottomBackground", getCompatColor(R.color.white)) + putPrefInt(PreferKey.cPrimary, getCompatColor(R.color.white)) + putPrefInt(PreferKey.cAccent, getCompatColor(R.color.black)) + putPrefInt(PreferKey.cBackground, getCompatColor(R.color.white)) + putPrefInt(PreferKey.cBBackground, getCompatColor(R.color.white)) AppConfig.isNightTheme = false App.INSTANCE.applyDayNight() postEvent(EventBus.RECREATE, "") - } else { - ReadBookConfig.pageAnim = getPrefInt("lastReadBookPageAnim") - if (getPrefBoolean("lastIsNightTheme")) { - putPrefInt("colorPrimaryNight", getPrefInt("lastColorPrimary")) - putPrefInt("colorAccentNight", getPrefInt("lastColorAccent")) - putPrefInt("colorBackgroundNight", getPrefInt("lastColorBackground")) - putPrefInt( - "colorBottomBackgroundNight", - getPrefInt("lastColorBottomBackground") - ) + } else if (getPrefString(PreferKey.themeMode) != null) { + ReadBookConfig.pageAnim = getPrefInt(PreferKey.lastPageAnim) + val isNightTheme = getPrefBoolean(PreferKey.lastIsNight) + if (isNightTheme) { + putPrefInt(PreferKey.cNPrimary, getPrefInt(PreferKey.cLPrimary)) + putPrefInt(PreferKey.cNAccent, getPrefInt(PreferKey.cLAccent)) + putPrefInt(PreferKey.cNBackground, getPrefInt(PreferKey.cLBackground)) + putPrefInt(PreferKey.cNBBackground, getPrefInt(PreferKey.cLBBackground)) } else { - putPrefInt("colorPrimary", getPrefInt("lastColorPrimary")) - putPrefInt("colorAccent", getPrefInt("lastColorAccent")) - putPrefInt("colorBackground", getPrefInt("lastColorBackground")) - putPrefInt( - "colorBottomBackground", - getPrefInt("lastColorBottomBackground") - ) + putPrefInt(PreferKey.cPrimary, getPrefInt(PreferKey.cLPrimary)) + putPrefInt(PreferKey.cAccent, getPrefInt(PreferKey.cLAccent)) + putPrefInt(PreferKey.cBackground, getPrefInt(PreferKey.cLBackground)) + putPrefInt(PreferKey.cBBackground, getPrefInt(PreferKey.cLBBackground)) } - AppConfig.isNightTheme = getPrefBoolean("lastIsNightTheme") + AppConfig.isNightTheme = isNightTheme App.INSTANCE.applyDayNight() postEvent(EventBus.RECREATE, "") } From 0f4f914f105db81f30c35ed90cf1a89a1ba484f1 Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 18 Jun 2020 22:50:20 +0800 Subject: [PATCH 241/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8DEInk=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/main/my/MyFragment.kt | 32 ++++++++----------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt index 1d20baeab..264fb5a8d 100644 --- a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt @@ -16,7 +16,6 @@ import io.legado.app.constant.PreferKey import io.legado.app.help.AppConfig import io.legado.app.help.ReadBookConfig import io.legado.app.lib.theme.ATH -import io.legado.app.lib.theme.ThemeStore import io.legado.app.service.WebService import io.legado.app.ui.about.AboutActivity import io.legado.app.ui.about.DonateActivity @@ -128,10 +127,10 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog. if (AppConfig.isEInkMode) { //保存开启前的设置 putPrefInt(PreferKey.lastPageAnim, ReadBookConfig.pageAnim) - putPrefInt(PreferKey.cLPrimary, ThemeStore.primaryColor()) - putPrefInt(PreferKey.cLAccent, ThemeStore.accentColor()) - putPrefInt(PreferKey.cLBackground, ThemeStore.backgroundColor()) - putPrefInt(PreferKey.cLBBackground, ThemeStore.bottomBackground()) + putPrefInt(PreferKey.cLPrimary, getPrefInt(PreferKey.cPrimary)) + putPrefInt(PreferKey.cLAccent, getPrefInt(PreferKey.cAccent)) + putPrefInt(PreferKey.cLBackground, getPrefInt(PreferKey.cBackground)) + putPrefInt(PreferKey.cLBBackground, getPrefInt(PreferKey.cBBackground)) putPrefBoolean(PreferKey.lastIsNight, AppConfig.isNightTheme) putPrefString( PreferKey.lastThemeMode, @@ -147,21 +146,16 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog. AppConfig.isNightTheme = false App.INSTANCE.applyDayNight() postEvent(EventBus.RECREATE, "") - } else if (getPrefString(PreferKey.themeMode) != null) { + } else if (getPrefString(PreferKey.lastThemeMode) != null) { ReadBookConfig.pageAnim = getPrefInt(PreferKey.lastPageAnim) - val isNightTheme = getPrefBoolean(PreferKey.lastIsNight) - if (isNightTheme) { - putPrefInt(PreferKey.cNPrimary, getPrefInt(PreferKey.cLPrimary)) - putPrefInt(PreferKey.cNAccent, getPrefInt(PreferKey.cLAccent)) - putPrefInt(PreferKey.cNBackground, getPrefInt(PreferKey.cLBackground)) - putPrefInt(PreferKey.cNBBackground, getPrefInt(PreferKey.cLBBackground)) - } else { - putPrefInt(PreferKey.cPrimary, getPrefInt(PreferKey.cLPrimary)) - putPrefInt(PreferKey.cAccent, getPrefInt(PreferKey.cLAccent)) - putPrefInt(PreferKey.cBackground, getPrefInt(PreferKey.cLBackground)) - putPrefInt(PreferKey.cBBackground, getPrefInt(PreferKey.cLBBackground)) - } - AppConfig.isNightTheme = isNightTheme + putPrefInt(PreferKey.cPrimary, getPrefInt(PreferKey.cLPrimary)) + putPrefInt(PreferKey.cAccent, getPrefInt(PreferKey.cLAccent)) + putPrefInt(PreferKey.cBackground, getPrefInt(PreferKey.cLBackground)) + putPrefInt(PreferKey.cBBackground, getPrefInt(PreferKey.cLBBackground)) + putPrefString( + PreferKey.themeMode, + getPrefString(PreferKey.lastThemeMode) ?: "0" + ) App.INSTANCE.applyDayNight() postEvent(EventBus.RECREATE, "") } From 28011069c6fc468d1ab38ab396a37f9f1b9e00d8 Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 19 Jun 2020 07:54:24 +0800 Subject: [PATCH 242/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8DEInk=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt index 264fb5a8d..806d79942 100644 --- a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt @@ -131,7 +131,6 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog. putPrefInt(PreferKey.cLAccent, getPrefInt(PreferKey.cAccent)) putPrefInt(PreferKey.cLBackground, getPrefInt(PreferKey.cBackground)) putPrefInt(PreferKey.cLBBackground, getPrefInt(PreferKey.cBBackground)) - putPrefBoolean(PreferKey.lastIsNight, AppConfig.isNightTheme) putPrefString( PreferKey.lastThemeMode, getPrefString(PreferKey.themeMode) ?: "0" From 0d81d3f03066c6c67aa0b769d2071354bb356ec0 Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 19 Jun 2020 21:47:46 +0800 Subject: [PATCH 243/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8DEInk=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 ++ .../java/io/legado/app/constant/PreferKey.kt | 1 - .../java/io/legado/app/help/ReadBookConfig.kt | 36 +++++++++---------- .../app/ui/book/read/page/ChapterProvider.kt | 5 ++- .../app/ui/book/read/page/ContentTextView.kt | 2 +- .../app/ui/book/read/page/ContentView.kt | 18 +++++----- .../main/res/layout/activity_import_book.xml | 16 ++++++--- 7 files changed, 43 insertions(+), 38 deletions(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 64f30839c..e9681da2e 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/06/19** +* 修复eInk bug + **2020/06/18** * fadeapp.widgets:scrollless-recyclerView导致有些手机重影,暂时去除 * 下载界面添加分组 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 e4d8eafae..e82154432 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -63,6 +63,5 @@ object PreferKey { const val cLBBackground = "lastColorBottomBackground" const val lastPageAnim = "lastPageAnim" - const val lastIsNight = "lastIsNightTheme" const val lastThemeMode = "lastThemeMode" } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index 9288a1c76..1381e3838 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -26,25 +26,20 @@ object ReadBookConfig { val json = String(App.INSTANCE.assets.open(readConfigFileName).readBytes()) GSON.fromJsonArray(json)!! } - val durConfig get() = - if (AppConfig.isEInkMode) - einkConfig - else - getConfig(styleSelect) + val durConfig get() = getConfig(styleSelect) var bg: Drawable? = null var bgMeanColor: Int = 0 - private val einkConfig: Config + val textColor: Int + get() = + if (AppConfig.isEInkMode && !AppConfig.isNightTheme) { + Color.BLACK + } else { + durConfig.textColor() + } init { upConfig() - einkConfig = Config( - bgStr = "#FFFFFF", - bgStrNight = "#FFFFFF", - textColor = "#000000", - textColorNight = "#000000", - darkStatusIconNight = true - ) } @Synchronized @@ -83,11 +78,16 @@ object ReadBookConfig { val dm = resources.displayMetrics val width = dm.widthPixels val height = dm.heightPixels - bg = durConfig.bgDrawable(width, height).apply { - if (this is BitmapDrawable) { - bgMeanColor = BitmapUtils.getMeanColor(bitmap) - } else if (this is ColorDrawable) { - bgMeanColor = color + if (AppConfig.isEInkMode && !AppConfig.isNightTheme) { + bg = ColorDrawable(Color.WHITE) + bgMeanColor = Color.WHITE + } else { + bg = durConfig.bgDrawable(width, height).apply { + if (this is BitmapDrawable) { + bgMeanColor = BitmapUtils.getMeanColor(bitmap) + } else if (this is ColorDrawable) { + bgMeanColor = color + } } } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index 15f3ac23c..5f52bd12f 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt @@ -6,7 +6,6 @@ import android.text.Layout import android.text.StaticLayout import android.text.TextPaint import android.text.TextUtils -import com.hankcs.hanlp.HanLP import io.legado.app.App import io.legado.app.constant.PreferKey import io.legado.app.data.entities.BookChapter @@ -293,14 +292,14 @@ object ChapterProvider { //标题 titlePaint = TextPaint() - titlePaint.color = ReadBookConfig.durConfig.textColor() + titlePaint.color = ReadBookConfig.textColor titlePaint.letterSpacing = ReadBookConfig.letterSpacing titlePaint.typeface = titleFont titlePaint.textSize = with(ReadBookConfig) { textSize + titleSize }.sp.toFloat() titlePaint.isAntiAlias = true //正文 contentPaint = TextPaint() - contentPaint.color = ReadBookConfig.durConfig.textColor() + contentPaint.color = ReadBookConfig.textColor contentPaint.letterSpacing = ReadBookConfig.letterSpacing contentPaint.typeface = textFont contentPaint.textSize = ReadBookConfig.textSize.sp.toFloat() 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 62f240303..fb996cc29 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 @@ -144,7 +144,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at ) { val textPaint = if (isTitle) ChapterProvider.titlePaint else ChapterProvider.contentPaint textPaint.color = - if (isReadAloud) context.accentColor else ReadBookConfig.durConfig.textColor() + if (isReadAloud) context.accentColor else ReadBookConfig.textColor textChars.forEach { canvas.drawText(it.charData, it.start, lineBase, textPaint) if (it.selected) { 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 8cf679114..37a3acd77 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 @@ -7,10 +7,8 @@ import android.view.MotionEvent import android.widget.FrameLayout import androidx.core.view.isGone import androidx.core.view.isInvisible -import com.hankcs.hanlp.HanLP import io.legado.app.R import io.legado.app.constant.AppConst.timeFormat -import io.legado.app.help.AppConfig import io.legado.app.help.ReadBookConfig import io.legado.app.help.ReadTipConfig import io.legado.app.ui.book.read.page.entities.TextPage @@ -57,14 +55,14 @@ class ContentView(context: Context) : FrameLayout(context) { tv_footer_left.typeface = ChapterProvider.typeface tv_footer_middle.typeface = ChapterProvider.typeface tv_footer_right.typeface = ChapterProvider.typeface - bv_header_left.setColor(durConfig.textColor()) - tv_header_left.setColor(durConfig.textColor()) - tv_header_middle.setColor(durConfig.textColor()) - tv_header_right.setColor(durConfig.textColor()) - bv_footer_left.setColor(durConfig.textColor()) - tv_footer_left.setColor(durConfig.textColor()) - tv_footer_middle.setColor(durConfig.textColor()) - tv_footer_right.setColor(durConfig.textColor()) + bv_header_left.setColor(textColor) + tv_header_left.setColor(textColor) + tv_header_middle.setColor(textColor) + tv_header_right.setColor(textColor) + bv_footer_left.setColor(textColor) + tv_footer_left.setColor(textColor) + tv_footer_middle.setColor(textColor) + tv_footer_right.setColor(textColor) //显示状态栏时隐藏header vw_status_bar.setPadding(0, context.statusBarHeight, 0, 0) vw_status_bar.isGone = hideStatusBar diff --git a/app/src/main/res/layout/activity_import_book.xml b/app/src/main/res/layout/activity_import_book.xml index 38d0b4f55..7fb75bdb2 100644 --- a/app/src/main/res/layout/activity_import_book.xml +++ b/app/src/main/res/layout/activity_import_book.xml @@ -53,13 +53,19 @@ tools:ignore="UnusedAttribute" /> - + android:layout_weight="1" + app:layout_constraintTop_toBottomOf="@id/layTop" + app:layout_constraintBottom_toTopOf="@id/select_action_bar"> + + + + Date: Fri, 19 Jun 2020 21:49:11 +0800 Subject: [PATCH 244/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8DEInk=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index e9681da2e..682dbbb74 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -5,6 +5,8 @@ **2020/06/19** * 修复eInk bug +* 修复分组下载bug +* 导入本地添加滚动条 **2020/06/18** * fadeapp.widgets:scrollless-recyclerView导致有些手机重影,暂时去除 From 701ed7cece49adee66de1f3d755765e427e44f80 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 20 Jun 2020 11:14:33 +0800 Subject: [PATCH 245/296] =?UTF-8?q?feat:=20=E9=80=82=E9=85=8DNavigationBar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/App.kt | 2 ++ app/src/main/java/io/legado/app/base/BaseActivity.kt | 1 + app/src/main/java/io/legado/app/lib/theme/ThemeStore.kt | 5 ++++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt index dde82c946..05d6f1837 100644 --- a/app/src/main/java/io/legado/app/App.kt +++ b/app/src/main/java/io/legado/app/App.kt @@ -71,6 +71,7 @@ class App : Application() { fun applyTheme() { if (AppConfig.isNightTheme) { ThemeStore.editTheme(this) + .coloredNavigationBar(true) .primaryColor( getPrefInt(PreferKey.cNPrimary, getCompatColor(R.color.md_blue_grey_600)) ).accentColor( @@ -82,6 +83,7 @@ class App : Application() { ).apply() } else { ThemeStore.editTheme(this) + .coloredNavigationBar(true) .primaryColor( getPrefInt(PreferKey.cPrimary, getCompatColor(R.color.md_indigo_800)) ).accentColor( diff --git a/app/src/main/java/io/legado/app/base/BaseActivity.kt b/app/src/main/java/io/legado/app/base/BaseActivity.kt index e0d4713d7..e98c7cdea 100644 --- a/app/src/main/java/io/legado/app/base/BaseActivity.kt +++ b/app/src/main/java/io/legado/app/base/BaseActivity.kt @@ -107,6 +107,7 @@ abstract class BaseActivity( } else if (theme == Theme.Light) { ATH.setLightStatusBar(this, true) } + ATH.setNavigationBarColorAuto(this) } open fun observeLiveBus() { diff --git a/app/src/main/java/io/legado/app/lib/theme/ThemeStore.kt b/app/src/main/java/io/legado/app/lib/theme/ThemeStore.kt index 415938c22..4259b6a7c 100644 --- a/app/src/main/java/io/legado/app/lib/theme/ThemeStore.kt +++ b/app/src/main/java/io/legado/app/lib/theme/ThemeStore.kt @@ -237,7 +237,10 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { fun navigationBarColor(context: Context): Int { return if (!coloredNavigationBar(context)) { Color.BLACK - } else prefs(context).getInt(ThemeStorePrefKeys.KEY_NAVIGATION_BAR_COLOR, primaryColor(context)) + } else prefs(context).getInt( + ThemeStorePrefKeys.KEY_NAVIGATION_BAR_COLOR, + bottomBackground(context) + ) } @CheckResult From 5379d6619af7cbc52f589ddcd5668346b3c9df66 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 20 Jun 2020 11:18:05 +0800 Subject: [PATCH 246/296] =?UTF-8?q?feat:=20=E9=80=82=E9=85=8DNavigationBar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 682dbbb74..f081c92bc 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/06/20** +* 适配NavigationBar + **2020/06/19** * 修复eInk bug * 修复分组下载bug From 4f81827e156cef51df780a18ea7d8481ddadac53 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 20 Jun 2020 23:32:05 +0800 Subject: [PATCH 247/296] =?UTF-8?q?feat:=20=E5=8F=8C=E5=87=BB=E4=B9=A6?= =?UTF-8?q?=E6=9E=B6=E5=9B=BE=E6=A0=87=E8=BF=94=E5=9B=9E=E9=A1=B6=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/main/MainActivity.kt | 15 +++++++++++++++ .../app/ui/main/bookshelf/BookshelfFragment.kt | 4 ++++ .../app/ui/main/bookshelf/books/BooksFragment.kt | 9 +++++++++ 3 files changed, 28 insertions(+) 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 d604465a1..1eb3250e0 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 @@ -30,10 +30,12 @@ import org.jetbrains.anko.toast class MainActivity : VMBaseActivity(R.layout.activity_main), BottomNavigationView.OnNavigationItemSelectedListener, + BottomNavigationView.OnNavigationItemReselectedListener, ViewPager.OnPageChangeListener by ViewPager.SimpleOnPageChangeListener() { override val viewModel: MainViewModel get() = getViewModel(MainViewModel::class.java) private var exitTime: Long = 0 + private var bookshelfReselected: Long = 0 private var pagePosition = 0 private val fragmentId = arrayOf(0, 1, 2, 3) private val fragmentMap = mapOf( @@ -50,6 +52,7 @@ class MainActivity : VMBaseActivity(R.layout.activity_main), view_pager_main.adapter = TabFragmentPageAdapter(supportFragmentManager) view_pager_main.addOnPageChangeListener(this) bottom_navigation_view.setOnNavigationItemSelectedListener(this) + bottom_navigation_view.setOnNavigationItemReselectedListener(this) bottom_navigation_view.menu.findItem(R.id.menu_rss).isVisible = AppConfig.isShowRSS } @@ -74,6 +77,18 @@ class MainActivity : VMBaseActivity(R.layout.activity_main), return false } + override fun onNavigationItemReselected(item: MenuItem) { + when (item.itemId) { + R.id.menu_bookshelf -> { + if (System.currentTimeMillis() - bookshelfReselected > 300) { + bookshelfReselected = System.currentTimeMillis() + } else { + (fragmentMap[0] as? BookshelfFragment)?.gotoTop() + } + } + } + } + private fun upVersion() { if (getPrefInt(PreferKey.versionCode) != App.INSTANCE.versionCode) { putPrefInt(PreferKey.versionCode, App.INSTANCE.versionCode) diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt index 341a45eb5..cfd4f7d6d 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt @@ -266,6 +266,10 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b } } + fun gotoTop() { + fragmentMap[selectedGroup.groupId]?.gotoTop() + } + private inner class TabFragmentPageAdapter internal constructor(fm: FragmentManager) : FragmentStatePagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt index 4d3d51663..f0731f1ed 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt @@ -16,6 +16,7 @@ import io.legado.app.constant.BookType import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey import io.legado.app.data.entities.Book +import io.legado.app.help.AppConfig import io.legado.app.help.IntentDataHelp import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.accentColor @@ -122,6 +123,14 @@ class BooksFragment : BaseFragment(R.layout.fragment_books), return booksAdapter.getItems() } + fun gotoTop() { + if (AppConfig.isEInkMode) { + rv_bookshelf.scrollToPosition(0) + } else { + rv_bookshelf.smoothScrollToPosition(0) + } + } + override fun open(book: Book) { when (book.type) { BookType.audio -> From ecb9a5a8e1793b24b7ba21cc09247b802070286f Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 20 Jun 2020 23:32:25 +0800 Subject: [PATCH 248/296] =?UTF-8?q?feat:=20=E5=8F=8C=E5=87=BB=E4=B9=A6?= =?UTF-8?q?=E6=9E=B6=E5=9B=BE=E6=A0=87=E8=BF=94=E5=9B=9E=E9=A1=B6=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index f081c92bc..8bd51d775 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -5,6 +5,7 @@ **2020/06/20** * 适配NavigationBar +* 双击书架图标返回顶部 **2020/06/19** * 修复eInk bug From b5d65e8911aac03ea4f3a578b42585c20627a3bd Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 21 Jun 2020 20:45:35 +0800 Subject: [PATCH 249/296] =?UTF-8?q?feat:=20=E5=8F=8C=E5=87=BB=E4=B9=A6?= =?UTF-8?q?=E6=9E=B6=E5=9B=BE=E6=A0=87=E8=BF=94=E5=9B=9E=E9=A1=B6=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 8bd51d775..30a008b5f 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,9 +3,11 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/06/21** +* 双击书架图标返回顶部 + **2020/06/20** * 适配NavigationBar -* 双击书架图标返回顶部 **2020/06/19** * 修复eInk bug From a6582c14c45de4c96b33d2ba7d0ab5332c5d3f42 Mon Sep 17 00:00:00 2001 From: gedoor Date: Mon, 22 Jun 2020 20:35:05 +0800 Subject: [PATCH 250/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dxpath?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=AD=A3=E6=96=87=E5=A4=9A=E4=BA=86=E8=AE=B8?= =?UTF-8?q?=E5=A4=9A=E9=80=97=E5=8F=B7=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/model/analyzeRule/AnalyzeByXPath.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByXPath.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByXPath.kt index 52f3b7560..0439713e8 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByXPath.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByXPath.kt @@ -169,7 +169,7 @@ class AnalyzeByXPath { if (rules.size == 1) { val jxNodes = jxNode?.sel(rule) ?: jxDocument?.selN(rule) jxNodes?.let { - return TextUtils.join(",", jxNodes) + return TextUtils.join("\n", jxNodes) } return null } else { From 979ab7bd9ff844fb71381f4e9035708248317dd0 Mon Sep 17 00:00:00 2001 From: gedoor Date: Mon, 22 Jun 2020 20:42:08 +0800 Subject: [PATCH 251/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dxpath?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=AD=A3=E6=96=87=E5=A4=9A=E4=BA=86=E8=AE=B8?= =?UTF-8?q?=E5=A4=9A=E9=80=97=E5=8F=B7=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 30a008b5f..b526c0c75 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/06/22** +* 修复xpath获取正文多了许多逗号的bug + **2020/06/21** * 双击书架图标返回顶部 From e0129752c66a51ca51dd3496785c2bb862c271c1 Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 23 Jun 2020 14:01:15 +0800 Subject: [PATCH 252/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96NavigationBar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/base/BaseActivity.kt | 4 ++++ .../main/java/io/legado/app/lib/theme/ATH.kt | 15 +++++---------- .../app/ui/book/read/ReadBookActivity.kt | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/base/BaseActivity.kt b/app/src/main/java/io/legado/app/base/BaseActivity.kt index e98c7cdea..bfa46c4b0 100644 --- a/app/src/main/java/io/legado/app/base/BaseActivity.kt +++ b/app/src/main/java/io/legado/app/base/BaseActivity.kt @@ -107,6 +107,10 @@ abstract class BaseActivity( } else if (theme == Theme.Light) { ATH.setLightStatusBar(this, true) } + upNavigationBarColor() + } + + open fun upNavigationBarColor() { ATH.setNavigationBarColorAuto(this) } diff --git a/app/src/main/java/io/legado/app/lib/theme/ATH.kt b/app/src/main/java/io/legado/app/lib/theme/ATH.kt index 19304862c..1b0bf723d 100644 --- a/app/src/main/java/io/legado/app/lib/theme/ATH.kt +++ b/app/src/main/java/io/legado/app/lib/theme/ATH.kt @@ -93,18 +93,13 @@ object ATH { } } - fun setLightNavigationBarAuto(activity: Activity, bgColor: Int) { - setLightNavigationBar(activity, ColorUtils.isColorLight(bgColor)) - } - - fun setNavigationBarColorAuto(activity: Activity) { - setNavigationBarColor(activity, ThemeStore.navigationBarColor(activity)) - } - - fun setNavigationBarColor(activity: Activity, color: Int) { + fun setNavigationBarColorAuto( + activity: Activity, + color: Int = ThemeStore.navigationBarColor(activity) + ) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { activity.window.navigationBarColor = color - setLightNavigationBarAuto(activity, color) + setLightNavigationBar(activity, ColorUtils.isColorLight(color)) } } 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 dcfaa88ee..0be7a1ea3 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 @@ -4,6 +4,8 @@ import android.annotation.SuppressLint import android.app.Activity import android.content.Intent import android.content.res.Configuration +import android.graphics.Color +import android.graphics.drawable.ColorDrawable import android.net.Uri import android.os.Bundle import android.os.Handler @@ -30,6 +32,7 @@ import io.legado.app.help.storage.SyncBookProgress import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.noButton import io.legado.app.lib.dialogs.okButton +import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.accentColor import io.legado.app.receiver.TimeBatteryReceiver import io.legado.app.service.BaseReadAloudService @@ -144,6 +147,20 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo } } + override fun upNavigationBarColor() { + when { + read_menu.isVisible -> { + ATH.setNavigationBarColorAuto(this) + } + ReadBookConfig.bg is ColorDrawable -> { + ATH.setNavigationBarColorAuto(this, ReadBookConfig.bgMeanColor) + } + else -> { + ATH.setNavigationBarColorAuto(this, Color.BLACK) + } + } + } + /** * 初始化View */ @@ -656,6 +673,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo */ override fun upSystemUiVisibility() { Help.upSystemUiVisibility(this, !read_menu.isVisible) + upNavigationBarColor() } /** From eb5c29c0fbdd495571e43e91cd1a2593bd27e58b Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 23 Jun 2020 14:48:02 +0800 Subject: [PATCH 253/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96NavigationBar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt | 1 + 1 file changed, 1 insertion(+) 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 0be7a1ea3..d778b999c 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 @@ -149,6 +149,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo override fun upNavigationBarColor() { when { + read_menu == null -> return read_menu.isVisible -> { ATH.setNavigationBarColorAuto(this) } From 427157941886b932c2091f3ebf3aaf00ecd7f7e5 Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 23 Jun 2020 21:05:14 +0800 Subject: [PATCH 254/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/utils/BitmapUtils.kt | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/io/legado/app/utils/BitmapUtils.kt b/app/src/main/java/io/legado/app/utils/BitmapUtils.kt index 138a0c063..7786bfed4 100644 --- a/app/src/main/java/io/legado/app/utils/BitmapUtils.kt +++ b/app/src/main/java/io/legado/app/utils/BitmapUtils.kt @@ -18,6 +18,7 @@ import kotlin.math.* @Suppress("unused", "WeakerAccess") object BitmapUtils { + /** * 从path中获取图片信息,在通过BitmapFactory.decodeFile(String path)方法将突破转成Bitmap时, * 遇到大一些的图片,我们经常会遇到OOM(Out Of Memory)的问题。所以用到了我们上面提到的BitmapFactory.Options这个类。 @@ -51,15 +52,11 @@ object BitmapUtils { * @param path 图片路径 * @return */ - fun decodeBitmap(path: String): Bitmap { val opts = BitmapFactory.Options() - opts.inJustDecodeBounds = true BitmapFactory.decodeFile(path, opts) - opts.inSampleSize = computeSampleSize(opts, -1, 128 * 128) - opts.inJustDecodeBounds = false return BitmapFactory.decodeFile(path, opts) @@ -125,7 +122,6 @@ object BitmapUtils { width: Int, height: Int ): Bitmap? { - var inputStream = context.assets.open(fileNameInAssets) val op = BitmapFactory.Options() // inJustDecodeBounds如果设置为true,仅仅返回图片实际的宽和高,宽和高是赋值给opts.outWidth,opts.outHeight; @@ -171,11 +167,8 @@ object BitmapUtils { minSideLength: Int, maxNumOfPixels: Int ): Int { - val initialSize = computeInitialSampleSize(options, minSideLength, maxNumOfPixels) - var roundedSize: Int - if (initialSize <= 8) { roundedSize = 1 while (roundedSize < initialSize) { @@ -184,7 +177,6 @@ object BitmapUtils { } else { roundedSize = (initialSize + 7) / 8 * 8 } - return roundedSize } @@ -198,27 +190,34 @@ object BitmapUtils { val w = options.outWidth.toDouble() val h = options.outHeight.toDouble() - val lowerBound = if (maxNumOfPixels == -1) - 1 - else - ceil(sqrt(w * h / maxNumOfPixels)).toInt() + val lowerBound = when (maxNumOfPixels) { + -1 -> 1 + else -> ceil(sqrt(w * h / maxNumOfPixels)).toInt() + } - val upperBound = if (minSideLength == -1) 128 else min( - floor(w / minSideLength), - floor(h / minSideLength) - ).toInt() + val upperBound = when (minSideLength) { + -1 -> 128 + else -> min( + floor(w / minSideLength), + floor(h / minSideLength) + ).toInt() + } if (upperBound < lowerBound) { // return the larger one when there is no overlapping zone. return lowerBound } - return if (maxNumOfPixels == -1 && minSideLength == -1) { - 1 - } else if (minSideLength == -1) { - lowerBound - } else { - upperBound + return when { + maxNumOfPixels == -1 && minSideLength == -1 -> { + 1 + } + minSideLength == -1 -> { + lowerBound + } + else -> { + upperBound + } } } @@ -278,7 +277,8 @@ object BitmapUtils { val averagePixelGreen = pixelSumGreen / 3000 return Color.rgb( averagePixelRed + 3, - averagePixelGreen + 3, averagePixelBlue + 3 + averagePixelGreen + 3, + averagePixelBlue + 3 ) } From e7ecca5c0d351e5dad51a55e695eac37a44bbf55 Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 23 Jun 2020 21:26:04 +0800 Subject: [PATCH 255/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8D=E6=A3=80?= =?UTF-8?q?=E9=AA=8C=E6=9C=89=E6=95=88=E4=B9=A6=E6=BA=90=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E5=A4=B1=E6=95=88=E5=88=86=E7=BB=84=E5=A4=B1=E8=B4=A5=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/data/entities/BookSource.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 62026ef7b..48e436262 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 @@ -96,7 +96,7 @@ data class BookSource( fun addGroup(group: String) { bookSourceGroup?.let { if (!it.contains(group)) { - bookSourceGroup = "$it;$group" + bookSourceGroup = "$it,$group" } } ?: let { bookSourceGroup = group @@ -104,7 +104,7 @@ data class BookSource( } fun removeGroup(group: String) { - bookSourceGroup?.splitNotBlank(",")?.toHashSet()?.let { + bookSourceGroup?.splitNotBlank("[,;]".toRegex())?.toHashSet()?.let { it.remove(group) bookSourceGroup = TextUtils.join(",", it) } From 6b8ba0e94f6bbac4f2a68162e40237972aeabddd Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 23 Jun 2020 21:26:33 +0800 Subject: [PATCH 256/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8D=E6=A3=80?= =?UTF-8?q?=E9=AA=8C=E6=9C=89=E6=95=88=E4=B9=A6=E6=BA=90=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E5=A4=B1=E6=95=88=E5=88=86=E7=BB=84=E5=A4=B1=E8=B4=A5=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index b526c0c75..34446e303 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -5,6 +5,7 @@ **2020/06/22** * 修复xpath获取正文多了许多逗号的bug +* 修复检验有效书源移除失效分组失败的bug **2020/06/21** * 双击书架图标返回顶部 From f5279f92b4770855b8050227c4210b7d9540fce2 Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 25 Jun 2020 11:36:57 +0800 Subject: [PATCH 257/296] =?UTF-8?q?feat:=20=E5=8D=87=E7=BA=A7=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 7c6d6b445..d54e75be2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -109,7 +109,7 @@ kapt { } dependencies { - coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.5' + coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.9' implementation fileTree(dir: 'libs', include: ['*.jar']) testImplementation 'junit:junit:4.13' androidTestImplementation 'androidx.test:runner:1.2.0' @@ -127,7 +127,7 @@ dependencies { implementation 'androidx.media:media:1.1.0' implementation 'androidx.preference:preference:1.1.1' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' - implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0' + implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' implementation 'androidx.viewpager2:viewpager2:1.0.0' implementation 'com.google.android.material:material:1.1.0' implementation 'com.google.android:flexbox:1.1.0' From f71e18c164c2cd5852e1e2c79a10b4976e26292d Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 25 Jun 2020 12:29:56 +0800 Subject: [PATCH 258/296] =?UTF-8?q?feat:=20E-Ink=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E5=90=88=E5=B9=B6=E5=88=B0=E4=B8=BB=E9=A2=98=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E9=87=8C,=20E-Ink=E6=A8=A1=E5=BC=8F=E4=B8=8D=E8=83=BD=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E9=98=85=E8=AF=BB=E7=95=8C=E9=9D=A2=E8=83=8C=E6=99=AF?= =?UTF-8?q?=E5=92=8C=E6=96=87=E5=AD=97=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/constant/PreferKey.kt | 1 - app/src/main/java/io/legado/app/help/AppConfig.kt | 7 ++++--- app/src/main/res/values-zh-rHK/arrays.xml | 1 + app/src/main/res/values-zh-rTW/arrays.xml | 1 + app/src/main/res/values/array_values.xml | 1 + app/src/main/res/values/arrays.xml | 1 + app/src/main/res/xml/pref_main.xml | 8 -------- 7 files changed, 8 insertions(+), 12 deletions(-) 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 e82154432..8236536ca 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -43,7 +43,6 @@ object PreferKey { const val readStyleSelect = "readStyleSelect" const val systemTypefaces = "system_typefaces" const val readBodyToLh = "readBodyToLh" - const val eInkMode = "isEInkMode" const val textFullJustify = "textFullJustify" const val autoReadSpeed = "autoReadSpeed" diff --git a/app/src/main/java/io/legado/app/help/AppConfig.kt b/app/src/main/java/io/legado/app/help/AppConfig.kt index 2ebd8f47a..5e98ae482 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -13,6 +13,7 @@ object AppConfig { return when (context.getPrefString(PreferKey.themeMode, "0")) { "1" -> false "2" -> true + "3" -> false else -> context.sysIsDarkMode() } } @@ -27,6 +28,9 @@ object AppConfig { } } + val isEInkMode: Boolean + get() = App.INSTANCE.getPrefString(PreferKey.themeMode) == "3" + var isTransparentStatusBar: Boolean get() = App.INSTANCE.getPrefBoolean("transparentStatusBar") set(value) { @@ -80,9 +84,6 @@ object AppConfig { val ttsSpeechPer: String get() = App.INSTANCE.getPrefString(PreferKey.ttsSpeechPer) ?: "0" - val isEInkMode: Boolean - get() = App.INSTANCE.getPrefBoolean(PreferKey.eInkMode) - val clickAllNext: Boolean get() = App.INSTANCE.getPrefBoolean(PreferKey.clickAllNext, false) var chineseConverterType: Int diff --git a/app/src/main/res/values-zh-rHK/arrays.xml b/app/src/main/res/values-zh-rHK/arrays.xml index b99ad1992..315f18e35 100644 --- a/app/src/main/res/values-zh-rHK/arrays.xml +++ b/app/src/main/res/values-zh-rHK/arrays.xml @@ -20,6 +20,7 @@ 跟隨系統 亮色主題 暗色主題 + E-Ink(墨水屏) diff --git a/app/src/main/res/values-zh-rTW/arrays.xml b/app/src/main/res/values-zh-rTW/arrays.xml index 4efd0c56f..5d4e2aaeb 100644 --- a/app/src/main/res/values-zh-rTW/arrays.xml +++ b/app/src/main/res/values-zh-rTW/arrays.xml @@ -44,6 +44,7 @@ 跟隨系統 亮色主題 暗色主題 + E-Ink(墨水屏) diff --git a/app/src/main/res/values/array_values.xml b/app/src/main/res/values/array_values.xml index 40bc6684e..b6b32fa5b 100644 --- a/app/src/main/res/values/array_values.xml +++ b/app/src/main/res/values/array_values.xml @@ -23,6 +23,7 @@ 0 1 2 + 3 diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index e8a99ff2a..5b580aeb3 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -44,6 +44,7 @@ 跟随系统 亮色主题 暗色主题 + E-Ink(墨水屏) diff --git a/app/src/main/res/xml/pref_main.xml b/app/src/main/res/xml/pref_main.xml index 72a02e97a..37b223d60 100644 --- a/app/src/main/res/xml/pref_main.xml +++ b/app/src/main/res/xml/pref_main.xml @@ -30,14 +30,6 @@ android:icon="@drawable/ic_cfg_theme" app:iconSpaceReserved="false" /> - - Date: Thu, 25 Jun 2020 12:31:01 +0800 Subject: [PATCH 259/296] =?UTF-8?q?feat:=20E-Ink=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E5=90=88=E5=B9=B6=E5=88=B0=E4=B8=BB=E9=A2=98=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E9=87=8C,=20E-Ink=E6=A8=A1=E5=BC=8F=E4=B8=8D=E8=83=BD=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E9=98=85=E8=AF=BB=E7=95=8C=E9=9D=A2=E8=83=8C=E6=99=AF?= =?UTF-8?q?=E5=92=8C=E6=96=87=E5=AD=97=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 34446e303..7cc685092 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/06/25** +* E-Ink模式合并到主题模式里, E-Ink模式不能修改阅读界面背景和文字颜色 + **2020/06/22** * 修复xpath获取正文多了许多逗号的bug * 修复检验有效书源移除失效分组失败的bug From 6745ba4baf65196029a7cc83b3304454236418ce Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 25 Jun 2020 13:09:02 +0800 Subject: [PATCH 260/296] =?UTF-8?q?feat:=20E-Ink=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E5=90=88=E5=B9=B6=E5=88=B0=E4=B8=BB=E9=A2=98=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E9=87=8C,=20E-Ink=E6=A8=A1=E5=BC=8F=E4=B8=8D=E8=83=BD=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E9=98=85=E8=AF=BB=E7=95=8C=E9=9D=A2=E8=83=8C=E6=99=AF?= =?UTF-8?q?=E5=92=8C=E6=96=87=E5=AD=97=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/App.kt | 61 +++++++++++-------- .../io/legado/app/ui/main/my/MyFragment.kt | 38 ------------ 2 files changed, 37 insertions(+), 62 deletions(-) diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt index 05d6f1837..93ea305a1 100644 --- a/app/src/main/java/io/legado/app/App.kt +++ b/app/src/main/java/io/legado/app/App.kt @@ -5,6 +5,7 @@ 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 androidx.annotation.RequiresApi import androidx.appcompat.app.AppCompatDelegate @@ -69,30 +70,42 @@ class App : Application() { * 更新主题 */ fun applyTheme() { - if (AppConfig.isNightTheme) { - ThemeStore.editTheme(this) - .coloredNavigationBar(true) - .primaryColor( - getPrefInt(PreferKey.cNPrimary, getCompatColor(R.color.md_blue_grey_600)) - ).accentColor( - getPrefInt(PreferKey.cNAccent, getCompatColor(R.color.md_deep_orange_800)) - ).backgroundColor( - getPrefInt(PreferKey.cNBackground, getCompatColor(R.color.shine_color)) - ).bottomBackground( - getPrefInt(PreferKey.cNBBackground, getCompatColor(R.color.md_grey_850)) - ).apply() - } else { - ThemeStore.editTheme(this) - .coloredNavigationBar(true) - .primaryColor( - getPrefInt(PreferKey.cPrimary, getCompatColor(R.color.md_indigo_800)) - ).accentColor( - getPrefInt(PreferKey.cAccent, getCompatColor(R.color.md_red_600)) - ).backgroundColor( - getPrefInt(PreferKey.cBackground, getCompatColor(R.color.md_grey_100)) - ).bottomBackground( - getPrefInt(PreferKey.cBBackground, getCompatColor(R.color.md_grey_200)) - ).apply() + when { + AppConfig.isEInkMode -> { + ThemeStore.editTheme(this) + .coloredNavigationBar(true) + .primaryColor(Color.WHITE) + .accentColor(Color.BLACK) + .backgroundColor(Color.WHITE) + .bottomBackground(Color.WHITE) + .apply() + } + AppConfig.isNightTheme -> { + ThemeStore.editTheme(this) + .coloredNavigationBar(true) + .primaryColor( + getPrefInt(PreferKey.cNPrimary, getCompatColor(R.color.md_blue_grey_600)) + ).accentColor( + getPrefInt(PreferKey.cNAccent, getCompatColor(R.color.md_deep_orange_800)) + ).backgroundColor( + getPrefInt(PreferKey.cNBackground, getCompatColor(R.color.shine_color)) + ).bottomBackground( + getPrefInt(PreferKey.cNBBackground, getCompatColor(R.color.md_grey_850)) + ).apply() + } + else -> { + ThemeStore.editTheme(this) + .coloredNavigationBar(true) + .primaryColor( + getPrefInt(PreferKey.cPrimary, getCompatColor(R.color.md_indigo_800)) + ).accentColor( + getPrefInt(PreferKey.cAccent, getCompatColor(R.color.md_red_600)) + ).backgroundColor( + getPrefInt(PreferKey.cBackground, getCompatColor(R.color.md_grey_100)) + ).bottomBackground( + getPrefInt(PreferKey.cBBackground, getCompatColor(R.color.md_grey_200)) + ).apply() + } } } diff --git a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt index 806d79942..88bb95afe 100644 --- a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt @@ -14,7 +14,6 @@ import io.legado.app.base.BaseFragment import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey import io.legado.app.help.AppConfig -import io.legado.app.help.ReadBookConfig import io.legado.app.lib.theme.ATH import io.legado.app.service.WebService import io.legado.app.ui.about.AboutActivity @@ -122,43 +121,6 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog. } } "recordLog" -> LogUtils.upLevel() - PreferKey.eInkMode -> { - //既然是 E-Ink 模式,为什么不一步到位呢 - if (AppConfig.isEInkMode) { - //保存开启前的设置 - putPrefInt(PreferKey.lastPageAnim, ReadBookConfig.pageAnim) - putPrefInt(PreferKey.cLPrimary, getPrefInt(PreferKey.cPrimary)) - putPrefInt(PreferKey.cLAccent, getPrefInt(PreferKey.cAccent)) - putPrefInt(PreferKey.cLBackground, getPrefInt(PreferKey.cBackground)) - putPrefInt(PreferKey.cLBBackground, getPrefInt(PreferKey.cBBackground)) - putPrefString( - PreferKey.lastThemeMode, - getPrefString(PreferKey.themeMode) ?: "0" - ) - - //设置 E-Ink 模式配置 - ReadBookConfig.pageAnim = 4 - putPrefInt(PreferKey.cPrimary, getCompatColor(R.color.white)) - putPrefInt(PreferKey.cAccent, getCompatColor(R.color.black)) - putPrefInt(PreferKey.cBackground, getCompatColor(R.color.white)) - putPrefInt(PreferKey.cBBackground, getCompatColor(R.color.white)) - AppConfig.isNightTheme = false - App.INSTANCE.applyDayNight() - postEvent(EventBus.RECREATE, "") - } else if (getPrefString(PreferKey.lastThemeMode) != null) { - ReadBookConfig.pageAnim = getPrefInt(PreferKey.lastPageAnim) - putPrefInt(PreferKey.cPrimary, getPrefInt(PreferKey.cLPrimary)) - putPrefInt(PreferKey.cAccent, getPrefInt(PreferKey.cLAccent)) - putPrefInt(PreferKey.cBackground, getPrefInt(PreferKey.cLBackground)) - putPrefInt(PreferKey.cBBackground, getPrefInt(PreferKey.cLBBackground)) - putPrefString( - PreferKey.themeMode, - getPrefString(PreferKey.lastThemeMode) ?: "0" - ) - App.INSTANCE.applyDayNight() - postEvent(EventBus.RECREATE, "") - } - } } } From 1810f5015396a9558373de1a5dcd9d5afdfe5ed1 Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 25 Jun 2020 13:36:00 +0800 Subject: [PATCH 261/296] =?UTF-8?q?feat:=20E-Ink=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E5=90=88=E5=B9=B6=E5=88=B0=E4=B8=BB=E9=A2=98=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E9=87=8C,=20E-Ink=E6=A8=A1=E5=BC=8F=E4=B8=8D=E8=83=BD=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E9=98=85=E8=AF=BB=E7=95=8C=E9=9D=A2=E8=83=8C=E6=99=AF?= =?UTF-8?q?=E5=92=8C=E6=96=87=E5=AD=97=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/ReadBookConfig.kt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index 1381e3838..823ddee55 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -136,13 +136,10 @@ object ReadBookConfig { App.INSTANCE.putPrefBoolean(PreferKey.shareLayout, value) } } - var pageAnim = App.INSTANCE.getPrefInt(PreferKey.pageAnim) + var pageAnim: Int + get() = if (AppConfig.isEInkMode) -1 else App.INSTANCE.getPrefInt(PreferKey.pageAnim) set(value) { - field = value - isScroll = value == 3 - if (App.INSTANCE.getPrefInt(PreferKey.pageAnim) != value) { - App.INSTANCE.putPrefInt(PreferKey.pageAnim, value) - } + App.INSTANCE.putPrefInt(PreferKey.pageAnim, value) } var isScroll = pageAnim == 3 val clickTurnPage get() = App.INSTANCE.getPrefBoolean(PreferKey.clickTurnPage, true) From 2b9363e4bf02fab2330433230218510b34d8f6cf Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 25 Jun 2020 14:01:06 +0800 Subject: [PATCH 262/296] =?UTF-8?q?feat:=20E-Ink=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E5=90=88=E5=B9=B6=E5=88=B0=E4=B8=BB=E9=A2=98=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E9=87=8C,=20E-Ink=E6=A8=A1=E5=BC=8F=E4=B8=8D=E8=83=BD=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E9=98=85=E8=AF=BB=E7=95=8C=E9=9D=A2=E8=83=8C=E6=99=AF?= =?UTF-8?q?=E5=92=8C=E6=96=87=E5=AD=97=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/App.kt | 3 +++ app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt | 3 +++ 2 files changed, 6 insertions(+) diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt index 93ea305a1..9474efac5 100644 --- a/app/src/main/java/io/legado/app/App.kt +++ b/app/src/main/java/io/legado/app/App.kt @@ -13,6 +13,7 @@ import com.jeremyliao.liveeventbus.LiveEventBus 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 @@ -22,6 +23,7 @@ import io.legado.app.help.ReadBookConfig import io.legado.app.lib.theme.ThemeStore import io.legado.app.utils.getCompatColor import io.legado.app.utils.getPrefInt +import io.legado.app.utils.postEvent @Suppress("DEPRECATION") class App : Application() { @@ -113,6 +115,7 @@ class App : Application() { ReadBookConfig.upBg() applyTheme() initNightMode() + postEvent(EventBus.RECREATE, "") } private fun initNightMode() { diff --git a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt index 88bb95afe..b16cbaf17 100644 --- a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt @@ -65,6 +65,9 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog. BackupRestoreUi.onActivityResult(requestCode, resultCode, data) } + /** + * 配置 + */ class PreferenceFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedPreferenceChangeListener { From af983b79037c0a8778e0dcc84811b0d3a6c16627 Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 25 Jun 2020 14:04:18 +0800 Subject: [PATCH 263/296] =?UTF-8?q?feat:=20E-Ink=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E5=90=88=E5=B9=B6=E5=88=B0=E4=B8=BB=E9=A2=98=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E9=87=8C,=20E-Ink=E6=A8=A1=E5=BC=8F=E4=B8=8D=E8=83=BD=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E9=98=85=E8=AF=BB=E7=95=8C=E9=9D=A2=E8=83=8C=E6=99=AF?= =?UTF-8?q?=E5=92=8C=E6=96=87=E5=AD=97=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 36793bed1..65befde89 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 @@ -4,12 +4,12 @@ import android.content.Context import android.util.AttributeSet import android.view.WindowManager import android.view.animation.Animation -import android.view.animation.AnimationUtils import android.widget.FrameLayout import android.widget.SeekBar import androidx.core.view.isVisible import io.legado.app.App import io.legado.app.R +import io.legado.app.constant.EventBus import io.legado.app.help.AppConfig import io.legado.app.help.ReadBookConfig import io.legado.app.lib.theme.accentColor @@ -153,6 +153,7 @@ class ReadMenu : FrameLayout { fabNightTheme.onClick { AppConfig.isNightTheme = !AppConfig.isNightTheme App.INSTANCE.applyDayNight() + postEvent(EventBus.RECREATE, "") } //上一章 From b412bb9ee75528027ba1c6c14d9c22b6a2d93beb Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 25 Jun 2020 14:05:14 +0800 Subject: [PATCH 264/296] =?UTF-8?q?feat:=20E-Ink=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E5=90=88=E5=B9=B6=E5=88=B0=E4=B8=BB=E9=A2=98=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E9=87=8C,=20E-Ink=E6=A8=A1=E5=BC=8F=E4=B8=8D=E8=83=BD=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E9=98=85=E8=AF=BB=E7=95=8C=E9=9D=A2=E8=83=8C=E6=99=AF?= =?UTF-8?q?=E5=92=8C=E6=96=87=E5=AD=97=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 7cc685092..676cab469 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -5,6 +5,7 @@ **2020/06/25** * E-Ink模式合并到主题模式里, E-Ink模式不能修改阅读界面背景和文字颜色 +* 如果出现花屏请重新配置下主题颜色试试 **2020/06/22** * 修复xpath获取正文多了许多逗号的bug From a7a9f2e61cd51843b00383f8c3e53996d1e46e78 Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 25 Jun 2020 14:20:15 +0800 Subject: [PATCH 265/296] =?UTF-8?q?feat:=20E-Ink=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E5=90=88=E5=B9=B6=E5=88=B0=E4=B8=BB=E9=A2=98=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E9=87=8C,=20E-Ink=E6=A8=A1=E5=BC=8F=E4=B8=8D=E8=83=BD=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E9=98=85=E8=AF=BB=E7=95=8C=E9=9D=A2=E8=83=8C=E6=99=AF?= =?UTF-8?q?=E5=92=8C=E6=96=87=E5=AD=97=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 676cab469..67667181e 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -5,7 +5,7 @@ **2020/06/25** * E-Ink模式合并到主题模式里, E-Ink模式不能修改阅读界面背景和文字颜色 -* 如果出现花屏请重新配置下主题颜色试试 +* 如果出现花屏请恢复下默认主题试试 **2020/06/22** * 修复xpath获取正文多了许多逗号的bug From ce5f8bc7b869eb335ebe24031e95434ae347199c Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 25 Jun 2020 21:17:29 +0800 Subject: [PATCH 266/296] =?UTF-8?q?feat:=20=E9=98=B2=E6=AD=A2=E8=83=8C?= =?UTF-8?q?=E6=99=AF=E9=A2=9C=E8=89=B2=E9=80=8F=E6=98=8E,=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=E9=87=8D=E5=BD=B1,=E8=8A=B1=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/App.kt | 45 +++++++++++-------- .../app/ui/widget/prefs/ColorPreference.kt | 39 ++++++++++------ 2 files changed, 53 insertions(+), 31 deletions(-) diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt index 9474efac5..59ca19d30 100644 --- a/app/src/main/java/io/legado/app/App.kt +++ b/app/src/main/java/io/legado/app/App.kt @@ -20,6 +20,7 @@ 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.ColorUtils import io.legado.app.lib.theme.ThemeStore import io.legado.app.utils.getCompatColor import io.legado.app.utils.getPrefInt @@ -83,30 +84,38 @@ class App : Application() { .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)) + val background = + getPrefInt(PreferKey.cNBackground, getCompatColor(R.color.shine_color)) + val bBackground = + getPrefInt(PreferKey.cNBBackground, getCompatColor(R.color.md_grey_850)) ThemeStore.editTheme(this) .coloredNavigationBar(true) - .primaryColor( - getPrefInt(PreferKey.cNPrimary, getCompatColor(R.color.md_blue_grey_600)) - ).accentColor( - getPrefInt(PreferKey.cNAccent, getCompatColor(R.color.md_deep_orange_800)) - ).backgroundColor( - getPrefInt(PreferKey.cNBackground, getCompatColor(R.color.shine_color)) - ).bottomBackground( - getPrefInt(PreferKey.cNBBackground, getCompatColor(R.color.md_grey_850)) - ).apply() + .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_indigo_800)) + val accent = + getPrefInt(PreferKey.cAccent, getCompatColor(R.color.md_red_600)) + val background = + getPrefInt(PreferKey.cBackground, getCompatColor(R.color.md_grey_100)) + val bBackground = + getPrefInt(PreferKey.cBBackground, getCompatColor(R.color.md_grey_200)) ThemeStore.editTheme(this) .coloredNavigationBar(true) - .primaryColor( - getPrefInt(PreferKey.cPrimary, getCompatColor(R.color.md_indigo_800)) - ).accentColor( - getPrefInt(PreferKey.cAccent, getCompatColor(R.color.md_red_600)) - ).backgroundColor( - getPrefInt(PreferKey.cBackground, getCompatColor(R.color.md_grey_100)) - ).bottomBackground( - getPrefInt(PreferKey.cBBackground, getCompatColor(R.color.md_grey_200)) - ).apply() + .primaryColor(ColorUtils.withAlpha(primary, 1f)) + .accentColor(ColorUtils.withAlpha(accent, 1f)) + .backgroundColor(ColorUtils.withAlpha(background, 1f)) + .bottomBackground(ColorUtils.withAlpha(bBackground, 1f)) + .apply() } } } diff --git a/app/src/main/java/io/legado/app/ui/widget/prefs/ColorPreference.kt b/app/src/main/java/io/legado/app/ui/widget/prefs/ColorPreference.kt index 101b6678a..0ea45510f 100644 --- a/app/src/main/java/io/legado/app/ui/widget/prefs/ColorPreference.kt +++ b/app/src/main/java/io/legado/app/ui/widget/prefs/ColorPreference.kt @@ -14,6 +14,7 @@ import androidx.preference.Preference import androidx.preference.PreferenceViewHolder import com.jaredrummler.android.colorpicker.* import io.legado.app.lib.theme.ATH +import io.legado.app.lib.theme.ColorUtils class ColorPreference(context: Context, attrs: AttributeSet) : Preference(context, attrs), ColorPickerDialogListener { @@ -22,8 +23,9 @@ class ColorPreference(context: Context, attrs: AttributeSet) : Preference(contex private val sizeLarge = 1 private var onShowDialogListener: OnShowDialogListener? = null - private var color = Color.BLACK + private var mColor = Color.BLACK private var showDialog: Boolean = false + @ColorPickerDialog.DialogType private var dialogType: Int = 0 private var colorShape: Int = 0 @@ -42,7 +44,8 @@ class ColorPreference(context: Context, attrs: AttributeSet) : Preference(contex val a = context.obtainStyledAttributes(attrs, R.styleable.ColorPreference) showDialog = a.getBoolean(R.styleable.ColorPreference_cpv_showDialog, true) - dialogType = a.getInt(R.styleable.ColorPreference_cpv_dialogType, ColorPickerDialog.TYPE_PRESETS) + dialogType = + a.getInt(R.styleable.ColorPreference_cpv_dialogType, ColorPickerDialog.TYPE_PRESETS) colorShape = a.getInt(R.styleable.ColorPreference_cpv_colorShape, ColorShape.CIRCLE) allowPresets = a.getBoolean(R.styleable.ColorPreference_cpv_allowPresets, true) allowCustom = a.getBoolean(R.styleable.ColorPreference_cpv_allowCustom, true) @@ -50,7 +53,8 @@ class ColorPreference(context: Context, attrs: AttributeSet) : Preference(contex showColorShades = a.getBoolean(R.styleable.ColorPreference_cpv_showColorShades, true) previewSize = a.getInt(R.styleable.ColorPreference_cpv_previewSize, sizeNormal) val presetsResId = a.getResourceId(R.styleable.ColorPreference_cpv_colorPresets, 0) - dialogTitle = a.getResourceId(R.styleable.ColorPreference_cpv_dialogTitle, R.string.cpv_default_title) + dialogTitle = + a.getResourceId(R.styleable.ColorPreference_cpv_dialogTitle, R.string.cpv_default_title) presets = if (presetsResId != 0) { context.resources.getIntArray(presetsResId) } else { @@ -67,7 +71,7 @@ class ColorPreference(context: Context, attrs: AttributeSet) : Preference(contex override fun onClick() { super.onClick() if (onShowDialogListener != null) { - onShowDialogListener!!.onShowColorPickerDialog(title as String, color) + onShowDialogListener!!.onShowColorPickerDialog(title as String, mColor) } else if (showDialog) { val dialog = ColorPickerDialogCompat.newBuilder() .setDialogType(dialogType) @@ -78,7 +82,7 @@ class ColorPreference(context: Context, attrs: AttributeSet) : Preference(contex .setAllowCustom(allowCustom) .setShowAlphaSlider(showAlphaSlider) .setShowColorShades(showColorShades) - .setColor(color) + .setColor(mColor) .create() dialog.setColorPickerDialogListener(this) getActivity().supportFragmentManager @@ -111,10 +115,12 @@ class ColorPreference(context: Context, attrs: AttributeSet) : Preference(contex } override fun onBindViewHolder(holder: PreferenceViewHolder) { - val v = io.legado.app.ui.widget.prefs.Preference.bindView(context, holder, icon, title, summary, widgetLayoutResource, - io.legado.app.R.id.cpv_preference_preview_color_panel, 30, 30) + val v = io.legado.app.ui.widget.prefs.Preference.bindView( + context, holder, icon, title, summary, widgetLayoutResource, + io.legado.app.R.id.cpv_preference_preview_color_panel, 30, 30 + ) if (v is ColorPanelView) { - v.color = color + v.color = mColor } super.onBindViewHolder(holder) } @@ -122,10 +128,10 @@ class ColorPreference(context: Context, attrs: AttributeSet) : Preference(contex override fun onSetInitialValue(defaultValue: Any?) { super.onSetInitialValue(defaultValue) if (defaultValue is Int) { - color = (defaultValue as Int?)!! - persistInt(color) + mColor = if (!showAlphaSlider) ColorUtils.withAlpha(defaultValue, 1f) else defaultValue + persistInt(mColor) } else { - color = getPersistedInt(-0x1000000) + mColor = getPersistedInt(-0x1000000) } } @@ -147,8 +153,8 @@ class ColorPreference(context: Context, attrs: AttributeSet) : Preference(contex * @param color The newly selected color */ fun saveValue(@ColorInt color: Int) { - this.color = color - persistInt(this.color) + mColor = if (showAlphaSlider) color else ColorUtils.withAlpha(color, 1f) + persistInt(mColor) notifyChanged() callChangeListener(color) } @@ -231,17 +237,23 @@ class ColorPreference(context: Context, attrs: AttributeSet) : Preference(contex class Builder internal constructor() { internal var colorPickerDialogListener: ColorPickerDialogListener? = null + @StringRes internal var dialogTitle = R.string.cpv_default_title + @StringRes internal var presetsButtonText = R.string.cpv_presets + @StringRes internal var customButtonText = R.string.cpv_custom + @StringRes internal var selectedButtonText = R.string.cpv_select + @DialogType internal var dialogType = TYPE_PRESETS internal var presets = MATERIAL_COLORS + @ColorInt internal var color = Color.BLACK internal var dialogId = 0 @@ -249,6 +261,7 @@ class ColorPreference(context: Context, attrs: AttributeSet) : Preference(contex internal var allowPresets = true internal var allowCustom = true internal var showColorShades = true + @ColorShape internal var colorShape = ColorShape.CIRCLE From 7167542db0f625716b7f69c2968ba27714392078 Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 25 Jun 2020 21:38:02 +0800 Subject: [PATCH 267/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/ui/main/MainActivity.kt | 6 ------ 1 file changed, 6 deletions(-) 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 1eb3250e0..a417f4ca1 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 @@ -18,7 +18,6 @@ import io.legado.app.help.AppConfig import io.legado.app.help.storage.Backup import io.legado.app.lib.theme.ATH import io.legado.app.service.BaseReadAloudService -import io.legado.app.service.help.ReadAloud import io.legado.app.ui.main.bookshelf.BookshelfFragment import io.legado.app.ui.main.explore.ExploreFragment import io.legado.app.ui.main.my.MyFragment @@ -144,11 +143,6 @@ class MainActivity : VMBaseActivity(R.layout.activity_main), } } - override fun onDestroy() { - super.onDestroy() - ReadAloud.stop(this) - } - override fun observeLiveBus() { observeEvent(EventBus.RECREATE) { recreate() From 1cf9c1ded6e855d067a0846cdfe7361d1c1ee51e Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 25 Jun 2020 21:46:20 +0800 Subject: [PATCH 268/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/App.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt index 59ca19d30..b93a0d8ab 100644 --- a/app/src/main/java/io/legado/app/App.kt +++ b/app/src/main/java/io/legado/app/App.kt @@ -25,6 +25,7 @@ import io.legado.app.lib.theme.ThemeStore import io.legado.app.utils.getCompatColor import io.legado.app.utils.getPrefInt import io.legado.app.utils.postEvent +import io.legado.app.utils.putPrefInt @Suppress("DEPRECATION") class App : Application() { @@ -105,10 +106,18 @@ class App : Application() { getPrefInt(PreferKey.cPrimary, getCompatColor(R.color.md_indigo_800)) val accent = getPrefInt(PreferKey.cAccent, getCompatColor(R.color.md_red_600)) - val background = + var background = getPrefInt(PreferKey.cBackground, getCompatColor(R.color.md_grey_100)) - val bBackground = + if (!ColorUtils.isColorLight(background)) { + background = getCompatColor(R.color.md_grey_100) + putPrefInt(PreferKey.cBackground, background) + } + var bBackground = getPrefInt(PreferKey.cBBackground, getCompatColor(R.color.md_grey_200)) + if (!ColorUtils.isColorLight(bBackground)) { + bBackground = getCompatColor(R.color.md_grey_200) + putPrefInt(PreferKey.cBBackground, bBackground) + } ThemeStore.editTheme(this) .coloredNavigationBar(true) .primaryColor(ColorUtils.withAlpha(primary, 1f)) From 76c95103212f88cc690fc182fb966adf4a3cc793 Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 25 Jun 2020 21:54:45 +0800 Subject: [PATCH 269/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 67667181e..979f9637e 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -5,7 +5,7 @@ **2020/06/25** * E-Ink模式合并到主题模式里, E-Ink模式不能修改阅读界面背景和文字颜色 -* 如果出现花屏请恢复下默认主题试试 +* 添加判断,防止背景透明引起重影,花屏问题 **2020/06/22** * 修复xpath获取正文多了许多逗号的bug From 9dde645644f10f67223215e8a3c82cb347ad1432 Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 26 Jun 2020 10:19:00 +0800 Subject: [PATCH 270/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/App.kt | 14 ++- .../app/ui/config/ThemeConfigFragment.kt | 96 ++++++++++--------- app/src/main/res/values/colors.xml | 1 - 3 files changed, 60 insertions(+), 51 deletions(-) diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt index b93a0d8ab..43381a2c8 100644 --- a/app/src/main/java/io/legado/app/App.kt +++ b/app/src/main/java/io/legado/app/App.kt @@ -89,10 +89,18 @@ class App : Application() { getPrefInt(PreferKey.cNPrimary, getCompatColor(R.color.md_blue_grey_600)) val accent = getPrefInt(PreferKey.cNAccent, getCompatColor(R.color.md_deep_orange_800)) - val background = - getPrefInt(PreferKey.cNBackground, getCompatColor(R.color.shine_color)) - val bBackground = + 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) + } + var bBackground = getPrefInt(PreferKey.cNBBackground, getCompatColor(R.color.md_grey_850)) + if (!ColorUtils.isColorLight(bBackground)) { + bBackground = getCompatColor(R.color.md_grey_850) + putPrefInt(PreferKey.cNBBackground, bBackground) + } ThemeStore.editTheme(this) .coloredNavigationBar(true) .primaryColor(ColorUtils.withAlpha(primary, 1f)) 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 13d12c4b0..d15fac81b 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 @@ -132,59 +132,15 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), @SuppressLint("PrivateResource") override fun onPreferenceTreeClick(preference: Preference?): Boolean { when (preference?.key) { - "defaultTheme" -> alert(title = "切换默认主题") { - items(items) { _, which -> - when (which) { - 0 -> { - putPrefInt("colorPrimary", getCompatColor(R.color.md_grey_100)) - putPrefInt("colorAccent", getCompatColor(R.color.lightBlue_color)) - putPrefInt("colorBackground", getCompatColor(R.color.md_grey_100)) - AppConfig.isNightTheme = false - } - 1 -> { - putPrefInt("colorPrimaryNight", getCompatColor(R.color.shine_color)) - putPrefInt("colorAccentNight", getCompatColor(R.color.lightBlue_color)) - putPrefInt("colorBackgroundNight", getCompatColor(R.color.shine_color)) - AppConfig.isNightTheme = true - } - 2 -> { - putPrefInt("colorPrimary", getCompatColor(R.color.md_light_blue_500)) - putPrefInt("colorAccent", getCompatColor(R.color.md_pink_800)) - putPrefInt("colorBackground", getCompatColor(R.color.md_grey_100)) - AppConfig.isNightTheme = false - } - 3 -> { - putPrefInt("colorPrimary", getCompatColor(R.color.white)) - putPrefInt("colorAccent", getCompatColor(R.color.black)) - putPrefInt("colorBackground", getCompatColor(R.color.white)) - putPrefInt("colorBottomBackground", getCompatColor(R.color.white)) - AppConfig.isNightTheme = false - } - 4 -> { - putPrefInt("colorPrimaryNight", getCompatColor(R.color.black)) - putPrefInt( - "colorAccentNight", - getCompatColor(R.color.md_grey_500) - ) - putPrefInt( - "colorBackgroundNight", - getCompatColor(R.color.black) - ) - putPrefInt("colorBottomBackgroundNight", getCompatColor(R.color.black)) - AppConfig.isNightTheme = true - } - } - App.INSTANCE.applyDayNight() - recreateActivities() - } - }.show().applyTint() + "defaultTheme" -> changeTheme() "barElevation" -> NumberPickerDialog(requireContext()) .setTitle(getString(R.string.bar_elevation)) .setMaxValue(32) .setMinValue(0) .setValue(AppConfig.elevation) .setCustomButton((R.string.btn_default_s)) { - AppConfig.elevation = App.INSTANCE.resources.getDimension(R.dimen.design_appbar_elevation).toInt() + AppConfig.elevation = + App.INSTANCE.resources.getDimension(R.dimen.design_appbar_elevation).toInt() recreateActivities() } .show { @@ -195,6 +151,52 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), return super.onPreferenceTreeClick(preference) } + private fun changeTheme() { + alert(title = "切换默认主题") { + items(items) { _, which -> + when (which) { + 0 -> { + putPrefInt(PreferKey.cPrimary, getCompatColor(R.color.md_grey_100)) + putPrefInt(PreferKey.cAccent, getCompatColor(R.color.lightBlue_color)) + putPrefInt(PreferKey.cBackground, getCompatColor(R.color.md_grey_100)) + putPrefInt(PreferKey.cBBackground, getCompatColor(R.color.md_grey_200)) + AppConfig.isNightTheme = false + } + 1 -> { + putPrefInt(PreferKey.cNPrimary, getCompatColor(R.color.md_grey_900)) + putPrefInt(PreferKey.cNAccent, getCompatColor(R.color.lightBlue_color)) + putPrefInt(PreferKey.cNBackground, getCompatColor(R.color.md_grey_900)) + putPrefInt(PreferKey.cNBBackground, getCompatColor(R.color.md_grey_900)) + AppConfig.isNightTheme = true + } + 2 -> { + putPrefInt(PreferKey.cPrimary, getCompatColor(R.color.md_light_blue_500)) + putPrefInt(PreferKey.cAccent, getCompatColor(R.color.md_pink_800)) + putPrefInt(PreferKey.cBackground, getCompatColor(R.color.md_grey_100)) + putPrefInt(PreferKey.cBBackground, getCompatColor(R.color.md_grey_200)) + AppConfig.isNightTheme = false + } + 3 -> { + putPrefInt(PreferKey.cPrimary, getCompatColor(R.color.white)) + putPrefInt(PreferKey.cAccent, getCompatColor(R.color.black)) + putPrefInt(PreferKey.cBackground, getCompatColor(R.color.white)) + putPrefInt(PreferKey.cBBackground, getCompatColor(R.color.white)) + AppConfig.isNightTheme = false + } + 4 -> { + putPrefInt(PreferKey.cNPrimary, getCompatColor(R.color.black)) + putPrefInt(PreferKey.cNAccent, getCompatColor(R.color.md_grey_500)) + putPrefInt(PreferKey.cNBackground, getCompatColor(R.color.black)) + putPrefInt(PreferKey.cNBBackground, getCompatColor(R.color.black)) + AppConfig.isNightTheme = true + } + } + App.INSTANCE.applyDayNight() + recreateActivities() + } + }.show().applyTint() + } + private fun backgroundIsDark(sharedPreferences: SharedPreferences): Boolean { return !ColorUtils.isColorLight( sharedPreferences.getInt( diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index d74c3a850..b730f36c9 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -6,7 +6,6 @@ #66666666 #FF578FCC - #FF212227 #eb4333 #439b53 From 7a52ea78b9cfe8a601b3d8c04f89ecd7a4f83a23 Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 26 Jun 2020 10:36:41 +0800 Subject: [PATCH 271/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/config/ThemeConfigFragment.kt | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) 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 d15fac81b..81fc16204 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 @@ -77,17 +77,17 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), when (key) { PreferKey.launcherIcon -> LauncherIconHelp.changeIcon(getPrefString(key)) "transparentStatusBar" -> recreateActivities() - "colorPrimary", - "colorAccent", - "colorBackground", - "colorBottomBackground" -> { + PreferKey.cPrimary, + PreferKey.cAccent, + PreferKey.cBackground, + PreferKey.cBBackground -> { if (backgroundIsDark(sharedPreferences)) { alert { title = "白天背景太暗" message = "将会恢复默认背景?" yesButton { putPrefInt( - "colorBackground", + PreferKey.cBackground, getCompatColor(R.color.md_grey_100) ) upTheme(false) @@ -101,17 +101,17 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), upTheme(false) } } - "colorPrimaryNight", - "colorAccentNight", - "colorBackgroundNight", - "colorBottomBackgroundNight" -> { + PreferKey.cNPrimary, + PreferKey.cNAccent, + PreferKey.cNBackground, + PreferKey.cNBBackground -> { if (backgroundIsLight(sharedPreferences)) { alert { title = "夜间背景太亮" message = "将会恢复默认背景?" yesButton { putPrefInt( - "colorBackgroundNight", + PreferKey.cNBackground, getCompatColor(R.color.md_grey_800) ) upTheme(true) @@ -200,7 +200,7 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), private fun backgroundIsDark(sharedPreferences: SharedPreferences): Boolean { return !ColorUtils.isColorLight( sharedPreferences.getInt( - "colorBackground", + PreferKey.cBackground, getCompatColor(R.color.md_grey_100) ) ) @@ -209,7 +209,7 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), private fun backgroundIsLight(sharedPreferences: SharedPreferences): Boolean { return ColorUtils.isColorLight( sharedPreferences.getInt( - "colorBackgroundNight", + PreferKey.cNBackground, getCompatColor(R.color.md_grey_800) ) ) From ede9917488f1d6c7713f2c87a7d35a865e7d7b13 Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 26 Jun 2020 10:41:08 +0800 Subject: [PATCH 272/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/constant/PreferKey.kt | 7 ------- 1 file changed, 7 deletions(-) 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 8236536ca..b3c6f6d68 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -56,11 +56,4 @@ object PreferKey { const val cNBackground = "colorBackgroundNight" const val cNBBackground = "colorBottomBackgroundNight" - const val cLPrimary = "lastColorPrimary" - const val cLAccent = "lastColorAccent" - const val cLBackground = "lastColorBackground" - const val cLBBackground = "lastColorBottomBackground" - - const val lastPageAnim = "lastPageAnim" - const val lastThemeMode = "lastThemeMode" } \ No newline at end of file From d3da122d30ae5d7dbf6871fba85fec9ed195db95 Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 26 Jun 2020 10:59:19 +0800 Subject: [PATCH 273/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/constant/PreferKey.kt | 1 + app/src/main/java/io/legado/app/help/AppConfig.kt | 4 ++-- .../java/io/legado/app/ui/config/ThemeConfigFragment.kt | 7 ++++--- 3 files changed, 7 insertions(+), 5 deletions(-) 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 b3c6f6d68..3e28526c5 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -45,6 +45,7 @@ object PreferKey { const val readBodyToLh = "readBodyToLh" const val textFullJustify = "textFullJustify" const val autoReadSpeed = "autoReadSpeed" + const val barElevation = "barElevation" const val cPrimary = "colorPrimary" const val cAccent = "colorAccent" diff --git a/app/src/main/java/io/legado/app/help/AppConfig.kt b/app/src/main/java/io/legado/app/help/AppConfig.kt index 5e98ae482..bf8713c8c 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -125,11 +125,11 @@ object AppConfig { var elevation: Int @SuppressLint("PrivateResource") get() = App.INSTANCE.getPrefInt( - "elevation", + PreferKey.barElevation, App.INSTANCE.resources.getDimension(R.dimen.design_appbar_elevation).toInt() ) set(value) { - App.INSTANCE.putPrefInt("elevation", value) + App.INSTANCE.putPrefInt(PreferKey.barElevation, value) } val autoChangeSource: Boolean get() = App.INSTANCE.getPrefBoolean("autoChangeSource", true) 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 81fc16204..6d9d94027 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 @@ -38,7 +38,7 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), preferenceScreen.removePreference(it) } } - upPreferenceSummary("barElevation", AppConfig.elevation.toString()) + upPreferenceSummary(PreferKey.barElevation, AppConfig.elevation.toString()) } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -133,7 +133,7 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), override fun onPreferenceTreeClick(preference: Preference?): Boolean { when (preference?.key) { "defaultTheme" -> changeTheme() - "barElevation" -> NumberPickerDialog(requireContext()) + PreferKey.barElevation -> NumberPickerDialog(requireContext()) .setTitle(getString(R.string.bar_elevation)) .setMaxValue(32) .setMinValue(0) @@ -231,7 +231,8 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), private fun upPreferenceSummary(preferenceKey: String, value: String?) { val preference = findPreference(preferenceKey) ?: return when (preferenceKey) { - "barElevation" -> preference.summary = getString(R.string.bar_elevation_s, value) + PreferKey.barElevation -> preference.summary = + getString(R.string.bar_elevation_s, value) } } } \ No newline at end of file From 4f63ee1cdc96f31389ec1103453bb4b33dc3fe4d Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 26 Jun 2020 11:33:45 +0800 Subject: [PATCH 274/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/xml/pref_config_theme.xml | 106 ++++++++++----------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/app/src/main/res/xml/pref_config_theme.xml b/app/src/main/res/xml/pref_config_theme.xml index 94bef734c..569e2d0d8 100644 --- a/app/src/main/res/xml/pref_config_theme.xml +++ b/app/src/main/res/xml/pref_config_theme.xml @@ -43,85 +43,85 @@ + android:defaultValue="@color/md_light_blue_600" + android:key="colorPrimary" + android:summary="@string/day_color_primary" + android:title="@string/primary" + app:cpv_dialogType="preset" + app:iconSpaceReserved="false" /> + android:defaultValue="@color/md_pink_800" + android:key="colorAccent" + android:summary="@string/day_color_accent" + android:title="@string/accent" + app:cpv_dialogType="preset" + app:iconSpaceReserved="false" /> + android:defaultValue="@color/md_grey_100" + android:key="colorBackground" + android:summary="@string/day_background_color" + android:title="@string/background_color" + app:cpv_dialogType="preset" + app:iconSpaceReserved="false" /> + android:defaultValue="@color/md_grey_200" + android:key="colorBottomBackground" + android:summary="@string/day_navbar_color" + android:title="@string/navbar_color" + app:cpv_dialogType="preset" + app:allowDividerAbove="false" + app:allowDividerBelow="false" + app:iconSpaceReserved="false" /> + android:defaultValue="@color/md_grey_900" + android:key="colorPrimaryNight" + android:summary="@string/night_primary" + android:title="@string/primary" + app:cpv_dialogType="preset" + app:iconSpaceReserved="false" /> + android:defaultValue="@color/md_deep_orange_800" + android:key="colorAccentNight" + android:summary="@string/night_accent" + android:title="@string/accent" + app:cpv_dialogType="preset" + app:iconSpaceReserved="false" /> + android:defaultValue="@color/md_black_1000" + android:key="colorBackgroundNight" + android:summary="@string/night_background_color" + android:title="@string/background_color" + app:cpv_dialogType="preset" + app:iconSpaceReserved="false" /> + android:defaultValue="@color/md_grey_800" + android:key="colorBottomBackgroundNight" + android:summary="@string/night_navbar_color" + android:title="@string/navbar_color" + app:cpv_dialogType="preset" + app:iconSpaceReserved="false" /> From fc47582ac9060382986fff857d988c6c12927b54 Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 26 Jun 2020 12:27:05 +0800 Subject: [PATCH 275/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/constant/PreferKey.kt | 1 + app/src/main/java/io/legado/app/help/AppConfig.kt | 4 ++-- .../main/java/io/legado/app/ui/config/ThemeConfigFragment.kt | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) 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 3e28526c5..93ea963ca 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -46,6 +46,7 @@ object PreferKey { const val textFullJustify = "textFullJustify" const val autoReadSpeed = "autoReadSpeed" const val barElevation = "barElevation" + const val transparentStatusBar = "transparentStatusBar" const val cPrimary = "colorPrimary" const val cAccent = "colorAccent" diff --git a/app/src/main/java/io/legado/app/help/AppConfig.kt b/app/src/main/java/io/legado/app/help/AppConfig.kt index bf8713c8c..43d4e8ac3 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -32,9 +32,9 @@ object AppConfig { get() = App.INSTANCE.getPrefString(PreferKey.themeMode) == "3" var isTransparentStatusBar: Boolean - get() = App.INSTANCE.getPrefBoolean("transparentStatusBar") + get() = App.INSTANCE.getPrefBoolean(PreferKey.transparentStatusBar) set(value) { - App.INSTANCE.putPrefBoolean("transparentStatusBar", value) + App.INSTANCE.putPrefBoolean(PreferKey.transparentStatusBar, value) } val requestedDirection: String? 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 6d9d94027..42a3db246 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 @@ -76,7 +76,7 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), sharedPreferences ?: return when (key) { PreferKey.launcherIcon -> LauncherIconHelp.changeIcon(getPrefString(key)) - "transparentStatusBar" -> recreateActivities() + PreferKey.transparentStatusBar -> recreateActivities() PreferKey.cPrimary, PreferKey.cAccent, PreferKey.cBackground, From 503c7ab8de8d628c1d2734c21324a070f894c16e Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 26 Jun 2020 12:29:13 +0800 Subject: [PATCH 276/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/ui/about/AboutFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e44666349..81ed18e32 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 @@ -53,7 +53,7 @@ class AboutFragment : PreferenceFragmentCompat() { "license" -> requireContext().openUrl(licenseUrl) "disclaimer" -> requireContext().openUrl(disclaimerUrl) "qq" -> showQqGroups() - "gzGzh" -> requireContext().sendToClip("开源阅读软件") + "gzGzh" -> requireContext().sendToClip(getString(R.string.legado_gzh)) } return super.onPreferenceTreeClick(preference) } From 497737444bf3b75ab800fb7fb45e537bfacac379 Mon Sep 17 00:00:00 2001 From: david082321 <7046617+david082321@users.noreply.github.com> Date: Fri, 26 Jun 2020 15:33:38 +0800 Subject: [PATCH 277/296] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将"没有上一页"与"没有下一页",移到res/values/strings.xml --- .../io/legado/app/ui/book/read/page/delegate/PageDelegate.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt index 2f3bf9728..1f46e1dfa 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt @@ -15,6 +15,7 @@ import io.legado.app.help.ReadBookConfig import io.legado.app.ui.book.read.page.ContentView import io.legado.app.ui.book.read.page.PageView import kotlin.math.abs +import io.legado.app.R abstract class PageDelegate(protected val pageView: PageView) : GestureDetector.SimpleOnGestureListener() { @@ -316,7 +317,7 @@ abstract class PageDelegate(protected val pageView: PageView) : val hasPrev = pageView.pageFactory.hasPrev() if (!hasPrev) { if (!snackBar.isShown) { - snackBar.setText("没有上一页") + snackBar.setText(R.string.no_prev_page) snackBar.show() } } @@ -330,7 +331,7 @@ abstract class PageDelegate(protected val pageView: PageView) : val hasNext = pageView.pageFactory.hasNext() if (!hasNext) { if (!snackBar.isShown) { - snackBar.setText("没有下一页") + snackBar.setText(R.string.no_next_page) snackBar.show() } } From 5b53569861ad57f3d2aeabe1cd4fd5f257ec0209 Mon Sep 17 00:00:00 2001 From: david082321 <7046617+david082321@users.noreply.github.com> Date: Fri, 26 Jun 2020 15:36:24 +0800 Subject: [PATCH 278/296] Update strings.xml --- app/src/main/res/values/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b32c7ffbd..ab9bdaa15 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -377,6 +377,8 @@ 登录%s 成功 当前源没有配置登陆地址 + 没有上一页 + 没有下一页 源名称(sourceName) From dd7bd6a02aaee18c06fdcfa0be5b43a2d44e2c2e Mon Sep 17 00:00:00 2001 From: david082321 <7046617+david082321@users.noreply.github.com> Date: Fri, 26 Jun 2020 15:37:57 +0800 Subject: [PATCH 279/296] Update strings.xml --- app/src/main/res/values-zh-rHK/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index c499172ad..4f5ea6840 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -375,6 +375,8 @@ 登錄 %s 成功 當前源沒有配置登陸地址 + 沒有上一頁 + 沒有下一頁 源名稱 (sourceName) From c7e6ee67697e9c699f605843c6eb8dc9200c97b0 Mon Sep 17 00:00:00 2001 From: david082321 <7046617+david082321@users.noreply.github.com> Date: Fri, 26 Jun 2020 15:40:35 +0800 Subject: [PATCH 280/296] Update strings.xml --- app/src/main/res/values-zh-rTW/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 181cdddbd..672ad5e4d 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -376,6 +376,8 @@ 登入%s 成功 目前源沒有配置登入地址 + 沒有上一頁 + 沒有下一頁 源名稱(sourceName) From 81616e3d025691a62ae1f1b4e335db1b310416be Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 26 Jun 2020 17:18:17 +0800 Subject: [PATCH 281/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6b2bafdd8..0bcfbc414 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -240,6 +240,10 @@ android:name="io.legado.app.ui.book.chapterlist.ChapterListActivity" android:screenOrientation="behind" android:launchMode="singleTop" /> + + - - Date: Fri, 26 Jun 2020 20:31:54 +0800 Subject: [PATCH 282/296] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E4=BE=9D?= =?UTF-8?q?=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index d54e75be2..b68424a9a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -144,7 +144,7 @@ dependencies { kapt "androidx.room:room-compiler:$room_version" //paging - implementation 'androidx.paging:paging-runtime:2.1.2' + implementation 'androidx.paging:paging-runtime-ktx:2.1.2' //anko def anko_version = '0.10.8' From 09a405647af5230e4e8650a63b31bba48db6306f Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 27 Jun 2020 11:54:33 +0800 Subject: [PATCH 283/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/service/DownloadService.kt | 185 ++++++++++++------ 1 file changed, 123 insertions(+), 62 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/DownloadService.kt b/app/src/main/java/io/legado/app/service/DownloadService.kt index bf6b90629..845f99fc0 100644 --- a/app/src/main/java/io/legado/app/service/DownloadService.kt +++ b/app/src/main/java/io/legado/app/service/DownloadService.kt @@ -9,6 +9,7 @@ import io.legado.app.base.BaseService import io.legado.app.constant.AppConst import io.legado.app.constant.EventBus import io.legado.app.constant.IntentAction +import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter import io.legado.app.help.AppConfig import io.legado.app.help.BookHelp @@ -24,14 +25,21 @@ import org.jetbrains.anko.toast import java.util.concurrent.Executors class DownloadService : BaseService() { + private val threadCount = AppConfig.threadCount private var searchPool = - Executors.newFixedThreadPool(AppConfig.threadCount).asCoroutineDispatcher() + Executors.newFixedThreadPool(threadCount).asCoroutineDispatcher() private var tasks = CompositeCoroutine() private val handler = Handler() private var runnable: Runnable = Runnable { upDownload() } + private val bookMap = hashMapOf() + private val webBookMap = hashMapOf() private val downloadMap = hashMapOf>() private val downloadCount = hashMapOf() private val finalMap = hashMapOf>() + private val downloadingList = arrayListOf() + + @Volatile + private var downloadingCount = 0 private var notificationContent = "正在启动下载" private val notificationBuilder by lazy { @@ -78,20 +86,50 @@ class DownloadService : BaseService() { postEvent(EventBus.UP_DOWNLOAD, downloadMap) } + private fun getBook(bookUrl: String): Book? { + var book = bookMap[bookUrl] + if (book == null) { + book = App.db.bookDao().getBook(bookUrl) + } + if (book == null) { + removeDownload(bookUrl) + } + return book + } + + private fun getWebBook(bookUrl: String, origin: String): WebBook? { + var webBook = webBookMap[origin] + if (webBook == null) { + App.db.bookSourceDao().getBookSource(origin)?.let { + webBook = WebBook(it) + } + } + if (webBook == null) { + removeDownload(bookUrl) + } + return webBook + } + private fun addDownloadData(bookUrl: String?, start: Int, end: Int) { bookUrl ?: return if (downloadMap.containsKey(bookUrl)) { toast("该书已在下载列表") return } + downloadCount[bookUrl] = DownloadCount() execute { - val chapterMap = downloadMap[bookUrl] ?: linkedSetOf().apply { - downloadMap[bookUrl] = this - } App.db.bookChapterDao().getChapterList(bookUrl, start, end).let { - chapterMap.addAll(it) + if (it.isNotEmpty()) { + val chapters = linkedSetOf() + chapters.addAll(it) + downloadMap[bookUrl] = chapters + } + } + for (i in 0 until threadCount) { + if (downloadingCount < threadCount) { + download() + } } - download() } } @@ -100,70 +138,84 @@ class DownloadService : BaseService() { finalMap.remove(bookUrl) } - private fun updateNotification(downloadCount:DownloadCount, totalCount: Int, content: String){ - notificationContent = - "进度:${downloadCount.downloadFinishedCount}/$totalCount,成功:${downloadCount.successCount},$content" - } - private fun download() { - val task = Coroutine.async(this, context = searchPool) { - downloadMap.forEach { entry -> - if (!isActive) return@async - if (!finalMap.containsKey(entry.key)) { - val book = App.db.bookDao().getBook(entry.key) ?: return@async - val bookSource = - App.db.bookSourceDao().getBookSource(book.origin) ?: return@async - val webBook = WebBook(bookSource) - - downloadCount[entry.key] = DownloadCount() - - entry.value.forEach { chapter -> - if (!isActive) return@async - if (downloadMap.containsKey(book.bookUrl)) { - if (!BookHelp.hasContent(book, chapter)) { - webBook.getContent( - book, - chapter, - scope = this, - context = searchPool - ).onSuccess(IO) { content -> - downloadCount[entry.key]?.increaseSuccess() - BookHelp.saveContent(book, chapter, content) - } - .onFinally(IO) { - synchronized(this@DownloadService) { - downloadCount[entry.key]?.increaseFinished() - downloadCount[entry.key]?.let { updateNotification(it, entry.value.size, chapter.title) } - val chapterMap = - finalMap[book.bookUrl] - ?: linkedSetOf().apply { - finalMap[book.bookUrl] = this - } - chapterMap.add(chapter) - if (chapterMap.size == entry.value.size) { - downloadMap.remove(book.bookUrl) - finalMap.remove(book.bookUrl) - downloadCount.remove(entry.key) - } - } + ++downloadingCount + tasks.add(Coroutine.async(this, context = searchPool) { + if (!isActive) return@async + val bookChapter: BookChapter? = synchronized(this@DownloadService) { + downloadMap.forEach { + it.value.forEach { chapter -> + if (!downloadingList.contains(chapter.url)) { + downloadingList.add(chapter.url) + return@synchronized chapter + } + } + } + return@synchronized null + } + if (bookChapter == null) { + postDownloading(false) + } else { + val book = getBook(bookChapter.bookUrl) + if (book == null) { + postDownloading(true) + return@async + } + val webBook = getWebBook(bookChapter.bookUrl, book.origin) + if (webBook == null) { + postDownloading(true) + return@async + } + if (!BookHelp.hasContent(book, bookChapter)) { + webBook.getContent( + book, + bookChapter, + scope = this, + context = searchPool + ).onSuccess(IO) { content -> + downloadCount[book.bookUrl]?.increaseSuccess() + BookHelp.saveContent(book, bookChapter, content) + }.onFinally(IO) { + synchronized(this@DownloadService) { + downloadCount[book.bookUrl]?.increaseFinished() + downloadCount[book.bookUrl]?.let { + updateNotification( + it, + downloadMap[book.bookUrl]?.size, + bookChapter.title + ) + } + val chapterMap = + finalMap[book.bookUrl] + ?: linkedSetOf().apply { + finalMap[book.bookUrl] = this } - } else{ - //无需下载的,设置为增加成功 - downloadCount[entry.key]?.increaseSuccess() - downloadCount[entry.key]?.increaseFinished() + chapterMap.add(bookChapter) + if (chapterMap.size == downloadMap[book.bookUrl]?.size) { + downloadMap.remove(book.bookUrl) + finalMap.remove(book.bookUrl) + downloadCount.remove(book.bookUrl) } } } + postDownloading(true) + } else { + //无需下载的,设置为增加成功 + downloadCount[book.bookUrl]?.increaseSuccess() + downloadCount[book.bookUrl]?.increaseFinished() + postDownloading(true) } - } - } + }) + } - tasks.add(task) - task.invokeOnCompletion { - tasks.remove(task) - if (tasks.isEmpty) { - stopSelf() + private fun postDownloading(hasChapter: Boolean) { + --downloadingCount + if (hasChapter) { + download() + } else { + if (downloadingCount < 1) { + stopDownload() } } } @@ -180,6 +232,15 @@ class DownloadService : BaseService() { handler.postDelayed(runnable, 1000) } + private fun updateNotification( + downloadCount: DownloadCount, + totalCount: Int?, + content: String + ) { + notificationContent = + "进度:${downloadCount.downloadFinishedCount}/$totalCount,成功:${downloadCount.successCount},$content" + } + /** * 更新通知 */ From 35a825c1d378b35bb9f918da7d0124cdc6979de5 Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 3 Jul 2020 20:09:21 +0800 Subject: [PATCH 284/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8D=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E4=B8=A4=E7=AB=AF=E5=AF=B9=E9=BD=90=E6=98=AF=E6=9C=97?= =?UTF-8?q?=E8=AF=BB=E9=AB=98=E4=BA=AE=E4=B8=8D=E5=87=86=E7=A1=AE=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/book/read/page/ChapterProvider.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index 5f52bd12f..39d552c67 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt @@ -124,7 +124,7 @@ object ChapterProvider { val x = if (isTitle && ReadBookConfig.titleMode == 1) (visibleWidth - layout.getLineWidth(lineIndex)) / 2 else 0f - addCharsToLineLast(textLine, words, textPaint, x) + addCharsToLineLast(textLine, words, textPaint, x, true) } else { //中间行 addCharsToLineMiddle(textLine, words, textPaint, desiredWidth, 0f) @@ -163,7 +163,7 @@ object ChapterProvider { ) { var x = 0f if (!ReadBookConfig.textFullJustify) { - addCharsToLineLast(textLine, words, textPaint, x) + addCharsToLineLast(textLine, words, textPaint, x, false) return } val bodyIndent = ReadBookConfig.bodyIndent @@ -192,7 +192,7 @@ object ChapterProvider { startX: Float ) { if (!ReadBookConfig.textFullJustify) { - addCharsToLineLast(textLine, words, textPaint, startX) + addCharsToLineLast(textLine, words, textPaint, startX, false) return } val gapCount: Int = words.length - 1 @@ -218,9 +218,10 @@ object ChapterProvider { textLine: TextLine, words: String, textPaint: TextPaint, - startX: Float + startX: Float, + isLast: Boolean ) { - textLine.text = "$words\n" + textLine.text = if (isLast) "$words\n" else words var x = startX words.toStringArray().forEach { val cw = StaticLayout.getDesiredWidth(it, textPaint) From 43bc739966e8674416f8275882b514eaebe5f23b Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 3 Jul 2020 20:10:00 +0800 Subject: [PATCH 285/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8D=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E4=B8=A4=E7=AB=AF=E5=AF=B9=E9=BD=90=E6=98=AF=E6=9C=97?= =?UTF-8?q?=E8=AF=BB=E9=AB=98=E4=BA=AE=E4=B8=8D=E5=87=86=E7=A1=AE=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 979f9637e..d8e993a82 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/07/03** +* 修复关闭两端对齐是朗读高亮不准确的bug + **2020/06/25** * E-Ink模式合并到主题模式里, E-Ink模式不能修改阅读界面背景和文字颜色 * 添加判断,防止背景透明引起重影,花屏问题 From 72d599354683d07f74f55e9142ca45b9f78adc91 Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 3 Jul 2020 20:26:59 +0800 Subject: [PATCH 286/296] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=96=87?= =?UTF-8?q?=E5=AD=97=E5=BA=95=E9=83=A8=E5=AF=B9=E9=BD=90=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/constant/PreferKey.kt | 1 + app/src/main/java/io/legado/app/help/ReadBookConfig.kt | 1 + .../io/legado/app/ui/book/read/config/MoreConfigDialog.kt | 3 ++- .../io/legado/app/ui/book/read/page/entities/TextPage.kt | 2 ++ app/src/main/res/values-zh-rHK/strings.xml | 1 + app/src/main/res/values-zh-rTW/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/pref_config_read.xml | 6 ++++++ 8 files changed, 15 insertions(+), 1 deletion(-) 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 93ea963ca..4d0194d38 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -44,6 +44,7 @@ object PreferKey { const val systemTypefaces = "system_typefaces" const val readBodyToLh = "readBodyToLh" const val textFullJustify = "textFullJustify" + const val textBottomJustify = "textBottomJustify" const val autoReadSpeed = "autoReadSpeed" const val barElevation = "barElevation" const val transparentStatusBar = "transparentStatusBar" diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index 823ddee55..761946347 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -144,6 +144,7 @@ object ReadBookConfig { var isScroll = pageAnim == 3 val clickTurnPage get() = App.INSTANCE.getPrefBoolean(PreferKey.clickTurnPage, true) val textFullJustify get() = App.INSTANCE.getPrefBoolean(PreferKey.textFullJustify, true) + val textBottomJustify get() = App.INSTANCE.getPrefBoolean(PreferKey.textBottomJustify, true) var bodyIndentCount = App.INSTANCE.getPrefInt(PreferKey.bodyIndent, 2) set(value) { field = value diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt index 7033b82d0..37d30f3d0 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt @@ -111,7 +111,8 @@ class MoreConfigDialog : DialogFragment() { Help.setOrientation(it) } } - PreferKey.textFullJustify -> { + PreferKey.textFullJustify, + PreferKey.textBottomJustify -> { postEvent(EventBus.UP_CONFIG, true) } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt index e81af6986..773fb6150 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt @@ -4,6 +4,7 @@ import android.text.Layout import android.text.StaticLayout import io.legado.app.App import io.legado.app.R +import io.legado.app.help.ReadBookConfig import io.legado.app.ui.book.read.page.ChapterProvider import java.text.DecimalFormat @@ -19,6 +20,7 @@ data class TextPage( ) { fun upLinesPosition() = ChapterProvider.apply { + if (!ReadBookConfig.textBottomJustify) return@apply if (textLines.size <= 1) return@apply if (visibleHeight - height >= with(textLines.last()) { lineBottom - lineTop }) return@apply val surplus = (visibleBottom - textLines.last().lineBottom) diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 4f5ea6840..e1655852a 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -705,4 +705,5 @@ 選擇舊版備份文件夾 已啓用 已禁用 + 文字底部對齊 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 672ad5e4d..3b228acc2 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -705,5 +705,6 @@ 選擇舊版備份文件夾 已啓用 已禁用 + 文字底部對齊 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ab9bdaa15..909721105 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -698,6 +698,7 @@ 夜间,底栏色 自动换源 文字两端对齐 + 文字底部对齐 自动翻页速度 地址排序 本地和WebDav一起备份 diff --git a/app/src/main/res/xml/pref_config_read.xml b/app/src/main/res/xml/pref_config_read.xml index 3b1e81f3c..6125aba08 100644 --- a/app/src/main/res/xml/pref_config_read.xml +++ b/app/src/main/res/xml/pref_config_read.xml @@ -42,6 +42,12 @@ android:key="textFullJustify" app:iconSpaceReserved="false" /> + + Date: Fri, 3 Jul 2020 20:27:28 +0800 Subject: [PATCH 287/296] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=96=87?= =?UTF-8?q?=E5=AD=97=E5=BA=95=E9=83=A8=E5=AF=B9=E9=BD=90=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index d8e993a82..994b04d60 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -5,6 +5,7 @@ **2020/07/03** * 修复关闭两端对齐是朗读高亮不准确的bug +* 添加文字底部对齐开关 **2020/06/25** * E-Ink模式合并到主题模式里, E-Ink模式不能修改阅读界面背景和文字颜色 From cdcc652d8e42f0844e5c452b002c543341b547db Mon Sep 17 00:00:00 2001 From: fisher Date: Fri, 3 Jul 2020 23:30:08 +0800 Subject: [PATCH 288/296] default on for standard title format --- app/src/main/assets/txtTocRule.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/assets/txtTocRule.json b/app/src/main/assets/txtTocRule.json index 62c8afd26..d585846fd 100644 --- a/app/src/main/assets/txtTocRule.json +++ b/app/src/main/assets/txtTocRule.json @@ -8,7 +8,7 @@ }, { "id": -2, - "enable": false, + "enable": true, "name": "目录(去空白)", "rule": "(?<=[ \\s])(?:序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|篇(?!张))).{0,30}$", "serialNumber": 1 From e8aeee6db4452cc7bc59f17fdffe65d42787c572 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 4 Jul 2020 11:09:56 +0800 Subject: [PATCH 289/296] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=96=87?= =?UTF-8?q?=E5=AD=97=E5=BA=95=E9=83=A8=E5=AF=B9=E9=BD=90=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/ReadBookConfig.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index 761946347..3664a3be8 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -141,7 +141,7 @@ object ReadBookConfig { set(value) { App.INSTANCE.putPrefInt(PreferKey.pageAnim, value) } - var isScroll = pageAnim == 3 + val isScroll get() = pageAnim == 3 val clickTurnPage get() = App.INSTANCE.getPrefBoolean(PreferKey.clickTurnPage, true) val textFullJustify get() = App.INSTANCE.getPrefBoolean(PreferKey.textFullJustify, true) val textBottomJustify get() = App.INSTANCE.getPrefBoolean(PreferKey.textBottomJustify, true) From 7087d9f2f41beafa884ac51f6ed10f1f90ba6594 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 4 Jul 2020 11:22:54 +0800 Subject: [PATCH 290/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8D=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8=E7=BF=BB=E9=A1=B5bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/help/ReadBookConfig.kt | 4 +++- .../main/java/io/legado/app/help/storage/Restore.kt | 11 ++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index 3664a3be8..9476cf936 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -90,6 +90,7 @@ object ReadBookConfig { } } } + isScroll = pageAnim == 3 } fun save() { @@ -140,8 +141,9 @@ object ReadBookConfig { get() = if (AppConfig.isEInkMode) -1 else App.INSTANCE.getPrefInt(PreferKey.pageAnim) set(value) { App.INSTANCE.putPrefInt(PreferKey.pageAnim, value) + isScroll = pageAnim == 3 } - val isScroll get() = pageAnim == 3 + var isScroll = pageAnim == 3 val clickTurnPage get() = App.INSTANCE.getPrefBoolean(PreferKey.clickTurnPage, true) val textFullJustify get() = App.INSTANCE.getPrefBoolean(PreferKey.textFullJustify, true) val textBottomJustify get() = App.INSTANCE.getPrefBoolean(PreferKey.textBottomJustify, true) diff --git a/app/src/main/java/io/legado/app/help/storage/Restore.kt b/app/src/main/java/io/legado/app/help/storage/Restore.kt index c92f408bd..058e22933 100644 --- a/app/src/main/java/io/legado/app/help/storage/Restore.kt +++ b/app/src/main/java/io/legado/app/help/storage/Restore.kt @@ -2,7 +2,6 @@ package io.legado.app.help.storage import android.content.Context import android.net.Uri -import androidx.appcompat.app.AppCompatDelegate import androidx.documentfile.provider.DocumentFile import com.jayway.jsonpath.Configuration import com.jayway.jsonpath.JsonPath @@ -13,7 +12,6 @@ import io.legado.app.BuildConfig import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey import io.legado.app.data.entities.* -import io.legado.app.help.AppConfig import io.legado.app.help.LauncherIconHelp import io.legado.app.help.ReadBookConfig import io.legado.app.service.help.ReadBook @@ -132,13 +130,8 @@ object Restore { ReadBook.loadContent(resetPageOffset = false) } withContext(Main) { - if (AppConfig.isNightTheme && AppCompatDelegate.getDefaultNightMode() != AppCompatDelegate.MODE_NIGHT_YES) { - App.INSTANCE.applyDayNight() - } else if (!AppConfig.isNightTheme && AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_YES) { - App.INSTANCE.applyDayNight() - } else { - postEvent(EventBus.RECREATE, "true") - } + App.INSTANCE.applyDayNight() + postEvent(EventBus.RECREATE, "true") if (!BuildConfig.DEBUG) { LauncherIconHelp.changeIcon(App.INSTANCE.getPrefString(PreferKey.launcherIcon)) } From af2aa192249649c632c65568ab7a9af6fc8d7deb Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 4 Jul 2020 11:27:30 +0800 Subject: [PATCH 291/296] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8D=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8=E7=BF=BB=E9=A1=B5bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 994b04d60..6eb4b87e5 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 +**2020/07/04** +* 修复滚动bug + **2020/07/03** * 修复关闭两端对齐是朗读高亮不准确的bug * 添加文字底部对齐开关 From e58a80156d284525c6fb4fb51cf6d7aab06e9534 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 4 Jul 2020 17:52:26 +0800 Subject: [PATCH 292/296] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A06=E7=BE=A4?= =?UTF-8?q?=E7=BE=A4=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/ui/about/AboutFragment.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 81ed18e32..b9e1b2c60 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 @@ -27,7 +27,8 @@ class AboutFragment : PreferenceFragmentCompat() { Pair("(QQ群2)773736122", "5Bm5w6OgLupXnICbYvbgzpPUgf0UlsJF"), Pair("(QQ群3)981838750", "g_Sgmp2nQPKqcZQ5qPcKLHziwX_mpps9"), Pair("(QQ群4)256929088", "czEJPLDnT4Pd9SKQ6RoRVzKhDxLchZrO"), - Pair("(QQ群5)811843556", "zKZ2UYGZ7o5CzcA6ylxzlqi21si_iqaX") + Pair("(QQ群5)811843556", "zKZ2UYGZ7o5CzcA6ylxzlqi21si_iqaX"), + Pair("(QQ群6)870270970", "FeCF8iSxfQbe90HPvGsvcqs5P5oSeY5n") ) override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { From 23e84678db85fb627e62a7e6d951d3c14a9ee64a Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 4 Jul 2020 18:00:16 +0800 Subject: [PATCH 293/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/service/AudioPlayService.kt | 9 +++------ .../java/io/legado/app/service/HttpReadAloudService.kt | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/AudioPlayService.kt b/app/src/main/java/io/legado/app/service/AudioPlayService.kt index fa56e85d0..1817da185 100644 --- a/app/src/main/java/io/legado/app/service/AudioPlayService.kt +++ b/app/src/main/java/io/legado/app/service/AudioPlayService.kt @@ -96,12 +96,9 @@ class AudioPlayService : BaseService(), IntentAction.adjustSpeed -> upSpeed(intent.getFloatExtra("adjust", 1f)) IntentAction.addTimer -> addTimer() IntentAction.setTimer -> setTimer(intent.getIntExtra("minute", 0)) - IntentAction.adjustProgress -> adjustProgress( - intent.getIntExtra( - "position", - position - ) - ) + IntentAction.adjustProgress -> { + adjustProgress(intent.getIntExtra("position", position)) + } else -> stopSelf() } } diff --git a/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt b/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt index 4c29f84ae..e3219d1a4 100644 --- a/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt @@ -206,7 +206,7 @@ class HttpReadAloudService : BaseReadAloudService(), } else { nextChapter() } - }, 100) + }, 50) return true } From 41817eee345e63568ee01b7cdeb01877a7336a14 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 4 Jul 2020 18:37:00 +0800 Subject: [PATCH 294/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/layout/view_title_bar.xml | 1 + app/src/main/res/values/styles.xml | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/app/src/main/res/layout/view_title_bar.xml b/app/src/main/res/layout/view_title_bar.xml index 3b7641388..b19cdc8c9 100644 --- a/app/src/main/res/layout/view_title_bar.xml +++ b/app/src/main/res/layout/view_title_bar.xml @@ -5,4 +5,5 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="?attr/actionBarStyle" + app:titleTextAppearance="@style/ToolbarTitle" app:popupTheme="@style/AppTheme.PopupOverlay"/> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 4cc3907e0..a8400c4fc 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -81,6 +81,10 @@ @null + + //**************************************************************Widget Style******************************************************************************// From 6f810fca54fdcb49527ff2dbb7f4adad8336b185 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 4 Jul 2020 18:55:23 +0800 Subject: [PATCH 295/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 6eb4b87e5..bfd654e0d 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -5,6 +5,7 @@ **2020/07/04** * 修复滚动bug +* 其它一些优化 **2020/07/03** * 修复关闭两端对齐是朗读高亮不准确的bug From daefd81e807c3aa237fe9874fb8dd1b43d6f6af5 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 4 Jul 2020 19:06:25 +0800 Subject: [PATCH 296/296] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/utils/MenuExtensions.kt | 1 - 1 file changed, 1 deletion(-) 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 9167eda46..807ff7c34 100644 --- a/app/src/main/java/io/legado/app/utils/MenuExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/MenuExtensions.kt @@ -10,7 +10,6 @@ import androidx.core.view.forEach import io.legado.app.R import io.legado.app.constant.Theme import io.legado.app.lib.theme.DrawableUtils -import io.legado.app.lib.theme.primaryTextColor import java.lang.reflect.Method import java.util.*