feat: 优化

pull/219/head
kunfei 5 years ago
parent f39ac0a011
commit c5d3d5a1ea
  1. 14
      app/src/main/java/io/legado/app/data/AppDatabase.kt
  2. 1
      app/src/main/java/io/legado/app/data/entities/RssSource.kt
  3. 10
      app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt
  4. 13
      app/src/main/res/drawable/bg_img_border.xml
  5. 64
      app/src/main/res/layout/item_rss_article_1.xml
  6. 54
      app/src/main/res/layout/item_rss_article_2.xml
  7. 5
      app/src/main/res/menu/rss_articles.xml
  8. 1
      app/src/main/res/values-zh-rHK/strings.xml
  9. 1
      app/src/main/res/values/strings.xml
  10. 14
      app/src/main/res/xml/pref_main.xml

@ -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

@ -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,

@ -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<Boolean>(EventBus.WEB_SERVICE_STOP) {
webServicePre?.isChecked = false
}
if (requireContext().channel == "google") {
findPreference<NameListPreference>(PreferKey.themeMode)?.let {
it.setOnPreferenceChangeListener { _, _ ->
view?.post { App.INSTANCE.applyDayNight() }
true
}
}
if (AppConfig.isGooglePlay) {
findPreference<PreferenceCategory>("aboutCategory")
?.removePreference(findPreference("donate"))
}

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/background" />
<stroke
android:width="1dp"
android:color="@color/bg_divider_line" />
<corners android:radius="1dp" />
<padding
android:left="0dp"
android:top="0dp"
android:right="0dp"
android:bottom="0dp" />
</shape>

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image_view"
android:layout_width="0dp"
android:layout_height="220dp"
android:contentDescription="@string/loading"
android:visibility="visible"
android:scaleType="centerCrop"
android:paddingTop="12dp"
android:paddingRight="12dp"
android:paddingLeft="12dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
tools:ignore="RtlHardcoded,RtlSymmetry" />
<TextView
android:id="@+id/tv_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:maxLines="2"
android:ellipsize="end"
android:text="@string/app_name"
android:textColor="@color/tv_text_default"
android:textSize="15sp"
android:textStyle="bold"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:paddingTop="12dp"
app:layout_constraintTop_toBottomOf="@+id/image_view"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
<TextView
android:id="@+id/tv_pub_date"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/app_name"
android:textSize="11sp"
android:maxLines="1"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:paddingTop="10dp"
app:layout_constraintTop_toBottomOf="@+id/tv_title"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
tools:ignore="SmallSp" />
<View
android:layout_marginTop="12dp"
app:layout_constraintTop_toBottomOf="@+id/tv_pub_date"
android:layout_height="8dp"
android:layout_width="match_parent"
android:background="@color/bg_divider_line" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:paddingLeft="4dp"
android:paddingTop="8dp"
android:paddingBottom="6dp"
android:paddingRight="4dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image_view"
android:layout_width="0dp"
android:layout_height="272dp"
android:contentDescription="@string/loading"
android:visibility="visible"
android:scaleType="centerCrop"
android:background="@drawable/bg_img_border"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
tools:ignore="RtlHardcoded,RtlSymmetry" />
<TextView
android:id="@+id/tv_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:maxLines="2"
android:ellipsize="end"
android:text="@string/app_name"
android:textColor="@color/tv_text_default"
android:textSize="13sp"
android:paddingTop="10dp"
app:layout_constraintTop_toBottomOf="@+id/image_view"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
<TextView
android:id="@+id/tv_pub_date"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/app_name"
android:textSize="11sp"
android:maxLines="1"
android:paddingTop="8dp"
android:paddingBottom="2dp"
app:layout_constraintTop_toBottomOf="@+id/tv_title"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
tools:ignore="SmallSp" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -12,4 +12,9 @@
android:title="@string/clear"
app:showAsAction="never" />
<item
android:id="@+id/menu_switch_layout"
android:title="@string/switchLayout"
app:showAsAction="never" />
</menu>

@ -670,6 +670,7 @@
<string name="click_to_apply">點擊加入</string>
<string name="middle"></string>
<string name="information">信息</string>
<string name="switchLayout">切換佈局</string>
<!--color-->
<string name="primary">主色調</string>

@ -675,6 +675,7 @@
<string name="information">信息</string>
<string name="hideHeader">隐藏页眉</string>
<string name="hideFooter">隐藏页脚</string>
<string name="switchLayout">切换布局</string>
<!--color-->
<string name="primary">主色调</string>

@ -20,13 +20,23 @@
android:icon="@drawable/ic_cfg_replace"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
<io.legado.app.ui.widget.prefs.NameListPreference
android:defaultValue="0"
android:entries="@array/theme_mode"
android:entryValues="@array/theme_mode_v"
android:key="themeMode"
android:title="@string/theme_mode"
android:summary="@string/theme_mode_desc"
android:icon="@drawable/ic_cfg_theme"
app:iconSpaceReserved="false" />
<!-- <io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false"
android:key="isEInkMode"
android:title="@string/eink_theme"
android:summary="@string/eink_theme_desc"
android:icon="@drawable/ic_cfg_e_lnk"
app:iconSpaceReserved="false" />
app:iconSpaceReserved="false" />-->
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false"

Loading…
Cancel
Save