[WifiSetup] Tablet landscape layout
Created setup_preference for sw600dp-land, modeled after template_with_header in Setup Wizard. Copied over wide illustration, which is again a placeholder and needs real graphics from UX. Renamed SetupWizardHeader to SetupWizardIllustration. Added aspectRatio attribute to SetupWizardIllustration that, will set the aspect ratio of the top padding. If 0 or not specified, padding will not be set. Bug: 16349429 Change-Id: Ic2623ee0c0ee8864383d22da006b418b8c371bf0
This commit is contained in:
BIN
res/drawable-nodpi/illustration_wifi_wide.jpg
Normal file
BIN
res/drawable-nodpi/illustration_wifi_wide.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 142 KiB |
82
res/layout-sw600dp-land/setup_preference.xml
Normal file
82
res/layout-sw600dp-land/setup_preference.xml
Normal file
@@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (c) 2014 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.
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.android.settings.widget.SetupWizardIllustration
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:foreground="@drawable/illustration_wifi_wide"
|
||||
android:background="@drawable/grass">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="start|top"
|
||||
android:weightSum="16">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
style="@style/SetupCardTitle"
|
||||
android:text="@string/wifi_setup_wizard_title"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="@dimen/setup_wizard_card_margin_top"
|
||||
android:layout_weight="8"
|
||||
android:background="?android:attr/colorBackground"
|
||||
android:elevation="@dimen/setup_wizard_card_elevation"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/wifi_required_info"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="6dp"
|
||||
android:text="@string/wifi_required_info_text"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ListView
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:cacheColorHint="@android:color/transparent"
|
||||
android:clipToPadding="false"
|
||||
android:drawSelectorOnTop="false"
|
||||
android:headerDividersEnabled="false"
|
||||
android:scrollbarAlwaysDrawVerticalTrack="true" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.android.settings.widget.SetupWizardIllustration>
|
||||
|
||||
<fragment android:name="com.android.setupwizard.navigationbar.SetupWizardNavBar"
|
||||
android:id="@+id/navigation_bar"
|
||||
style="@style/setup_wizard_navbar_style" />
|
||||
|
||||
</LinearLayout>
|
||||
|
@@ -15,14 +15,16 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<com.android.settings.widget.SetupWizardHeader
|
||||
<com.android.settings.widget.SetupWizardIllustration
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
||||
android:id="@+id/title_area"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/grass"
|
||||
android:foreground="@drawable/illustration_wifi"
|
||||
android:tag="stickyContainer">
|
||||
android:tag="stickyContainer"
|
||||
settings:aspectRatio="2.0">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
@@ -32,4 +34,4 @@
|
||||
android:tag="sticky"
|
||||
android:text="@string/wifi_setup_wizard_title"/>
|
||||
|
||||
</com.android.settings.widget.SetupWizardHeader>
|
||||
</com.android.settings.widget.SetupWizardIllustration>
|
||||
|
@@ -22,6 +22,10 @@
|
||||
<attr name="icon" format="reference" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="SetupWizardIllustration">
|
||||
<attr name="aspectRatio" format="float" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="BatteryHistoryChart">
|
||||
<!-- Base text color, typeface, size, and style. -->
|
||||
<attr name="android:textAppearance" />
|
||||
|
@@ -48,6 +48,12 @@
|
||||
<!-- Size of padding to give in the wifi list when there is no icon -->
|
||||
<dimen name="setup_list_no_icon_padding">56dp</dimen>
|
||||
<dimen name="setup_add_network_item_height">56dp</dimen>
|
||||
<dimen name="setup_wizard_card_elevation">5dp</dimen>
|
||||
<dimen name="setup_wizard_card_margin_top">128dp</dimen>
|
||||
<dimen name="setup_wizard_card_title_margin_top">256dp</dimen>
|
||||
<dimen name="setup_wizard_card_title_padding_end">32dp</dimen>
|
||||
<dimen name="setup_wizard_card_title_padding_start">56dp</dimen>
|
||||
<dimen name="setup_wizard_card_title_padding_top">24dp</dimen>
|
||||
<dimen name="setup_wizard_margin_sides">40dp</dimen>
|
||||
|
||||
<dimen name="divider_height">3dip</dimen>
|
||||
|
@@ -174,6 +174,18 @@
|
||||
<item name="android:paddingTop">@dimen/setup_title_padding_top</item>
|
||||
</style>
|
||||
|
||||
<!-- Alternate title style used for some tablet-landscape layouts -->
|
||||
<style name="SetupCardTitle" parent="@android:style/TextAppearance.Material.Display1">
|
||||
<item name="android:layout_width">0dp</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:layout_marginTop">@dimen/setup_wizard_card_title_margin_top</item>
|
||||
<item name="android:layout_weight">6</item>
|
||||
<item name="android:paddingStart">@dimen/setup_wizard_card_title_padding_start</item>
|
||||
<item name="android:paddingEnd">@dimen/setup_wizard_card_title_padding_end</item>
|
||||
<item name="android:paddingTop">@dimen/setup_wizard_card_title_padding_top</item>
|
||||
<item name="android:textColor">@android:color/white</item>
|
||||
</style>
|
||||
|
||||
<style name="SetupAddWifiNetwork">
|
||||
<item name="android:fontFamily">sans-serif-medium</item>
|
||||
<item name="android:gravity">start|center_vertical</item>
|
||||
|
@@ -22,49 +22,51 @@ import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
/*
|
||||
* Copied from com.google.android.setupwizard.util.SetupWizardHeader
|
||||
*/
|
||||
public class SetupWizardHeader extends FrameLayout {
|
||||
import com.android.settings.R;
|
||||
|
||||
// Size the baseline grid in pixels
|
||||
/**
|
||||
* Class to draw the illustration of setup wizard. The aspectRatio attribute determines the aspect
|
||||
* ratio of the top padding, which is leaving space for the illustration. Draws an illustration
|
||||
* (foreground) to fit the width of the view and fills the rest with the background.
|
||||
*
|
||||
* Copied from com.google.android.setupwizard.util.SetupWizardIllustration
|
||||
*/
|
||||
public class SetupWizardIllustration extends FrameLayout {
|
||||
|
||||
private static final String TAG = "SetupWizardIllustration";
|
||||
|
||||
// Size of the baseline grid in pixels
|
||||
private float mBaselineGridSize;
|
||||
private Drawable mBackground;
|
||||
private Drawable mForeground;
|
||||
private int mForegroundHeight;
|
||||
private int mForegroundHeight = 0;
|
||||
private float mScale = 1.0f;
|
||||
private float mAspectRatio = 0.0f;
|
||||
|
||||
public SetupWizardHeader(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
public SetupWizardIllustration(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public SetupWizardHeader(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
initFromAttributes(context, attrs);
|
||||
public SetupWizardIllustration(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public SetupWizardHeader(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initFromAttributes(context, attrs);
|
||||
public SetupWizardIllustration(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
this(context, attrs, defStyleAttr, 0);
|
||||
}
|
||||
|
||||
public SetupWizardHeader(Context context, AttributeSet attrs, int defStyleAttr,
|
||||
public SetupWizardIllustration(Context context, AttributeSet attrs, int defStyleAttr,
|
||||
int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
initFromAttributes(context, attrs);
|
||||
}
|
||||
|
||||
private void initFromAttributes(Context context, AttributeSet attrs) {
|
||||
if (attrs != null) {
|
||||
TypedArray a = context.obtainStyledAttributes(attrs,
|
||||
new int[] { android.R.attr.foreground });
|
||||
setForeground(a.getDrawable(0));
|
||||
init();
|
||||
R.styleable.SetupWizardIllustration, 0, 0);
|
||||
mAspectRatio = a.getFloat(R.styleable.SetupWizardIllustration_aspectRatio, 0.0f);
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
// Number of pixels of the 8dp baseline grid as defined in material design specs
|
||||
mBaselineGridSize = getResources().getDisplayMetrics().density * 8;
|
||||
setWillNotDraw(false);
|
||||
@@ -83,15 +85,19 @@ public class SetupWizardHeader extends FrameLayout {
|
||||
* Sets the drawable used as the illustration. THe drawable is expected to have intrinsic
|
||||
* width and height defined and will be scaled to fit the width of the view.
|
||||
*/
|
||||
@Override
|
||||
public void setForeground(Drawable foreground) {
|
||||
mForeground = foreground;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int illustrationHeight = MeasureSpec.getSize(widthMeasureSpec) / 2;
|
||||
if (mAspectRatio != 0.0f) {
|
||||
int parentWidth = MeasureSpec.getSize(widthMeasureSpec);
|
||||
int illustrationHeight = (int) (parentWidth / mAspectRatio);
|
||||
illustrationHeight -= illustrationHeight % mBaselineGridSize;
|
||||
setPadding(0, illustrationHeight, 0, 0);
|
||||
setPaddingRelative(0, illustrationHeight, 0, 0);
|
||||
}
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
}
|
||||
|
||||
@@ -100,16 +106,25 @@ public class SetupWizardHeader extends FrameLayout {
|
||||
final int layoutWidth = right - left;
|
||||
final int layoutHeight = bottom - top;
|
||||
if (mForeground != null) {
|
||||
final float intrinsicWidth = mForeground.getIntrinsicWidth();
|
||||
final float intrinsicHeight = mForeground.getIntrinsicHeight();
|
||||
if (intrinsicWidth <= 0 || intrinsicHeight <= 0) {
|
||||
Log.e(TAG, "Foreground drawable intrinsic size must be defined and positive");
|
||||
mForeground = null;
|
||||
mForegroundHeight = 0;
|
||||
mScale = 1.0f;
|
||||
} else {
|
||||
// Scale the foreground to fill the width of the view
|
||||
mScale = layoutWidth / (float) mForeground.getIntrinsicWidth();
|
||||
mForegroundHeight = (int) (mForeground.getIntrinsicHeight() * mScale);
|
||||
mScale = layoutWidth / intrinsicWidth;
|
||||
mForegroundHeight = (int) (intrinsicHeight * mScale);
|
||||
mForeground.setBounds(0, 0, layoutWidth, mForegroundHeight);
|
||||
}
|
||||
}
|
||||
if (mBackground != null) {
|
||||
// Scale the bounds by mScale to compensate for the scale done to the canvas before
|
||||
// drawing.
|
||||
mBackground.setBounds(0, 0, (int) (layoutWidth / mScale),
|
||||
(int) ((layoutHeight - mForegroundHeight) / mScale));
|
||||
mBackground.setBounds(0, 0, (int) Math.ceil(layoutWidth / mScale),
|
||||
(int) Math.ceil((layoutHeight - mForegroundHeight) / mScale));
|
||||
}
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
}
|
||||
@@ -117,19 +132,20 @@ public class SetupWizardHeader extends FrameLayout {
|
||||
@Override
|
||||
public void onDraw(Canvas canvas) {
|
||||
if (mBackground != null) {
|
||||
canvas.save();
|
||||
// Draw the background filling parts not covered by the illustration
|
||||
int saveCount = canvas.save();
|
||||
canvas.translate(0, mForegroundHeight);
|
||||
// Scale the background so its size matches the foreground
|
||||
canvas.scale(mScale, mScale, 0, 0);
|
||||
mBackground.draw(canvas);
|
||||
canvas.restoreToCount(saveCount);
|
||||
canvas.restore();
|
||||
}
|
||||
if (mForeground != null) {
|
||||
canvas.save();
|
||||
// Draw the illustration
|
||||
mForeground.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
super.onDraw(canvas);
|
||||
}
|
||||
}
|
||||
|
@@ -28,10 +28,10 @@ import android.view.WindowInsets;
|
||||
import android.widget.ListView;
|
||||
|
||||
/**
|
||||
* This class provides sticky header functionality in a list view, to use with SetupWizardHeader.
|
||||
* To use this, add a header tagged with "sticky", or a header tagged with "stickyContainer" and
|
||||
* one of its child tagged as "sticky". The sticky container will be draw when the sticky element
|
||||
* hits the top of the view.
|
||||
* This class provides sticky header functionality in a list view, to use with
|
||||
* SetupWizardIllustration. To use this, add a header tagged with "sticky", or a header tagged with
|
||||
* "stickyContainer" and one of its child tagged as "sticky". The sticky container will be drawn
|
||||
* when the sticky element hits the top of the view.
|
||||
*
|
||||
* There are a few things to note:
|
||||
* 1. The two supported scenarios are StickyHeaderListView -> Header (stickyContainer) -> sticky,
|
||||
@@ -41,7 +41,7 @@ import android.widget.ListView;
|
||||
* 3. If fitsSystemWindows is true, then this will offset the sticking position by the height of
|
||||
* the system decorations at the top of the screen.
|
||||
*
|
||||
* @see com.google.android.setupwizard.util.SetupWizardHeader
|
||||
* @see SetupWizardIllustration
|
||||
* @see com.google.android.setupwizard.util.StickyHeaderScrollView
|
||||
*
|
||||
* Copied from com.google.android.setupwizard.util.StickyHeaderListView
|
||||
|
Reference in New Issue
Block a user