AI 143762: Fix for issue 1636784: Landscape only option for the browser.  (This change is in master.)  Add an option in the settings menu of the browser to give the user the option of always displaying in landscape, ignoring sensor/opening and closing of the keyboard.
  BUG=1636784

Automated import of CL 143762
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 98142ac..82e4602 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -282,6 +282,10 @@
     <string name="pref_content_autofit">Auto-fit pages</string>
     <!-- Settings summary -->
     <string name="pref_content_autofit_summary">Format Web pages to fit the screen</string>
+    <!-- Settings label for enabling a mode where the browser is always set to landscape mode -->
+    <string name="pref_content_landscape_only">Landscape only display</string>
+    <!-- Settings summary -->
+    <string name="pref_content_landscape_only_summary">Always read pages in the wider, landscape screen orientation</string>
     <!-- Settings screen, section title -->
     <string name="pref_privacy_title">Privacy settings</string>
     <!-- Settings label -->
diff --git a/res/xml/browser_preferences.xml b/res/xml/browser_preferences.xml
index fdfa839..79dfb92 100644
--- a/res/xml/browser_preferences.xml
+++ b/res/xml/browser_preferences.xml
@@ -54,6 +54,12 @@
                 android:summary="@string/pref_content_autofit_summary" />  
 
         <CheckBoxPreference
+                android:key="landscape_only"
+                android:defaultValue="false"
+                android:title="@string/pref_content_landscape_only"
+                android:summary="@string/pref_content_landscape_only_summary" />
+
+        <CheckBoxPreference
                 android:key="enable_javascript"
                 android:defaultValue="true"
                 android:title="@string/pref_content_javascript" />     
diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java
index 0e2c5af..39f1d7f 100644
--- a/src/com/android/browser/BrowserSettings.java
+++ b/src/com/android/browser/BrowserSettings.java
@@ -70,6 +70,7 @@
     private String homeUrl = "http://www.google.com/m?client=ms-";
     private boolean loginInitialized = false;
     private boolean autoFitPage = true;
+    private boolean landscapeOnly = false;
     private boolean showDebugSettings = false;
 
     // Development settings
@@ -237,6 +238,14 @@
         textSize = WebSettings.TextSize.valueOf(
                 p.getString(PREF_TEXT_SIZE, textSize.name()));
         autoFitPage = p.getBoolean("autofit_pages", autoFitPage);
+        boolean landscapeOnlyTemp =
+                p.getBoolean("landscape_only", landscapeOnly);
+        if (landscapeOnlyTemp != landscapeOnly) {
+            landscapeOnly = landscapeOnlyTemp;
+            mTabControl.getBrowserActivity().setRequestedOrientation(
+                    landscapeOnly ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
+                    : ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
+        }
         useWideViewPort = true; // use wide view port for either setting
         if (autoFitPage) {
             layoutAlgorithm = WebSettings.LayoutAlgorithm.NARROW_COLUMNS;