Skip to content

Commit 0697f6f

Browse files
committed
[Gradle] Enable non transitive R classes (resource namespacing) and fix errors
PiperOrigin-RevId: 738871402
1 parent e3f29ec commit 0697f6f

34 files changed

+141
-77
lines changed

catalog/java/io/material/catalog/color/ColorHarmonizationDemoActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public class ColorHarmonizationDemoActivity extends DemoActivity {
6464
R.id.cat_colors_error,
6565
R.id.cat_colors_harmonized_error,
6666
new int[] {
67-
R.attr.colorError,
67+
androidx.appcompat.R.attr.colorError,
6868
com.google.android.material.R.attr.colorOnError,
6969
com.google.android.material.R.attr.colorErrorContainer,
7070
com.google.android.material.R.attr.colorOnErrorContainer

catalog/java/io/material/catalog/color/ColorMainDemoFragment.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ private List<ColorRow> getColorRolesSurfaces() {
104104
private List<ColorRow> getColorRolesContent() {
105105
return Arrays.asList(
106106
new ColorRow(
107-
new ColorRoleItem(R.string.cat_color_role_primary, R.attr.colorPrimary),
107+
new ColorRoleItem(
108+
R.string.cat_color_role_primary, androidx.appcompat.R.attr.colorPrimary),
108109
new ColorRoleItem(R.string.cat_color_role_on_primary, com.google.android.material.R.attr.colorOnPrimary)),
109110
new ColorRow(
110111
new ColorRoleItem(
@@ -164,7 +165,8 @@ private List<ColorRow> getColorRolesContent() {
164165
private List<ColorRow> getColorRolesUtility() {
165166
return Arrays.asList(
166167
new ColorRow(
167-
new ColorRoleItem(R.string.cat_color_role_error, R.attr.colorError),
168+
new ColorRoleItem(
169+
R.string.cat_color_role_error, androidx.appcompat.R.attr.colorError),
168170
new ColorRoleItem(R.string.cat_color_role_on_error, com.google.android.material.R.attr.colorOnError)),
169171
new ColorRow(
170172
new ColorRoleItem(R.string.cat_color_role_error_container, com.google.android.material.R.attr.colorErrorContainer),

catalog/java/io/material/catalog/datepicker/DatePickerMainDemoFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ private CharSequence getTitleWithDescription() {
267267
String titleAndDescriptionText =
268268
context.getString(R.string.cat_picker_title_description_main) + alarmTimes;
269269
SpannableString spannable = new SpannableString(titleAndDescriptionText);
270-
int alarmTimesColor = resolveOrThrow(context, R.attr.colorPrimary);
270+
int alarmTimesColor = resolveOrThrow(context, androidx.appcompat.R.attr.colorPrimary);
271271
int spanStart = titleAndDescriptionText.indexOf(alarmTimes);
272272
int spanEnd = spanStart + alarmTimes.length();
273273
spannable.setSpan(

catalog/java/io/material/catalog/feature/DemoLandingFragment.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ public View onCreateView(
9494
TypedArray a =
9595
toolbarContext
9696
.getTheme()
97-
.obtainStyledAttributes(new int[] {com.google.android.material.R.attr.colorOnSurfaceVariant, R.attr.colorPrimary});
97+
.obtainStyledAttributes(
98+
new int[] {
99+
com.google.android.material.R.attr.colorOnSurfaceVariant, androidx.appcompat.R.attr.colorPrimary
100+
});
98101
menuIconColorUnchecked = a.getColor(0, 0);
99102
menuIconColorChecked = a.getColor(1, 0);
100103
a.recycle();

catalog/java/io/material/catalog/feature/FeatureDemoUtils.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ public static void startFragmentInternal(
9090
}
9191
} else {
9292
transaction.setCustomAnimations(
93-
R.anim.abc_grow_fade_in_from_bottom,
94-
R.anim.abc_fade_out,
95-
R.anim.abc_fade_in,
96-
R.anim.abc_shrink_fade_out_from_bottom);
93+
androidx.appcompat.R.anim.abc_grow_fade_in_from_bottom,
94+
androidx.appcompat.R.anim.abc_fade_out,
95+
androidx.appcompat.R.anim.abc_fade_in,
96+
androidx.appcompat.R.anim.abc_shrink_fade_out_from_bottom);
9797
}
9898

9999
transaction

catalog/java/io/material/catalog/feature/MemoryView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ protected void onAttachedToWindow() {
124124
TypedValue typedValue = new TypedValue();
125125
getContext()
126126
.getTheme()
127-
.resolveAttribute(R.attr.colorPrimary, typedValue, true);
127+
.resolveAttribute(androidx.appcompat.R.attr.colorPrimary, typedValue, true);
128128

129129
int colorPrimary = typedValue.data;
130130
paint.setColor(colorPrimary);

catalog/java/io/material/catalog/menu/MenuMainDemoFragment.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ public void setPopupItemLayoutRes(@LayoutRes int popupItemRes) {
173173

174174
private ListPopupWindow initializeListPopupMenu(View v) {
175175
ListPopupWindow listPopupWindow =
176-
new ListPopupWindow(getContext(), null, R.attr.listPopupWindowStyle);
176+
new ListPopupWindow(
177+
getContext(), null, androidx.appcompat.R.attr.listPopupWindowStyle);
177178
ArrayAdapter<CharSequence> adapter =
178179
new ArrayAdapter<>(
179180
getContext(),
@@ -198,7 +199,9 @@ private void highlightText(TextView textView) {
198199
Context context = textView.getContext();
199200
CharSequence text = textView.getText();
200201
TypedValue value = new TypedValue();
201-
context.getTheme().resolveAttribute(R.attr.colorPrimary, value, true);
202+
context
203+
.getTheme()
204+
.resolveAttribute(androidx.appcompat.R.attr.colorPrimary, value, true);
202205
Spannable spanText = Spannable.Factory.getInstance().newSpannable(text);
203206
spanText.setSpan(
204207
new BackgroundColorSpan(value.data), 0, text.length(), SPAN_EXCLUSIVE_EXCLUSIVE);

catalog/java/io/material/catalog/shapetheming/ShapeThemingDemoFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public View onCreateView(
5252
final TypedValue value = new TypedValue();
5353
wrappedContext
5454
.getTheme()
55-
.resolveAttribute(R.attr.colorPrimaryDark, value, true);
55+
.resolveAttribute(androidx.appcompat.R.attr.colorPrimaryDark, value, true);
5656
window.setStatusBarColor(value.data);
5757

5858
return super.onCreateView(layoutInflaterWithThemedContext, viewGroup, bundle);

catalog/java/io/material/catalog/topappbar/TopAppBarCollapsingMultilineDemoFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public View onCreateDemoView(
6464
Toolbar toolbar = view.findViewById(R.id.toolbar);
6565
AppCompatActivity activity = (AppCompatActivity) getActivity();
6666
activity.setSupportActionBar(toolbar);
67-
colorPrimary = MaterialColors.getColor(view, R.attr.colorPrimary);
67+
colorPrimary = MaterialColors.getColor(view, androidx.appcompat.R.attr.colorPrimary);
6868

6969
return view;
7070
}

gradle.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ org.gradle.parallel=true
1818

1919
android.useAndroidX=true
2020
android.enableUnitTestBinaryResources=true
21-
# (b/379121671) Non-transitive R classes were enabled by default in AGP 8+
22-
android.nonTransitiveRClass=false
2321

2422
# Disable "The option setting 'android.enableUnitTestBinaryResources=true' is experimental and unsupported" warning
2523
android.suppressUnsupportedOptionWarnings=android.suppressUnsupportedOptionWarnings,android.enableUnitTestBinaryResources

0 commit comments

Comments
 (0)