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

pull/298/head
gedoor 4 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
import android.content.Context
import android.os.Bundle
import android.util.AttributeSet
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.view.WindowManager
import android.widget.FrameLayout
import androidx.appcompat.app.AppCompatActivity
import io.legado.app.R
import io.legado.app.constant.Theme
import io.legado.app.lib.theme.ATH
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.utils.applyOpenTint
import io.legado.app.utils.applyTint
@ -27,6 +31,20 @@ abstract class BaseActivity(
) : AppCompatActivity(),
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?) {
window.decorView.disableAutoFill()
initTheme()

@ -84,7 +84,7 @@ interface BookDao {
@Query("update books set `group` = :newGroupId where `group` = :oldGroupId")
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>
@Query(

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

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

Loading…
Cancel
Save