Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix part of #5195: RestrictedApi. Using a private API #5198

Merged
merged 8 commits into from
Oct 20, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatCheckBox;
import androidx.core.widget.CompoundButtonCompat;
import androidx.databinding.BindingAdapter;

/**
Expand All @@ -13,6 +14,6 @@ public final class AppCompatCheckBoxBindingAdapters {
/** Sets the button tint for the specified checkbox, via data-binding. */
@BindingAdapter("app:buttonTint")
public static void setButtonTint(@NonNull AppCompatCheckBox checkBox, @ColorInt int colorRgb) {
checkBox.setSupportButtonTintList(ColorStateList.valueOf(colorRgb));
CompoundButtonCompat.setButtonTintList(checkBox, ColorStateList.valueOf(colorRgb));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class AppCompatCheckBoxBindingAdaptersTest {
activityRule.scenario.onActivity {
val appCompatCheckBox: AppCompatCheckBox = getAppCompatCheckBox(it)
setButtonTint(appCompatCheckBox, colorRgb)
assertThat(appCompatCheckBox.supportButtonTintList?.defaultColor).isEqualTo(colorRgb)
assertThat(appCompatCheckBox.buttonTintList?.defaultColor).isEqualTo(colorRgb)
}
}

Expand Down