diff options
-rw-r--r-- | library/Android.mk | 4 | ||||
-rw-r--r-- | library/main/res/values/attrs.xml | 1 | ||||
-rw-r--r-- | library/main/src/com/android/setupwizardlib/GlifLayout.java | 11 | ||||
-rw-r--r-- | library/test/robotest/src/com/android/setupwizardlib/GlifLayoutTest.java | 27 |
4 files changed, 39 insertions, 4 deletions
diff --git a/library/Android.mk b/library/Android.mk index 26f5e1f..030733e 100644 --- a/library/Android.mk +++ b/library/Android.mk @@ -43,8 +43,10 @@ LOCAL_SRC_FILES := $(call all-java-files-under, main/src gingerbread/src recycle ifdef LOCAL_USE_AAPT2 +LOCAL_JAVA_LIBRARIES := \ + android-support-annotations + LOCAL_SHARED_ANDROID_LIBRARIES := \ - android-support-annotations \ android-support-compat \ android-support-core-ui \ android-support-v7-appcompat \ diff --git a/library/main/res/values/attrs.xml b/library/main/res/values/attrs.xml index 36d5fb7..d378bb0 100644 --- a/library/main/res/values/attrs.xml +++ b/library/main/res/values/attrs.xml @@ -102,6 +102,7 @@ <attr name="suwBackgroundBaseColor" format="color" /> <attr name="suwColorPrimary" /> <attr name="suwFooter" format="reference" /> + <attr name="suwLayoutFullscreen" format="boolean" /> </declare-styleable> <declare-styleable name="SuwStatusBarBackgroundLayout"> diff --git a/library/main/src/com/android/setupwizardlib/GlifLayout.java b/library/main/src/com/android/setupwizardlib/GlifLayout.java index f4d52a5..dd0963b 100644 --- a/library/main/src/com/android/setupwizardlib/GlifLayout.java +++ b/library/main/src/com/android/setupwizardlib/GlifLayout.java @@ -77,6 +77,8 @@ public class GlifLayout extends TemplateLayout { @Nullable private ColorStateList mBackgroundBaseColor; + private boolean mLayoutFullscreen = true; + public GlifLayout(Context context) { this(context, 0, 0); } @@ -139,7 +141,13 @@ public class GlifLayout extends TemplateLayout { inflateFooter(footer); } + mLayoutFullscreen = a.getBoolean(R.styleable.SuwGlifLayout_suwLayoutFullscreen, true); + a.recycle(); + + if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP && mLayoutFullscreen) { + setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); + } } @Override @@ -280,9 +288,6 @@ public class GlifLayout extends TemplateLayout { patternBg.setBackgroundDrawable(background); } } - if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { - setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); - } } public boolean isProgressBarShown() { diff --git a/library/test/robotest/src/com/android/setupwizardlib/GlifLayoutTest.java b/library/test/robotest/src/com/android/setupwizardlib/GlifLayoutTest.java index d46409d..967a52e 100644 --- a/library/test/robotest/src/com/android/setupwizardlib/GlifLayoutTest.java +++ b/library/test/robotest/src/com/android/setupwizardlib/GlifLayoutTest.java @@ -32,6 +32,7 @@ import android.graphics.Color; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.os.Build; +import android.os.Build.VERSION_CODES; import android.support.annotation.IdRes; import android.view.ContextThemeWrapper; import android.view.View; @@ -266,6 +267,32 @@ public class GlifLayoutTest { assertNotNull(layout.findViewById(android.R.id.text1)); } + @Config(sdk = { VERSION_CODES.M, Config.NEWEST_SDK }) + @Test + public void createFromXml_shouldSetLayoutFullscreen_whenLayoutFullscreenIsNotSet() { + GlifLayout layout = new GlifLayout( + mContext, + Robolectric.buildAttributeSet() + .build()); + + assertEquals( + View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN, + layout.getSystemUiVisibility() & View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); + } + + @Test + public void createFromXml_shouldNotSetLayoutFullscreen_whenLayoutFullscreenIsFalse() { + GlifLayout layout = new GlifLayout( + mContext, + Robolectric.buildAttributeSet() + .addAttribute(R.attr.suwLayoutFullscreen, "false") + .build()); + + assertEquals( + 0, + layout.getSystemUiVisibility() & View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); + } + private Drawable getPhoneBackground(GlifLayout layout) { final StatusBarBackgroundLayout patternBg = (StatusBarBackgroundLayout) layout.findManagedViewById(R.id.suw_pattern_bg); |