From 315f7142f727a0f2c96674241482e3fa4f9553ff Mon Sep 17 00:00:00 2001
From: Invinciblelee <1760316362@qq.com>
Date: Fri, 31 May 2019 17:13:12 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/build.gradle | 6 +-
app/src/main/AndroidManifest.xml | 4 +-
.../java/io/legado/app/base/BaseActivity.kt | 84 ++++++++--------
.../main/java/io/legado/app/lib/theme/ATH.kt | 10 +-
.../app/lib/theme/{ATHUtil.kt => ATHUtils.kt} | 4 +-
.../lib/theme/{ColorUtil.kt => ColorUtils.kt} | 2 +-
.../io/legado/app/lib/theme/DrawableUtil.kt | 25 -----
.../io/legado/app/lib/theme/DrawableUtils.kt | 43 ++++++++
.../app/lib/theme/MaterialValueHelper.kt | 97 ++++++++++++-------
...tionViewUtil.kt => NavigationViewUtils.kt} | 2 +-
.../io/legado/app/lib/theme/ThemeStore.kt | 38 ++++----
.../app/lib/theme/ThemeStorePrefKeys.kt | 34 +++----
.../io/legado/app/lib/theme/TintHelper.kt | 22 ++---
.../lib/theme/{ViewUtil.kt => ViewUtils.kt} | 6 +-
.../app/lib/theme/view/ATEAccentBgTextView.kt | 4 +-
.../app/lib/theme/view/ATEStockSwitch.kt | 3 +-
.../io/legado/app/lib/theme/view/ATESwitch.kt | 3 +-
app/src/main/res/values-v21/styles.xml | 2 +-
app/src/main/res/values/styles.xml | 64 ++++++------
19 files changed, 253 insertions(+), 200 deletions(-)
rename app/src/main/java/io/legado/app/lib/theme/{ATHUtil.kt => ATHUtils.kt} (80%)
rename app/src/main/java/io/legado/app/lib/theme/{ColorUtil.kt => ColorUtils.kt} (99%)
delete mode 100644 app/src/main/java/io/legado/app/lib/theme/DrawableUtil.kt
create mode 100644 app/src/main/java/io/legado/app/lib/theme/DrawableUtils.kt
rename app/src/main/java/io/legado/app/lib/theme/{NavigationViewUtil.kt => NavigationViewUtils.kt} (97%)
rename app/src/main/java/io/legado/app/lib/theme/{ViewUtil.kt => ViewUtils.kt} (85%)
diff --git a/app/build.gradle b/app/build.gradle
index a8775b1c3..baa389c14 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -42,13 +42,11 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
- implementation 'androidx.core:core-ktx:1.0.2'
- implementation 'androidx.appcompat:appcompat:1.0.2'
+ implementation 'androidx.core:core-ktx:1.2.0-alpha01'
+ implementation 'androidx.appcompat:appcompat:1.1.0-alpha05'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
- implementation 'androidx.recyclerview:recyclerview:1.0.0'
- implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 9d4cfaca1..d540a2f60 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -23,7 +23,7 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
- android:theme="@style/CAppTheme"
+ android:theme="@style/AppTheme.Light"
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
@@ -32,7 +32,7 @@
+ android:theme="@style/AppTheme.Light.NoActionBar">
diff --git a/app/src/main/java/io/legado/app/base/BaseActivity.kt b/app/src/main/java/io/legado/app/base/BaseActivity.kt
index 2ee755f42..c58318df1 100644
--- a/app/src/main/java/io/legado/app/base/BaseActivity.kt
+++ b/app/src/main/java/io/legado/app/base/BaseActivity.kt
@@ -1,17 +1,17 @@
package io.legado.app.base
-import android.annotation.SuppressLint
-import android.graphics.PorterDuff
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
+import androidx.appcompat.view.menu.MenuItemImpl
+import androidx.core.content.ContextCompat
import androidx.lifecycle.ViewModel
import io.legado.app.R
-import io.legado.app.lib.theme.ColorUtil
-import io.legado.app.lib.theme.MaterialValueHelper
+import io.legado.app.lib.theme.ColorUtils
+import io.legado.app.lib.theme.DrawableUtils
import io.legado.app.lib.theme.ThemeStore
-import java.util.*
+import io.legado.app.lib.theme.getPrimaryTextColor
abstract class BaseActivity : AppCompatActivity() {
@@ -34,47 +34,45 @@ abstract class BaseActivity : AppCompatActivity() {
* 设置MENU图标颜色
*/
override fun onCreateOptionsMenu(menu: Menu): Boolean {
- val primaryTextColor = MaterialValueHelper
- .getPrimaryTextColor(this, ColorUtil.isColorLight(ThemeStore.primaryColor(this)))
+ val primaryTextColor = getPrimaryTextColor(ColorUtils.isColorLight(ThemeStore.primaryColor(this)))
+ val defaultTextColor = ContextCompat.getColor(this, R.color.tv_text_default)
for (i in 0 until menu.size()) {
- val drawable = menu.getItem(i).icon
- if (drawable != null) {
- drawable.mutate()
- drawable.setColorFilter(primaryTextColor, PorterDuff.Mode.SRC_ATOP)
+ (menu.getItem(i) as MenuItemImpl).let {//overflow:展开的item
+ DrawableUtils.setTint(it.icon, if (it.requiresOverflow()) defaultTextColor else primaryTextColor)
}
}
return super.onCreateOptionsMenu(menu)
}
- @SuppressLint("PrivateApi")
- override fun onMenuOpened(featureId: Int, menu: Menu?): Boolean {
- if (menu != null) {
- //展开菜单显示图标
- if (menu.javaClass.simpleName.equals("MenuBuilder", ignoreCase = true)) {
- try {
- var method = menu.javaClass.getDeclaredMethod("setOptionalIconsVisible", java.lang.Boolean.TYPE)
- method.isAccessible = true
- method.invoke(menu, true)
- method = menu.javaClass.getDeclaredMethod("getNonActionItems")
- val menuItems = method.invoke(menu) as ArrayList