theming fixes on Android 12+

This commit is contained in:
Pavel Poley 2022-05-01 22:50:19 +03:00
parent 3905d40c70
commit 0623482e2e
3 changed files with 33 additions and 10 deletions

View file

@ -5,9 +5,11 @@ import android.view.*
import android.widget.PopupMenu
import com.simplemobiletools.commons.R
import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.baseConfig
import com.simplemobiletools.commons.extensions.copyToClipboard
import com.simplemobiletools.commons.extensions.deleteBlockedNumber
import com.simplemobiletools.commons.extensions.getProperTextColor
import com.simplemobiletools.commons.helpers.isSPlus
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
import com.simplemobiletools.commons.models.BlockedNumber
import com.simplemobiletools.commons.views.MyRecyclerView
@ -82,7 +84,13 @@ class ManageBlockedNumbersAdapter(
}
private fun showPopupMenu(view: View, blockedNumber: BlockedNumber) {
val wrapper: Context = ContextThemeWrapper(activity, R.style.AppTheme_PopupMenuDarkStyle)
val theme = if (isSPlus() && activity.baseConfig.isUsingSystemTheme) {
R.style.AppTheme_YouPopupMenuStyle
} else {
R.style.AppTheme_PopupMenuDarkStyle
}
val wrapper: Context = ContextThemeWrapper(activity, theme)
PopupMenu(wrapper, view, Gravity.END)
.apply {
inflate(R.menu.cab_blocked_numbers)

View file

@ -51,5 +51,5 @@
<dimen name="cab_popup_menu_min_width">168dp</dimen>
<dimen name="cab_item_min_width">85dp</dimen>
<dimen name="overflow_icon_size">32dp</dimen>
<dimen name="popup_menu_elevation">4dp</dimen>
</resources>

View file

@ -204,6 +204,29 @@
<item name="android:popupBackground">@drawable/top_popup_menu_bg_dark</item>
</style>
<style name="AppTheme.YouPopupMenuStyle" parent="ThemeOverlay.AppCompat.Dark">
<item name="android:popupMenuStyle">@style/AppTheme.YouPopupMenu</item>
<item name="android:itemTextAppearance">@style/AppTheme.YouItemTextStyle</item>
</style>
<style name="AppTheme.YouItemTextStyle" parent="TextAppearance.AppCompat.Light.Widget.PopupMenu.Small">
<item name="android:textColor">@color/you_neutral_text_color</item>
</style>
<style name="AppTheme.YouPopupMenu" parent="@android:style/Widget.PopupMenu">
<item name="android:popupBackground">@color/you_dialog_background_color</item>
<item name="android:popupElevation">@dimen/popup_menu_elevation</item>
</style>
<style name="AppTheme.PopupMenuDarkStyle" parent="ThemeOverlay.AppCompat.Dark">
<item name="android:popupMenuStyle">@style/AppTheme.PopupMenuDark</item>
</style>
<style name="AppTheme.PopupMenuDark" parent="@android:style/Widget.PopupMenu">
<item name="android:popupBackground">@color/default_background_color</item>
<item name="android:popupElevation">@dimen/popup_menu_elevation</item>
</style>
<style name="BottomSheetDialogTheme" parent="Theme.Design.Light.BottomSheetDialog">
<item name="bottomSheetStyle">@style/BottomSheetModalStyle</item>
<item name="android:colorControlHighlight">@color/activated_item_foreground</item>
@ -2892,12 +2915,4 @@
<item name="colorAccent">@color/md_grey_black</item>
</style>
<style name="AppTheme.PopupMenuDarkStyle" parent="ThemeOverlay.AppCompat.Dark">
<item name="android:popupMenuStyle">@style/AppTheme.PopupMenuDark</item>
</style>
<style name="AppTheme.PopupMenuDark" parent="@android:style/Widget.PopupMenu">
<item name="android:popupBackground">@drawable/top_popup_menu_bg_dark</item>
<item name="android:popupElevation">10dp</item>
</style>
</resources>