Enable orientation in SetupWizard

Change-Id: I45e30c652feab1d30c4f0379379f8ca4e455fa02
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index e559325..9e252cf 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -138,7 +138,6 @@
                   android:theme="@android:style/Theme.Holo.NoActionBar"
                   android:windowBackground="@drawable/setups_bg_default"
                   android:clearTaskOnLaunch="true"
-                  android:screenOrientation="landscape"
                   android:exported="true" />
 
         <activity-alias android:name=".wifi.AdvancedSettings"
diff --git a/res/layout-xlarge-land/date_time_settings_setupwizard.xml b/res/layout-xlarge-land/date_time_settings_setupwizard.xml
new file mode 100644
index 0000000..ee425eb
--- /dev/null
+++ b/res/layout-xlarge-land/date_time_settings_setupwizard.xml
@@ -0,0 +1,168 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 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.
+  -->
+<RelativeLayout
+    android:id="@+id/layout_root"
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:paddingTop="154dip"
+    android:paddingLeft="128dip"
+    android:paddingRight="128dip"
+    android:paddingBottom="96dip">
+
+    <!-- Title: Set date & time-->
+    <TextView
+        android:id="@+id/title"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:minHeight="48dip"
+        android:layout_alignParentLeft="true"
+        android:layout_marginLeft="16dip"
+        android:layout_alignParentTop="true"
+        android:textSize="32dip"
+        android:textColor="#FF99cc00"
+        android:text="@string/date_and_time_settings_title_setup_wizard"
+        android:gravity="bottom" />
+
+    <!-- Divider -->
+    <View
+        android:id="@+id/top_divider"
+        android:layout_width="match_parent"
+        android:layout_height="3dip"
+        android:layout_below="@id/title"
+        android:layout_marginTop="6dip"
+        android:layout_marginBottom="17dip"
+        android:background="@color/divider_color" />
+
+    <RelativeLayout
+        android:id="@+id/timezone_auto_time"
+        android:layout_width="716dip"
+        android:layout_height="wrap_content"
+        android:layout_centerHorizontal="true"
+        android:layout_below="@id/top_divider">
+        <!-- timezone -->
+        <Button
+            android:id="@+id/time_zone_button"
+            style="?android:attr/dropDownSpinnerStyle"
+            android:layout_width="304dip"
+            android:layout_height="48dip"
+            android:layout_alignParentLeft="true"
+            android:layout_alignBottom="@+id/date_time_auto"
+            android:gravity="left|center_vertical"
+            android:textAppearance="?android:attr/textAppearanceMedium"
+            android:textSize="20dip" />
+
+        <LinearLayout
+            android:id="@+id/date_time_auto"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:orientation="vertical"
+            android:layout_toRightOf="@id/time_zone_button"
+            android:layout_marginLeft="32dip"
+            android:layout_alignParentRight="true">
+
+            <Switch
+                android:id="@+id/date_time_auto_button"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:minHeight="?android:attr/listPreferredItemHeight"
+                android:layout_marginLeft="16dip"
+                android:text="@string/date_time_auto"
+                android:textAppearance="?android:attr/textAppearanceMedium"
+                android:textSize="20dip" />
+
+            <!-- Divider -->
+            <View
+                android:layout_width="match_parent"
+                android:layout_height="1px"
+                android:background="@color/divider_color" />
+        </LinearLayout>
+    </RelativeLayout>
+
+    <LinearLayout
+        android:layout_width="624dip"
+        android:layout_height="wrap_content"
+        android:layout_centerHorizontal="true"
+        android:layout_below="@+id/timezone_auto_time"
+        android:layout_marginTop="48dip"
+        android:orientation="horizontal">
+
+        <LinearLayout
+            android:layout_width="312dip"
+            android:layout_height="wrap_content"
+            android:orientation="vertical">
+            <TextView
+                android:id="@+id/date_picker_title"
+                android:layout_width="match_parent"
+                android:layout_height="48dip"
+                android:text="@string/date_picker_title"
+                android:textAppearance="?android:attr/textAppearanceMedium"
+                android:textSize="20dip"
+                android:clickable="false"
+                android:longClickable="false"
+                android:gravity="center" />
+            <DatePicker
+                android:id="@+id/date_picker"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/date_picker_title" />
+        </LinearLayout>
+
+        <!-- divider -->
+        <View
+            android:id="@+id/center_divider"
+            android:layout_width="1dip"
+            android:layout_height="match_parent"
+            android:background="@color/divider_color" />
+
+        <LinearLayout
+            android:layout_width="312dip"
+            android:layout_height="wrap_content"
+            android:orientation="vertical">
+            <TextView
+                android:id="@+id/time_picker_title"
+                android:layout_width="match_parent"
+                android:layout_height="48dip"
+                android:text="@string/time_picker_title"
+                android:textAppearance="?android:attr/textAppearanceMedium"
+                android:textSize="20dip"
+                android:gravity="center" />
+
+            <TimePicker
+                android:id="@+id/time_picker"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/time_picker_title" />
+        </LinearLayout>
+    </LinearLayout>
+
+    <View
+        android:id="@+id/bottom_divider"
+        android:layout_width="match_parent"
+        android:layout_height="3dip"
+        android:layout_alignLeft="@id/timezone_auto_time"
+        android:layout_above="@+id/next_button"
+        android:layout_marginBottom="16dip"
+        android:background="@color/divider_color" />
+
+    <Button
+        android:id="@+id/next_button"
+        style="@style/setup_wizard_button"
+        android:layout_alignParentBottom="true"
+        android:layout_alignParentRight="true"
+        android:text="@string/next_label" />
+</RelativeLayout>
diff --git a/res/layout-xlarge-land/wifi_settings_for_setup_wizard_xl.xml b/res/layout-xlarge-land/wifi_settings_for_setup_wizard_xl.xml
new file mode 100644
index 0000000..78f182d
--- /dev/null
+++ b/res/layout-xlarge-land/wifi_settings_for_setup_wizard_xl.xml
@@ -0,0 +1,177 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 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.
+  -->
+
+<RelativeLayout
+    android:id="@+id/layout_root"
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="horizontal"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:paddingTop="60dip"
+    android:paddingLeft="128dip"
+    android:paddingRight="128dip"
+    android:paddingBottom="0dip" >
+
+    <FrameLayout
+        android:id="@+id/top_padding_layout"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_alignParentTop="true">
+        <!-- Set to gone when software keyboard appears -->
+        <View
+             android:id="@+id/top_padding"
+             android:layout_width="match_parent"
+             android:layout_height="94dip" />
+    </FrameLayout>
+
+    <TextView
+        android:id="@+id/wifi_setup_title"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:minHeight="48dip"
+        android:layout_alignParentLeft="true"
+        android:layout_centerVertical="true"
+        android:layout_marginLeft="16dip"
+        android:layout_below="@id/top_padding_layout"
+        android:textSize="32dip"
+        android:textColor="#ff99cc00"
+        android:text="@string/wifi_setup_title"
+        android:gravity="bottom"/>
+
+    <!-- Divider -->
+    <RelativeLayout
+        android:id="@+id/top_divider"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_below="@id/wifi_setup_title">
+        <ProgressBar
+            android:id="@+id/scanning_progress_bar"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            style="?android:attr/progressBarStyleHorizontal" />
+    </RelativeLayout>
+
+    <RelativeLayout
+        android:id="@+id/content"
+        android:layout_width="716dip"
+        android:layout_height="wrap_content"
+        android:layout_below="@id/top_divider"
+        android:layout_centerHorizontal="true"
+        android:layout_marginTop="10dip"
+        android:layout_marginBottom="0dip">
+
+        <FrameLayout
+            android:id="@+id/wifi_setup"
+            android:layout_width="match_parent"
+            android:layout_height="360dip">
+            <fragment
+                class="com.android.settings.wifi.WifiSettings"
+                android:id="@+id/wifi_setup_fragment"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content" />
+        </FrameLayout>
+        <FrameLayout
+            android:id="@+id/wifi_config_ui"
+            android:layout_width="wrap_content"
+            android:minWidth="406dip"
+            android:layout_height="wrap_content"
+            android:minHeight="160dip"
+            android:layout_alignParentLeft="true"
+            android:visibility="gone" />
+        <View
+            android:id="@+id/wifi_config_padding"
+            android:layout_width="match_parent"
+            android:layout_height="360dip"
+            android:visibility="gone" />
+        <LinearLayout
+            android:id="@+id/connecting_status_layout"
+            android:layout_width="match_parent"
+            android:layout_height="360dip"
+            android:visibility="gone">
+            <TextView
+                android:id="@+id/connecting_status"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:lineSpacingExtra="10dip"
+                android:inputType="textMultiLine"
+                android:textAppearance="?android:attr/textAppearanceMedium"
+                android:textSize="20sp"
+                android:clickable="false"
+                android:longClickable="false" />
+        </LinearLayout>
+
+    </RelativeLayout>
+
+    <!-- Divider -->
+    <View
+        android:id="@+id/bottom_divider"
+        android:layout_width="match_parent"
+        android:layout_height="3dip"
+        android:layout_marginBottom="16dip"
+        android:layout_below="@id/content"
+        android:layout_alignLeft="@id/content"
+        android:background="@color/divider_color" />  <!-- TODO: fix this -->
+
+    <RelativeLayout
+        android:id="@+id/bottom_buttons"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_below="@id/bottom_divider"
+        android:layout_alignLeft="@id/bottom_divider"
+        android:layout_alignParentRight="true"
+        android:layout_alignParentBottom="true">
+
+        <Button
+            android:id="@+id/wifi_setup_add_network"
+            style="@style/setup_wizard_button"
+            android:layout_alignParentLeft="true"
+            android:text="@string/wifi_setup_add_network"
+            android:enabled="false" />
+
+        <LinearLayout
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignParentRight="true"
+            android:orientation="horizontal">
+
+            <!-- This misleading name is for keeping consistency between non-XL
+                 layouts -->
+            <Button android:id="@+id/wifi_setup_cancel"
+                    style="@style/setup_wizard_button"
+                    android:text="@string/wifi_setup_back"
+                    android:visibility="gone" />
+
+            <Button android:id="@+id/wifi_setup_connect"
+                    style="@style/setup_wizard_button"
+                    android:layout_marginLeft="16dip"
+                    android:text="@string/wifi_setup_connect"
+                    android:enabled="false"
+                    android:visibility="gone" />
+
+            <Button android:id="@+id/wifi_setup_refresh_list"
+                    style="@style/setup_wizard_button"
+                    android:layout_marginLeft="16dip"
+                    android:text="@string/wifi_setup_refresh_list"
+                    android:enabled="false" />
+
+            <Button android:id="@+id/wifi_setup_skip_or_next"
+                    style="@style/setup_wizard_button"
+                    android:layout_marginLeft="16dip"
+                    android:text="@string/wifi_setup_skip"
+                    android:enabled="false" />
+        </LinearLayout>
+    </RelativeLayout>
+</RelativeLayout>
diff --git a/res/layout-xlarge/date_time_settings_setupwizard.xml b/res/layout-xlarge/date_time_settings_setupwizard.xml
index ee425eb..479e3fd 100644
--- a/res/layout-xlarge/date_time_settings_setupwizard.xml
+++ b/res/layout-xlarge/date_time_settings_setupwizard.xml
@@ -20,8 +20,8 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:paddingTop="154dip"
-    android:paddingLeft="128dip"
-    android:paddingRight="128dip"
+    android:paddingLeft="24dip"
+    android:paddingRight="24dip"
     android:paddingBottom="96dip">
 
     <!-- Title: Set date & time-->
diff --git a/res/layout-xlarge/wifi_settings_for_setup_wizard_xl.xml b/res/layout-xlarge/wifi_settings_for_setup_wizard_xl.xml
index 8926eee..dd76e70 100644
--- a/res/layout-xlarge/wifi_settings_for_setup_wizard_xl.xml
+++ b/res/layout-xlarge/wifi_settings_for_setup_wizard_xl.xml
@@ -21,8 +21,8 @@
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:paddingTop="60dip"
-    android:paddingLeft="128dip"
-    android:paddingRight="128dip"
+    android:paddingLeft="24dip"
+    android:paddingRight="24dip"
     android:paddingBottom="0dip" >
 
     <FrameLayout
diff --git a/src/com/android/settings/DateTimeSettingsSetupWizard.java b/src/com/android/settings/DateTimeSettingsSetupWizard.java
index c3d3bfd..08c0227 100644
--- a/src/com/android/settings/DateTimeSettingsSetupWizard.java
+++ b/src/com/android/settings/DateTimeSettingsSetupWizard.java
@@ -95,8 +95,6 @@
         mAutoTimeZoneButton.setText(autoTimeZoneEnabled ? R.string.zone_auto_summaryOn :
                 R.string.zone_auto_summaryOff);*/
 
-        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
-
         final TimeZone tz = TimeZone.getDefault();
         mSelectedTimeZone = tz;
         mTimeZoneButton = (Button)findViewById(R.id.time_zone_button);
diff --git a/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java b/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java
index 648a9fe..b619145 100644
--- a/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java
+++ b/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java
@@ -21,6 +21,7 @@
 import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
+import android.content.res.Configuration;
 import android.net.NetworkInfo.DetailedState;
 import android.net.wifi.WifiConfiguration;
 import android.net.wifi.WifiManager;
@@ -670,7 +671,8 @@
      * Replace the current background with a new background whose id is resId if needed.
      */
     private void trySetBackground(int resId) {
-        if (mBackgroundId != resId) {
+        final int orientation = getResources().getConfiguration().orientation;
+        if (orientation == Configuration.ORIENTATION_LANDSCAPE && mBackgroundId != resId) {
             getWindow().setBackgroundDrawable(getResources().getDrawable(resId));
             mBackgroundId = resId;
         }