public static void setTint(@NonNull RadioButton radioButton, @ColorInt int color, boolean useDarker) { ColorStateList sl = new ColorStateList(new int[][]{ new int[]{-android.R.attr.state_enabled}, new int[]{android.R.attr.state_enabled, -android.R.attr.state_checked}, new int[]{android.R.attr.state_enabled, android.R.attr.state_checked} }, new int[]{ // Rdio button includes own alpha for disabled state ATEUtil.stripAlpha(ContextCompat.getColor(radioButton.getContext(), useDarker ? R.color.ate_control_disabled_dark : R.color.ate_control_disabled_light)), ContextCompat.getColor(radioButton.getContext(), useDarker ? R.color.ate_control_normal_dark : R.color.ate_control_normal_light), color }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { radioButton.setButtonTintList(sl); } else { Drawable d = createTintedDrawable(ContextCompat.getDrawable(radioButton.getContext(), R.drawable.abc_btn_radio_material), sl); radioButton.setButtonDrawable(d); } }
public static void setTint(@NonNull RadioButton radioButton, @ColorInt int color, boolean useDarker) { ColorStateList sl = new ColorStateList(new int[][]{ new int[]{-android.R.attr.state_enabled}, new int[]{android.R.attr.state_enabled, -android.R.attr.state_checked}, new int[]{android.R.attr.state_enabled, android.R.attr.state_checked} }, new int[]{ ContextCompat.getColor(radioButton.getContext(), useDarker ? R.color.ate_disabled_radiobutton_dark : R.color.ate_disabled_radiobutton_light), Util.resolveColor(radioButton.getContext(), R.attr.colorControlNormal), color }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { radioButton.setButtonTintList(sl); } else { Drawable d = DrawableCompat.wrap(ContextCompat.getDrawable(radioButton.getContext(), R.drawable.abc_btn_radio_material)); DrawableCompat.setTintList(d, sl); radioButton.setButtonDrawable(d); } }
public static void setTint(@NonNull RadioButton radioButton, @ColorInt int color, boolean useDarker) { ColorStateList sl = new ColorStateList(new int[][]{ new int[]{-android.R.attr.state_enabled}, new int[]{android.R.attr.state_enabled, -android.R.attr.state_checked}, new int[]{android.R.attr.state_enabled, android.R.attr.state_checked} }, new int[]{ // Rdio button includes own alpha for disabled state ColorUtil.INSTANCE.stripAlpha(ContextCompat.getColor(radioButton.getContext(), useDarker ? R.color.ate_control_disabled_dark : R.color.ate_control_disabled_light)), ContextCompat.getColor(radioButton.getContext(), useDarker ? R.color.ate_control_normal_dark : R.color.ate_control_normal_light), color }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { radioButton.setButtonTintList(sl); } else { Drawable d = createTintedDrawable(ContextCompat.getDrawable(radioButton.getContext(), R.drawable.abc_btn_radio_material), sl); radioButton.setButtonDrawable(d); } }
private void refreshTrezorsList() { ImmutableList<InitializedTrezor> trezors = gct.getCommonDb().getTrezors(); if (radioGroupTrezors.getChildCount() > trezors.size()) { radioGroupTrezors.removeViews(trezors.size(), radioGroupTrezors.getChildCount() - trezors.size()); } LayoutInflater inflater = LayoutInflater.from(radioGroupTrezors.getContext()); for (int i = radioGroupTrezors.getChildCount(); i < trezors.size(); i++) { RadioButton btn = (RadioButton)inflater.inflate(R.layout.nav_drawer_trezor_radiobutton, radioGroupTrezors, false); btn.setCompoundDrawables(createNavDrawerButtonIcon(R.drawable.ic_trezor), null, null, null); btn.setOnClickListener(onTrezorClickListener); radioGroupTrezors.addView(btn); } for (int i = 0; i < trezors.size(); i++) { InitializedTrezor t = trezors.get(i); RadioButton btn = (RadioButton)radioGroupTrezors.getChildAt(i); btn.setText(TextUtils.isEmpty(t.getFeatures().getLabel()) ? btn.getContext().getString(R.string.init_trezor_device_label_default) : t.getFeatures().getLabel()); int id = getTrezorButtonId(t.getFeatures().getDeviceId()); btn.setId(id); } refreshCurrentSelectedTrezor(gct.getCommonDb().getLastSelectedDeviceId()); radioGroupTrezors.setVisibility(trezors.isEmpty() ? View.GONE : View.VISIBLE); dividerTrezors.setVisibility(trezors.isEmpty() ? View.GONE : View.VISIBLE); }