Fix options color on Andorid 5

This commit is contained in:
h4h13 2019-11-21 23:05:27 +05:30
parent 8303c376ca
commit 72964be920
7 changed files with 54 additions and 35 deletions

View file

@ -55,15 +55,15 @@ public class OptionMenuItemView extends FrameLayout {
super(context, attrs, defStyleAttr, defStyleRes); super(context, attrs, defStyleAttr, defStyleRes);
int accentColor = ThemeStore.Companion.accentColor(context); int accentColor = ThemeStore.Companion.accentColor(context);
setBackground(ContextCompat.getDrawable(context, R.drawable.menu_item_background)); int colorWithAlpha = ColorUtil.INSTANCE.adjustAlpha(accentColor, 0.22f);
setBackground(ContextCompat.getDrawable(context, R.drawable.option_menu_background));
setClickable(true); setClickable(true);
setFocusable(true); setFocusable(true);
inflate(context, R.layout.item_option_menu, this); inflate(context, R.layout.item_option_menu, this);
setBackgroundTintList(ColorStateList.valueOf(ColorUtil.INSTANCE.adjustAlpha(accentColor, 0.22f)));
textView = findViewById(R.id.title); textView = findViewById(R.id.title);
iconImageView = findViewById(R.id.icon); iconImageView = findViewById(R.id.icon);
@ -83,8 +83,11 @@ public class OptionMenuItemView extends FrameLayout {
super.setSelected(selected); super.setSelected(selected);
if (selected) { if (selected) {
int accentColor = ThemeStore.Companion.accentColor(getContext()); int accentColor = ThemeStore.Companion.accentColor(getContext());
int colorWithAlpha = ColorUtil.INSTANCE.adjustAlpha(accentColor, 0.22f);
textView.setTextColor(accentColor); textView.setTextColor(accentColor);
iconImageView.setImageTintList(ColorStateList.valueOf(accentColor)); iconImageView.setImageTintList(ColorStateList.valueOf(accentColor));
setBackgroundTintList(ColorStateList.valueOf(colorWithAlpha));
} }
} }
} }

View file

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (c) 2019 Hemanth Savarala.
~
~ Licensed under the GNU General Public License v3
~
~ This is free software: you can redistribute it and/or modify it under
~ the terms of the GNU General Public License as published by
~ the Free Software Foundation either version 3 of the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
~ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
~ See the GNU General Public License for more details.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" >
<shape>
<corners android:bottomRightRadius="30dp" android:topRightRadius="30dp" />
<solid android:color="@color/md_red_400" />
</shape>
</item>
<item android:drawable="@android:color/transparent" android:state_selected="false" />
</selector>

View file

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (c) 2019 Hemanth Savarala.
~
~ Licensed under the GNU General Public License v3
~
~ This is free software: you can redistribute it and/or modify it under
~ the terms of the GNU General Public License as published by
~ the Free Software Foundation either version 3 of the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
~ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
~ See the GNU General Public License for more details.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true">
<ripple android:color="?android:attr/colorControlHighlight">
<item>
<shape android:shape="rectangle">
<corners android:radius="8dp" />
<solid android:color="?colorPrimary" />
</shape>
</item>
</ripple>
</item>
<item android:state_pressed="true" android:state_selected="false">
<ripple android:color="?android:attr/colorControlHighlight">
<item>
<shape android:shape="rectangle">
<corners android:radius="8dp" />
<solid android:color="?colorPrimary" />
</shape>
</item>
</ripple>
</item>
</selector>

View file

@ -5,14 +5,15 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:paddingStart="0dp" android:paddingStart="8dp"
android:paddingEnd="16dp" android:paddingEnd="8dp"
tools:ignore="MissingPrefix"> tools:ignore="MissingPrefix">
<code.name.monkey.retromusic.views.OptionMenuItemView <code.name.monkey.retromusic.views.OptionMenuItemView
android:id="@+id/actionLibrary" android:id="@+id/actionLibrary"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="2dp"
app:optionIcon="@drawable/ic_library_music_white_24dp" app:optionIcon="@drawable/ic_library_music_white_24dp"
app:optionTitle="@string/library" /> app:optionTitle="@string/library" />
@ -20,6 +21,7 @@
android:id="@+id/actionFolders" android:id="@+id/actionFolders"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="2dp"
app:optionIcon="@drawable/ic_folder_white_24dp" app:optionIcon="@drawable/ic_folder_white_24dp"
app:optionTitle="@string/folders" /> app:optionTitle="@string/folders" />
@ -27,6 +29,7 @@
android:id="@+id/actionSettings" android:id="@+id/actionSettings"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="2dp"
app:optionIcon="@drawable/ic_settings_white_24dp" app:optionIcon="@drawable/ic_settings_white_24dp"
app:optionTitle="@string/action_settings" /> app:optionTitle="@string/action_settings" />
@ -34,6 +37,7 @@
android:id="@+id/actionRate" android:id="@+id/actionRate"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="2dp"
app:optionIcon="@drawable/ic_star_white_24dp" app:optionIcon="@drawable/ic_star_white_24dp"
app:optionTitle="@string/rate_app" /> app:optionTitle="@string/rate_app" />
</LinearLayout> </LinearLayout>

View file

@ -7,6 +7,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:paddingBottom="12dp"> android:paddingBottom="12dp">
<androidx.appcompat.widget.AppCompatImageView <androidx.appcompat.widget.AppCompatImageView
@ -15,8 +17,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0" android:layout_weight="0"
android:background="?roundSelector" android:background="?roundSelector"
android:paddingStart="12dp" android:padding="8dp"
android:paddingEnd="12dp"
app:srcCompat="@drawable/ic_volume_down_white_24dp" app:srcCompat="@drawable/ic_volume_down_white_24dp"
app:tint="?colorOnBackground" /> app:tint="?colorOnBackground" />
@ -39,9 +40,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0" android:layout_weight="0"
android:background="?roundSelector" android:background="?roundSelector"
android:paddingStart="12dp" android:padding="8dp"
android:paddingEnd="12dp"
android:paddingBottom="12dp"
app:srcCompat="@drawable/ic_volume_up_white_24dp" app:srcCompat="@drawable/ic_volume_up_white_24dp"
app:tint="?colorOnBackground" /> app:tint="?colorOnBackground" />
</LinearLayout> </LinearLayout>

View file

@ -19,8 +19,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingStart="0dp" android:paddingStart="8dp"
android:paddingEnd="16dp" android:paddingEnd="8dp"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">