From c5d3d5a1ea69d4d274176d34451b3ddfe2fa077b Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 18 May 2020 19:43:37 +0800 Subject: [PATCH] =?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" /> - + +