[Gradle] Enable non transitive R classes (resource namespacing) and fix errors

PiperOrigin-RevId: 738871402
This commit is contained in:
dsn5ft 2025-03-20 18:09:36 +00:00 committed by Dan Nizri
parent e3f29ec779
commit 0697f6fe89
34 changed files with 141 additions and 77 deletions

View File

@ -64,7 +64,7 @@ public class ColorHarmonizationDemoActivity extends DemoActivity {
R.id.cat_colors_error,
R.id.cat_colors_harmonized_error,
new int[] {
R.attr.colorError,
androidx.appcompat.R.attr.colorError,
com.google.android.material.R.attr.colorOnError,
com.google.android.material.R.attr.colorErrorContainer,
com.google.android.material.R.attr.colorOnErrorContainer

View File

@ -104,7 +104,8 @@ public final class ColorMainDemoFragment extends DemoFragment {
private List<ColorRow> getColorRolesContent() {
return Arrays.asList(
new ColorRow(
new ColorRoleItem(R.string.cat_color_role_primary, R.attr.colorPrimary),
new ColorRoleItem(
R.string.cat_color_role_primary, androidx.appcompat.R.attr.colorPrimary),
new ColorRoleItem(R.string.cat_color_role_on_primary, com.google.android.material.R.attr.colorOnPrimary)),
new ColorRow(
new ColorRoleItem(
@ -164,7 +165,8 @@ public final class ColorMainDemoFragment extends DemoFragment {
private List<ColorRow> getColorRolesUtility() {
return Arrays.asList(
new ColorRow(
new ColorRoleItem(R.string.cat_color_role_error, R.attr.colorError),
new ColorRoleItem(
R.string.cat_color_role_error, androidx.appcompat.R.attr.colorError),
new ColorRoleItem(R.string.cat_color_role_on_error, com.google.android.material.R.attr.colorOnError)),
new ColorRow(
new ColorRoleItem(R.string.cat_color_role_error_container, com.google.android.material.R.attr.colorErrorContainer),

View File

@ -267,7 +267,7 @@ public class DatePickerMainDemoFragment extends DemoFragment {
String titleAndDescriptionText =
context.getString(R.string.cat_picker_title_description_main) + alarmTimes;
SpannableString spannable = new SpannableString(titleAndDescriptionText);
int alarmTimesColor = resolveOrThrow(context, R.attr.colorPrimary);
int alarmTimesColor = resolveOrThrow(context, androidx.appcompat.R.attr.colorPrimary);
int spanStart = titleAndDescriptionText.indexOf(alarmTimes);
int spanEnd = spanStart + alarmTimes.length();
spannable.setSpan(

View File

@ -94,7 +94,10 @@ public abstract class DemoLandingFragment extends DaggerFragment {
TypedArray a =
toolbarContext
.getTheme()
.obtainStyledAttributes(new int[] {com.google.android.material.R.attr.colorOnSurfaceVariant, R.attr.colorPrimary});
.obtainStyledAttributes(
new int[] {
com.google.android.material.R.attr.colorOnSurfaceVariant, androidx.appcompat.R.attr.colorPrimary
});
menuIconColorUnchecked = a.getColor(0, 0);
menuIconColorChecked = a.getColor(1, 0);
a.recycle();

View File

@ -90,10 +90,10 @@ public abstract class FeatureDemoUtils {
}
} else {
transaction.setCustomAnimations(
R.anim.abc_grow_fade_in_from_bottom,
R.anim.abc_fade_out,
R.anim.abc_fade_in,
R.anim.abc_shrink_fade_out_from_bottom);
androidx.appcompat.R.anim.abc_grow_fade_in_from_bottom,
androidx.appcompat.R.anim.abc_fade_out,
androidx.appcompat.R.anim.abc_fade_in,
androidx.appcompat.R.anim.abc_shrink_fade_out_from_bottom);
}
transaction

View File

@ -124,7 +124,7 @@ public final class MemoryView extends AppCompatTextView {
TypedValue typedValue = new TypedValue();
getContext()
.getTheme()
.resolveAttribute(R.attr.colorPrimary, typedValue, true);
.resolveAttribute(androidx.appcompat.R.attr.colorPrimary, typedValue, true);
int colorPrimary = typedValue.data;
paint.setColor(colorPrimary);

View File

@ -173,7 +173,8 @@ public class MenuMainDemoFragment extends DemoFragment {
private ListPopupWindow initializeListPopupMenu(View v) {
ListPopupWindow listPopupWindow =
new ListPopupWindow(getContext(), null, R.attr.listPopupWindowStyle);
new ListPopupWindow(
getContext(), null, androidx.appcompat.R.attr.listPopupWindowStyle);
ArrayAdapter<CharSequence> adapter =
new ArrayAdapter<>(
getContext(),
@ -198,7 +199,9 @@ public class MenuMainDemoFragment extends DemoFragment {
Context context = textView.getContext();
CharSequence text = textView.getText();
TypedValue value = new TypedValue();
context.getTheme().resolveAttribute(R.attr.colorPrimary, value, true);
context
.getTheme()
.resolveAttribute(androidx.appcompat.R.attr.colorPrimary, value, true);
Spannable spanText = Spannable.Factory.getInstance().newSpannable(text);
spanText.setSpan(
new BackgroundColorSpan(value.data), 0, text.length(), SPAN_EXCLUSIVE_EXCLUSIVE);

View File

@ -52,7 +52,7 @@ public abstract class ShapeThemingDemoFragment extends DemoFragment {
final TypedValue value = new TypedValue();
wrappedContext
.getTheme()
.resolveAttribute(R.attr.colorPrimaryDark, value, true);
.resolveAttribute(androidx.appcompat.R.attr.colorPrimaryDark, value, true);
window.setStatusBarColor(value.data);
return super.onCreateView(layoutInflaterWithThemedContext, viewGroup, bundle);

View File

@ -64,7 +64,7 @@ public class TopAppBarCollapsingMultilineDemoFragment extends DemoFragment {
Toolbar toolbar = view.findViewById(R.id.toolbar);
AppCompatActivity activity = (AppCompatActivity) getActivity();
activity.setSupportActionBar(toolbar);
colorPrimary = MaterialColors.getColor(view, R.attr.colorPrimary);
colorPrimary = MaterialColors.getColor(view, androidx.appcompat.R.attr.colorPrimary);
return view;
}

View File

@ -18,8 +18,6 @@ org.gradle.parallel=true
android.useAndroidX=true
android.enableUnitTestBinaryResources=true
# (b/379121671) Non-transitive R classes were enabled by default in AGP 8+
android.nonTransitiveRClass=false
# Disable "The option setting 'android.enableUnitTestBinaryResources=true' is experimental and unsupported" warning
android.suppressUnsupportedOptionWarnings=android.suppressUnsupportedOptionWarnings,android.enableUnitTestBinaryResources

View File

@ -156,6 +156,7 @@ publishing {
publications {
release(MavenPublication) {
from components.findByName('release')
artifact androidSourcesJar
groupId = 'com.google.android.material'
artifactId = 'material'
@ -185,10 +186,6 @@ publishing {
url = 'https://github.com/material-components/material-components-android'
}
}
afterEvaluate {
from components.release
}
}
}
}

View File

@ -92,7 +92,7 @@ public class MaterialToolbar extends Toolbar {
}
public MaterialToolbar(@NonNull Context context, @Nullable AttributeSet attrs) {
this(context, attrs, R.attr.toolbarStyle);
this(context, attrs, androidx.appcompat.R.attr.toolbarStyle);
}
public MaterialToolbar(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {

View File

@ -143,11 +143,16 @@ class MaterialCardViewHelper {
TypedArray cardViewAttributes =
card.getContext()
.obtainStyledAttributes(attrs, R.styleable.CardView, defStyleAttr, R.style.CardView);
if (cardViewAttributes.hasValue(R.styleable.CardView_cardCornerRadius)) {
.obtainStyledAttributes(
attrs,
androidx.cardview.R.styleable.CardView,
defStyleAttr,
androidx.cardview.R.style.CardView);
if (cardViewAttributes.hasValue(androidx.cardview.R.styleable.CardView_cardCornerRadius)) {
// If cardCornerRadius is set, let it override the shape appearance.
shapeAppearanceModelBuilder.setAllCornerSizes(
cardViewAttributes.getDimension(R.styleable.CardView_cardCornerRadius, 0));
cardViewAttributes.getDimension(
androidx.cardview.R.styleable.CardView_cardCornerRadius, 0));
}
foregroundContentDrawable = new MaterialShapeDrawable();
@ -199,7 +204,8 @@ class MaterialCardViewHelper {
if (rippleColor == null) {
rippleColor =
ColorStateList.valueOf(
MaterialColors.getColor(materialCardView, R.attr.colorControlHighlight));
MaterialColors.getColor(
materialCardView, androidx.appcompat.R.attr.colorControlHighlight));
}
ColorStateList foregroundColor =

View File

@ -207,7 +207,10 @@ public class CarouselLayoutManager extends LayoutManager
if (attrs != null) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Carousel);
setCarouselAlignment(a.getInt(R.styleable.Carousel_carousel_alignment, ALIGNMENT_START));
setOrientation(a.getInt(R.styleable.RecyclerView_android_orientation, HORIZONTAL));
setOrientation(
a.getInt(
androidx.recyclerview.R.styleable.RecyclerView_android_orientation,
HORIZONTAL));
a.recycle();
}
}

View File

@ -225,7 +225,7 @@ public class MaterialCheckBox extends AppCompatCheckBox {
}
public MaterialCheckBox(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, R.attr.checkboxStyle);
this(context, attrs, androidx.appcompat.R.attr.checkboxStyle);
}
public MaterialCheckBox(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
@ -809,8 +809,10 @@ public class MaterialCheckBox extends AppCompatCheckBox {
private ColorStateList getMaterialThemeColorsTintList() {
if (materialThemeColorsTintList == null) {
int[] checkBoxColorsList = new int[CHECKBOX_STATES.length];
int colorControlActivated = MaterialColors.getColor(this, R.attr.colorControlActivated);
int colorError = MaterialColors.getColor(this, R.attr.colorError);
int colorControlActivated =
MaterialColors.getColor(this, androidx.appcompat.R.attr.colorControlActivated);
int colorError =
MaterialColors.getColor(this, androidx.appcompat.R.attr.colorError);
int colorSurface = MaterialColors.getColor(this, R.attr.colorSurface);
int colorOnSurface = MaterialColors.getColor(this, R.attr.colorOnSurface);

View File

@ -33,7 +33,7 @@ public final class HarmonizedColorAttributes {
private static final int[] HARMONIZED_MATERIAL_ATTRIBUTES =
new int[] {
R.attr.colorError,
androidx.appcompat.R.attr.colorError,
R.attr.colorOnError,
R.attr.colorErrorContainer,
R.attr.colorOnErrorContainer

View File

@ -16,8 +16,6 @@
package com.google.android.material.color;
import com.google.android.material.R;
import androidx.annotation.AttrRes;
import androidx.annotation.ColorRes;
import androidx.annotation.NonNull;
@ -80,7 +78,9 @@ public class HarmonizedColorsOptions {
@NonNull @ColorRes private int[] colorResourceIds = new int[] {};
@Nullable private HarmonizedColorAttributes colorAttributes;
@AttrRes private int colorAttributeToHarmonizeWith = R.attr.colorPrimary;
@AttrRes
private int colorAttributeToHarmonizeWith = androidx.appcompat.R.attr.colorPrimary;
/**
* Sets the array of color resource ids for harmonization.

View File

@ -15,8 +15,6 @@
*/
package com.google.android.material.color;
import com.google.android.material.R;
import static android.graphics.Color.TRANSPARENT;
import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP;
@ -263,7 +261,10 @@ public class MaterialColors {
public static int harmonizeWithPrimary(@NonNull Context context, @ColorInt int colorToHarmonize) {
return harmonize(
colorToHarmonize,
getColor(context, R.attr.colorPrimary, MaterialColors.class.getCanonicalName()));
getColor(
context,
androidx.appcompat.R.attr.colorPrimary,
MaterialColors.class.getCanonicalName()));
}
/**
@ -348,7 +349,7 @@ public class MaterialColors {
static boolean isLightTheme(@NonNull Context context) {
return MaterialAttributes.resolveBoolean(
context, R.attr.isLightTheme, /* defaultValue= */ true);
context, androidx.appcompat.R.attr.isLightTheme, /* defaultValue= */ true);
}
@ColorInt

View File

@ -71,7 +71,9 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue;
*/
public class MaterialAlertDialogBuilder extends AlertDialog.Builder {
@AttrRes private static final int DEF_STYLE_ATTR = R.attr.alertDialogStyle;
@AttrRes
private static final int DEF_STYLE_ATTR = androidx.appcompat.R.attr.alertDialogStyle;
@StyleRes private static final int DEF_STYLE_RES = R.style.MaterialAlertDialog_MaterialComponents;
@AttrRes

View File

@ -41,7 +41,9 @@ import com.google.android.material.resources.MaterialAttributes;
@RestrictTo(LIBRARY_GROUP)
public final class ThemeEnforcement {
private static final int[] APPCOMPAT_CHECK_ATTRS = {R.attr.colorPrimary};
private static final int[] APPCOMPAT_CHECK_ATTRS = {
androidx.appcompat.R.attr.colorPrimary
};
private static final String APPCOMPAT_THEME_NAME = "Theme.AppCompat";
private static final int[] MATERIAL_CHECK_ATTRS = {R.attr.colorPrimaryVariant};

View File

@ -274,7 +274,11 @@ public final class LoadingIndicator extends View implements Drawable.Callback {
public void setIndicatorColor(@ColorInt int... indicatorColors) {
if (indicatorColors.length == 0) {
// Uses theme primary color for indicator by default. Indicator color cannot be empty.
indicatorColors = new int[] {MaterialColors.getColor(getContext(), R.attr.colorPrimary, -1)};
indicatorColors =
new int[] {
MaterialColors.getColor(
getContext(), androidx.appcompat.R.attr.colorPrimary, -1)
};
}
if (!Arrays.equals(getIndicatorColor(), indicatorColors)) {
specs.indicatorColors = indicatorColors;

View File

@ -85,7 +85,10 @@ public final class LoadingIndicatorSpec {
private void loadIndicatorColors(@NonNull Context context, @NonNull TypedArray typedArray) {
if (!typedArray.hasValue(R.styleable.LoadingIndicator_indicatorColor)) {
// Uses theme primary color for indicator if not provided in the attribute set.
indicatorColors = new int[] {MaterialColors.getColor(context, R.attr.colorPrimary, -1)};
indicatorColors =
new int[] {
MaterialColors.getColor(context, androidx.appcompat.R.attr.colorPrimary, -1)
};
return;
}

View File

@ -589,7 +589,11 @@ public abstract class BaseProgressIndicator<S extends BaseProgressIndicatorSpec>
public void setIndicatorColor(@ColorInt int... indicatorColors) {
if (indicatorColors.length == 0) {
// Uses theme primary color for indicator by default. Indicator color cannot be empty.
indicatorColors = new int[] {MaterialColors.getColor(getContext(), R.attr.colorPrimary, -1)};
indicatorColors =
new int[] {
MaterialColors.getColor(
getContext(), androidx.appcompat.R.attr.colorPrimary, -1)
};
}
if (!Arrays.equals(getIndicatorColor(), indicatorColors)) {
spec.indicatorColors = indicatorColors;

View File

@ -182,7 +182,10 @@ public abstract class BaseProgressIndicatorSpec {
private void loadIndicatorColors(@NonNull Context context, @NonNull TypedArray typedArray) {
if (!typedArray.hasValue(R.styleable.BaseProgressIndicator_indicatorColor)) {
// Uses theme primary color for indicator if not provided in the attribute set.
indicatorColors = new int[] {MaterialColors.getColor(context, R.attr.colorPrimary, -1)};
indicatorColors =
new int[] {
MaterialColors.getColor(context, androidx.appcompat.R.attr.colorPrimary, -1)
};
return;
}

View File

@ -64,7 +64,7 @@ public class MaterialRadioButton extends AppCompatRadioButton {
}
public MaterialRadioButton(@NonNull Context context, @Nullable AttributeSet attrs) {
this(context, attrs, R.attr.radioButtonStyle);
this(context, attrs, androidx.appcompat.R.attr.radioButtonStyle);
}
public MaterialRadioButton(
@ -122,7 +122,8 @@ public class MaterialRadioButton extends AppCompatRadioButton {
private ColorStateList getMaterialThemeColorsTintList() {
if (materialThemeColorsTintList == null) {
int colorControlActivated = MaterialColors.getColor(this, R.attr.colorControlActivated);
int colorControlActivated =
MaterialColors.getColor(this, androidx.appcompat.R.attr.colorControlActivated);
int colorOnSurface = MaterialColors.getColor(this, R.attr.colorOnSurface);
int colorSurface = MaterialColors.getColor(this, R.attr.colorSurface);

View File

@ -200,9 +200,12 @@ public class MaterialResources {
return defValue;
}
TypedArray a = context.obtainStyledAttributes(textAppearance, R.styleable.TextAppearance);
TypedArray a =
context.obtainStyledAttributes(
textAppearance, androidx.appcompat.R.styleable.TextAppearance);
TypedValue v = new TypedValue();
boolean available = a.getValue(R.styleable.TextAppearance_android_textSize, v);
boolean available =
a.getValue(androidx.appcompat.R.styleable.TextAppearance_android_textSize, v);
a.recycle();
if (!available) {

View File

@ -86,34 +86,53 @@ public class TextAppearance {
/** Parses the given TextAppearance style resource. */
public TextAppearance(@NonNull Context context, @StyleRes int id) {
TypedArray a = context.obtainStyledAttributes(id, R.styleable.TextAppearance);
TypedArray a =
context.obtainStyledAttributes(id, androidx.appcompat.R.styleable.TextAppearance);
setTextSize(a.getDimension(R.styleable.TextAppearance_android_textSize, 0f));
setTextSize(
a.getDimension(
androidx.appcompat.R.styleable.TextAppearance_android_textSize, 0f));
setTextColor(
MaterialResources.getColorStateList(
context, a, R.styleable.TextAppearance_android_textColor));
context, a, androidx.appcompat.R.styleable.TextAppearance_android_textColor));
textColorHint =
MaterialResources.getColorStateList(
context, a, R.styleable.TextAppearance_android_textColorHint);
context,
a,
androidx.appcompat.R.styleable.TextAppearance_android_textColorHint);
textColorLink =
MaterialResources.getColorStateList(
context, a, R.styleable.TextAppearance_android_textColorLink);
textStyle = a.getInt(R.styleable.TextAppearance_android_textStyle, Typeface.NORMAL);
typeface = a.getInt(R.styleable.TextAppearance_android_typeface, TYPEFACE_SANS);
context,
a,
androidx.appcompat.R.styleable.TextAppearance_android_textColorLink);
textStyle =
a.getInt(
androidx.appcompat.R.styleable.TextAppearance_android_textStyle,
Typeface.NORMAL);
typeface =
a.getInt(
androidx.appcompat.R.styleable.TextAppearance_android_typeface,
TYPEFACE_SANS);
int fontFamilyIndex =
MaterialResources.getIndexWithValue(
a,
R.styleable.TextAppearance_fontFamily,
R.styleable.TextAppearance_android_fontFamily);
androidx.appcompat.R.styleable.TextAppearance_fontFamily,
androidx.appcompat.R.styleable.TextAppearance_android_fontFamily);
fontFamilyResourceId = a.getResourceId(fontFamilyIndex, 0);
fontFamily = a.getString(fontFamilyIndex);
textAllCaps = a.getBoolean(R.styleable.TextAppearance_textAllCaps, false);
textAllCaps =
a.getBoolean(androidx.appcompat.R.styleable.TextAppearance_textAllCaps, false);
shadowColor =
MaterialResources.getColorStateList(
context, a, R.styleable.TextAppearance_android_shadowColor);
shadowDx = a.getFloat(R.styleable.TextAppearance_android_shadowDx, 0);
shadowDy = a.getFloat(R.styleable.TextAppearance_android_shadowDy, 0);
shadowRadius = a.getFloat(R.styleable.TextAppearance_android_shadowRadius, 0);
context,
a,
androidx.appcompat.R.styleable.TextAppearance_android_shadowColor);
shadowDx =
a.getFloat(androidx.appcompat.R.styleable.TextAppearance_android_shadowDx, 0);
shadowDy =
a.getFloat(androidx.appcompat.R.styleable.TextAppearance_android_shadowDy, 0);
shadowRadius =
a.getFloat(androidx.appcompat.R.styleable.TextAppearance_android_shadowRadius, 0);
a.recycle();

View File

@ -16,8 +16,6 @@
package com.google.android.material.ripple;
import com.google.android.material.R;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Color;
@ -229,7 +227,9 @@ public class RippleUtils {
new InsetDrawable(maskDrawable, padding, padding, padding, padding);
return new RippleDrawable(
MaterialColors.getColorStateList(
context, R.attr.colorControlHighlight, ColorStateList.valueOf(Color.TRANSPARENT)),
context,
androidx.appcompat.R.attr.colorControlHighlight,
ColorStateList.valueOf(Color.TRANSPARENT)),
null,
maskWithPaddings);
}

View File

@ -259,7 +259,8 @@ public class SearchBar extends Toolbar {
backgroundShape.setStroke(strokeWidth, strokeColor);
}
int rippleColor = MaterialColors.getColor(this, R.attr.colorControlHighlight);
int rippleColor =
MaterialColors.getColor(this, androidx.appcompat.R.attr.colorControlHighlight);
Drawable background;
backgroundShape.setFillColor(ColorStateList.valueOf(backgroundColor));
background =

View File

@ -63,7 +63,7 @@ public class SwitchMaterial extends SwitchCompat {
}
public SwitchMaterial(@NonNull Context context, @Nullable AttributeSet attrs) {
this(context, attrs, R.attr.switchStyle);
this(context, attrs, androidx.appcompat.R.attr.switchStyle);
}
public SwitchMaterial(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
@ -120,7 +120,8 @@ public class SwitchMaterial extends SwitchCompat {
private ColorStateList getMaterialThemeColorsThumbTintList() {
if (materialThemeColorsThumbTintList == null) {
int colorSurface = MaterialColors.getColor(this, R.attr.colorSurface);
int colorControlActivated = MaterialColors.getColor(this, R.attr.colorControlActivated);
int colorControlActivated =
MaterialColors.getColor(this, androidx.appcompat.R.attr.colorControlActivated);
float thumbElevation = getResources().getDimension(R.dimen.mtrl_switch_thumb_elevation);
if (elevationOverlayProvider.isThemeElevationOverlayEnabled()) {
thumbElevation += ViewUtils.getParentAbsoluteElevation(this);
@ -145,7 +146,8 @@ public class SwitchMaterial extends SwitchCompat {
if (materialThemeColorsTrackTintList == null) {
int[] switchTrackColorsList = new int[ENABLED_CHECKED_STATES.length];
int colorSurface = MaterialColors.getColor(this, R.attr.colorSurface);
int colorControlActivated = MaterialColors.getColor(this, R.attr.colorControlActivated);
int colorControlActivated =
MaterialColors.getColor(this, androidx.appcompat.R.attr.colorControlActivated);
int colorOnSurface = MaterialColors.getColor(this, R.attr.colorOnSurface);
switchTrackColorsList[0] =
MaterialColors.layer(colorSurface, colorControlActivated, MaterialColors.ALPHA_MEDIUM);

View File

@ -89,7 +89,7 @@ public class MaterialAutoCompleteTextView extends AppCompatAutoCompleteTextView
public MaterialAutoCompleteTextView(
@NonNull Context context, @Nullable AttributeSet attributeSet) {
this(context, attributeSet, R.attr.autoCompleteTextViewStyle);
this(context, attributeSet, androidx.appcompat.R.attr.autoCompleteTextViewStyle);
}
public MaterialAutoCompleteTextView(
@ -104,7 +104,7 @@ public class MaterialAutoCompleteTextView extends AppCompatAutoCompleteTextView
attributeSet,
R.styleable.MaterialAutoCompleteTextView,
defStyleAttr,
R.style.Widget_AppCompat_AutoCompleteTextView);
androidx.appcompat.R.style.Widget_AppCompat_AutoCompleteTextView);
// Due to a framework bug, setting android:inputType="none" on xml has no effect. Therefore,
// we check it here in case the autoCompleteTextView should be non-editable.

View File

@ -66,7 +66,7 @@ public class TextInputEditText extends AppCompatEditText {
}
public TextInputEditText(@NonNull Context context, @Nullable AttributeSet attrs) {
this(context, attrs, R.attr.editTextStyle);
this(context, attrs, androidx.appcompat.R.attr.editTextStyle);
}
public TextInputEditText(

View File

@ -868,7 +868,9 @@ public class TextInputLayout extends LinearLayout implements OnGlobalLayoutListe
return boxBackground;
}
int rippleColor = MaterialColors.getColor(editText, R.attr.colorControlHighlight);
int rippleColor =
MaterialColors.getColor(
editText, androidx.appcompat.R.attr.colorControlHighlight);
if (boxBackgroundMode == TextInputLayout.BOX_BACKGROUND_OUTLINE) {
return getOutlinedBoxBackgroundWithRipple(
getContext(), boxBackground, rippleColor, EDIT_TEXT_BACKGROUND_RIPPLE_STATE);
@ -2877,7 +2879,8 @@ public class TextInputLayout extends LinearLayout implements OnGlobalLayoutListe
if (useDefaultColor) {
// Probably caused by our theme not extending from Theme.Design*. Instead
// we manually set something appropriate
TextViewCompat.setTextAppearance(textView, R.style.TextAppearance_AppCompat_Caption);
TextViewCompat.setTextAppearance(
textView, androidx.appcompat.R.style.TextAppearance_AppCompat_Caption);
textView.setTextColor(ContextCompat.getColor(getContext(), R.color.design_error));
}
}
@ -4537,9 +4540,11 @@ public class TextInputLayout extends LinearLayout implements OnGlobalLayoutListe
@RequiresApi(VERSION_CODES.Q)
private void updateCursorColor() {
ColorStateList color = cursorColor != null
? cursorColor
: MaterialColors.getColorStateListOrNull(getContext(), R.attr.colorControlActivated);
ColorStateList color =
cursorColor != null
? cursorColor
: MaterialColors.getColorStateListOrNull(
getContext(), androidx.appcompat.R.attr.colorControlActivated);
if (editText == null || editText.getTextCursorDrawable() == null) {
// If there's no cursor, return.

View File

@ -45,7 +45,7 @@ public class MaterialThemeOverlay {
private MaterialThemeOverlay() {}
private static final int[] ANDROID_THEME_OVERLAY_ATTRS =
new int[] {android.R.attr.theme, R.attr.theme};
new int[] {android.R.attr.theme, androidx.appcompat.R.attr.theme};
private static final int[] MATERIAL_THEME_OVERLAY_ATTR = new int[] {R.attr.materialThemeOverlay};