updating a couple menu related things
This commit is contained in:
parent
b16cc87e63
commit
4c7bf44340
7 changed files with 54 additions and 6 deletions
|
@ -194,13 +194,16 @@ abstract class BaseSimpleActivity : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
fun updateMenuItemColors(menu: Menu?, useCrossAsBack: Boolean = false, baseColor: Int = getProperPrimaryColor(), updateHomeAsUpColor: Boolean = true) {
|
||||
fun updateMenuItemColors(
|
||||
menu: Menu?, useCrossAsBack: Boolean = false, baseColor: Int = getProperPrimaryColor(), updateHomeAsUpColor: Boolean = true,
|
||||
isContextualMenu: Boolean = false
|
||||
) {
|
||||
if (menu == null) {
|
||||
return
|
||||
}
|
||||
|
||||
var color = baseColor.getContrastColor()
|
||||
if (baseConfig.isUsingSystemTheme) {
|
||||
if (baseConfig.isUsingSystemTheme && !isContextualMenu) {
|
||||
color = getProperTextColor()
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.simplemobiletools.commons.adapters
|
|||
|
||||
import android.graphics.Color
|
||||
import android.view.*
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.ActionBar
|
||||
import androidx.recyclerview.widget.DividerItemDecoration
|
||||
|
@ -74,9 +75,24 @@ abstract class MyRecyclerViewAdapter(val activity: BaseSimpleActivity, val recyc
|
|||
selectAll()
|
||||
}
|
||||
}
|
||||
|
||||
activity.menuInflater.inflate(getActionMenuId(), menu)
|
||||
activity.updateMenuItemColors(menu, baseColor = Color.BLACK, updateHomeAsUpColor = false)
|
||||
val bgColor = if (baseConfig.isUsingSystemTheme) {
|
||||
resources.getColor(R.color.you_contextual_status_bar_color, activity.theme)
|
||||
} else {
|
||||
Color.BLACK
|
||||
}
|
||||
|
||||
actBarTextView!!.setTextColor(bgColor.getContrastColor())
|
||||
activity.updateMenuItemColors(menu, baseColor = bgColor, updateHomeAsUpColor = true, isContextualMenu = true)
|
||||
onActionModeCreated()
|
||||
|
||||
if (baseConfig.isUsingSystemTheme) {
|
||||
actBarTextView?.onGlobalLayout {
|
||||
val backArrow = activity.findViewById<ImageView>(R.id.action_mode_close_button)
|
||||
backArrow?.applyColorFilter(bgColor.getContrastColor())
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.simplemobiletools.commons.adapters
|
||||
|
||||
import android.graphics.Color
|
||||
import android.view.*
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.ActionBar
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
|
@ -80,8 +82,24 @@ abstract class MyRecyclerViewListAdapter<T>(
|
|||
selectAll()
|
||||
}
|
||||
}
|
||||
|
||||
activity.menuInflater.inflate(getActionMenuId(), menu)
|
||||
val bgColor = if (baseConfig.isUsingSystemTheme) {
|
||||
resources.getColor(R.color.you_contextual_status_bar_color, activity.theme)
|
||||
} else {
|
||||
Color.BLACK
|
||||
}
|
||||
|
||||
actBarTextView!!.setTextColor(bgColor.getContrastColor())
|
||||
activity.updateMenuItemColors(menu, baseColor = bgColor, updateHomeAsUpColor = true, isContextualMenu = true)
|
||||
onActionModeCreated()
|
||||
|
||||
if (baseConfig.isUsingSystemTheme) {
|
||||
actBarTextView?.onGlobalLayout {
|
||||
val backArrow = activity.findViewById<ImageView>(R.id.action_mode_close_button)
|
||||
backArrow?.applyColorFilter(bgColor.getContrastColor())
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
@ -14,19 +14,19 @@ import com.simplemobiletools.commons.views.*
|
|||
|
||||
// handle system default theme (Material You) specially as the color is taken from the system, not hardcoded by us
|
||||
fun Context.getProperTextColor() = if (baseConfig.isUsingSystemTheme) {
|
||||
resources.getColor(R.color.you_neutral_text_color)
|
||||
resources.getColor(R.color.you_neutral_text_color, theme)
|
||||
} else {
|
||||
baseConfig.textColor
|
||||
}
|
||||
|
||||
fun Context.getProperBackgroundColor() = if (baseConfig.isUsingSystemTheme) {
|
||||
resources.getColor(R.color.you_background_color)
|
||||
resources.getColor(R.color.you_background_color, theme)
|
||||
} else {
|
||||
baseConfig.backgroundColor
|
||||
}
|
||||
|
||||
fun Context.getProperPrimaryColor() = when {
|
||||
baseConfig.isUsingSystemTheme -> resources.getColor(R.color.you_primary_color)
|
||||
baseConfig.isUsingSystemTheme -> resources.getColor(R.color.you_primary_color, theme)
|
||||
isWhiteTheme() || isBlackAndWhiteTheme() -> baseConfig.accentColor
|
||||
else -> baseConfig.primaryColor
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="you_status_bar_color">@android:color/system_accent2_800</color>
|
||||
<color name="you_contextual_status_bar_color">@android:color/system_accent1_700</color>
|
||||
<color name="you_background_color">@android:color/system_neutral1_900</color>
|
||||
<color name="you_neutral_text_color">@android:color/system_accent1_10</color>
|
||||
<color name="you_primary_color">@android:color/system_accent1_400</color>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="you_status_bar_color">@android:color/system_accent2_50</color>
|
||||
<color name="you_contextual_status_bar_color">@android:color/system_accent1_300</color>
|
||||
<color name="you_background_color">@android:color/system_neutral1_10</color>
|
||||
<color name="you_neutral_text_color">@android:color/system_accent1_900</color>
|
||||
<color name="you_primary_color">@android:color/system_accent1_400</color>
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
<item name="actionOverflowMenuStyle">@style/TopPopupMenuYou</item>
|
||||
<item name="actionBarPopupTheme">@style/TopPopupMenuTextYou</item>
|
||||
<item name="actionBarStyle">@style/AppTheme.ActionBar</item>
|
||||
<item name="actionModeStyle">@style/AppTheme.ActionMode</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.Base.System.Light" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">
|
||||
|
@ -41,6 +42,7 @@
|
|||
<item name="actionOverflowMenuStyle">@style/TopPopupMenuYou</item>
|
||||
<item name="actionBarPopupTheme">@style/TopPopupMenuTextYou</item>
|
||||
<item name="actionBarStyle">@style/AppTheme.ActionBar</item>
|
||||
<item name="actionModeStyle">@style/AppTheme.ActionMode</item>
|
||||
</style>
|
||||
|
||||
<!-- remove the shadow under actionBar, keep it there around Overflow menu that appears at pressing the 3 dots -->
|
||||
|
@ -48,6 +50,13 @@
|
|||
<item name="android:outlineProvider">none</item>
|
||||
</style>
|
||||
|
||||
<!-- contextual action mode -->
|
||||
<style name="AppTheme.ActionMode" parent="@style/Widget.AppCompat.ActionMode">
|
||||
<item name="android:outlineProvider">none</item>
|
||||
<item name="background">@color/you_contextual_status_bar_color</item>
|
||||
<item name="actionOverflowButtonStyle">@style/TopPopupMenuYou</item>
|
||||
</style>
|
||||
|
||||
<style name="TopPopupMenuYou">
|
||||
<item name="android:popupBackground">@drawable/dialog_you_background</item>
|
||||
<item name="android:dropDownHorizontalOffset">-10dp</item>
|
||||
|
|
Loading…
Reference in a new issue