diff --git a/library/Android.mk b/library/Android.mk index 376948b..63a64a9 100644 --- a/library/Android.mk +++ b/library/Android.mk @@ -12,6 +12,8 @@ LOCAL_RESOURCE_DIR := \ $(LOCAL_PATH)/main/res \ $(LOCAL_PATH)/platform/res LOCAL_SDK_VERSION := current +LOCAL_SHARED_ANDROID_LIBRARIES := \ + android-support-annotations LOCAL_SRC_FILES := $(call all-java-files-under, main/src platform/src) include $(BUILD_STATIC_JAVA_LIBRARY) @@ -32,6 +34,7 @@ LOCAL_RESOURCE_DIR := \ LOCAL_SDK_VERSION := current LOCAL_SRC_FILES := $(call all-java-files-under, main/src eclair-mr1/src) LOCAL_SHARED_ANDROID_LIBRARIES := \ + android-support-annotations \ android-support-v4 \ android-support-v7-appcompat @@ -54,6 +57,7 @@ LOCAL_RESOURCE_DIR := \ LOCAL_SDK_VERSION := current LOCAL_SRC_FILES := $(call all-java-files-under, main/src eclair-mr1/src full-support/src) LOCAL_SHARED_ANDROID_LIBRARIES := \ + android-support-annotations \ android-support-v4 \ android-support-v7-appcompat \ android-support-v7-recyclerview diff --git a/library/build.gradle b/library/build.gradle index e3e6720..7230aa8 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -31,6 +31,7 @@ ext { // } // deps = [ + 'support-annotations': project(':support-annotations'), 'support-appcompat-v7': project(':support-appcompat-v7'), 'support-recyclerview-v7': project(':support-recyclerview-v7') ] diff --git a/library/eclair-mr1/src/com/android/setupwizardlib/view/NavigationBarButton.java b/library/eclair-mr1/src/com/android/setupwizardlib/view/NavigationBarButton.java index 6e555a1..35e7050 100644 --- a/library/eclair-mr1/src/com/android/setupwizardlib/view/NavigationBarButton.java +++ b/library/eclair-mr1/src/com/android/setupwizardlib/view/NavigationBarButton.java @@ -22,6 +22,7 @@ import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import android.os.Build; +import android.support.annotation.NonNull; import android.util.AttributeSet; import android.widget.Button; @@ -129,7 +130,7 @@ public class NavigationBarButton extends Button { } @Override - public boolean setState(int[] stateSet) { + public boolean setState(@NonNull int[] stateSet) { boolean needsInvalidate = super.setState(stateSet); boolean needsInvalidateForState = updateState(); return needsInvalidate || needsInvalidateForState; diff --git a/library/main/src/com/android/setupwizardlib/GlifPatternDrawable.java b/library/main/src/com/android/setupwizardlib/GlifPatternDrawable.java index f258d21..5615b0d 100644 --- a/library/main/src/com/android/setupwizardlib/GlifPatternDrawable.java +++ b/library/main/src/com/android/setupwizardlib/GlifPatternDrawable.java @@ -32,6 +32,7 @@ import android.graphics.PorterDuffXfermode; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Build; +import android.support.annotation.NonNull; import com.android.setupwizardlib.annotations.VisibleForTesting; @@ -103,7 +104,7 @@ public class GlifPatternDrawable extends Drawable { } @Override - public void draw(Canvas canvas) { + public void draw(@NonNull Canvas canvas) { final Rect bounds = getBounds(); int drawableWidth = bounds.width(); int drawableHeight = bounds.height(); diff --git a/library/main/src/com/android/setupwizardlib/view/NavigationBar.java b/library/main/src/com/android/setupwizardlib/view/NavigationBar.java index 228d875..9bb123f 100644 --- a/library/main/src/com/android/setupwizardlib/view/NavigationBar.java +++ b/library/main/src/com/android/setupwizardlib/view/NavigationBar.java @@ -21,6 +21,7 @@ import android.content.Context; import android.content.res.TypedArray; import android.graphics.Color; import android.os.Build.VERSION_CODES; +import android.support.annotation.StyleableRes; import android.util.AttributeSet; import android.view.ContextThemeWrapper; import android.view.View; @@ -55,14 +56,17 @@ public class NavigationBar extends LinearLayout implements View.OnClickListener R.attr.suwNavBarTheme, android.R.attr.colorForeground, android.R.attr.colorBackground }); - int theme = attributes.getResourceId(0, 0); + @StyleableRes int suwNavBarTheme = 0; + @StyleableRes int colorForeground = 1; + @StyleableRes int colorBackground = 2; + int theme = attributes.getResourceId(suwNavBarTheme, 0); if (theme == 0) { // Compare the value of the foreground against the background color to see if current // theme is light-on-dark or dark-on-light. float[] foregroundHsv = new float[3]; float[] backgroundHsv = new float[3]; - Color.colorToHSV(attributes.getColor(1, 0), foregroundHsv); - Color.colorToHSV(attributes.getColor(2, 0), backgroundHsv); + Color.colorToHSV(attributes.getColor(colorForeground, 0), foregroundHsv); + Color.colorToHSV(attributes.getColor(colorBackground, 0), backgroundHsv); boolean isDarkBg = foregroundHsv[2] > backgroundHsv[2]; theme = isDarkBg ? R.style.SuwNavBarThemeDark : R.style.SuwNavBarThemeLight; } diff --git a/library/rules.gradle b/library/rules.gradle index f38d9f4..7c69244 100644 --- a/library/rules.gradle +++ b/library/rules.gradle @@ -25,11 +25,7 @@ android { // Platform version that will not include the compatibility libraries platform { minSdkVersion 21 - } - // Compatibility build that provides the L layout for SDK versions ICS+ - icsCompat { - minSdkVersion 14 dependencies { // Read the dependencies from the "deps" map in the extra properties. // @@ -47,6 +43,15 @@ android { // deps = ['project-name': 'com.example.group:project-name:1.0.0'] // } // + platformCompile deps['support-annotations'] + } + } + + // Compatibility build that provides the L layout for SDK versions ICS+ + icsCompat { + minSdkVersion 14 + dependencies { + icsCompatCompile deps['support-annotations'] icsCompatCompile deps['support-appcompat-v7'] } } @@ -55,6 +60,7 @@ android { eclairMr1Compat { minSdkVersion 7 dependencies { + eclairMr1CompatCompile deps['support-annotations'] eclairMr1CompatCompile deps['support-appcompat-v7'] } } @@ -64,6 +70,7 @@ android { fullSupport { minSdkVersion 7 dependencies { + fullSupportCompile deps['support-annotations'] fullSupportCompile deps['support-appcompat-v7'] fullSupportCompile deps['support-recyclerview-v7'] } diff --git a/library/standalone-rules.gradle b/library/standalone-rules.gradle index 5e1c77d..a7a73cf 100644 --- a/library/standalone-rules.gradle +++ b/library/standalone-rules.gradle @@ -26,6 +26,7 @@ ext { // } // deps = [ + 'support-annotations': 'com.android.support:support-annotations:23.4.0', 'support-appcompat-v7': 'com.android.support:appcompat-v7:23.4.0', 'support-recyclerview-v7': 'com.android.support:recyclerview-v7:23.4.0' ] diff --git a/library/test/src/com/android/setupwizardlib/test/util/MockWindow.java b/library/test/src/com/android/setupwizardlib/test/util/MockWindow.java index f7dd87e..354e394 100644 --- a/library/test/src/com/android/setupwizardlib/test/util/MockWindow.java +++ b/library/test/src/com/android/setupwizardlib/test/util/MockWindow.java @@ -5,6 +5,7 @@ import android.content.res.Configuration; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; +import android.support.annotation.NonNull; import android.view.InputQueue; import android.view.KeyEvent; import android.view.LayoutInflater; @@ -60,6 +61,7 @@ public class MockWindow extends Window { throw new UnsupportedOperationException("Unexpected method call on mock"); } + @NonNull @Override public LayoutInflater getLayoutInflater() { throw new UnsupportedOperationException("Unexpected method call on mock");