Make selection follow theme
This commit is contained in:
parent
7b6dccb2ff
commit
7be7e0e11e
@ -1,6 +1,7 @@
|
||||
package com.cringe_studios.cringe_authenticator.grouplist;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Build;
|
||||
@ -40,7 +41,10 @@ public class GroupListItem extends RecyclerView.ViewHolder {
|
||||
this.selected = selected;
|
||||
|
||||
if(selected) {
|
||||
binding.menuItemBackground.setBackground(new ColorDrawable(binding.getRoot().getContext().getResources().getColor(R.color.selected_highlight)));
|
||||
TypedArray array = binding.getRoot().getContext().getTheme().obtainStyledAttributes(new int[] { R.attr.colorTheme1 });
|
||||
int color = array.getColor(0, 0xFFFF00FF);
|
||||
color = Color.argb(0x55, Color.red(color), Color.green(color), Color.blue(color));
|
||||
binding.menuItemBackground.setBackground(new ColorDrawable(color));
|
||||
}else {
|
||||
binding.menuItemBackground.setBackground(null);
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.cringe_studios.cringe_authenticator.otplist;
|
||||
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@ -52,7 +54,10 @@ public class OTPListItem extends RecyclerView.ViewHolder {
|
||||
this.selected = selected;
|
||||
|
||||
if(selected) {
|
||||
binding.otpCodeBackground.setBackground(new ColorDrawable(binding.getRoot().getContext().getResources().getColor(R.color.selected_highlight)));
|
||||
TypedArray array = binding.getRoot().getContext().getTheme().obtainStyledAttributes(new int[] { R.attr.colorTheme1 });
|
||||
int color = array.getColor(0, 0xFFFF00FF);
|
||||
color = Color.argb(0x55, Color.red(color), Color.green(color), Color.blue(color));
|
||||
binding.otpCodeBackground.setBackground(new ColorDrawable(color));
|
||||
}else {
|
||||
binding.otpCodeBackground.setBackground(null);
|
||||
}
|
||||
|
@ -16,6 +16,4 @@
|
||||
<color name="color_yellow">#FFE500</color>
|
||||
<color name="color_turquoise">#00FFF7</color>
|
||||
<color name="color_green">#00FF0A</color>
|
||||
|
||||
<color name="selected_highlight">#33008BFF</color>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user