Replace AppCompatRatingBar stars with vector drawables.
Binary size of minified obfuscated v7 demo:
- before the change 2,401,715 bytes
- after the change 2,375,002 bytes
for the total reduction of about 26KB
Potential downsides:
- additional overhead during the inflation, as we inflate the vector
and then make a bitmap drawable out of it
- slight variations in pixels along the edges (differences between
the original PNGs and the new vector source) for golden images tests
Bug: 126209808
Bug: 126204182
Test: ./gradlew appcompat:appcompat:connectedCheck --info --daemon -Pandroid.testInstrumentationRunnerArguments.package=androidx.appcompat.widget
Test: ./gradlew textclassifier:textclassifier:assembleAndroidTest
Relnote: "AppCompatRatingBar PNG drawables have been replaced with vector sources.
This may cause slight changes in the visual appearance of individual stars."
Change-Id: I6b99d3fde8d3cd275d0fc279324066bcd7f3ecd6
diff --git a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatDrawableManager.java b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatDrawableManager.java
index 9777298..f251436 100644
--- a/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatDrawableManager.java
+++ b/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatDrawableManager.java
@@ -25,14 +25,19 @@
import android.content.Context;
import android.content.res.ColorStateList;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
+import android.graphics.Shader;
+import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.util.Log;
import androidx.annotation.ColorInt;
+import androidx.annotation.DimenRes;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
@@ -237,9 +242,76 @@
R.drawable.abc_cab_background_top_mtrl_alpha)
});
}
+ if (resId == R.drawable.abc_ratingbar_material) {
+ return getRatingBarLayerDrawable(resourceManager, context,
+ R.dimen.abc_star_big);
+ }
+ if (resId == R.drawable.abc_ratingbar_indicator_material) {
+ return getRatingBarLayerDrawable(resourceManager, context,
+ R.dimen.abc_star_medium);
+ }
+ if (resId == R.drawable.abc_ratingbar_small_material) {
+ return getRatingBarLayerDrawable(resourceManager, context,
+ R.dimen.abc_star_small);
+ }
return null;
}
+ private LayerDrawable getRatingBarLayerDrawable(
+ @NonNull ResourceManagerInternal resourceManager,
+ @NonNull Context context, @DimenRes int dimenResId) {
+ int starSize = context.getResources().getDimensionPixelSize(dimenResId);
+
+ Drawable star = resourceManager.getDrawable(context,
+ R.drawable.abc_star_black_48dp);
+ Drawable halfStar = resourceManager.getDrawable(context,
+ R.drawable.abc_star_half_black_48dp);
+
+ BitmapDrawable starBitmapDrawable;
+ BitmapDrawable tiledStarBitmapDrawable;
+ if ((star instanceof BitmapDrawable) && (star.getIntrinsicWidth() == starSize)
+ && (star.getIntrinsicHeight() == starSize)) {
+ // no need for extra conversion
+ starBitmapDrawable = (BitmapDrawable) star;
+
+ tiledStarBitmapDrawable =
+ new BitmapDrawable(starBitmapDrawable.getBitmap());
+ } else {
+ Bitmap bitmapStar = Bitmap.createBitmap(starSize, starSize,
+ Bitmap.Config.ARGB_8888);
+ Canvas canvasStar = new Canvas(bitmapStar);
+ star.setBounds(0, 0, starSize, starSize);
+ star.draw(canvasStar);
+ starBitmapDrawable = new BitmapDrawable(bitmapStar);
+
+ tiledStarBitmapDrawable = new BitmapDrawable(bitmapStar);
+ }
+ tiledStarBitmapDrawable.setTileModeX(Shader.TileMode.REPEAT);
+
+ BitmapDrawable halfStarBitmapDrawable;
+ if ((halfStar instanceof BitmapDrawable)
+ && (halfStar.getIntrinsicWidth() == starSize)
+ && (halfStar.getIntrinsicHeight() == starSize)) {
+ // no need for extra conversion
+ halfStarBitmapDrawable = (BitmapDrawable) halfStar;
+ } else {
+ Bitmap bitmapHalfStar = Bitmap.createBitmap(starSize, starSize,
+ Bitmap.Config.ARGB_8888);
+ Canvas canvasHalfStar = new Canvas(bitmapHalfStar);
+ halfStar.setBounds(0, 0, starSize, starSize);
+ halfStar.draw(canvasHalfStar);
+ halfStarBitmapDrawable = new BitmapDrawable(bitmapHalfStar);
+ }
+
+ LayerDrawable result = new LayerDrawable(new Drawable[]{
+ starBitmapDrawable, halfStarBitmapDrawable, tiledStarBitmapDrawable
+ });
+ result.setId(0, android.R.id.background);
+ result.setId(1, android.R.id.secondaryProgress);
+ result.setId(2, android.R.id.progress);
+ return result;
+ }
+
private void setPorterDuffColorFilter(Drawable d, int color, PorterDuff.Mode mode) {
if (DrawableUtils.canSafelyMutateDrawable(d)) {
d = d.mutate();
diff --git a/appcompat/appcompat/src/main/res/drawable-hdpi/abc_ic_star_black_36dp.png b/appcompat/appcompat/src/main/res/drawable-hdpi/abc_ic_star_black_36dp.png
deleted file mode 100644
index 64b2aa7..0000000
--- a/appcompat/appcompat/src/main/res/drawable-hdpi/abc_ic_star_black_36dp.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-hdpi/abc_ic_star_black_48dp.png b/appcompat/appcompat/src/main/res/drawable-hdpi/abc_ic_star_black_48dp.png
deleted file mode 100644
index 54d3065..0000000
--- a/appcompat/appcompat/src/main/res/drawable-hdpi/abc_ic_star_black_48dp.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-hdpi/abc_ic_star_half_black_16dp.png b/appcompat/appcompat/src/main/res/drawable-hdpi/abc_ic_star_half_black_16dp.png
deleted file mode 100644
index cf270fe..0000000
--- a/appcompat/appcompat/src/main/res/drawable-hdpi/abc_ic_star_half_black_16dp.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-hdpi/abc_ic_star_half_black_36dp.png b/appcompat/appcompat/src/main/res/drawable-hdpi/abc_ic_star_half_black_36dp.png
deleted file mode 100644
index 49ad6cd..0000000
--- a/appcompat/appcompat/src/main/res/drawable-hdpi/abc_ic_star_half_black_36dp.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-hdpi/abc_ic_star_half_black_48dp.png b/appcompat/appcompat/src/main/res/drawable-hdpi/abc_ic_star_half_black_48dp.png
deleted file mode 100644
index 1aa9965..0000000
--- a/appcompat/appcompat/src/main/res/drawable-hdpi/abc_ic_star_half_black_48dp.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-mdpi/abc_ic_star_black_36dp.png b/appcompat/appcompat/src/main/res/drawable-mdpi/abc_ic_star_black_36dp.png
deleted file mode 100644
index 2ddcdd9..0000000
--- a/appcompat/appcompat/src/main/res/drawable-mdpi/abc_ic_star_black_36dp.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-mdpi/abc_ic_star_black_48dp.png b/appcompat/appcompat/src/main/res/drawable-mdpi/abc_ic_star_black_48dp.png
deleted file mode 100644
index c636ce8..0000000
--- a/appcompat/appcompat/src/main/res/drawable-mdpi/abc_ic_star_black_48dp.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-mdpi/abc_ic_star_half_black_16dp.png b/appcompat/appcompat/src/main/res/drawable-mdpi/abc_ic_star_half_black_16dp.png
deleted file mode 100644
index 077f9b0..0000000
--- a/appcompat/appcompat/src/main/res/drawable-mdpi/abc_ic_star_half_black_16dp.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-mdpi/abc_ic_star_half_black_36dp.png b/appcompat/appcompat/src/main/res/drawable-mdpi/abc_ic_star_half_black_36dp.png
deleted file mode 100644
index ac6ad11..0000000
--- a/appcompat/appcompat/src/main/res/drawable-mdpi/abc_ic_star_half_black_36dp.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-mdpi/abc_ic_star_half_black_48dp.png b/appcompat/appcompat/src/main/res/drawable-mdpi/abc_ic_star_half_black_48dp.png
deleted file mode 100644
index 0065111..0000000
--- a/appcompat/appcompat/src/main/res/drawable-mdpi/abc_ic_star_half_black_48dp.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_ic_star_black_36dp.png b/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_ic_star_black_36dp.png
deleted file mode 100644
index 45887c1..0000000
--- a/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_ic_star_black_36dp.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_ic_star_black_48dp.png b/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_ic_star_black_48dp.png
deleted file mode 100644
index 7be2280..0000000
--- a/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_ic_star_black_48dp.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_ic_star_half_black_16dp.png b/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_ic_star_half_black_16dp.png
deleted file mode 100644
index ea6033a..0000000
--- a/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_ic_star_half_black_16dp.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_ic_star_half_black_36dp.png b/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_ic_star_half_black_36dp.png
deleted file mode 100644
index 2f4818b..0000000
--- a/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_ic_star_half_black_36dp.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_ic_star_half_black_48dp.png b/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_ic_star_half_black_48dp.png
deleted file mode 100644
index 2456a74..0000000
--- a/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_ic_star_half_black_48dp.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_ic_star_black_36dp.png b/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_ic_star_black_36dp.png
deleted file mode 100644
index 72685ab..0000000
--- a/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_ic_star_black_36dp.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_ic_star_black_48dp.png b/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_ic_star_black_48dp.png
deleted file mode 100644
index 918a395..0000000
--- a/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_ic_star_black_48dp.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_ic_star_half_black_16dp.png b/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_ic_star_half_black_16dp.png
deleted file mode 100644
index 8e985b4..0000000
--- a/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_ic_star_half_black_16dp.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_ic_star_half_black_36dp.png b/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_ic_star_half_black_36dp.png
deleted file mode 100644
index 19bbc12..0000000
--- a/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_ic_star_half_black_36dp.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_ic_star_half_black_48dp.png b/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_ic_star_half_black_48dp.png
deleted file mode 100644
index 601bf0c..0000000
--- a/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_ic_star_half_black_48dp.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_ic_star_black_36dp.png b/appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_ic_star_black_36dp.png
deleted file mode 100644
index dc312c1..0000000
--- a/appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_ic_star_black_36dp.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_ic_star_black_48dp.png b/appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_ic_star_black_48dp.png
deleted file mode 100644
index 67e25d5..0000000
--- a/appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_ic_star_black_48dp.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_ic_star_half_black_16dp.png b/appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_ic_star_half_black_16dp.png
deleted file mode 100644
index 1c7f66e..0000000
--- a/appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_ic_star_half_black_16dp.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_ic_star_half_black_36dp.png b/appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_ic_star_half_black_36dp.png
deleted file mode 100644
index 82e7293..0000000
--- a/appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_ic_star_half_black_36dp.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_ic_star_half_black_48dp.png b/appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_ic_star_half_black_48dp.png
deleted file mode 100644
index b028a36..0000000
--- a/appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_ic_star_half_black_48dp.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable/abc_ratingbar_indicator_material.xml b/appcompat/appcompat/src/main/res/drawable/abc_ratingbar_indicator_material.xml
index bc339a3..97ba1de 100644
--- a/appcompat/appcompat/src/main/res/drawable/abc_ratingbar_indicator_material.xml
+++ b/appcompat/appcompat/src/main/res/drawable/abc_ratingbar_indicator_material.xml
@@ -14,16 +14,5 @@
limitations under the License.
-->
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item
- android:id="@android:id/background"
- android:drawable="@drawable/abc_ic_star_black_36dp"/>
- <item
- android:id="@android:id/secondaryProgress"
- android:drawable="@drawable/abc_ic_star_half_black_36dp"/>
- <item android:id="@android:id/progress">
- <bitmap
- android:src="@drawable/abc_ic_star_black_36dp"
- android:tileModeX="repeat"/>
- </item>
-</layer-list>
+<!-- Placeholder. The real content is inflated at runtime in AppCompatDrawableManager -->
+<layer-list />
diff --git a/appcompat/appcompat/src/main/res/drawable/abc_ratingbar_material.xml b/appcompat/appcompat/src/main/res/drawable/abc_ratingbar_material.xml
index dde914e..97ba1de 100644
--- a/appcompat/appcompat/src/main/res/drawable/abc_ratingbar_material.xml
+++ b/appcompat/appcompat/src/main/res/drawable/abc_ratingbar_material.xml
@@ -14,16 +14,5 @@
limitations under the License.
-->
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item
- android:id="@android:id/background"
- android:drawable="@drawable/abc_ic_star_black_48dp"/>
- <item
- android:id="@android:id/secondaryProgress"
- android:drawable="@drawable/abc_ic_star_half_black_48dp"/>
- <item android:id="@android:id/progress">
- <bitmap
- android:src="@drawable/abc_ic_star_black_48dp"
- android:tileModeX="repeat"/>
- </item>
-</layer-list>
+<!-- Placeholder. The real content is inflated at runtime in AppCompatDrawableManager -->
+<layer-list />
diff --git a/appcompat/appcompat/src/main/res/drawable/abc_ratingbar_small_material.xml b/appcompat/appcompat/src/main/res/drawable/abc_ratingbar_small_material.xml
index 6daff8b..97ba1de 100644
--- a/appcompat/appcompat/src/main/res/drawable/abc_ratingbar_small_material.xml
+++ b/appcompat/appcompat/src/main/res/drawable/abc_ratingbar_small_material.xml
@@ -14,14 +14,5 @@
limitations under the License.
-->
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:id="@android:id/background"
- android:drawable="@drawable/abc_ic_star_black_16dp" />
- <item android:id="@android:id/secondaryProgress"
- android:drawable="@drawable/abc_ic_star_half_black_16dp" />
- <item android:id="@android:id/progress">
- <bitmap
- android:src="@drawable/abc_ic_star_black_16dp"
- android:tileModeX="repeat"/>
- </item>
-</layer-list>
+<!-- Placeholder. The real content is inflated at runtime in AppCompatDrawableManager -->
+<layer-list />
diff --git a/appcompat/appcompat/src/main/res/drawable/abc_star_black_48dp.xml b/appcompat/appcompat/src/main/res/drawable/abc_star_black_48dp.xml
new file mode 100644
index 0000000..4f380aa
--- /dev/null
+++ b/appcompat/appcompat/src/main/res/drawable/abc_star_black_48dp.xml
@@ -0,0 +1,25 @@
+<!--
+ Copyright 2020 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="48dp"
+ android:height="48dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:pathData="M12,17.27L18.18,21l-1.64,-7.03L22,9.24l-7.19,-0.61L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21z"
+ android:fillColor="@android:color/black"/>
+</vector>
diff --git a/appcompat/appcompat/src/main/res/drawable/abc_star_half_black_48dp.xml b/appcompat/appcompat/src/main/res/drawable/abc_star_half_black_48dp.xml
new file mode 100644
index 0000000..ba1dc575
--- /dev/null
+++ b/appcompat/appcompat/src/main/res/drawable/abc_star_half_black_48dp.xml
@@ -0,0 +1,25 @@
+<!--
+ Copyright 2020 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="48dp"
+ android:height="48dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:pathData="M12,2L9.19,8.63L2,9.24l5.46,4.73L5.82,21L12,17.27z"
+ android:fillColor="@android:color/black"/>
+</vector>
diff --git a/appcompat/appcompat/src/main/res/values/dimens.xml b/appcompat/appcompat/src/main/res/values/dimens.xml
index 46b83436..d412d59 100644
--- a/appcompat/appcompat/src/main/res/values/dimens.xml
+++ b/appcompat/appcompat/src/main/res/values/dimens.xml
@@ -115,4 +115,9 @@
<dimen name="tooltip_precise_anchor_threshold">96dp</dimen>
<!-- Extra tooltip offset used when anchoring to the mouse/touch position -->
<dimen name="tooltip_precise_anchor_extra_offset">8dp</dimen>
+
+ <!-- Dimensions for rating bar stars -->
+ <dimen name="abc_star_big">48dp</dimen>
+ <dimen name="abc_star_medium">36dp</dimen>
+ <dimen name="abc_star_small">16dp</dimen>
</resources>
diff --git a/samples/Support7Demos/src/main/AndroidManifest.xml b/samples/Support7Demos/src/main/AndroidManifest.xml
index 551f5b6..10165ace 100644
--- a/samples/Support7Demos/src/main/AndroidManifest.xml
+++ b/samples/Support7Demos/src/main/AndroidManifest.xml
@@ -269,8 +269,17 @@
</activity>
<activity android:name=".app.AppCompatWidgetsButtons"
- android:label="@string/appcompat_widgets_buttons"
- android:theme="@style/Theme.AppCompat.Light.DarkActionBar">
+ android:label="@string/appcompat_widgets_buttons"
+ android:theme="@style/Theme.AppCompat.Light.DarkActionBar">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="com.example.android.supportv7.SAMPLE_CODE" />
+ </intent-filter>
+ </activity>
+
+ <activity android:name=".app.AppCompatWidgetsRatingBars"
+ android:label="@string/appcompat_widgets_ratingbars"
+ android:theme="@style/Theme.AppCompat.Light.DarkActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="com.example.android.supportv7.SAMPLE_CODE" />
diff --git a/samples/Support7Demos/src/main/java/com/example/android/supportv7/app/AppCompatWidgetsRatingBars.java b/samples/Support7Demos/src/main/java/com/example/android/supportv7/app/AppCompatWidgetsRatingBars.java
new file mode 100644
index 0000000..df6ddcf
--- /dev/null
+++ b/samples/Support7Demos/src/main/java/com/example/android/supportv7/app/AppCompatWidgetsRatingBars.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.supportv7.app;
+
+import android.os.Bundle;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import com.example.android.supportv7.R;
+
+/**
+ * This demonstrates the styled {@link android.widget.RatingBar} widgets in AppCompat.
+ */
+public class AppCompatWidgetsRatingBars extends AppCompatActivity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.appcompat_widgets_ratingbars);
+ }
+
+}
diff --git a/samples/Support7Demos/src/main/res/layout/appcompat_widgets_buttons.xml b/samples/Support7Demos/src/main/res/layout/appcompat_widgets_buttons.xml
index 3595f9c..bc5562a 100644
--- a/samples/Support7Demos/src/main/res/layout/appcompat_widgets_buttons.xml
+++ b/samples/Support7Demos/src/main/res/layout/appcompat_widgets_buttons.xml
@@ -144,10 +144,6 @@
android:text="Button (colored + tinted) disabled"
app:backgroundTint="@color/background_tint" />
- <RatingBar
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
</LinearLayout>
</ScrollView>
\ No newline at end of file
diff --git a/samples/Support7Demos/src/main/res/layout/appcompat_widgets_ratingbars.xml b/samples/Support7Demos/src/main/res/layout/appcompat_widgets_ratingbars.xml
new file mode 100644
index 0000000..09aef77
--- /dev/null
+++ b/samples/Support7Demos/src/main/res/layout/appcompat_widgets_ratingbars.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2020 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<ScrollView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:padding="16dp">
+
+ <RatingBar
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:stepSize="1.0"
+ android:rating="3" />
+
+ <RatingBar
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:stepSize="0.1"
+ android:rating="2.5" />
+
+ <RatingBar
+ style="?attr/ratingBarStyleIndicator"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:stepSize="1.0"
+ android:rating="3" />
+
+ <RatingBar
+ style="?attr/ratingBarStyleIndicator"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:stepSize="0.1"
+ android:rating="2.5" />
+
+ <RatingBar
+ style="?attr/ratingBarStyleSmall"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:stepSize="1.0"
+ android:rating="3" />
+
+ <RatingBar
+ style="?attr/ratingBarStyleSmall"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:stepSize="0.1"
+ android:rating="2.5" />
+
+ </LinearLayout>
+
+</ScrollView>
\ No newline at end of file
diff --git a/samples/Support7Demos/src/main/res/values/strings.xml b/samples/Support7Demos/src/main/res/values/strings.xml
index 4411d75..69d5367 100644
--- a/samples/Support7Demos/src/main/res/values/strings.xml
+++ b/samples/Support7Demos/src/main/res/values/strings.xml
@@ -78,6 +78,7 @@
<string name="action_bar_action_mode">AppCompat/Action Bar/Action Mode</string>
<string name="action_bar_hide_scroll">AppCompat/Action Bar/Hide on Scroll</string>
<string name="appcompat_widgets_buttons">AppCompat/Widgets/Buttons</string>
+ <string name="appcompat_widgets_ratingbars">AppCompat/Widgets/Rating Bars</string>
<string name="appcompat_widgets_spinners">AppCompat/Widgets/Spinners</string>
<string name="appcompat_widgets_switches">AppCompat/Widgets/Switches</string>
<string name="appcompat_widgets_text_input">AppCompat/Widgets/Text Input</string>
diff --git a/textclassifier/textclassifier/src/androidTest/java/androidx/textclassifier/TextClassificationTest.java b/textclassifier/textclassifier/src/androidTest/java/androidx/textclassifier/TextClassificationTest.java
index a59a767..0c302cf 100644
--- a/textclassifier/textclassifier/src/androidTest/java/androidx/textclassifier/TextClassificationTest.java
+++ b/textclassifier/textclassifier/src/androidTest/java/androidx/textclassifier/TextClassificationTest.java
@@ -35,6 +35,7 @@
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SdkSuppress;
import androidx.test.filters.SmallTest;
+import androidx.textclassifier.test.R;
import org.junit.Before;
import org.junit.Test;
@@ -203,8 +204,7 @@
.setText(TEXT)
.setEntityType(TextClassifier.TYPE_ADDRESS, ADDRESS_SCORE)
.setEntityType(TextClassifier.TYPE_PHONE, PHONE_SCORE)
- .setIcon(mContext.getDrawable(
- androidx.appcompat.R.drawable.abc_ic_star_black_16dp))
+ .setIcon(mContext.getDrawable(R.drawable.ic_star_black_16dp))
.setLabel(PRIMARY_LABEL)
.setIntent(PRIMARY_INTENT)
.build();
diff --git a/appcompat/appcompat/src/main/res/drawable-hdpi/abc_ic_star_black_16dp.png b/textclassifier/textclassifier/src/androidTest/res/drawable-hdpi/ic_star_black_16dp.png
similarity index 100%
rename from appcompat/appcompat/src/main/res/drawable-hdpi/abc_ic_star_black_16dp.png
rename to textclassifier/textclassifier/src/androidTest/res/drawable-hdpi/ic_star_black_16dp.png
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-mdpi/abc_ic_star_black_16dp.png b/textclassifier/textclassifier/src/androidTest/res/drawable-mdpi/ic_star_black_16dp.png
similarity index 100%
rename from appcompat/appcompat/src/main/res/drawable-mdpi/abc_ic_star_black_16dp.png
rename to textclassifier/textclassifier/src/androidTest/res/drawable-mdpi/ic_star_black_16dp.png
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xhdpi/abc_ic_star_black_16dp.png b/textclassifier/textclassifier/src/androidTest/res/drawable-xhdpi/ic_star_black_16dp.png
similarity index 100%
rename from appcompat/appcompat/src/main/res/drawable-xhdpi/abc_ic_star_black_16dp.png
rename to textclassifier/textclassifier/src/androidTest/res/drawable-xhdpi/ic_star_black_16dp.png
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_ic_star_black_16dp.png b/textclassifier/textclassifier/src/androidTest/res/drawable-xxhdpi/ic_star_black_16dp.png
similarity index 100%
rename from appcompat/appcompat/src/main/res/drawable-xxhdpi/abc_ic_star_black_16dp.png
rename to textclassifier/textclassifier/src/androidTest/res/drawable-xxhdpi/ic_star_black_16dp.png
Binary files differ
diff --git a/appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_ic_star_black_16dp.png b/textclassifier/textclassifier/src/androidTest/res/drawable-xxxhdpi/ic_star_black_16dp.png
similarity index 100%
rename from appcompat/appcompat/src/main/res/drawable-xxxhdpi/abc_ic_star_black_16dp.png
rename to textclassifier/textclassifier/src/androidTest/res/drawable-xxxhdpi/ic_star_black_16dp.png
Binary files differ