From e70821f3d09d67bc3d2acf457f779827edcbaa2b Mon Sep 17 00:00:00 2001 From: osodebailar Date: Tue, 22 Mar 2022 09:31:22 +0100 Subject: [PATCH] Minor actions tab 3 dot menu bug --- .../java/info/nightscout/androidaps/MainActivity.kt | 11 +++++++++++ core/src/main/res/values-night/styles.xml | 2 ++ core/src/main/res/values/attrs.xml | 2 ++ core/src/main/res/values/styles.xml | 4 ++-- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt index 484f9262ff..01e7696df7 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt @@ -7,6 +7,7 @@ import android.os.Bundle import android.os.PersistableBundle import android.text.SpannableString import android.text.method.LinkMovementMethod +import android.text.style.ForegroundColorSpan import android.text.util.Linkify import android.util.TypedValue import android.view.Menu @@ -116,6 +117,7 @@ class MainActivity : NoSplashAppCompatActivity() { override fun onPageSelected(position: Int) { setPluginPreferenceMenuName() checkPluginPreferences(binding.mainPager) + setDisabledMenuItemColorPluginPreferences() } }) @@ -256,6 +258,14 @@ class MainActivity : NoSplashAppCompatActivity() { return super.dispatchTouchEvent(event) } + private fun setDisabledMenuItemColorPluginPreferences() { + if( pluginPreferencesMenuItem?.isEnabled == false){ + val spanString = SpannableString(this.menu?.findItem(R.id.nav_plugin_preferences)?.title.toString()) + spanString.setSpan(ForegroundColorSpan(rh.gac(R.attr.disabledTextColor)), 0, spanString.length, 0) + this.menu?.findItem(R.id.nav_plugin_preferences)?.title = spanString + } + } + private fun setPluginPreferenceMenuName() { if (binding.mainPager.currentItem >= 0) { val plugin = (binding.mainPager.adapter as TabPageAdapter).getPluginAt(binding.mainPager.currentItem) @@ -284,6 +294,7 @@ class MainActivity : NoSplashAppCompatActivity() { pluginPreferencesMenuItem = menu.findItem(R.id.nav_plugin_preferences) setPluginPreferenceMenuName() checkPluginPreferences(binding.mainPager) + setDisabledMenuItemColorPluginPreferences() return true } diff --git a/core/src/main/res/values-night/styles.xml b/core/src/main/res/values-night/styles.xml index 534c57bd62..94a77f46f4 100644 --- a/core/src/main/res/values-night/styles.xml +++ b/core/src/main/res/values-night/styles.xml @@ -109,6 +109,8 @@ @style/DialogTheme @style/DialogTheme @style/DialogTheme + + @color/sandGray