change name: pluginpreference with <plugin name> preference

This commit is contained in:
osodebailar 2020-12-17 15:49:47 +01:00
parent df8616e60b
commit 00145520ff

View file

@ -95,6 +95,7 @@ class MainActivity : NoSplashAppCompatActivity() {
private lateinit var actionBarDrawerToggle: ActionBarDrawerToggle private lateinit var actionBarDrawerToggle: ActionBarDrawerToggle
private var pluginPreferencesMenuItem: MenuItem? = null private var pluginPreferencesMenuItem: MenuItem? = null
private var menu: Menu? = null
val callForPrefFile = registerForActivityResult(PrefsFileContract()) { val callForPrefFile = registerForActivityResult(PrefsFileContract()) {
it?.let { it?.let {
@ -122,6 +123,7 @@ class MainActivity : NoSplashAppCompatActivity() {
override fun onPageScrollStateChanged(state: Int) {} override fun onPageScrollStateChanged(state: Int) {}
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {} override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {}
override fun onPageSelected(position: Int) { override fun onPageSelected(position: Int) {
setPluginPreferenceMenuName()
checkPluginPreferences(main_pager) checkPluginPreferences(main_pager)
} }
}) })
@ -272,9 +274,16 @@ class MainActivity : NoSplashAppCompatActivity() {
return super.dispatchTouchEvent(event) return super.dispatchTouchEvent(event)
} }
private fun setPluginPreferenceMenuName() {
val plugin = (main_pager.adapter as TabPageAdapter).getPluginAt(main_pager.currentItem)
this.menu?.findItem(R.id.nav_plugin_preferences)?.title = plugin.name + ' ' + resourceHelper.gs(R.string.nav_preferences)
}
override fun onCreateOptionsMenu(menu: Menu): Boolean { override fun onCreateOptionsMenu(menu: Menu): Boolean {
this.menu = menu
menuInflater.inflate(R.menu.menu_main, menu) menuInflater.inflate(R.menu.menu_main, menu)
pluginPreferencesMenuItem = menu.findItem(R.id.nav_plugin_preferences) pluginPreferencesMenuItem = menu.findItem(R.id.nav_plugin_preferences)
setPluginPreferenceMenuName()
checkPluginPreferences(main_pager) checkPluginPreferences(main_pager)
return true return true
} }