[SuwLib] Turn on fatal lint

Fix (or suppress) lint warnings and make it fatal again in the build
process.
Additionally, warnings are treated as errors now. If there are
warnings that are not applicable, add @SuppressLint or tools:ignore
to suppress the warning, so code reviewers can be aware of the lint
issue too.

Test: ./gradlew lint
Change-Id: I63c83ff1b95a0817dc2ac777adce0fa9f9ebd45a
This commit is contained in:
Maurice Lam 2016-11-23 11:37:38 -08:00
parent e57bdc10c8
commit 63cdc5ccb7
28 changed files with 157 additions and 69 deletions

View File

@ -16,12 +16,13 @@
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
xmlns:tools="http://schemas.android.com/tools" android:shape="rectangle">
<corners
android:topLeftRadius="@dimen/suw_card_corner_radius"
android:topRightRadius="@dimen/suw_card_corner_radius" />
<solid android:color="@color/background_material_dark" />
<!-- Ignore PrivateResource: This should be fixed -->
<solid android:color="@color/background_material_dark" tools:ignore="PrivateResource" />
</shape>

View File

@ -16,12 +16,13 @@
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
xmlns:tools="http://schemas.android.com/tools" android:shape="rectangle">
<corners
android:topLeftRadius="@dimen/suw_card_corner_radius"
android:topRightRadius="@dimen/suw_card_corner_radius" />
<solid android:color="@color/background_material_light" />
<!-- Ignore PrivateResource: This should be fixed -->
<solid android:color="@color/background_material_light" tools:ignore="PrivateResource" />
</shape>

View File

@ -15,10 +15,12 @@
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<selector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<item android:state_pressed="true">
<color android:color="@color/ripple_material_dark" />
<!-- Ignore PrivateResource: This should be fixed -->
<color android:color="@color/ripple_material_dark" tools:ignore="PrivateResource" />
</item>
<item>

View File

@ -15,10 +15,13 @@
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<selector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<item android:state_pressed="true">
<color android:color="@color/ripple_material_light" />
<!-- Ignore PrivateResource: This should be fixed -->
<color android:color="@color/ripple_material_light" tools:ignore="PrivateResource" />
</item>
<item>

View File

@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import android.annotation.SuppressLint;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
@ -96,6 +97,7 @@ public class RichTextViewTest {
}
@SuppressLint("SetTextI18n") // It's OK. This is just a test.
@Test
public void testTextContainingNoLinksAreNotFocusable() {
RichTextView textView = new RichTextView(InstrumentationRegistry.getContext());
@ -108,6 +110,7 @@ public class RichTextViewTest {
// Based on the text contents of the text view, the "focusable" property of the element
// should also be automatically changed.
@SuppressLint("SetTextI18n") // It's OK. This is just a test.
@Test
public void testRichTxtViewFocusChangesWithTextChange() {
RichTextView textView = new RichTextView(InstrumentationRegistry.getContext());

View File

@ -16,9 +16,12 @@
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:orientation="vertical"
tools:ignore="UnusedResources">
<!-- Ignore UnusedResources: can be used by clients -->
<FrameLayout
android:id="@+id/suw_layout_content"

View File

@ -15,12 +15,17 @@
limitations under the License.
-->
<resources>
<resources xmlns:tools="http://schemas.android.com/tools">
<item name="suw_preference_recycler_view" type="layout">@layout/suw_preference_recycler_view_header</item>
<item name="suw_preference_template" type="layout">@layout/suw_preference_template_header</item>
<item name="suw_recycler_template" type="layout">@layout/suw_recycler_template_header</item>
<item name="suw_recycler_template_short" type="layout">@layout/suw_recycler_template_header_collapsed</item>
<item
name="suw_recycler_template_short"
type="layout"
tools:ignore="UnusedResources">@layout/suw_recycler_template_header_collapsed</item>
<!-- Ignore UnusedResources: can be used by clients -->
<item name="suw_glif_preference_template" type="layout">@layout/suw_glif_blank_template_compact</item>
<item name="suw_glif_recycler_template" type="layout">@layout/suw_glif_recycler_template_compact</item>

View File

@ -16,6 +16,7 @@
package com.android.setupwizardlib.view;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Build;
@ -116,6 +117,8 @@ public class HeaderRecyclerView extends RecyclerView {
setHasStableIds(mAdapter.hasStableIds());
}
@SuppressLint("InlinedApi") // MATCH_PARENT is the same constant as FILL_PARENT available
// on earlier versions.
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
/*

View File

@ -15,11 +15,6 @@
limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.setupwizardlib">
<uses-sdk
android:minSdkVersion="1"
android:targetSdkVersion="21" />
<manifest package="com.android.setupwizardlib">
</manifest>

View File

@ -19,8 +19,11 @@
setXFraction(float) and getXFraction methods implemented. Also make sure these 2 methods are
not stripped out by proguard. -->
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:duration="@integer/suwTransitionDuration"
android:interpolator="@android:interpolator/decelerate_quad"
android:propertyName="xFraction"
android:valueFrom="1.0"
android:valueTo="0" />
android:valueTo="0"
tools:ignore="UnusedResources" />
<!-- Ignore UnusedResources: can be used by clients -->

View File

@ -19,8 +19,11 @@
setXFraction(float) and getXFraction methods implemented. Also make sure these 2 methods are
not stripped out by proguard. -->
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:duration="@integer/suwTransitionDuration"
android:interpolator="@android:interpolator/decelerate_quad"
android:propertyName="xFraction"
android:valueFrom="0"
android:valueTo="-1.0" />
android:valueTo="-1.0"
tools:ignore="UnusedResources" />
<!-- Ignore UnusedResources: can be used by clients -->

View File

@ -19,8 +19,11 @@
setXFraction(float) and getXFraction methods implemented. Also make sure these 2 methods are
not stripped out by proguard. -->
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:duration="@integer/suwTransitionDuration"
android:interpolator="@android:interpolator/decelerate_quad"
android:propertyName="xFraction"
android:valueFrom="-1.0"
android:valueTo="0" />
android:valueTo="0"
tools:ignore="UnusedResources" />
<!-- Ignore UnusedResources: can be used by clients -->

View File

@ -19,8 +19,11 @@
setXFraction(float) and getXFraction methods implemented. Also make sure these 2 methods are
not stripped out by proguard. -->
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:duration="@integer/suwTransitionDuration"
android:interpolator="@android:interpolator/decelerate_quad"
android:propertyName="xFraction"
android:valueFrom="0"
android:valueTo="1.0" />
android:valueTo="1.0"
tools:ignore="UnusedResources" />
<!-- Ignore UnusedResources: can be used by clients -->

View File

@ -15,8 +15,11 @@
limitations under the License.
-->
<!-- Ignore UnusedResources: This is only used in platform variant, move to platform directory -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
xmlns:tools="http://schemas.android.com/tools"
android:shape="rectangle"
tools:ignore="UnusedResources">
<corners
android:topLeftRadius="@dimen/suw_card_corner_radius"

View File

@ -20,7 +20,9 @@
style="@style/SuwItemContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:orientation="horizontal"
tools:ignore="DisableBaselineAlignment">
<!-- TODO: Investigate if baseline alignment can be disabled -->
<FrameLayout
android:id="@+id/suw_items_icon_container"

View File

@ -20,7 +20,10 @@
style="?attr/suwItemDescriptionStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:orientation="horizontal"
tools:ignore="DisableBaselineAlignment,UnusedResources">
<!-- Ignore UnusedResources: can be used by clients -->
<!-- TODO: Investigate if baseline alignment can be disabled -->
<FrameLayout
android:id="@+id/suw_items_icon_container"

View File

@ -20,7 +20,10 @@
style="@style/SuwItemContainer.Verbose"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:orientation="horizontal"
tools:ignore="DisableBaselineAlignment,UnusedResources">
<!-- Ignore UnusedResources: can be used by clients -->
<!-- TODO: Investigate if baseline alignment can be disabled -->
<FrameLayout
android:id="@+id/suw_items_icon_container"
@ -32,7 +35,8 @@
<ImageView
android:id="@+id/suw_items_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:contentDescription="@null" />
</FrameLayout>

View File

@ -15,7 +15,8 @@
limitations under the License.
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<com.android.setupwizardlib.view.NavigationBarButton
android:id="@+id/suw_navbar_back"
@ -24,7 +25,10 @@
android:layout_height="match_parent"
android:contentDescription="@string/suw_back_button_label"
android:drawableLeft="@drawable/suw_navbar_ic_back"
android:drawableStart="@drawable/suw_navbar_ic_back" />
android:drawableStart="@drawable/suw_navbar_ic_back"
tools:ignore="RtlHardcoded" />
<!-- Ignore RtlHardcoded: drawableLeft is needed for compatibility.
Will be overridden by drawableStart on versions that support it. -->
<View
android:layout_width="0dp"
@ -41,7 +45,10 @@
android:drawableEnd="@drawable/suw_navbar_ic_more"
android:drawableRight="@drawable/suw_navbar_ic_more"
android:gravity="end|center_vertical"
android:visibility="gone" />
android:visibility="gone"
tools:ignore="RtlHardcoded" />
<!-- Ignore RtlHardcoded: drawableRight is needed for compatibility.
Will be overridden by drawableEnd on versions that support it. -->
<com.android.setupwizardlib.view.NavigationBarButton
android:id="@+id/suw_navbar_next"
@ -51,6 +58,9 @@
android:drawableEnd="@drawable/suw_navbar_ic_next"
android:drawableRight="@drawable/suw_navbar_ic_next"
android:gravity="end|center_vertical"
android:text="@string/suw_next_button_label" />
android:text="@string/suw_next_button_label"
tools:ignore="RtlHardcoded" />
<!-- Ignore RtlHardcoded: drawableRight is needed for compatibility.
Will be overridden by drawableEnd on versions that support it. -->
</merge>

View File

@ -56,7 +56,9 @@
android:id="@+id/suw_layout_content"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
android:layout_weight="1"
tools:ignore="NestedWeights" />
<!-- Ignore NestedWeights: Needed to fill the screen's height with the layout content -->
</LinearLayout>

View File

@ -15,7 +15,7 @@
limitations under the License.
-->
<resources>
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- General -->
<dimen name="suw_layout_margin_sides">40dp</dimen>
@ -28,7 +28,6 @@
<dimen name="suw_check_box_margin_start">1dp</dimen>
<dimen name="suw_check_box_margin_top">24dp</dimen>
<dimen name="suw_check_box_padding_start">15dp</dimen>
<dimen name="suw_check_box_text_size">16sp</dimen>
<dimen name="suw_content_frame_padding_top">0dp</dimen>
<dimen name="suw_content_frame_padding_bottom">16dp</dimen>
@ -60,8 +59,6 @@
<dimen name="suw_card_title_padding_top">16dp</dimen>
<dimen name="suw_card_title_padding_bottom">28dp</dimen>
<dimen name="suw_tablet_illustration_height">256dp</dimen>
<!-- Decor view (illustration or the header without illustration) -->
<dimen name="suw_decor_padding_top">0dp</dimen>
@ -95,11 +92,15 @@
<dimen name="suw_items_padding_vertical">15dp</dimen>
<dimen name="suw_items_verbose_padding_vertical">20dp</dimen>
<dimen name="suw_items_icon_divider_inset">88dp</dimen>
<dimen name="suw_items_text_divider_inset">40dp</dimen>
<!-- Ignore UnusedResources: can be used by clients -->
<dimen name="suw_items_icon_divider_inset" tools:ignore="UnusedResources">88dp</dimen>
<!-- Ignore UnusedResources: can be used by clients -->
<dimen name="suw_items_text_divider_inset" tools:ignore="UnusedResources">40dp</dimen>
<dimen name="suw_items_glif_icon_divider_inset">72dp</dimen>
<dimen name="suw_items_glif_text_divider_inset">24dp</dimen>
<!-- Ignore UnusedResources: can be used by clients -->
<dimen name="suw_items_glif_icon_divider_inset" tools:ignore="UnusedResources">72dp</dimen>
<!-- Ignore UnusedResources: can be used by clients -->
<dimen name="suw_items_glif_text_divider_inset" tools:ignore="UnusedResources">24dp</dimen>
<!-- Extra padding in the bottom to compensate for difference between descent and (top) internal leading -->
<dimen name="suw_items_padding_bottom_extra">1dp</dimen>
@ -107,7 +108,8 @@
<dimen name="suw_items_preferred_height">56dp</dimen>
<!-- Navigation bar -->
<dimen name="suw_navbar_button_drawable_padding">6dp</dimen>
<!-- TODO: Move this dimen to eclair-mr1, or see if it should be in platform style as well -->
<dimen name="suw_navbar_button_drawable_padding" tools:ignore="UnusedResources">6dp</dimen>
<dimen name="suw_navbar_button_padding_sides">10dp</dimen>
<dimen name="suw_navbar_height">56dp</dimen>
<dimen name="suw_navbar_ic_intrinsic_size">24dp</dimen>
@ -119,7 +121,9 @@
<dimen name="suw_progress_bar_margin_vertical">-7dp</dimen>
<dimen name="suw_glif_progress_bar_margin_vertical">7dp</dimen>
<dimen name="suw_switch_padding_start">16dp</dimen>
<dimen name="suw_switch_padding_end">0dp</dimen>
<!-- Ignore UnusedResources: This should be moved to eclar-mr1 as it's only used there -->
<dimen name="suw_switch_padding_start" tools:ignore="UnusedResources">16dp</dimen>
<!-- Ignore UnusedResources: This should be moved to eclar-mr1 as it's only used there -->
<dimen name="suw_switch_padding_end" tools:ignore="UnusedResources">0dp</dimen>
</resources>

View File

@ -15,18 +15,35 @@
limitations under the License.
-->
<resources>
<resources xmlns:tools="http://schemas.android.com/tools">
<item name="suw_template" type="layout">@layout/suw_template_header</item>
<item name="suw_template_short" type="layout">@layout/suw_template_header_collapsed</item>
<!-- Ignore UnusedResources: can be used by clients -->
<item name="suw_template_short" type="layout" tools:ignore="UnusedResources">
@layout/suw_template_header_collapsed</item>
<item name="suw_list_template" type="layout">@layout/suw_list_template_header</item>
<item name="suw_list_template_short" type="layout">@layout/suw_list_template_header_collapsed</item>
<item name="suw_no_scroll_template" type="layout">@layout/suw_no_scroll_template_header</item>
<item name="suw_no_scroll_template_short" type="layout">@layout/suw_no_scroll_template_header_collapsed</item>
<!-- Ignore UnusedResources: can be used by clients -->
<item name="suw_list_template_short" type="layout" tools:ignore="UnusedResources">
@layout/suw_list_template_header_collapsed</item>
<!-- Ignore UnusedResources: can be used by clients -->
<item name="suw_no_scroll_template" type="layout" tools:ignore="UnusedResources">
@layout/suw_no_scroll_template_header</item>
<!-- Ignore UnusedResources: can be used by clients -->
<item name="suw_no_scroll_template_short" type="layout" tools:ignore="UnusedResources">
@layout/suw_no_scroll_template_header_collapsed</item>
<item name="suw_glif_template" type="layout">@layout/suw_glif_template_compact</item>
<item name="suw_glif_list_template" type="layout">@layout/suw_glif_list_template_compact</item>
<item name="suw_glif_blank_template" type="layout">@layout/suw_glif_blank_template_compact</item>
<!-- Ignore UnusedResources: can be used by clients -->
<item name="suw_glif_blank_template" type="layout" tools:ignore="UnusedResources">
@layout/suw_glif_blank_template_compact</item>
</resources>

View File

@ -28,7 +28,8 @@
<!-- Content styles -->
<style name="SuwContentFrame">
<!-- Ignore UnusedResources: Used by clients -->
<style name="SuwContentFrame" tools:ignore="UnusedResources">
<item name="android:clipToPadding">false</item>
<item name="android:paddingTop">@dimen/suw_content_frame_padding_top</item>
<item name="android:paddingLeft">?attr/suwMarginSides</item>
@ -36,7 +37,8 @@
<item name="android:paddingBottom">@dimen/suw_content_frame_padding_bottom</item>
</style>
<style name="SuwDescription">
<!-- Ignore UnusedResources: Used by clients -->
<style name="SuwDescription" tools:ignore="UnusedResources">
<!-- Before Honeycomb, layout_gravity is needed for FrameLayout to apply the margins -->
<item name="android:layout_gravity">top</item>
<item name="android:layout_marginBottom">@dimen/suw_description_margin_bottom</item>
@ -45,7 +47,8 @@
<item name="android:textAppearance">@style/TextAppearance.SuwDescription</item>
</style>
<style name="SuwDescription.Glif" parent="SuwDescription">
<!-- Ignore UnusedResources: Used by clients -->
<style name="SuwDescription.Glif" parent="SuwDescription" tools:ignore="UnusedResources">
<item name="android:layout_marginTop">@dimen/suw_description_glif_margin_top</item>
</style>
@ -57,7 +60,8 @@
<item name="android:textColor">?android:attr/textColorSecondary</item>
</style>
<style name="SuwRadioButton">
<!-- Ignore UnusedResources: Used by clients -->
<style name="SuwRadioButton" tools:ignore="UnusedResources">
<item name="android:layout_marginBottom">@dimen/suw_radio_button_margin_bottom</item>
<item name="android:layout_marginLeft">@dimen/suw_radio_button_margin_start</item>
<item name="android:layout_marginStart" tools:ignore="NewApi">@dimen/suw_radio_button_margin_start</item>
@ -68,7 +72,8 @@
<item name="android:textAppearance">@style/TextAppearance.SuwDescription</item>
</style>
<style name="SuwCheckBox">
<!-- Ignore UnusedResources: used by clients -->
<style name="SuwCheckBox" tools:ignore="UnusedResources">
<item name="android:layout_marginBottom">@dimen/suw_check_box_margin_bottom</item>
<item name="android:layout_marginLeft">@dimen/suw_check_box_margin_start</item>
<item name="android:layout_marginStart" tools:ignore="NewApi">@dimen/suw_check_box_margin_start</item>
@ -79,7 +84,8 @@
<item name="android:textAppearance">@style/TextAppearance.SuwDescription</item>
</style>
<style name="SuwCheckBox.Multiline" parent="SuwCheckBox">
<!-- Ignore UnusedResources: used by clients -->
<style name="SuwCheckBox.Multiline" parent="SuwCheckBox" tools:ignore="UnusedResources">
<item name="android:gravity">top</item>
</style>
@ -103,7 +109,7 @@
<style name="SuwGlifCardContainer">
<item name="android:background">?android:attr/colorBackground</item>
<item name="android:elevation" tools:ignore="NewApi">5dp</item>
<item name="android:elevation" tools:ignore="NewApi">@dimen/suw_glif_card_elevation</item>
</style>
<!-- Header layout (for phones) -->

View File

@ -16,6 +16,7 @@
package com.android.setupwizardlib;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.ColorStateList;
@ -220,6 +221,7 @@ public class GlifLayout extends TemplateLayout {
return mPrimaryColor;
}
@SuppressLint("InlinedApi") // View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN is guarded by SDK check
private void setGlifPatternColor(ColorStateList color) {
if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);

View File

@ -122,7 +122,7 @@ public class SetupWizardLayout extends TemplateLayout {
// Set the illustration aspect ratio. See Illustration.setAspectRatio(float). This will
// override suwIllustrationPaddingTop if its value is not 0.
// override suwDecorPaddingTop if its value is not 0.
float illustrationAspectRatio = a.getFloat(
R.styleable.SuwSetupWizardLayout_suwIllustrationAspectRatio, -1f);
if (illustrationAspectRatio == -1f) {

View File

@ -16,6 +16,7 @@
package com.android.setupwizardlib.util;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.InsetDrawable;
@ -31,6 +32,7 @@ public class DrawableLayoutDirectionHelper {
* Creates an {@link android.graphics.drawable.InsetDrawable} according to the layout direction
* of {@code view}.
*/
@SuppressLint("InlinedApi") // Use of View.LAYOUT_DIRECTION_RTL is guarded by version check
public static InsetDrawable createRelativeInsetDrawable(Drawable drawable,
int insetStart, int insetTop, int insetEnd, int insetBottom, View view) {
boolean isRtl = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1
@ -43,6 +45,7 @@ public class DrawableLayoutDirectionHelper {
* Creates an {@link android.graphics.drawable.InsetDrawable} according to the layout direction
* of {@code context}.
*/
@SuppressLint("InlinedApi") // Use of View.LAYOUT_DIRECTION_RTL is guarded by version check
public static InsetDrawable createRelativeInsetDrawable(Drawable drawable,
int insetStart, int insetTop, int insetEnd, int insetBottom, Context context) {
boolean isRtl = false;
@ -59,9 +62,10 @@ public class DrawableLayoutDirectionHelper {
* Creates an {@link android.graphics.drawable.InsetDrawable} according to
* {@code layoutDirection}.
*/
@SuppressLint("InlinedApi") // Given layoutDirection will not be View.LAYOUT_DIRECTION_RTL if
// SDK version doesn't support it.
public static InsetDrawable createRelativeInsetDrawable(Drawable drawable,
int insetStart, int insetTop, int insetEnd, int insetBottom, int layoutDirection) {
//noinspection AndroidLintInlinedApi
return createRelativeInsetDrawable(drawable, insetStart, insetTop, insetEnd, insetBottom,
layoutDirection == View.LAYOUT_DIRECTION_RTL);
}

View File

@ -35,11 +35,11 @@ android.sourceSets {
android.defaultConfig.testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
android.lintOptions {
// TODO: Fix lint errors and re-enable fatal lint
abortOnError false
abortOnError true
htmlReport true
textOutput 'stderr'
textReport true
warningsAsErrors true
xmlReport false
}

View File

@ -19,6 +19,7 @@ package com.android.setupwizardlib.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Color;
@ -46,6 +47,7 @@ public class DrawableLayoutDirectionHelperTest {
@Test
public void testCreateRelativeInsetDrawableLtr() {
final Drawable drawable = new ColorDrawable(Color.RED);
@SuppressLint("InlinedApi") // Testing with inlined constant is OK here
final InsetDrawable insetDrawable =
DrawableLayoutDirectionHelper.createRelativeInsetDrawable(drawable,
1 /* start */, 2 /* top */, 3 /* end */, 4 /* bottom */,
@ -63,6 +65,7 @@ public class DrawableLayoutDirectionHelperTest {
@Test
public void testCreateRelativeInsetDrawableRtl() {
final Drawable drawable = new ColorDrawable(Color.RED);
@SuppressLint("InlinedApi") // Testing with inlined constant is OK here
final InsetDrawable insetDrawable =
DrawableLayoutDirectionHelper.createRelativeInsetDrawable(drawable,
1 /* start */, 2 /* top */, 3 /* end */, 4 /* bottom */,
@ -133,6 +136,7 @@ public class DrawableLayoutDirectionHelperTest {
}
@Override
@SuppressLint("InlinedApi") // Testing with inlined constant is OK here
public int getLayoutDirection() {
return View.LAYOUT_DIRECTION_RTL;
}

View File

@ -28,6 +28,7 @@ import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Parcelable;
import android.support.annotation.IdRes;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
@ -51,6 +52,9 @@ import org.junit.runner.RunWith;
@SmallTest
public class SetupWizardLayoutTest {
@IdRes
private static final int ID1234 = 1234;
private Context mContext;
@Before
@ -179,15 +183,13 @@ public class SetupWizardLayoutTest {
@Test
public void testOnRestoreFromInstanceState() {
final SetupWizardLayout layout = new SetupWizardLayout(mContext);
// noinspection ResourceType
layout.setId(1234);
layout.setId(ID1234);
SparseArray<Parcelable> container = new SparseArray<>();
layout.saveHierarchyState(container);
final SetupWizardLayout layout2 = new SetupWizardLayout(mContext);
// noinspection ResourceType
layout2.setId(1234);
layout2.setId(ID1234);
layout2.restoreHierarchyState(container);
assertFalse("Progress bar should not be shown", layout2.isProgressBarShown());
@ -196,8 +198,7 @@ public class SetupWizardLayoutTest {
@Test
public void testOnRestoreFromInstanceStateProgressBarShown() {
final SetupWizardLayout layout = new SetupWizardLayout(mContext);
// noinspection ResourceType
layout.setId(1234);
layout.setId(ID1234);
layout.setProgressBarShown(true);
@ -205,8 +206,7 @@ public class SetupWizardLayoutTest {
layout.saveHierarchyState(container);
final SetupWizardLayout layout2 = new SetupWizardLayout(mContext);
// noinspection ResourceType
layout2.setId(1234);
layout2.setId(ID1234);
layout2.restoreHierarchyState(container);
assertTrue("Progress bar should be shown", layout2.isProgressBarShown());
@ -215,8 +215,7 @@ public class SetupWizardLayoutTest {
@Test
public void testOnRestoreFromIncompatibleInstanceState() {
final SetupWizardLayout layout = new SetupWizardLayout(mContext);
// noinspection ResourceType
layout.setId(1234);
layout.setId(ID1234);
SparseArray<Parcelable> container = new SparseArray<>();
container.put(1234, AbsSavedState.EMPTY_STATE);