Loading res/values/attrs.xml +0 −36 Original line number Original line Diff line number Diff line Loading @@ -15,22 +15,6 @@ --> --> <resources> <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"> <declare-styleable name="DropBadgeView"> <attr name="state_reject_drop" format="boolean"/> <attr name="state_reject_drop" format="boolean"/> <attr name="state_copy" format="boolean"/> <attr name="state_copy" format="boolean"/> Loading @@ -47,24 +31,4 @@ <attr name="state_highlighted" format="boolean"/> <attr name="state_highlighted" format="boolean"/> </declare-styleable> </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> </resources> src/com/android/documentsui/dirlist/DocumentsSwipeRefreshLayout.java +4 −3 Original line number Original line Diff line number Diff line Loading @@ -42,9 +42,10 @@ public class DocumentsSwipeRefreshLayout extends SwipeRefreshLayout { public DocumentsSwipeRefreshLayout(Context context, AttributeSet attrs) { public DocumentsSwipeRefreshLayout(Context context, AttributeSet attrs) { super(context, attrs); super(context, attrs); TypedArray a = context.obtainStyledAttributes(R.styleable.SwipeRefresh); final int[] styledAttrs = {android.R.attr.colorPrimary}; @ColorRes int colorId = a.getResourceId(R.styleable.SwipeRefresh_android_colorPrimary, -1); TypedArray a = context.obtainStyledAttributes(styledAttrs); @ColorRes int colorId = a.getResourceId(0, -1); if (colorId == -1) { if (colorId == -1) { Log.w(TAG, "Retrive colorPrimary colorId from theme fail, assign R.color.primary"); Log.w(TAG, "Retrive colorPrimary colorId from theme fail, assign R.color.primary"); colorId = R.color.primary; colorId = R.color.primary; Loading tests/res/values/attrs.xml 0 → 100644 +34 −0 Original line number Original line Diff line number Diff line <?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 tests/unit/com/android/documentsui/ui/DarkThemeUiTest.java +10 −13 Original line number Original line Diff line number Diff line Loading @@ -23,7 +23,7 @@ import androidx.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import androidx.test.runner.AndroidJUnit4; import com.android.documentsui.R; import com.android.documentsui.tests.R; import org.junit.Before; import org.junit.Before; import org.junit.Test; import org.junit.Test; Loading @@ -47,14 +47,9 @@ public class DarkThemeUiTest extends ThemeUiTestBase { @Test @Test public void themeNightModeEnable_actionBarColorShouldBeDark() { public void themeNightModeEnable_actionBarColorShouldBeDark() { assertTheme(R.styleable.ActionBarView, R.styleable.ActionBarView_android_colorBackground, assertTheme(R.styleable.ThemeColor, R.styleable.ThemeColor_android_colorBackground, 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_gridItemTintColorShouldBeThemeable() { assertTheme(R.styleable.GridItem, R.styleable.GridItem_gridItemTint, mTheme.getResources().getColor(R.color.item_doc_grid_tint, mTheme)); } } @Test @Test Loading @@ -78,18 +73,20 @@ public class DarkThemeUiTest extends ThemeUiTestBase { @Test @Test public void themeNightModeEnable_windowBackgroundColorShouldBeDark() { public void themeNightModeEnable_windowBackgroundColorShouldBeDark() { assertTheme(R.styleable.SystemWindow, R.styleable.SystemWindow_android_windowBackground, 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 @Test public void themeNightModeEnable_statusBarColorShouldBeDark() { public void themeNightModeEnable_statusBarColorShouldBeDark() { assertTheme(R.styleable.SystemWindow, R.styleable.SystemWindow_android_statusBarColor, 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 @Test public void appCompatThemeNightModeEnable_colorPrimaryShouldBeThemeable() { public void appCompatThemeNightModeEnable_colorPrimaryShouldBeThemeable() { assertTheme(R.styleable.AppCompatTheme, R.styleable.AppCompatTheme_colorPrimary, assertTheme(R.styleable.ThemeColor, R.styleable.ThemeColor_android_colorPrimary, mTheme.getResources().getColor(R.color.primary, mTheme)); mTheme.getResources().getColor(com.android.documentsui.R.color.primary, mTheme)); } } } } No newline at end of file tests/unit/com/android/documentsui/ui/ThemeUiTest.java +4 −10 Original line number Original line Diff line number Diff line Loading @@ -22,7 +22,7 @@ import android.graphics.Color; import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import androidx.test.runner.AndroidJUnit4; import com.android.documentsui.R; import com.android.documentsui.tests.R; import org.junit.Before; import org.junit.Before; import org.junit.Test; import org.junit.Test; Loading @@ -44,16 +44,10 @@ public class ThemeUiTest extends ThemeUiTestBase { @Test @Test public void themeNightModeDisable_actionBarColorShouldBeLight() { public void themeNightModeDisable_actionBarColorShouldBeLight() { assertTheme(R.styleable.ActionBarView, R.styleable.ActionBarView_android_colorBackground, assertTheme(R.styleable.ThemeColor, R.styleable.ThemeColor_android_colorBackground, Color.WHITE); 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 @Test public void themeNightModeDisable_windowLightNavigationBarShouldBeTrue() { public void themeNightModeDisable_windowLightNavigationBarShouldBeTrue() { assertTheme(R.styleable.SystemWindow, assertTheme(R.styleable.SystemWindow, Loading Loading @@ -86,7 +80,7 @@ public class ThemeUiTest extends ThemeUiTestBase { @Test @Test public void appCompatThemeNightModeDisable_colorPrimaryShouldBeThemeable() { public void appCompatThemeNightModeDisable_colorPrimaryShouldBeThemeable() { assertTheme(R.styleable.AppCompatTheme, R.styleable.AppCompatTheme_colorPrimary, assertTheme(R.styleable.ThemeColor, R.styleable.ThemeColor_android_colorPrimary, mTheme.getResources().getColor(R.color.primary, mTheme)); mTheme.getResources().getColor(com.android.documentsui.R.color.primary, mTheme)); } } } } Loading
res/values/attrs.xml +0 −36 Original line number Original line Diff line number Diff line Loading @@ -15,22 +15,6 @@ --> --> <resources> <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"> <declare-styleable name="DropBadgeView"> <attr name="state_reject_drop" format="boolean"/> <attr name="state_reject_drop" format="boolean"/> <attr name="state_copy" format="boolean"/> <attr name="state_copy" format="boolean"/> Loading @@ -47,24 +31,4 @@ <attr name="state_highlighted" format="boolean"/> <attr name="state_highlighted" format="boolean"/> </declare-styleable> </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> </resources>
src/com/android/documentsui/dirlist/DocumentsSwipeRefreshLayout.java +4 −3 Original line number Original line Diff line number Diff line Loading @@ -42,9 +42,10 @@ public class DocumentsSwipeRefreshLayout extends SwipeRefreshLayout { public DocumentsSwipeRefreshLayout(Context context, AttributeSet attrs) { public DocumentsSwipeRefreshLayout(Context context, AttributeSet attrs) { super(context, attrs); super(context, attrs); TypedArray a = context.obtainStyledAttributes(R.styleable.SwipeRefresh); final int[] styledAttrs = {android.R.attr.colorPrimary}; @ColorRes int colorId = a.getResourceId(R.styleable.SwipeRefresh_android_colorPrimary, -1); TypedArray a = context.obtainStyledAttributes(styledAttrs); @ColorRes int colorId = a.getResourceId(0, -1); if (colorId == -1) { if (colorId == -1) { Log.w(TAG, "Retrive colorPrimary colorId from theme fail, assign R.color.primary"); Log.w(TAG, "Retrive colorPrimary colorId from theme fail, assign R.color.primary"); colorId = R.color.primary; colorId = R.color.primary; Loading
tests/res/values/attrs.xml 0 → 100644 +34 −0 Original line number Original line Diff line number Diff line <?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
tests/unit/com/android/documentsui/ui/DarkThemeUiTest.java +10 −13 Original line number Original line Diff line number Diff line Loading @@ -23,7 +23,7 @@ import androidx.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import androidx.test.runner.AndroidJUnit4; import com.android.documentsui.R; import com.android.documentsui.tests.R; import org.junit.Before; import org.junit.Before; import org.junit.Test; import org.junit.Test; Loading @@ -47,14 +47,9 @@ public class DarkThemeUiTest extends ThemeUiTestBase { @Test @Test public void themeNightModeEnable_actionBarColorShouldBeDark() { public void themeNightModeEnable_actionBarColorShouldBeDark() { assertTheme(R.styleable.ActionBarView, R.styleable.ActionBarView_android_colorBackground, assertTheme(R.styleable.ThemeColor, R.styleable.ThemeColor_android_colorBackground, 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_gridItemTintColorShouldBeThemeable() { assertTheme(R.styleable.GridItem, R.styleable.GridItem_gridItemTint, mTheme.getResources().getColor(R.color.item_doc_grid_tint, mTheme)); } } @Test @Test Loading @@ -78,18 +73,20 @@ public class DarkThemeUiTest extends ThemeUiTestBase { @Test @Test public void themeNightModeEnable_windowBackgroundColorShouldBeDark() { public void themeNightModeEnable_windowBackgroundColorShouldBeDark() { assertTheme(R.styleable.SystemWindow, R.styleable.SystemWindow_android_windowBackground, 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 @Test public void themeNightModeEnable_statusBarColorShouldBeDark() { public void themeNightModeEnable_statusBarColorShouldBeDark() { assertTheme(R.styleable.SystemWindow, R.styleable.SystemWindow_android_statusBarColor, 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 @Test public void appCompatThemeNightModeEnable_colorPrimaryShouldBeThemeable() { public void appCompatThemeNightModeEnable_colorPrimaryShouldBeThemeable() { assertTheme(R.styleable.AppCompatTheme, R.styleable.AppCompatTheme_colorPrimary, assertTheme(R.styleable.ThemeColor, R.styleable.ThemeColor_android_colorPrimary, mTheme.getResources().getColor(R.color.primary, mTheme)); mTheme.getResources().getColor(com.android.documentsui.R.color.primary, mTheme)); } } } } No newline at end of file
tests/unit/com/android/documentsui/ui/ThemeUiTest.java +4 −10 Original line number Original line Diff line number Diff line Loading @@ -22,7 +22,7 @@ import android.graphics.Color; import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import androidx.test.runner.AndroidJUnit4; import com.android.documentsui.R; import com.android.documentsui.tests.R; import org.junit.Before; import org.junit.Before; import org.junit.Test; import org.junit.Test; Loading @@ -44,16 +44,10 @@ public class ThemeUiTest extends ThemeUiTestBase { @Test @Test public void themeNightModeDisable_actionBarColorShouldBeLight() { public void themeNightModeDisable_actionBarColorShouldBeLight() { assertTheme(R.styleable.ActionBarView, R.styleable.ActionBarView_android_colorBackground, assertTheme(R.styleable.ThemeColor, R.styleable.ThemeColor_android_colorBackground, Color.WHITE); 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 @Test public void themeNightModeDisable_windowLightNavigationBarShouldBeTrue() { public void themeNightModeDisable_windowLightNavigationBarShouldBeTrue() { assertTheme(R.styleable.SystemWindow, assertTheme(R.styleable.SystemWindow, Loading Loading @@ -86,7 +80,7 @@ public class ThemeUiTest extends ThemeUiTestBase { @Test @Test public void appCompatThemeNightModeDisable_colorPrimaryShouldBeThemeable() { public void appCompatThemeNightModeDisable_colorPrimaryShouldBeThemeable() { assertTheme(R.styleable.AppCompatTheme, R.styleable.AppCompatTheme_colorPrimary, assertTheme(R.styleable.ThemeColor, R.styleable.ThemeColor_android_colorPrimary, mTheme.getResources().getColor(R.color.primary, mTheme)); mTheme.getResources().getColor(com.android.documentsui.R.color.primary, mTheme)); } } } }