diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt index 3efc22b59d..a158bfbd12 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt @@ -95,6 +95,7 @@ class MainActivity : NoSplashAppCompatActivity() { private lateinit var actionBarDrawerToggle: ActionBarDrawerToggle private var pluginPreferencesMenuItem: MenuItem? = null + private var menu: Menu? = null val callForPrefFile = registerForActivityResult(PrefsFileContract()) { it?.let { @@ -122,6 +123,7 @@ class MainActivity : NoSplashAppCompatActivity() { override fun onPageScrollStateChanged(state: Int) {} override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {} override fun onPageSelected(position: Int) { + setPluginPreferenceMenuName() checkPluginPreferences(main_pager) } }) @@ -272,9 +274,16 @@ class MainActivity : NoSplashAppCompatActivity() { 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 { + this.menu = menu menuInflater.inflate(R.menu.menu_main, menu) pluginPreferencesMenuItem = menu.findItem(R.id.nav_plugin_preferences) + setPluginPreferenceMenuName() checkPluginPreferences(main_pager) return true }