diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2017-11-07 22:45:53 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-11-07 22:45:53 +0000 |
commit | e9637dfe4be78747a96fc5a9fd8f44edf7bbeb65 (patch) | |
tree | 0c737110da140892bd7f1c5924fc22cdeddf4cfe /library | |
parent | 58195c5316855122593366bd867ed51a91bd5c11 (diff) | |
parent | 00e551ce2deaeb4414fc5a387d8ea8de6a19876c (diff) | |
download | setupwizard-e9637dfe4be78747a96fc5a9fd8f44edf7bbeb65.tar.gz |
Merge "Allow GlifLayout to not request fullscreen"
Diffstat (limited to 'library')
3 files changed, 36 insertions, 3 deletions
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); |