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
Binary files /dev/null and b/library/eclair-mr1/res/drawable-hdpi/suw_navbar_ic_down_arrow_dark.png 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
Binary files /dev/null and b/library/eclair-mr1/res/drawable-hdpi/suw_navbar_ic_down_arrow_light.png 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
Binary files /dev/null and b/library/eclair-mr1/res/drawable-mdpi/suw_navbar_ic_down_arrow_dark.png 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
Binary files /dev/null and b/library/eclair-mr1/res/drawable-mdpi/suw_navbar_ic_down_arrow_light.png 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
Binary files /dev/null and b/library/eclair-mr1/res/drawable-xhdpi/suw_navbar_ic_down_arrow_dark.png 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
Binary files /dev/null and b/library/eclair-mr1/res/drawable-xhdpi/suw_navbar_ic_down_arrow_light.png 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
Binary files /dev/null and b/library/eclair-mr1/res/drawable-xxhdpi/suw_navbar_ic_down_arrow_dark.png 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
Binary files /dev/null and b/library/eclair-mr1/res/drawable-xxhdpi/suw_navbar_ic_down_arrow_light.png 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
Binary files /dev/null and b/library/eclair-mr1/res/drawable-xxxhdpi/suw_navbar_ic_down_arrow_dark.png 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
Binary files /dev/null and b/library/eclair-mr1/res/drawable-xxxhdpi/suw_navbar_ic_down_arrow_light.png 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 @@
+
+
+
+
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 @@
+
+
+
+
diff --git a/library/eclair-mr1/res/values/styles.xml b/library/eclair-mr1/res/values/styles.xml
index 9b6b659..fdea831 100644
--- a/library/eclair-mr1/res/values/styles.xml
+++ b/library/eclair-mr1/res/values/styles.xml
@@ -86,6 +86,7 @@
- @drawable/suw_navbar_ic_back_dark
- @color/suw_navbar_bg_dark
- @drawable/suw_navbar_btn_bg_dark
+ - @drawable/suw_navbar_ic_more_dark
- @drawable/suw_navbar_ic_next_dark
- @color/suw_navbar_text_dark
@@ -94,6 +95,7 @@
- @drawable/suw_navbar_ic_back_light
- @color/suw_navbar_bg_light
- @drawable/suw_navbar_btn_bg_light
+ - @drawable/suw_navbar_ic_more_light
- @drawable/suw_navbar_ic_next_light
- @color/suw_navbar_text_light
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 @@
+
+
+
+
+
+
+
+
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
@@ -32,6 +32,17 @@
android:layout_weight="1"
android:visibility="invisible" />
+
+
@drawable/suw_navbar_ic_back
- @color/suw_navbar_bg_dark
- @drawable/suw_navbar_btn_bg
+ - @drawable/suw_navbar_ic_more
- @drawable/suw_navbar_ic_next
- @color/suw_navbar_text_dark
@@ -62,6 +63,7 @@
- @drawable/suw_navbar_ic_back
- @color/suw_navbar_bg_light
- @drawable/suw_navbar_btn_bg
+ - @drawable/suw_navbar_ic_more
- @drawable/suw_navbar_ic_next
- @color/suw_navbar_text_light
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 @@
+
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 @@
-->
-
+
Next
-
+
Back
+
+
+ More
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/view/NavigationBar.java b/library/main/src/com/android/setupwizardlib/view/NavigationBar.java
index bc06976..d2bef6c 100644
--- a/library/main/src/com/android/setupwizardlib/view/NavigationBar.java
+++ b/library/main/src/com/android/setupwizardlib/view/NavigationBar.java
@@ -68,6 +68,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 +93,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 +104,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) {
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);
+ }
+ }
+}