summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorim Jaggi <jjaggi@google.com>2015-04-23 23:48:31 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-04-23 23:48:31 +0000
commitaa7fad30f4b12ffb26f96d5834fb223fb5ee4a06 (patch)
treeda0ebe6919ac91840ea8d8d45963280c2048d9b3
parentb01e885bac69f64b860f2d26b4760d8c0186707c (diff)
parent7114577a094593dbf55b625146b3809800697030 (diff)
downloadandroid_frameworks_opt_setupwizard-aa7fad30f4b12ffb26f96d5834fb223fb5ee4a06.tar.gz
android_frameworks_opt_setupwizard-aa7fad30f4b12ffb26f96d5834fb223fb5ee4a06.tar.bz2
android_frameworks_opt_setupwizard-aa7fad30f4b12ffb26f96d5834fb223fb5ee4a06.zip
am 7114577a: [SetupWizard] Add attributes for illustration size
* commit '7114577a094593dbf55b625146b3809800697030': [SetupWizard] Add attributes for illustration size
-rw-r--r--library/main/res/layout/suw_list_header.xml2
-rw-r--r--library/main/res/layout/suw_list_template_card.xml1
-rw-r--r--library/main/res/layout/suw_list_template_card_wide.xml3
-rw-r--r--library/main/res/layout/suw_no_scroll_template_card.xml1
-rw-r--r--library/main/res/layout/suw_no_scroll_template_card_wide.xml3
-rw-r--r--library/main/res/layout/suw_no_scroll_template_header.xml2
-rw-r--r--library/main/res/layout/suw_template_card.xml1
-rw-r--r--library/main/res/layout/suw_template_card_wide.xml3
-rw-r--r--library/main/res/layout/suw_template_header.xml2
-rw-r--r--library/main/res/values-land/dimens.xml6
-rw-r--r--library/main/res/values-sw600dp-land/dimens.xml26
-rw-r--r--library/main/res/values-sw600dp/dimens.xml26
-rw-r--r--library/main/res/values/attrs.xml2
-rw-r--r--library/main/res/values/dimens.xml8
-rw-r--r--library/main/src/com/android/setupwizardlib/SetupWizardLayout.java54
-rw-r--r--library/main/src/com/android/setupwizardlib/view/Illustration.java14
16 files changed, 138 insertions, 16 deletions
diff --git a/library/main/res/layout/suw_list_header.xml b/library/main/res/layout/suw_list_header.xml
index 7e6c770..8bbe38a 100644
--- a/library/main/res/layout/suw_list_header.xml
+++ b/library/main/res/layout/suw_list_header.xml
@@ -16,7 +16,6 @@
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -29,7 +28,6 @@
android:layout_height="wrap_content"
android:background="@drawable/suw_layout_background"
android:elevation="@dimen/suw_title_area_elevation"
- app:suwAspectRatio="2.22"
tools:ignore="UnusedAttribute">
<TextView
diff --git a/library/main/res/layout/suw_list_template_card.xml b/library/main/res/layout/suw_list_template_card.xml
index 08fd83b..7281e8f 100644
--- a/library/main/res/layout/suw_list_template_card.xml
+++ b/library/main/res/layout/suw_list_template_card.xml
@@ -31,7 +31,6 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_marginTop="@dimen/suw_tablet_illustration_height"
android:orientation="vertical"
android:paddingLeft="@dimen/suw_card_port_margin_sides"
android:paddingRight="@dimen/suw_card_port_margin_sides">
diff --git a/library/main/res/layout/suw_list_template_card_wide.xml b/library/main/res/layout/suw_list_template_card_wide.xml
index 1812bdc..7574153 100644
--- a/library/main/res/layout/suw_list_template_card_wide.xml
+++ b/library/main/res/layout/suw_list_template_card_wide.xml
@@ -39,13 +39,12 @@
style="@style/SuwCardTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/suw_tablet_illustration_height"
+ android:layout_marginTop="@dimen/suw_card_land_header_text_margin_top"
android:layout_weight="6" />
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
- android:layout_marginTop="@dimen/suw_card_land_margin_top"
android:layout_weight="8"
android:background="?attr/suwCardBackground"
android:elevation="@dimen/suw_card_elevation"
diff --git a/library/main/res/layout/suw_no_scroll_template_card.xml b/library/main/res/layout/suw_no_scroll_template_card.xml
index 21356c2..e799473 100644
--- a/library/main/res/layout/suw_no_scroll_template_card.xml
+++ b/library/main/res/layout/suw_no_scroll_template_card.xml
@@ -34,7 +34,6 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_marginTop="@dimen/suw_tablet_illustration_height"
android:orientation="vertical"
android:paddingLeft="@dimen/suw_card_port_margin_sides"
android:paddingRight="@dimen/suw_card_port_margin_sides">
diff --git a/library/main/res/layout/suw_no_scroll_template_card_wide.xml b/library/main/res/layout/suw_no_scroll_template_card_wide.xml
index 82fe8c9..a09b9b6 100644
--- a/library/main/res/layout/suw_no_scroll_template_card_wide.xml
+++ b/library/main/res/layout/suw_no_scroll_template_card_wide.xml
@@ -42,13 +42,12 @@
style="@style/SuwCardTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/suw_tablet_illustration_height"
+ android:layout_marginTop="@dimen/suw_card_land_header_text_margin_top"
android:layout_weight="6" />
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
- android:layout_marginTop="@dimen/suw_card_land_margin_top"
android:layout_weight="8"
android:background="?attr/suwCardBackground"
android:elevation="@dimen/suw_card_elevation"
diff --git a/library/main/res/layout/suw_no_scroll_template_header.xml b/library/main/res/layout/suw_no_scroll_template_header.xml
index bdd64e3..413b329 100644
--- a/library/main/res/layout/suw_no_scroll_template_header.xml
+++ b/library/main/res/layout/suw_no_scroll_template_header.xml
@@ -21,7 +21,6 @@
header to the RecyclerView or avoid using this layout (e.g. use suw_no_scroll_template_short
instead of suw_no_scroll_template) -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -40,7 +39,6 @@
android:background="@drawable/suw_layout_background"
android:elevation="@dimen/suw_title_area_elevation"
android:tag="stickyContainer"
- app:suwAspectRatio="2.22"
tools:ignore="UnusedAttribute">
<TextView
diff --git a/library/main/res/layout/suw_template_card.xml b/library/main/res/layout/suw_template_card.xml
index ca0ab25..b913bb8 100644
--- a/library/main/res/layout/suw_template_card.xml
+++ b/library/main/res/layout/suw_template_card.xml
@@ -31,7 +31,6 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_marginTop="@dimen/suw_tablet_illustration_height"
android:orientation="vertical"
android:paddingLeft="@dimen/suw_card_port_margin_sides"
android:paddingRight="@dimen/suw_card_port_margin_sides">
diff --git a/library/main/res/layout/suw_template_card_wide.xml b/library/main/res/layout/suw_template_card_wide.xml
index 5238963..a069007 100644
--- a/library/main/res/layout/suw_template_card_wide.xml
+++ b/library/main/res/layout/suw_template_card_wide.xml
@@ -39,13 +39,12 @@
style="@style/SuwCardTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/suw_tablet_illustration_height"
+ android:layout_marginTop="@dimen/suw_card_land_header_text_margin_top"
android:layout_weight="6" />
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
- android:layout_marginTop="@dimen/suw_card_land_margin_top"
android:layout_weight="8"
android:background="?attr/suwCardBackground"
android:elevation="@dimen/suw_card_elevation"
diff --git a/library/main/res/layout/suw_template_header.xml b/library/main/res/layout/suw_template_header.xml
index e130728..7945dcf 100644
--- a/library/main/res/layout/suw_template_header.xml
+++ b/library/main/res/layout/suw_template_header.xml
@@ -16,7 +16,6 @@
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -54,7 +53,6 @@
android:background="@drawable/suw_layout_background"
android:elevation="@dimen/suw_title_area_elevation"
android:orientation="vertical"
- app:suwAspectRatio="2.22"
tools:ignore="UnusedAttribute">
<TextView
diff --git a/library/main/res/values-land/dimens.xml b/library/main/res/values-land/dimens.xml
index f48548b..ab068c9 100644
--- a/library/main/res/values-land/dimens.xml
+++ b/library/main/res/values-land/dimens.xml
@@ -23,4 +23,10 @@
<dimen name="suw_card_title_padding_top">24dp</dimen>
<dimen name="suw_card_title_padding_bottom">0dp</dimen>
+ <!-- Decor view (illustration or the header without illustration) -->
+ <dimen name="suw_decor_padding_top">0dp</dimen>
+
+ <!-- Illustration -->
+ <item name="suw_illustration_aspect_ratio" format="float" type="dimen">0</item>
+
</resources>
diff --git a/library/main/res/values-sw600dp-land/dimens.xml b/library/main/res/values-sw600dp-land/dimens.xml
new file mode 100644
index 0000000..57b7e3e
--- /dev/null
+++ b/library/main/res/values-sw600dp-land/dimens.xml
@@ -0,0 +1,26 @@
+<?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.
+-->
+
+<resources>
+
+ <!-- Decor view (illustration or the header without illustration) -->
+ <dimen name="suw_decor_padding_top">128dp</dimen>
+
+ <!-- Illustration -->
+ <item name="suw_illustration_aspect_ratio" format="float" type="dimen">0.0</item>
+
+</resources>
diff --git a/library/main/res/values-sw600dp/dimens.xml b/library/main/res/values-sw600dp/dimens.xml
new file mode 100644
index 0000000..bd05972
--- /dev/null
+++ b/library/main/res/values-sw600dp/dimens.xml
@@ -0,0 +1,26 @@
+<?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.
+-->
+
+<resources>
+
+ <!-- Decor view (illustration or the header without illustration) -->
+ <dimen name="suw_decor_padding_top">256dp</dimen>
+
+ <!-- Illustration -->
+ <item name="suw_illustration_aspect_ratio" format="float" type="dimen">0</item>
+
+</resources>
diff --git a/library/main/res/values/attrs.xml b/library/main/res/values/attrs.xml
index 25bfe6e..c9fbe55 100644
--- a/library/main/res/values/attrs.xml
+++ b/library/main/res/values/attrs.xml
@@ -40,7 +40,9 @@
<attr name="suwBackground" format="color|reference" />
<attr name="suwBackgroundTile" format="color|reference" />
<attr name="suwHeaderText" format="string" localization="suggested" />
+ <attr name="suwDecorPaddingTop" format="dimension|reference" />
<attr name="suwIllustration" format="color|reference" />
+ <attr name="suwIllustrationAspectRatio" format="float|reference" />
<attr name="suwIllustrationHorizontalTile" format="color|reference" />
<attr name="suwIllustrationImage" format="color|reference" />
</declare-styleable>
diff --git a/library/main/res/values/dimens.xml b/library/main/res/values/dimens.xml
index 2f9c65f..fd5aac0 100644
--- a/library/main/res/values/dimens.xml
+++ b/library/main/res/values/dimens.xml
@@ -32,7 +32,7 @@
<!-- Card layout (for tablets) -->
<dimen name="suw_card_corner_radius">2dp</dimen>
<dimen name="suw_card_elevation">5dp</dimen>
- <dimen name="suw_card_land_margin_top">128dp</dimen>
+ <dimen name="suw_card_land_header_text_margin_top">128dp</dimen>
<dimen name="suw_card_port_margin_sides">56dp</dimen>
<dimen name="suw_card_title_padding_end">0dp</dimen>
@@ -42,6 +42,9 @@
<dimen name="suw_tablet_illustration_height">256dp</dimen>
+ <!-- Decor view (illustration or the header without illustration) -->
+ <dimen name="suw_decor_padding_top">0dp</dimen>
+
<!-- Header layout (for phones) -->
<dimen name="suw_title_area_elevation">3dp</dimen>
@@ -52,6 +55,9 @@
<!-- This is the extra spacing required to make the leading exactly 32sp -->
<dimen name="suw_header_title_line_spacing_extra">3.67sp</dimen>
+ <!-- Illustration -->
+ <item name="suw_illustration_aspect_ratio" format="float" type="dimen">2.22</item>
+
<!-- Navigation bar -->
<dimen name="suw_navbar_button_drawable_padding">6dp</dimen>
<dimen name="suw_navbar_button_padding_sides">10dp</dimen>
diff --git a/library/main/src/com/android/setupwizardlib/SetupWizardLayout.java b/library/main/src/com/android/setupwizardlib/SetupWizardLayout.java
index d542064..9ec844e 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.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
@@ -117,6 +118,26 @@ public class SetupWizardLayout extends FrameLayout {
}
}
+ // Set the top padding of the illustration
+ int decorPaddingTop = a.getDimensionPixelSize(
+ R.styleable.SuwSetupWizardLayout_suwDecorPaddingTop, -1);
+ if (decorPaddingTop == -1) {
+ decorPaddingTop = getResources().getDimensionPixelSize(R.dimen.suw_decor_padding_top);
+ }
+ setDecorPaddingTop(decorPaddingTop);
+
+
+ // Set the illustration aspect ratio. See Illustration.setAspectRatio(float). This will
+ // override suwIllustrationPaddingTop if its value is not 0.
+ float illustrationAspectRatio = a.getFloat(
+ R.styleable.SuwSetupWizardLayout_suwIllustrationAspectRatio, -1f);
+ if (illustrationAspectRatio == -1f) {
+ final TypedValue out = new TypedValue();
+ getResources().getValue(R.dimen.suw_illustration_aspect_ratio, out, true);
+ illustrationAspectRatio = out.getFloat();
+ }
+ setIllustrationAspectRatio(illustrationAspectRatio);
+
// Set the header text
final CharSequence headerText =
a.getText(R.styleable.SuwSetupWizardLayout_suwHeaderText);
@@ -259,6 +280,39 @@ public class SetupWizardLayout extends FrameLayout {
}
/**
+ * Sets the aspect ratio of the illustration. This will be the space (padding top) reserved
+ * above the header text. This will override the padding top of the illustration.
+ *
+ * @param aspectRatio The aspect ratio
+ * @see com.android.setupwizardlib.view.Illustration#setAspectRatio(float)
+ */
+ public void setIllustrationAspectRatio(float aspectRatio) {
+ final View view = findViewById(R.id.suw_layout_decor);
+ if (view instanceof Illustration) {
+ final Illustration illustration = (Illustration) view;
+ illustration.setAspectRatio(aspectRatio);
+ }
+ }
+
+ /**
+ * Set the top padding of the decor view. If the decor is an Illustration and the aspect ratio
+ * is set, this value will be overridden.
+ *
+ * Note: Currently the default top padding for tablet landscape is 128dp, which is the offset
+ * of the card from the top. This is likely to change in future versions so this value aligns
+ * with the height of the illustration instead.
+ *
+ * @param paddingTop The top padding in pixels.
+ */
+ public void setDecorPaddingTop(int paddingTop) {
+ final View view = findViewById(R.id.suw_layout_decor);
+ if (view != null) {
+ view.setPadding(view.getPaddingLeft(), paddingTop, view.getPaddingRight(),
+ view.getPaddingBottom());
+ }
+ }
+
+ /**
* Set the background of the layout, which is expected to be able to extend infinitely. If it is
* a bitmap tile and you want it to repeat, use {@link #setBackgroundTile(int)} instead.
*/
diff --git a/library/main/src/com/android/setupwizardlib/view/Illustration.java b/library/main/src/com/android/setupwizardlib/view/Illustration.java
index 91c8a59..537ddc7 100644
--- a/library/main/src/com/android/setupwizardlib/view/Illustration.java
+++ b/library/main/src/com/android/setupwizardlib/view/Illustration.java
@@ -112,6 +112,20 @@ public class Illustration extends FrameLayout {
requestLayout();
}
+ /**
+ * Set the aspect ratio reserved for the illustration. This overrides the top padding of the
+ * view according to the width of this view and the aspect ratio. Children views will start
+ * being laid out below this aspect ratio.
+ *
+ * @param aspectRatio A float value specifying the aspect ratio (= width / height). 0 to not
+ * override the top padding.
+ */
+ public void setAspectRatio(float aspectRatio) {
+ mAspectRatio = aspectRatio;
+ invalidate();
+ requestLayout();
+ }
+
@Override
@Deprecated
public void setForeground(Drawable d) {