pull/1649/head
kunfei 3 years ago
parent 104f4ced59
commit 577e257fe7
  1. 8
      app/src/main/java/io/legado/app/base/BaseActivity.kt
  2. 9
      app/src/main/java/io/legado/app/utils/MenuExtensions.kt
  3. 16
      app/src/main/res/drawable/ic_bubble_chart.xml
  4. 5
      app/src/main/res/menu/book_read.xml

@ -99,11 +99,9 @@ abstract class BaseActivity<VB : ViewBinding>(
abstract fun onActivityCreated(savedInstanceState: Bundle?)
final override fun onCreateOptionsMenu(menu: Menu): Boolean {
return menu.let {
val bool = onCompatCreateOptionsMenu(it)
it.applyTint(this, toolBarTheme)
bool
}
val bool = onCompatCreateOptionsMenu(menu)
menu.applyTint(this, toolBarTheme)
return bool
}
override fun onMenuOpened(featureId: Int, menu: Menu): Boolean {

@ -6,6 +6,7 @@ import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.view.menu.MenuBuilder
import androidx.appcompat.view.menu.MenuItemImpl
import androidx.appcompat.view.menu.SubMenuBuilder
import androidx.core.view.forEach
import io.legado.app.R
import io.legado.app.constant.Theme
@ -33,7 +34,7 @@ fun Menu.applyOpenTint(context: Context) {
//展开菜单显示图标
if (this.javaClass.simpleName.equals("MenuBuilder", ignoreCase = true)) {
val defaultTextColor = context.getCompatColor(R.color.primaryText)
try {
kotlin.runCatching {
var method: Method =
this.javaClass.getDeclaredMethod("setOptionalIconsVisible", java.lang.Boolean.TYPE)
method.isAccessible = true
@ -47,7 +48,11 @@ fun Menu.applyOpenTint(context: Context) {
}
}
}
} catch (ignored: Exception) {
}
} else if (this.javaClass.simpleName.equals("SubMenuBuilder", ignoreCase = true)) {
val defaultTextColor = context.getCompatColor(R.color.primaryText)
(this as? SubMenuBuilder)?.forEach { item: MenuItem ->
item.icon?.setTintMutate(defaultTextColor)
}
}
}

@ -0,0 +1,16 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M7.2,14.4m-3.2,0a3.2,3.2 0,1 1,6.4 0a3.2,3.2 0,1 1,-6.4 0" />
<path
android:fillColor="@android:color/white"
android:pathData="M14.8,18m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
<path
android:fillColor="@android:color/white"
android:pathData="M15.2,8.8m-4.8,0a4.8,4.8 0,1 1,9.6 0a4.8,4.8 0,1 1,-9.6 0" />
</vector>

@ -15,11 +15,13 @@
<item
android:id="@+id/menu_chapter_change_source"
android:icon="@drawable/ic_bubble_chart"
android:title="@string/chapter_change_source"
app:showAsAction="never" />
<item
android:id="@+id/menu_book_change_source"
android:icon="@drawable/ic_bubble_chart"
android:title="@string/book_change_source"
app:showAsAction="never" />
@ -37,16 +39,19 @@
<item
android:id="@+id/menu_refresh_dur"
android:icon="@drawable/ic_bubble_chart"
android:title="@string/menu_refresh_dur"
app:showAsAction="never" />
<item
android:id="@+id/menu_refresh_after"
android:icon="@drawable/ic_bubble_chart"
android:title="@string/menu_refresh_after"
app:showAsAction="never" />
<item
android:id="@+id/menu_refresh_all"
android:icon="@drawable/ic_bubble_chart"
android:title="@string/menu_refresh_all"
app:showAsAction="never" />

Loading…
Cancel
Save