summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--library/eclair-mr1/res/drawable-hdpi/suw_navbar_ic_down_arrow_dark.pngbin0 -> 168 bytes
-rw-r--r--library/eclair-mr1/res/drawable-hdpi/suw_navbar_ic_down_arrow_light.pngbin0 -> 160 bytes
-rw-r--r--library/eclair-mr1/res/drawable-mdpi/suw_navbar_ic_down_arrow_dark.pngbin0 -> 145 bytes
-rw-r--r--library/eclair-mr1/res/drawable-mdpi/suw_navbar_ic_down_arrow_light.pngbin0 -> 140 bytes
-rw-r--r--library/eclair-mr1/res/drawable-xhdpi/suw_navbar_ic_down_arrow_dark.pngbin0 -> 201 bytes
-rw-r--r--library/eclair-mr1/res/drawable-xhdpi/suw_navbar_ic_down_arrow_light.pngbin0 -> 191 bytes
-rw-r--r--library/eclair-mr1/res/drawable-xxhdpi/suw_navbar_ic_down_arrow_dark.pngbin0 -> 268 bytes
-rw-r--r--library/eclair-mr1/res/drawable-xxhdpi/suw_navbar_ic_down_arrow_light.pngbin0 -> 257 bytes
-rw-r--r--library/eclair-mr1/res/drawable-xxxhdpi/suw_navbar_ic_down_arrow_dark.pngbin0 -> 303 bytes
-rw-r--r--library/eclair-mr1/res/drawable-xxxhdpi/suw_navbar_ic_down_arrow_light.pngbin0 -> 280 bytes
-rw-r--r--library/eclair-mr1/res/drawable/suw_navbar_ic_more_dark.xml19
-rw-r--r--library/eclair-mr1/res/drawable/suw_navbar_ic_more_light.xml19
-rw-r--r--library/eclair-mr1/res/values/styles.xml4
-rw-r--r--library/main/res/drawable-v21/suw_navbar_ic_more.xml28
-rw-r--r--library/main/res/layout/suw_navbar_view.xml11
-rw-r--r--library/main/res/values-v21/styles.xml5
-rw-r--r--library/main/res/values/attrs.xml1
-rw-r--r--library/main/res/values/colors.xml4
-rw-r--r--library/main/res/values/strings.xml7
-rw-r--r--library/main/src/com/android/setupwizardlib/SetupWizardLayout.java19
-rw-r--r--library/main/src/com/android/setupwizardlib/util/RequireScrollHelper.java86
-rw-r--r--library/main/src/com/android/setupwizardlib/util/SystemBarHelper.java3
-rw-r--r--library/main/src/com/android/setupwizardlib/view/NavigationBar.java15
-rw-r--r--library/test/src/com/android/setupwizardlib/test/RequireScrollHelperTest.java104
24 files changed, 316 insertions, 9 deletions
diff --git a/library/eclair-mr1/res/drawable-hdpi/suw_navbar_ic_down_arrow_dark.png b/library/eclair-mr1/res/drawable-hdpi/suw_navbar_ic_down_arrow_dark.png
new file mode 100644
index 0000000..bbb4fb4
--- /dev/null
+++ b/library/eclair-mr1/res/drawable-hdpi/suw_navbar_ic_down_arrow_dark.png
Binary files differ
diff --git a/library/eclair-mr1/res/drawable-hdpi/suw_navbar_ic_down_arrow_light.png b/library/eclair-mr1/res/drawable-hdpi/suw_navbar_ic_down_arrow_light.png
new file mode 100644
index 0000000..3d7f83f
--- /dev/null
+++ b/library/eclair-mr1/res/drawable-hdpi/suw_navbar_ic_down_arrow_light.png
Binary files differ
diff --git a/library/eclair-mr1/res/drawable-mdpi/suw_navbar_ic_down_arrow_dark.png b/library/eclair-mr1/res/drawable-mdpi/suw_navbar_ic_down_arrow_dark.png
new file mode 100644
index 0000000..ef8a4b6
--- /dev/null
+++ b/library/eclair-mr1/res/drawable-mdpi/suw_navbar_ic_down_arrow_dark.png
Binary files differ
diff --git a/library/eclair-mr1/res/drawable-mdpi/suw_navbar_ic_down_arrow_light.png b/library/eclair-mr1/res/drawable-mdpi/suw_navbar_ic_down_arrow_light.png
new file mode 100644
index 0000000..5b1fa06
--- /dev/null
+++ b/library/eclair-mr1/res/drawable-mdpi/suw_navbar_ic_down_arrow_light.png
Binary files differ
diff --git a/library/eclair-mr1/res/drawable-xhdpi/suw_navbar_ic_down_arrow_dark.png b/library/eclair-mr1/res/drawable-xhdpi/suw_navbar_ic_down_arrow_dark.png
new file mode 100644
index 0000000..058cebb
--- /dev/null
+++ b/library/eclair-mr1/res/drawable-xhdpi/suw_navbar_ic_down_arrow_dark.png
Binary files differ
diff --git a/library/eclair-mr1/res/drawable-xhdpi/suw_navbar_ic_down_arrow_light.png b/library/eclair-mr1/res/drawable-xhdpi/suw_navbar_ic_down_arrow_light.png
new file mode 100644
index 0000000..94016f4
--- /dev/null
+++ b/library/eclair-mr1/res/drawable-xhdpi/suw_navbar_ic_down_arrow_light.png
Binary files differ
diff --git a/library/eclair-mr1/res/drawable-xxhdpi/suw_navbar_ic_down_arrow_dark.png b/library/eclair-mr1/res/drawable-xxhdpi/suw_navbar_ic_down_arrow_dark.png
new file mode 100644
index 0000000..f9622b7
--- /dev/null
+++ b/library/eclair-mr1/res/drawable-xxhdpi/suw_navbar_ic_down_arrow_dark.png
Binary files differ
diff --git a/library/eclair-mr1/res/drawable-xxhdpi/suw_navbar_ic_down_arrow_light.png b/library/eclair-mr1/res/drawable-xxhdpi/suw_navbar_ic_down_arrow_light.png
new file mode 100644
index 0000000..17811ae
--- /dev/null
+++ b/library/eclair-mr1/res/drawable-xxhdpi/suw_navbar_ic_down_arrow_light.png
Binary files differ
diff --git a/library/eclair-mr1/res/drawable-xxxhdpi/suw_navbar_ic_down_arrow_dark.png b/library/eclair-mr1/res/drawable-xxxhdpi/suw_navbar_ic_down_arrow_dark.png
new file mode 100644
index 0000000..30948d9
--- /dev/null
+++ b/library/eclair-mr1/res/drawable-xxxhdpi/suw_navbar_ic_down_arrow_dark.png
Binary files differ
diff --git a/library/eclair-mr1/res/drawable-xxxhdpi/suw_navbar_ic_down_arrow_light.png b/library/eclair-mr1/res/drawable-xxxhdpi/suw_navbar_ic_down_arrow_light.png
new file mode 100644
index 0000000..cb6a422
--- /dev/null
+++ b/library/eclair-mr1/res/drawable-xxxhdpi/suw_navbar_ic_down_arrow_light.png
Binary files differ
diff --git a/library/eclair-mr1/res/drawable/suw_navbar_ic_more_dark.xml b/library/eclair-mr1/res/drawable/suw_navbar_ic_more_dark.xml
new file mode 100644
index 0000000..15df735
--- /dev/null
+++ b/library/eclair-mr1/res/drawable/suw_navbar_ic_more_dark.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2015 The Android Open Source Project
+
+ 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.
+-->
+
+<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
+ android:src="@drawable/suw_navbar_ic_down_arrow_dark" />
diff --git a/library/eclair-mr1/res/drawable/suw_navbar_ic_more_light.xml b/library/eclair-mr1/res/drawable/suw_navbar_ic_more_light.xml
new file mode 100644
index 0000000..9c6e809
--- /dev/null
+++ b/library/eclair-mr1/res/drawable/suw_navbar_ic_more_light.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2015 The Android Open Source Project
+
+ 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.
+-->
+
+<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
+ android:src="@drawable/suw_navbar_ic_down_arrow_light" />
diff --git a/library/eclair-mr1/res/values/styles.xml b/library/eclair-mr1/res/values/styles.xml
index 9b6b659..282d7cb 100644
--- a/library/eclair-mr1/res/values/styles.xml
+++ b/library/eclair-mr1/res/values/styles.xml
@@ -52,8 +52,6 @@
<style name="SuwDescription">
<!-- Before Honeycomb, layout_gravity is needed for FrameLayout to apply the margins -->
<item name="android:layout_gravity">top</item>
- <item name="android:layout_width">match_parent</item>
- <item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginBottom">@dimen/suw_description_margin_bottom</item>
<item name="android:layout_marginTop">@dimen/suw_description_margin_top</item>
<item name="android:lineSpacingExtra">@dimen/suw_description_line_spacing_extra</item>
@@ -86,6 +84,7 @@
<item name="suwNavBarBackButton">@drawable/suw_navbar_ic_back_dark</item>
<item name="suwNavBarBackgroundColor">@color/suw_navbar_bg_dark</item>
<item name="suwNavBarButtonBackground">@drawable/suw_navbar_btn_bg_dark</item>
+ <item name="suwNavBarMoreButton">@drawable/suw_navbar_ic_more_dark</item>
<item name="suwNavBarNextButton">@drawable/suw_navbar_ic_next_dark</item>
<item name="suwNavBarTextColor">@color/suw_navbar_text_dark</item>
</style>
@@ -94,6 +93,7 @@
<item name="suwNavBarBackButton">@drawable/suw_navbar_ic_back_light</item>
<item name="suwNavBarBackgroundColor">@color/suw_navbar_bg_light</item>
<item name="suwNavBarButtonBackground">@drawable/suw_navbar_btn_bg_light</item>
+ <item name="suwNavBarMoreButton">@drawable/suw_navbar_ic_more_light</item>
<item name="suwNavBarNextButton">@drawable/suw_navbar_ic_next_light</item>
<item name="suwNavBarTextColor">@color/suw_navbar_text_light</item>
</style>
diff --git a/library/main/res/drawable-v21/suw_navbar_ic_more.xml b/library/main/res/drawable-v21/suw_navbar_ic_more.xml
new file mode 100644
index 0000000..ce4073a
--- /dev/null
+++ b/library/main/res/drawable-v21/suw_navbar_ic_more.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2015 The Android Open Source Project
+
+ 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.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="@dimen/suw_navbar_ic_intrinsic_size"
+ android:height="@dimen/suw_navbar_ic_intrinsic_size"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+
+ <path
+ android:fillColor="?attr/suwNavBarTextColor"
+ android:pathData="M16.6,8.6l-4.6,4.6 -4.6,-4.6 -1.4,1.4 6,6 6,-6z"/>
+
+</vector>
diff --git a/library/main/res/layout/suw_navbar_view.xml b/library/main/res/layout/suw_navbar_view.xml
index c3af53d..1c4cb33 100644
--- a/library/main/res/layout/suw_navbar_view.xml
+++ b/library/main/res/layout/suw_navbar_view.xml
@@ -33,6 +33,17 @@
android:visibility="invisible" />
<view class="com.android.setupwizardlib.view.NavigationBar$NavButton"
+ android:id="@+id/suw_navbar_more"
+ style="@style/SuwNavBarButtonStyle"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:contentDescription="@string/suw_more_button_label"
+ android:drawableEnd="?attr/suwNavBarMoreButton"
+ android:drawableRight="?attr/suwNavBarMoreButton"
+ android:gravity="end|center_vertical"
+ android:visibility="gone" />
+
+ <view class="com.android.setupwizardlib.view.NavigationBar$NavButton"
android:id="@+id/suw_navbar_next"
style="@style/SuwNavBarButtonStyle"
android:layout_width="wrap_content"
diff --git a/library/main/res/values-v21/styles.xml b/library/main/res/values-v21/styles.xml
index c69e8e7..027fff0 100644
--- a/library/main/res/values-v21/styles.xml
+++ b/library/main/res/values-v21/styles.xml
@@ -20,8 +20,6 @@
<!-- Content styles -->
<style name="SuwDescription">
- <item name="android:layout_width">match_parent</item>
- <item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginBottom">@dimen/suw_description_margin_bottom</item>
<item name="android:layout_marginTop">@dimen/suw_description_margin_top</item>
<item name="android:lineSpacingExtra">@dimen/suw_description_line_spacing_extra</item>
@@ -40,7 +38,6 @@
<style name="SuwNavBarButtonStyle" parent="@android:style/Widget.Material.Button.Borderless">
<item name="android:background">?attr/suwNavBarButtonBackground</item>
- <item name="android:drawablePadding">@dimen/suw_navbar_button_drawable_padding</item>
<item name="android:fontFamily">sans-serif</item>
<item name="android:minWidth">0dp</item>
<item name="android:paddingLeft">@dimen/suw_navbar_button_padding_sides</item>
@@ -54,6 +51,7 @@
<item name="suwNavBarBackButton">@drawable/suw_navbar_ic_back</item>
<item name="suwNavBarBackgroundColor">@color/suw_navbar_bg_dark</item>
<item name="suwNavBarButtonBackground">@drawable/suw_navbar_btn_bg</item>
+ <item name="suwNavBarMoreButton">@drawable/suw_navbar_ic_more</item>
<item name="suwNavBarNextButton">@drawable/suw_navbar_ic_next</item>
<item name="suwNavBarTextColor">@color/suw_navbar_text_dark</item>
</style>
@@ -62,6 +60,7 @@
<item name="suwNavBarBackButton">@drawable/suw_navbar_ic_back</item>
<item name="suwNavBarBackgroundColor">@color/suw_navbar_bg_light</item>
<item name="suwNavBarButtonBackground">@drawable/suw_navbar_btn_bg</item>
+ <item name="suwNavBarMoreButton">@drawable/suw_navbar_ic_more</item>
<item name="suwNavBarNextButton">@drawable/suw_navbar_ic_next</item>
<item name="suwNavBarTextColor">@color/suw_navbar_text_light</item>
</style>
diff --git a/library/main/res/values/attrs.xml b/library/main/res/values/attrs.xml
index c9fbe55..7e9753d 100644
--- a/library/main/res/values/attrs.xml
+++ b/library/main/res/values/attrs.xml
@@ -23,6 +23,7 @@
<attr name="suwNavBarBackButton" format="reference" />
<attr name="suwNavBarBackgroundColor" format="color" />
<attr name="suwNavBarButtonBackground" format="color|reference" />
+ <attr name="suwNavBarMoreButton" format="reference" />
<attr name="suwNavBarNextButton" format="reference" />
<attr name="suwNavBarTextColor" format="color" />
<attr name="suwNavBarTheme" format="reference" />
diff --git a/library/main/res/values/colors.xml b/library/main/res/values/colors.xml
index c010d73..5e3cb7f 100644
--- a/library/main/res/values/colors.xml
+++ b/library/main/res/values/colors.xml
@@ -23,10 +23,10 @@
<color name="suw_color_accent_light">#ff3367d6</color>
<color name="suw_color_secondary_dark">#ff9e9e9e</color>
<color name="suw_color_secondary_light">#ff757575</color>
- <color name="suw_progress_bar_color_dark">#ffffcd40</color>
- <color name="suw_progress_bar_color_light">#fff4b400</color>
<color name="suw_link_color_dark">#ff448aff</color>
<color name="suw_link_color_light">#ff3367d6</color>
+ <color name="suw_progress_bar_color_dark">#ffffcd40</color>
+ <color name="suw_progress_bar_color_light">#fff4b400</color>
<!-- Navigation bar colors -->
diff --git a/library/main/res/values/strings.xml b/library/main/res/values/strings.xml
index df30031..9436690 100644
--- a/library/main/res/values/strings.xml
+++ b/library/main/res/values/strings.xml
@@ -16,9 +16,12 @@
-->
<resources>
- <!-- Button for going to the next screen or step [CHAR LIMIT=40] -->
+ <!-- Button for going to the next screen or step [CHAR LIMIT=20] -->
<string name="suw_next_button_label">Next</string>
- <!-- Button for going to the previous screen or step [CHAR LIMIT=40] -->
+ <!-- Button for going to the previous screen or step [CHAR LIMIT=20] -->
<string name="suw_back_button_label">Back</string>
+
+ <!-- Button for scrolling down to reveal more content on the screen [CHAR LIMIT=20] -->
+ <string name="suw_more_button_label">More</string>
</resources>
diff --git a/library/main/src/com/android/setupwizardlib/SetupWizardLayout.java b/library/main/src/com/android/setupwizardlib/SetupWizardLayout.java
index a628d9e..60da563 100644
--- a/library/main/src/com/android/setupwizardlib/SetupWizardLayout.java
+++ b/library/main/src/com/android/setupwizardlib/SetupWizardLayout.java
@@ -29,6 +29,7 @@ import android.os.Build.VERSION_CODES;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
+import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
@@ -38,6 +39,8 @@ import android.view.ViewStub;
import android.widget.FrameLayout;
import android.widget.TextView;
+import com.android.setupwizardlib.util.RequireScrollHelper;
+import com.android.setupwizardlib.view.BottomScrollView;
import com.android.setupwizardlib.view.Illustration;
import com.android.setupwizardlib.view.NavigationBar;
@@ -222,6 +225,22 @@ public class SetupWizardLayout extends FrameLayout {
return view instanceof NavigationBar ? (NavigationBar) view : null;
}
+ private BottomScrollView getScrollView() {
+ final View view = findViewById(R.id.suw_bottom_scroll_view);
+ return view instanceof BottomScrollView ? (BottomScrollView) view : null;
+ }
+
+ public void requireScrollToBottom() {
+ final NavigationBar navigationBar = getNavigationBar();
+ final BottomScrollView scrollView = getScrollView();
+ if (navigationBar != null && scrollView != null) {
+ RequireScrollHelper.requireScroll(navigationBar, scrollView);
+ } else {
+ Log.e(TAG, "Both suw_layout_navigation_bar and suw_bottom_scroll_view must exist in"
+ + " the template to require scrolling.");
+ }
+ }
+
public void setHeaderText(int title) {
final TextView titleView = (TextView) findViewById(R.id.suw_layout_title);
if (titleView != null) {
diff --git a/library/main/src/com/android/setupwizardlib/util/RequireScrollHelper.java b/library/main/src/com/android/setupwizardlib/util/RequireScrollHelper.java
new file mode 100644
index 0000000..8d796d7
--- /dev/null
+++ b/library/main/src/com/android/setupwizardlib/util/RequireScrollHelper.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * 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.
+ */
+
+package com.android.setupwizardlib.util;
+
+import android.view.View;
+import android.widget.ScrollView;
+
+import com.android.setupwizardlib.view.BottomScrollView;
+import com.android.setupwizardlib.view.NavigationBar;
+
+/**
+ * Add this helper to require the scroll view to be scrolled to the bottom, making sure that the
+ * user sees all content on the screen. This will change the navigation bar to show the more button
+ * instead of the next button when there is more content to be seen. When the more button is
+ * clicked, the scroll view will be scrolled one page down.
+ */
+public class RequireScrollHelper implements BottomScrollView.BottomScrollListener,
+ View.OnClickListener {
+
+ /**
+ * Require scrolling on the scrollView, so that if the scrollView has content hidden beneath the
+ * fold, the next button will be hidden and the more button will be shown instead. The more
+ * button will scroll the scrollView downwards when clicked until the bottom is reached.
+ *
+ * @param navigationBar The navigation bar in which the next button's label will be changed.
+ * @param scrollView The {@link BottomScrollView} to be scrolled.
+ */
+ public static RequireScrollHelper requireScroll(NavigationBar navigationBar,
+ BottomScrollView scrollView) {
+ final RequireScrollHelper helper = new RequireScrollHelper(navigationBar, scrollView);
+ helper.requireScroll();
+ return helper;
+ }
+
+ private final BottomScrollView mScrollView;
+ private final NavigationBar mNavigationBar;
+
+ private boolean mScrollNeeded;
+
+ private RequireScrollHelper(NavigationBar navigationBar, BottomScrollView scrollView) {
+ mNavigationBar = navigationBar;
+ mScrollView = scrollView;
+ }
+
+ private void requireScroll() {
+ mNavigationBar.getMoreButton().setOnClickListener(this);
+ mScrollView.setBottomScrollListener(this);
+ }
+
+ @Override
+ public void onScrolledToBottom() {
+ if (mScrollNeeded) {
+ mNavigationBar.getNextButton().setVisibility(View.VISIBLE);
+ mNavigationBar.getMoreButton().setVisibility(View.GONE);
+ mScrollNeeded = false;
+ }
+ }
+
+ @Override
+ public void onRequiresScroll() {
+ if (!mScrollNeeded) {
+ mNavigationBar.getNextButton().setVisibility(View.GONE);
+ mNavigationBar.getMoreButton().setVisibility(View.VISIBLE);
+ mScrollNeeded = true;
+ }
+ }
+
+ @Override
+ public void onClick(View view) {
+ mScrollView.pageScroll(ScrollView.FOCUS_DOWN);
+ }
+}
diff --git a/library/main/src/com/android/setupwizardlib/util/SystemBarHelper.java b/library/main/src/com/android/setupwizardlib/util/SystemBarHelper.java
index ff6e05f..2bc00a1 100644
--- a/library/main/src/com/android/setupwizardlib/util/SystemBarHelper.java
+++ b/library/main/src/com/android/setupwizardlib/util/SystemBarHelper.java
@@ -147,6 +147,9 @@ public class SystemBarHelper {
* view to be immediately above the keyboard, and assumes that the view sits immediately above
* the navigation bar.
*
+ * Note that you must set windowSoftInputMode to adjustResize for this class to work. Otherwise
+ * window insets are not dispatched and this method will have no effect.
+ *
* This will only take effect in versions Lollipop or above. Otherwise this is a no-op.
*
* @param view The view to be resized when the keyboard is shown.
diff --git a/library/main/src/com/android/setupwizardlib/view/NavigationBar.java b/library/main/src/com/android/setupwizardlib/view/NavigationBar.java
index bc06976..489c23c 100644
--- a/library/main/src/com/android/setupwizardlib/view/NavigationBar.java
+++ b/library/main/src/com/android/setupwizardlib/view/NavigationBar.java
@@ -23,6 +23,7 @@ import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
+import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.ContextThemeWrapper;
import android.view.View;
@@ -68,6 +69,7 @@ public class NavigationBar extends LinearLayout implements View.OnClickListener
private Button mNextButton;
private Button mBackButton;
+ private Button mMoreButton;
private NavigationBarListener mListener;
public NavigationBar(Context context) {
@@ -92,6 +94,7 @@ public class NavigationBar extends LinearLayout implements View.OnClickListener
View.inflate(getContext(), R.layout.suw_navbar_view, this);
mNextButton = (Button) findViewById(R.id.suw_navbar_next);
mBackButton = (Button) findViewById(R.id.suw_navbar_back);
+ mMoreButton = (Button) findViewById(R.id.suw_navbar_more);
}
public Button getBackButton() {
@@ -102,6 +105,10 @@ public class NavigationBar extends LinearLayout implements View.OnClickListener
return mNextButton;
}
+ public Button getMoreButton() {
+ return mMoreButton;
+ }
+
public void setNavigationBarListener(NavigationBarListener listener) {
mListener = listener;
if (mListener != null) {
@@ -153,6 +160,14 @@ public class NavigationBar extends LinearLayout implements View.OnClickListener
}
}
}
+
+ @Override
+ protected void onTextChanged(CharSequence text, int start, int lengthBefore,
+ int lengthAfter) {
+ super.onTextChanged(text, start, lengthBefore, lengthAfter);
+ setCompoundDrawablePadding(TextUtils.isEmpty(text) ? 0 : getResources()
+ .getDimensionPixelSize(R.dimen.suw_navbar_button_drawable_padding));
+ }
}
}
diff --git a/library/test/src/com/android/setupwizardlib/test/RequireScrollHelperTest.java b/library/test/src/com/android/setupwizardlib/test/RequireScrollHelperTest.java
new file mode 100644
index 0000000..101d50a
--- /dev/null
+++ b/library/test/src/com/android/setupwizardlib/test/RequireScrollHelperTest.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * 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.
+ */
+
+package com.android.setupwizardlib.test;
+
+import android.content.Context;
+import android.test.AndroidTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+import android.view.View;
+
+import com.android.setupwizardlib.util.RequireScrollHelper;
+import com.android.setupwizardlib.view.BottomScrollView;
+import com.android.setupwizardlib.view.NavigationBar;
+
+public class RequireScrollHelperTest extends AndroidTestCase {
+
+ private TestBottomScrollView mScrollView;
+ private NavigationBar mNavigationBar;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mScrollView = new TestBottomScrollView(getContext());
+ mNavigationBar = new NavigationBar(getContext());
+ }
+
+ @SmallTest
+ public void testRequireScroll() {
+ RequireScrollHelper.requireScroll(mNavigationBar, mScrollView);
+ assertEquals("More button should be gone initially", View.GONE,
+ mNavigationBar.getMoreButton().getVisibility());
+ assertEquals("Next button should be shown", View.VISIBLE,
+ mNavigationBar.getNextButton().getVisibility());
+
+ mScrollView.listener.onRequiresScroll();
+ assertEquals("More button should be shown when scroll is required", View.VISIBLE,
+ mNavigationBar.getMoreButton().getVisibility());
+ assertEquals("Next button should not be shown when scroll is required", View.GONE,
+ mNavigationBar.getNextButton().getVisibility());
+ }
+
+ @SmallTest
+ public void testScrolledToBottom() {
+ RequireScrollHelper.requireScroll(mNavigationBar, mScrollView);
+ mScrollView.listener.onRequiresScroll();
+ assertEquals("More button should be shown when scroll is required", View.VISIBLE,
+ mNavigationBar.getMoreButton().getVisibility());
+ assertEquals("Next button should not be shown when scroll is required", View.GONE,
+ mNavigationBar.getNextButton().getVisibility());
+
+ mScrollView.listener.onScrolledToBottom();
+ assertEquals("More button should be hidden when scrolled to bottom", View.GONE,
+ mNavigationBar.getMoreButton().getVisibility());
+ assertEquals("Next button should be shown when scrolled to bottom", View.VISIBLE,
+ mNavigationBar.getNextButton().getVisibility());
+ }
+
+ @SmallTest
+ public void testClickScrollButton() {
+ RequireScrollHelper.requireScroll(mNavigationBar, mScrollView);
+ assertEquals("ScrollView page should be initially 0", 0, mScrollView.page);
+ mScrollView.listener.onRequiresScroll();
+ mNavigationBar.getMoreButton().performClick();
+ assertEquals("ScrollView page should be scrolled by 1", 1, mScrollView.page);
+ }
+
+ private static class TestBottomScrollView extends BottomScrollView {
+
+ public BottomScrollListener listener;
+ public int page = 0;
+
+ public TestBottomScrollView(Context context) {
+ super(context);
+ }
+
+ @Override
+ public void setBottomScrollListener(BottomScrollListener listener) {
+ this.listener = listener;
+ }
+
+ @Override
+ public boolean pageScroll(int direction) {
+ if (direction == FOCUS_DOWN) {
+ page++;
+ } else if (direction == FOCUS_UP) {
+ page--;
+ }
+ return super.pageScroll(direction);
+ }
+ }
+}