Fix options color on Andorid 5
This commit is contained in:
parent
8303c376ca
commit
72964be920
7 changed files with 54 additions and 35 deletions
|
@ -55,15 +55,15 @@ public class OptionMenuItemView extends FrameLayout {
|
|||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
|
||||
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);
|
||||
setFocusable(true);
|
||||
|
||||
inflate(context, R.layout.item_option_menu, this);
|
||||
|
||||
setBackgroundTintList(ColorStateList.valueOf(ColorUtil.INSTANCE.adjustAlpha(accentColor, 0.22f)));
|
||||
|
||||
textView = findViewById(R.id.title);
|
||||
iconImageView = findViewById(R.id.icon);
|
||||
|
||||
|
@ -83,8 +83,11 @@ public class OptionMenuItemView extends FrameLayout {
|
|||
super.setSelected(selected);
|
||||
if (selected) {
|
||||
int accentColor = ThemeStore.Companion.accentColor(getContext());
|
||||
int colorWithAlpha = ColorUtil.INSTANCE.adjustAlpha(accentColor, 0.22f);
|
||||
textView.setTextColor(accentColor);
|
||||
iconImageView.setImageTintList(ColorStateList.valueOf(accentColor));
|
||||
setBackgroundTintList(ColorStateList.valueOf(colorWithAlpha));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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>
|
35
app/src/main/res/drawable/option_menu_background.xml
Normal file
35
app/src/main/res/drawable/option_menu_background.xml
Normal 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>
|
|
@ -5,14 +5,15 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
tools:ignore="MissingPrefix">
|
||||
|
||||
<code.name.monkey.retromusic.views.OptionMenuItemView
|
||||
android:id="@+id/actionLibrary"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp"
|
||||
app:optionIcon="@drawable/ic_library_music_white_24dp"
|
||||
app:optionTitle="@string/library" />
|
||||
|
||||
|
@ -20,6 +21,7 @@
|
|||
android:id="@+id/actionFolders"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp"
|
||||
app:optionIcon="@drawable/ic_folder_white_24dp"
|
||||
app:optionTitle="@string/folders" />
|
||||
|
||||
|
@ -27,6 +29,7 @@
|
|||
android:id="@+id/actionSettings"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp"
|
||||
app:optionIcon="@drawable/ic_settings_white_24dp"
|
||||
app:optionTitle="@string/action_settings" />
|
||||
|
||||
|
@ -34,6 +37,7 @@
|
|||
android:id="@+id/actionRate"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp"
|
||||
app:optionIcon="@drawable/ic_star_white_24dp"
|
||||
app:optionTitle="@string/rate_app" />
|
||||
</LinearLayout>
|
|
@ -7,6 +7,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:paddingBottom="12dp">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
|
@ -15,8 +17,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:background="?roundSelector"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:padding="8dp"
|
||||
app:srcCompat="@drawable/ic_volume_down_white_24dp"
|
||||
app:tint="?colorOnBackground" />
|
||||
|
||||
|
@ -39,9 +40,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:background="?roundSelector"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingBottom="12dp"
|
||||
android:padding="8dp"
|
||||
app:srcCompat="@drawable/ic_volume_up_white_24dp"
|
||||
app:tint="?colorOnBackground" />
|
||||
</LinearLayout>
|
|
@ -19,8 +19,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
|
Loading…
Reference in a new issue