Merge "Fix java.lang.NoSuchFieldError on R$styleable" into qt-dev am: 508601ae7b
am: bc5312f8d7

Change-Id: I442278bbf7c77169ec0e14e4dc3068e47169674f
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index de29725..dcebd0a 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -15,22 +15,6 @@
 -->
 <resources>
 
-    <declare-styleable name="ActionBarView">
-        <attr name="android:colorBackground" />
-        <attr name="android:colorPrimary" />
-        <attr name="android:colorControlNormal" />
-        <attr name="android:textColorPrimary" />
-    </declare-styleable>
-
-    <declare-styleable name="DrawerMenuTitle">
-        <attr name="android:textColor" />
-        <attr name="android:textSize" />
-    </declare-styleable>
-
-    <declare-styleable name="CardView">
-        <attr name="android:colorBackgroundFloating" format="color" />
-    </declare-styleable>
-
     <declare-styleable name="DropBadgeView">
         <attr name="state_reject_drop" format="boolean"/>
         <attr name="state_copy" format="boolean"/>
@@ -47,24 +31,4 @@
         <attr name="state_highlighted" format="boolean"/>
     </declare-styleable>
 
-    <declare-styleable name="SnackbarView">
-        <attr name="android:textColor" />
-    </declare-styleable>
-
-    <declare-styleable name="SystemWindow">
-        <attr name="android:statusBarColor" />
-        <attr name="android:navigationBarColor" />
-        <attr name="android:windowBackground" />
-        <attr name="android:windowLightStatusBar" />
-        <attr name="android:windowLightNavigationBar" />
-    </declare-styleable>
-
-    <declare-styleable name="SwipeRefresh">
-        <attr name="android:colorPrimary" />
-    </declare-styleable>
-
-    <declare-styleable name="MaterialButtons">
-        <attr name="materialButtonStyle" format="reference" />
-        <attr name="materialButtonOutlinedStyle" format="reference"/>
-    </declare-styleable>
 </resources>
diff --git a/src/com/android/documentsui/dirlist/DocumentsSwipeRefreshLayout.java b/src/com/android/documentsui/dirlist/DocumentsSwipeRefreshLayout.java
index 69daba6..a196364 100644
--- a/src/com/android/documentsui/dirlist/DocumentsSwipeRefreshLayout.java
+++ b/src/com/android/documentsui/dirlist/DocumentsSwipeRefreshLayout.java
@@ -42,9 +42,10 @@
     public DocumentsSwipeRefreshLayout(Context context, AttributeSet attrs) {
         super(context, attrs);
 
-        TypedArray a = context.obtainStyledAttributes(R.styleable.SwipeRefresh);
-        @ColorRes int colorId = a.getResourceId(R.styleable.SwipeRefresh_android_colorPrimary,
-                -1);
+        final int[] styledAttrs = {android.R.attr.colorPrimary};
+
+        TypedArray a = context.obtainStyledAttributes(styledAttrs);
+        @ColorRes int colorId = a.getResourceId(0, -1);
         if (colorId == -1) {
             Log.w(TAG, "Retrive colorPrimary colorId from theme fail, assign R.color.primary");
             colorId = R.color.primary;
diff --git a/tests/res/values/attrs.xml b/tests/res/values/attrs.xml
new file mode 100644
index 0000000..54d5828
--- /dev/null
+++ b/tests/res/values/attrs.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2019 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
+  -->
+<resources>
+
+    <declare-styleable name="ThemeColor">
+        <attr name="android:colorBackground" />
+        <attr name="android:colorPrimary" />
+        <attr name="android:colorControlNormal" />
+        <attr name="android:textColorPrimary" />
+    </declare-styleable>
+
+    <declare-styleable name="SystemWindow">
+        <attr name="android:statusBarColor" />
+        <attr name="android:navigationBarColor" />
+        <attr name="android:windowBackground" />
+        <attr name="android:windowLightStatusBar" />
+        <attr name="android:windowLightNavigationBar" />
+    </declare-styleable>
+
+</resources>
\ No newline at end of file
diff --git a/tests/unit/com/android/documentsui/ui/DarkThemeUiTest.java b/tests/unit/com/android/documentsui/ui/DarkThemeUiTest.java
index 20bcbaf..33938a2 100644
--- a/tests/unit/com/android/documentsui/ui/DarkThemeUiTest.java
+++ b/tests/unit/com/android/documentsui/ui/DarkThemeUiTest.java
@@ -23,7 +23,7 @@
 import androidx.test.filters.SmallTest;
 import androidx.test.runner.AndroidJUnit4;
 
-import com.android.documentsui.R;
+import com.android.documentsui.tests.R;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -47,14 +47,9 @@
 
     @Test
     public void themeNightModeEnable_actionBarColorShouldBeDark() {
-        assertTheme(R.styleable.ActionBarView, R.styleable.ActionBarView_android_colorBackground,
-                mTheme.getResources().getColor(R.color.app_background_color, mTheme));
-    }
-
-    @Test
-    public void themeNightModeEnable_gridItemTintColorShouldBeThemeable() {
-        assertTheme(R.styleable.GridItem, R.styleable.GridItem_gridItemTint,
-                mTheme.getResources().getColor(R.color.item_doc_grid_tint, mTheme));
+        assertTheme(R.styleable.ThemeColor, R.styleable.ThemeColor_android_colorBackground,
+                mTheme.getResources().getColor(com.android.documentsui.R.color.app_background_color,
+                        mTheme));
     }
 
     @Test
@@ -78,18 +73,20 @@
     @Test
     public void themeNightModeEnable_windowBackgroundColorShouldBeDark() {
         assertTheme(R.styleable.SystemWindow, R.styleable.SystemWindow_android_windowBackground,
-                mTheme.getResources().getColor(R.color.app_background_color, mTheme));
+                mTheme.getResources().getColor(com.android.documentsui.R.color.app_background_color,
+                        mTheme));
     }
 
     @Test
     public void themeNightModeEnable_statusBarColorShouldBeDark() {
         assertTheme(R.styleable.SystemWindow, R.styleable.SystemWindow_android_statusBarColor,
-                mTheme.getResources().getColor(R.color.app_background_color, mTheme));
+                mTheme.getResources().getColor(com.android.documentsui.R.color.app_background_color,
+                        mTheme));
     }
 
     @Test
     public void appCompatThemeNightModeEnable_colorPrimaryShouldBeThemeable() {
-        assertTheme(R.styleable.AppCompatTheme, R.styleable.AppCompatTheme_colorPrimary,
-                mTheme.getResources().getColor(R.color.primary, mTheme));
+        assertTheme(R.styleable.ThemeColor, R.styleable.ThemeColor_android_colorPrimary,
+                mTheme.getResources().getColor(com.android.documentsui.R.color.primary, mTheme));
     }
 }
\ No newline at end of file
diff --git a/tests/unit/com/android/documentsui/ui/ThemeUiTest.java b/tests/unit/com/android/documentsui/ui/ThemeUiTest.java
index 473b6fb..292ea83 100644
--- a/tests/unit/com/android/documentsui/ui/ThemeUiTest.java
+++ b/tests/unit/com/android/documentsui/ui/ThemeUiTest.java
@@ -22,7 +22,7 @@
 import androidx.test.filters.SmallTest;
 import androidx.test.runner.AndroidJUnit4;
 
-import com.android.documentsui.R;
+import com.android.documentsui.tests.R;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -44,17 +44,11 @@
 
     @Test
     public void themeNightModeDisable_actionBarColorShouldBeLight() {
-        assertTheme(R.styleable.ActionBarView, R.styleable.ActionBarView_android_colorBackground,
+        assertTheme(R.styleable.ThemeColor, R.styleable.ThemeColor_android_colorBackground,
                 Color.WHITE);
     }
 
     @Test
-    public void themeNightModeDisable_gridItemTintColorShouldBeThemeable() {
-        assertTheme(R.styleable.GridItem, R.styleable.GridItem_gridItemTint,
-                mTheme.getResources().getColor(R.color.item_doc_grid_tint, mTheme));
-    }
-
-    @Test
     public void themeNightModeDisable_windowLightNavigationBarShouldBeTrue() {
         assertTheme(R.styleable.SystemWindow,
                 R.styleable.SystemWindow_android_windowLightNavigationBar, true);
@@ -86,7 +80,7 @@
 
     @Test
     public void appCompatThemeNightModeDisable_colorPrimaryShouldBeThemeable() {
-        assertTheme(R.styleable.AppCompatTheme, R.styleable.AppCompatTheme_colorPrimary,
-                mTheme.getResources().getColor(R.color.primary, mTheme));
+        assertTheme(R.styleable.ThemeColor, R.styleable.ThemeColor_android_colorPrimary,
+                mTheme.getResources().getColor(com.android.documentsui.R.color.primary, mTheme));
     }
 }