diff options
-rw-r--r-- | library/gingerbread/res/values-v21/styles.xml | 27 | ||||
-rw-r--r-- | library/gingerbread/res/values/styles.xml | 7 | ||||
-rw-r--r-- | library/main/res/values-v21/styles.xml | 4 | ||||
-rw-r--r-- | library/main/res/values/styles.xml | 5 | ||||
-rw-r--r-- | library/platform/res/values-v27/styles.xml | 7 | ||||
-rw-r--r-- | library/test/robotest/src/com/android/setupwizardlib/util/GlifStyleTest.java | 33 |
6 files changed, 62 insertions, 21 deletions
diff --git a/library/gingerbread/res/values-v21/styles.xml b/library/gingerbread/res/values-v21/styles.xml new file mode 100644 index 0000000..3c0c254 --- /dev/null +++ b/library/gingerbread/res/values-v21/styles.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2018 Google Inc. + + 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 xmlns:tools="http://schemas.android.com/tools"> + + <!-- Button styles --> + + <style name="SuwGlifButton.Tertiary" parent="SuwGlifButton.BaseTertiary"> + <item name="android:fontFamily">sans-serif-medium</item> + <item name="textAllCaps" tools:targetApi="ice_cream_sandwich">false</item> + </style> + +</resources> diff --git a/library/gingerbread/res/values/styles.xml b/library/gingerbread/res/values/styles.xml index 956b6cd..d12f802 100644 --- a/library/gingerbread/res/values/styles.xml +++ b/library/gingerbread/res/values/styles.xml @@ -262,6 +262,13 @@ <item name="colorControlHighlight">@color/suw_flat_button_highlight</item> </style> + <!-- Ignore UnusedResources: used by clients --> + <style name="SuwGlifButton.Tertiary" + parent="SuwGlifButton.BaseTertiary" + tools:ignore="UnusedResources"> + <item name="textAllCaps" tools:targetApi="ice_cream_sandwich">false</item> + </style> + <!-- Card layout (for tablets) --> <style name="TextAppearance.SuwCardTitle" parent="@style/TextAppearance.AppCompat.Display1"> diff --git a/library/main/res/values-v21/styles.xml b/library/main/res/values-v21/styles.xml index d2c27f6..9c69ef1 100644 --- a/library/main/res/values-v21/styles.xml +++ b/library/main/res/values-v21/styles.xml @@ -38,10 +38,6 @@ <!-- Button styles --> - <style name="SuwGlifButton.Tertiary" parent="SuwGlifButton.BaseTertiary"> - <item name="android:fontFamily">sans-serif-medium</item> - </style> - <style name="SuwBase.ProgressBarLarge" parent="@android:style/Widget.Material.ProgressBar.Large" /> <style name="SuwFourColorIndeterminateProgressBar" parent="SuwBase.ProgressBarLarge"> diff --git a/library/main/res/values/styles.xml b/library/main/res/values/styles.xml index fa2a080..2a84d65 100644 --- a/library/main/res/values/styles.xml +++ b/library/main/res/values/styles.xml @@ -204,11 +204,6 @@ <item name="android:textAllCaps" tools:targetApi="ice_cream_sandwich">false</item> </style> - <!-- Ignore UnusedResources: used by clients --> - <style name="SuwGlifButton.Tertiary" - parent="SuwGlifButton.BaseTertiary" - tools:ignore="UnusedResources" /> - <!-- The start and end paddings are asymmetric because start buttons are borderless buttons which aligns the text label. --> <style name="SuwGlifButtonBar"> diff --git a/library/platform/res/values-v27/styles.xml b/library/platform/res/values-v27/styles.xml index 4739e24..202741c 100644 --- a/library/platform/res/values-v27/styles.xml +++ b/library/platform/res/values-v27/styles.xml @@ -218,4 +218,11 @@ <item name="android:colorControlHighlight">@color/suw_flat_button_highlight</item> </style> + <!-- Ignore UnusedResources: used by clients --> + <style name="SuwGlifButton.Tertiary" + parent="SuwGlifButton.BaseTertiary" + tools:ignore="UnusedResources"> + <item name="android:fontFamily">sans-serif-medium</item> + </style> + </resources> diff --git a/library/test/robotest/src/com/android/setupwizardlib/util/GlifStyleTest.java b/library/test/robotest/src/com/android/setupwizardlib/util/GlifStyleTest.java index 7321915..195fc9b 100644 --- a/library/test/robotest/src/com/android/setupwizardlib/util/GlifStyleTest.java +++ b/library/test/robotest/src/com/android/setupwizardlib/util/GlifStyleTest.java @@ -28,6 +28,7 @@ import android.content.Context; import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; import android.os.Bundle; +import android.util.AttributeSet; import android.view.ContextThemeWrapper; import android.widget.Button; import android.widget.ProgressBar; @@ -37,29 +38,21 @@ import androidx.annotation.Nullable; import com.android.setupwizardlib.R; import com.android.setupwizardlib.robolectric.SuwLibRobolectricTestRunner; -import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.Robolectric; import org.robolectric.annotation.Config; +import org.robolectric.util.ReflectionHelpers; +import org.robolectric.util.ReflectionHelpers.ClassParameter; @RunWith(SuwLibRobolectricTestRunner.class) @Config(sdk = {Config.OLDEST_SDK, Config.NEWEST_SDK}) public class GlifStyleTest { - private Context mContext; - - @Before - public void setUp() { - mContext = new ContextThemeWrapper(application, R.style.SuwThemeGlif_Light); - } - - @Ignore("b/78472674") @Test public void testSuwGlifButtonTertiary() { - Button button = new Button( - mContext, + Button button = createButton( + new ContextThemeWrapper(application, R.style.SuwThemeGlif_Light), Robolectric.buildAttributeSet() .setStyleAttribute("@style/SuwGlifButton.Tertiary") .build()); @@ -89,6 +82,22 @@ public class GlifStyleTest { activity.findViewById(R.id.suw_large_progress_bar) instanceof ProgressBar); } + private Button createButton(Context context, AttributeSet attrs) { + Class<? extends Button> buttonClass; + try { + // Use AppCompatButton in builds that have them (i.e. gingerbreadCompat) + // noinspection unchecked + buttonClass = (Class<? extends Button>) + Class.forName("androidx.appcompat.widget.AppCompatButton"); + } catch (ClassNotFoundException e) { + buttonClass = Button.class; + } + return ReflectionHelpers.callConstructor( + buttonClass, + ClassParameter.from(Context.class, context), + ClassParameter.from(AttributeSet.class, attrs)); + } + private static class GlifThemeActivity extends Activity { @Override |