pull/32/head
gedoor 6 years ago
parent 6e804e7b11
commit 6bb230acb6
  1. 26
      app/src/main/java/io/legado/app/ui/main/myconfig/MyConfigFragment.kt
  2. 2
      app/src/main/java/io/legado/app/utils/MenuExtensions.kt
  3. 9
      app/src/main/res/drawable/ic_live_help_black_24dp.xml
  4. 4
      app/src/main/res/menu/bookshelf.xml
  5. 13
      app/src/main/res/menu/my_config.xml
  6. 1
      app/src/main/res/values/strings.xml

@ -4,9 +4,17 @@ import android.os.Bundle
import android.util.Log import android.util.Log
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
import androidx.appcompat.view.menu.MenuBuilder
import androidx.appcompat.view.menu.MenuItemImpl
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.core.view.forEach
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import io.legado.app.R import io.legado.app.R
import io.legado.app.lib.theme.ColorUtils
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.utils.getCompatColor
import kotlinx.android.synthetic.main.view_titlebar.* import kotlinx.android.synthetic.main.view_titlebar.*
class MyConfigFragment : Fragment(R.layout.fragment_my_config), Toolbar.OnMenuItemClickListener { class MyConfigFragment : Fragment(R.layout.fragment_my_config), Toolbar.OnMenuItemClickListener {
@ -15,6 +23,24 @@ class MyConfigFragment : Fragment(R.layout.fragment_my_config), Toolbar.OnMenuIt
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
Log.e("TAG", "MyConfigFragment") Log.e("TAG", "MyConfigFragment")
toolbar.inflateMenu(R.menu.my_config) toolbar.inflateMenu(R.menu.my_config)
toolbar.menu?.let {
if (it is MenuBuilder) {
it.setOptionalIconsVisible(true)
}
context?.let { context ->
val primaryTextColor = getPrimaryTextColor(ColorUtils.isColorLight(ThemeStore.primaryColor(context)))
val defaultTextColor = getCompatColor(R.color.tv_text_default)
it.forEach { item ->
(item as MenuItemImpl).let { impl ->
//overflow:展开的item
DrawableUtils.setTint(
impl.icon,
if (impl.requiresOverflow()) defaultTextColor else primaryTextColor
)
}
}
}
}
toolbar.setOnMenuItemClickListener(this) toolbar.setOnMenuItemClickListener(this)
} }

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M19,2L5,2c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h4l3,3 3,-3h4c1.1,0 2,-0.9 2,-2L21,4c0,-1.1 -0.9,-2 -2,-2zM13,18h-2v-2h2v2zM15.07,10.25l-0.9,0.92C13.45,11.9 13,12.5 13,14h-2v-0.5c0,-1.1 0.45,-2.1 1.17,-2.83l1.24,-1.26c0.37,-0.36 0.59,-0.86 0.59,-1.41 0,-1.1 -0.9,-2 -2,-2s-2,0.9 -2,2L8,8c0,-2.21 1.79,-4 4,-4s4,1.79 4,4c0,0.88 -0.36,1.68 -0.93,2.25z"/>
</vector>

@ -3,9 +3,9 @@
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_settings" <item android:id="@+id/action_settings"
android:title="@string/action_settings" android:title="筛选"
android:orderInCategory="100" android:orderInCategory="100"
app:showAsAction="never"/> app:showAsAction="always"/>
<item android:id="@+id/action_test" <item android:id="@+id/action_test"
android:title="测试" android:title="测试"

@ -1,15 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_settings"
android:title="@string/action_settings"
android:orderInCategory="100"
app:showAsAction="never"/>
<item android:id="@+id/action_settings"
android:title="@string/help"
android:icon="@drawable/ic_live_help_black_24dp"
app:showAsAction="always"/>
<item android:id="@+id/action_test"
android:title="测试"
android:icon="@drawable/ic_search"
android:orderInCategory="100"
app:showAsAction="never"/>
</menu> </menu>

@ -469,4 +469,5 @@
<string name="clear_find_cache">清空发现缓存</string> <string name="clear_find_cache">清空发现缓存</string>
<string name="edit_find">编辑发现</string> <string name="edit_find">编辑发现</string>
<string name="change_icon_summary">切换软件显示在桌面的图标</string> <string name="change_icon_summary">切换软件显示在桌面的图标</string>
<string name="help">帮助</string>
</resources> </resources>

Loading…
Cancel
Save