优化,动态改变菜单背景颜色为主题色

pull/298/head
gedoor 5 years ago
parent 9c0f2ecd0b
commit 6a442cb173
  1. 18
      app/src/main/java/io/legado/app/base/BaseActivity.kt
  2. 2
      app/src/main/java/io/legado/app/data/dao/BookDao.kt
  3. 3
      app/src/main/java/io/legado/app/data/entities/BookProgress.kt
  4. 10
      app/src/main/java/io/legado/app/help/storage/SyncBookProgress.kt

@ -1,15 +1,19 @@
package io.legado.app.base package io.legado.app.base
import android.content.Context
import android.os.Bundle import android.os.Bundle
import android.util.AttributeSet
import android.view.Menu import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
import android.view.WindowManager import android.view.WindowManager
import android.widget.FrameLayout
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import io.legado.app.R import io.legado.app.R
import io.legado.app.constant.Theme import io.legado.app.constant.Theme
import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.ColorUtils import io.legado.app.lib.theme.ColorUtils
import io.legado.app.lib.theme.backgroundColor
import io.legado.app.lib.theme.primaryColor import io.legado.app.lib.theme.primaryColor
import io.legado.app.utils.applyOpenTint import io.legado.app.utils.applyOpenTint
import io.legado.app.utils.applyTint import io.legado.app.utils.applyTint
@ -27,6 +31,20 @@ abstract class BaseActivity(
) : AppCompatActivity(), ) : AppCompatActivity(),
CoroutineScope by MainScope() { CoroutineScope by MainScope() {
override fun onCreateView(
parent: View?,
name: String,
context: Context,
attrs: AttributeSet
): View? {
if (name == "androidx.appcompat.view.menu.ListMenuItemView" &&
parent?.parent is FrameLayout
) {
(parent.parent as View).setBackgroundColor(backgroundColor)
}
return super.onCreateView(parent, name, context, attrs)
}
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
window.decorView.disableAutoFill() window.decorView.disableAutoFill()
initTheme() initTheme()

@ -84,7 +84,7 @@ interface BookDao {
@Query("update books set `group` = :newGroupId where `group` = :oldGroupId") @Query("update books set `group` = :newGroupId where `group` = :oldGroupId")
fun upGroup(oldGroupId: Int, newGroupId: Int) fun upGroup(oldGroupId: Int, newGroupId: Int)
@get:Query("select bookUrl, durChapterIndex, durChapterPos, durChapterTime, durChapterTitle from books") @get:Query("select bookUrl, tocUrl, origin, originName, durChapterIndex, durChapterPos, durChapterTime, durChapterTitle from books")
val allBookProgress: List<BookProgress> val allBookProgress: List<BookProgress>
@Query( @Query(

@ -2,6 +2,9 @@ package io.legado.app.data.entities
data class BookProgress( data class BookProgress(
val bookUrl: String, val bookUrl: String,
val tocUrl: String = "",
var origin: String = "",
var originName: String = "",
val durChapterIndex: Int, val durChapterIndex: Int,
val durChapterPos: Int, val durChapterPos: Int,
val durChapterTime: Long, val durChapterTime: Long,

@ -35,11 +35,11 @@ object SyncBookProgress {
val json = file.readText() val json = file.readText()
GSON.fromJsonArray<BookProgress>(json)?.forEach { GSON.fromJsonArray<BookProgress>(json)?.forEach {
App.db.bookDao().upBookProgress( App.db.bookDao().upBookProgress(
it.bookUrl, bookUrl = it.bookUrl,
it.durChapterIndex, durChapterIndex = it.durChapterIndex,
it.durChapterPos, durChapterPos = it.durChapterPos,
it.durChapterTime, durChapterTime = it.durChapterTime,
it.durChapterTitle durChapterTitle = it.durChapterTitle
) )
} }
} }

Loading…
Cancel
Save