pull/32/head
Invinciblelee 6 years ago
parent fc28ac232a
commit 684a7f4617
  1. 7
      app/src/main/java/io/legado/app/App.kt
  2. 13
      app/src/main/java/io/legado/app/lib/theme/ATH.kt
  3. 42
      app/src/main/java/io/legado/app/lib/theme/MaterialValueHelper.kt
  4. 1
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt
  5. 2
      app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt
  6. 4
      app/src/main/java/io/legado/app/ui/widget/TitleBar.kt
  7. 5
      app/src/main/java/io/legado/app/utils/MenuExtensions.kt
  8. 4
      app/src/main/res/layout/activity_source_edit.xml
  9. 1
      app/src/main/res/layout/view_titlebar.xml

@ -5,6 +5,8 @@ import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import android.content.pm.PackageManager
import android.graphics.PorterDuff
import android.graphics.drawable.Drawable
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatDelegate
@ -15,6 +17,7 @@ import io.legado.app.constant.AppConst.channelIdWeb
import io.legado.app.data.AppDatabase
import io.legado.app.lib.theme.ThemeStore
import io.legado.app.utils.getCompatColor
import io.legado.app.utils.getCompatDrawable
import io.legado.app.utils.getPrefBoolean
import io.legado.app.utils.getPrefInt
import java.util.*
@ -42,14 +45,18 @@ class App : Application() {
} catch (e: PackageManager.NameNotFoundException) {
0
}
if (!ThemeStore.isConfigured(this, versionCode)) upThemeStore()
initNightTheme()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) createChannelId()
LiveEventBus.get()
.config()
.supportBroadcast(this)
.lifecycleObserverAlwaysActive(true)
.autoClear(false)
}
fun initNightTheme() {

@ -7,8 +7,11 @@ import android.content.Context
import android.os.Build
import android.view.View
import android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
import android.widget.EdgeEffect
import androidx.annotation.ColorInt
import androidx.appcompat.app.AlertDialog
import androidx.recyclerview.widget.RecyclerView
/**
* @author Karim Abou Zeid (kabouzeid)
@ -113,4 +116,14 @@ object ATH {
}
return dialog
}
fun setEdgeEffectColor(view: RecyclerView, color: Int) {
view.edgeEffectFactory = object : RecyclerView.EdgeEffectFactory() {
override fun createEdgeEffect(view: RecyclerView, direction: Int): EdgeEffect {
val edgeEffect = super.createEdgeEffect(view, direction)
edgeEffect.color = color
return edgeEffect
}
}
}
}

@ -75,6 +75,48 @@ fun Fragment.getSecondaryDisabledTextColor(dark: Boolean): Int {
} else ContextCompat.getColor(requireContext(), R.color.secondary_text_disabled_material_dark)
}
@ColorInt
fun Context.getPrimaryTextColor(): Int {
return getPrimaryTextColor(isDarkTheme())
}
@ColorInt
fun Context.getSecondaryTextColor(): Int {
return getSecondaryTextColor(isDarkTheme())
}
@ColorInt
fun Context.getPrimaryDisabledTextColor(): Int {
return getPrimaryDisabledTextColor(isDarkTheme())
}
@ColorInt
fun Context.getSecondaryDisabledTextColor(): Int {
return getSecondaryDisabledTextColor(isDarkTheme())
}
@ColorInt
fun Fragment.getPrimaryTextColor(): Int {
return getPrimaryTextColor(isDarkTheme())
}
@ColorInt
fun Fragment.getSecondaryTextColor(): Int {
return getSecondaryTextColor(isDarkTheme())
}
@ColorInt
fun Fragment.getPrimaryDisabledTextColor(): Int {
return getPrimaryDisabledTextColor(isDarkTheme())
}
@ColorInt
fun Fragment.getSecondaryDisabledTextColor(): Int {
return getSecondaryDisabledTextColor(isDarkTheme())
}
fun Context.isDarkTheme(): Boolean {
return ColorUtils.isColorLight(ThemeStore.primaryColor(this))
}

@ -3,6 +3,7 @@ package io.legado.app.ui.main.bookshelf
import android.os.Bundle
import android.view.Menu
import android.view.View
import androidx.core.view.forEach
import io.legado.app.R
import io.legado.app.base.BaseFragment
import kotlinx.android.synthetic.main.view_titlebar.*

@ -89,7 +89,7 @@ class ReplaceRuleActivity : BaseActivity<ReplaceRuleViewModel>() {
ItemTouchHelper(object : ItemTouchHelper.Callback() {
override fun getMovementFlags(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder): Int {
return ItemTouchHelper.Callback.makeMovementFlags(0, ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT)
return makeMovementFlags(0, ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT)
}
override fun onMove(

@ -2,6 +2,7 @@ package io.legado.app.ui.widget
import android.content.Context
import android.content.res.ColorStateList
import android.graphics.Color
import android.graphics.PorterDuff
import android.graphics.drawable.Drawable
import android.util.AttributeSet
@ -17,7 +18,6 @@ import io.legado.app.R
import io.legado.app.lib.theme.DrawableUtils
import io.legado.app.lib.theme.ThemeStore
import io.legado.app.lib.theme.getPrimaryTextColor
import io.legado.app.lib.theme.isDarkTheme
import io.legado.app.utils.getStatusBarHeight
import org.jetbrains.anko.bottomPadding
import org.jetbrains.anko.topPadding
@ -142,7 +142,7 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a
}
private fun wrapAppTheme() {
val primaryTextColor = context.getPrimaryTextColor(context.isDarkTheme())
val primaryTextColor = if (isInEditMode) Color.BLACK else context.getPrimaryTextColor()
DrawableUtils.setTint(toolbar.overflowIcon, primaryTextColor)
toolbar.setTitleTextColor(primaryTextColor)

@ -6,13 +6,14 @@ import androidx.appcompat.view.menu.MenuBuilder
import androidx.appcompat.view.menu.MenuItemImpl
import androidx.core.view.forEach
import io.legado.app.R
import io.legado.app.lib.theme.*
import io.legado.app.lib.theme.DrawableUtils
import io.legado.app.lib.theme.getPrimaryTextColor
fun Menu.setIconColor(context: Context): Menu = this.let { menu ->
if (menu is MenuBuilder) {
menu.setOptionalIconsVisible(true)
}
val primaryTextColor = context.getPrimaryTextColor(context.isDarkTheme())
val primaryTextColor = context.getPrimaryTextColor()
val defaultTextColor = context.getCompatColor(R.color.tv_text_default)
menu.forEach { item ->
(item as MenuItemImpl).let { impl ->

@ -19,14 +19,14 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.kunfei.bookshelf.widget.views.ATECheckBox
<io.legado.app.lib.theme.view.ATECheckBox
android:id="@+id/cb_is_enable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="@string/is_enable"/>
<com.kunfei.bookshelf.widget.views.ATECheckBox
<io.legado.app.lib.theme.view.ATECheckBox
android:id="@+id/cb_is_audio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

@ -5,5 +5,4 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="?attr/actionBarStyle"
app:popupTheme="@style/AppTheme.PopupOverlay"/>

Loading…
Cancel
Save