Bug 1095278 - Part 1: Assume new tablet UI. r=rnewman, a=sledru
authorMichael Comella <michael.l.comella@gmail.com>
Mon, 15 Dec 2014 18:23:25 +0000
changeset 242672 ce13de5c49b4388746661950644e202930ee3ed7
parent 242671 aaa8e2cd46e462e417c575691ad70e6df19a34fb
child 242673 2c0fdd936e83d8ccf3c773ba4e4b247c965171e2
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman, sledru
bugs1095278
milestone36.0a2
Bug 1095278 - Part 1: Assume new tablet UI. r=rnewman, a=sledru
mobile/android/base/NewTabletUI.java
mobile/android/base/preferences/GeckoPreferences.java
mobile/android/base/resources/xml/preferences_display.xml
mobile/android/base/tests/StringHelper.java
mobile/android/base/tests/testSettingsMenuItems.java
--- a/mobile/android/base/NewTabletUI.java
+++ b/mobile/android/base/NewTabletUI.java
@@ -1,34 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko;
 
 import android.content.Context;
-import android.content.SharedPreferences;
 
-import org.mozilla.gecko.AppConstants;
-import org.mozilla.gecko.preferences.GeckoPreferences;
+import org.mozilla.gecko.mozglue.RobocopTarget;
 import org.mozilla.gecko.util.HardwareUtils;
 
+@RobocopTarget
 public class NewTabletUI {
-    // This value should be in sync with preferences_display.xml. On non-release
-    // builds, the preference UI will be hidden and the (unused) default
-    // preference UI value will still be 'true'.
-    private static final boolean DEFAULT = !AppConstants.RELEASE_BUILD;
-
-    private static Boolean sNewTabletUI;
-
-    public static synchronized boolean isEnabled(Context context) {
-        if (!HardwareUtils.isTablet()) {
-            return false;
-        }
-
-        if (sNewTabletUI == null) {
-            final SharedPreferences prefs = GeckoSharedPrefs.forApp(context);
-            sNewTabletUI = prefs.getBoolean(GeckoPreferences.PREFS_NEW_TABLET_UI, DEFAULT);
-        }
-
-        return sNewTabletUI;
+    public static boolean isEnabled(final Context context) {
+        return HardwareUtils.isTablet();
     }
-}
\ No newline at end of file
+}
--- a/mobile/android/base/preferences/GeckoPreferences.java
+++ b/mobile/android/base/preferences/GeckoPreferences.java
@@ -124,17 +124,16 @@ OnSharedPreferenceChangeListener
 
     private static final String ACTION_STUMBLER_UPLOAD_PREF = AppConstants.ANDROID_PACKAGE_NAME + ".STUMBLER_PREF";
 
     // This isn't a Gecko pref, even if it looks like one.
     private static final String PREFS_BROWSER_LOCALE = "locale";
 
     public static final String PREFS_RESTORE_SESSION = NON_PREF_PREFIX + "restoreSession3";
     public static final String PREFS_SUGGESTED_SITES = NON_PREF_PREFIX + "home_suggested_sites";
-    public static final String PREFS_NEW_TABLET_UI = NON_PREF_PREFIX + "new_tablet_ui";
 
     // These values are chosen to be distinct from other Activity constants.
     private static final int REQUEST_CODE_PREF_SCREEN = 5;
     private static final int RESULT_CODE_EXIT_SETTINGS = 6;
 
     // Result code used when a locale preference changes.
     // Callers can recognize this code to refresh themselves to
     // accommodate a locale change.
@@ -665,22 +664,16 @@ OnSharedPreferenceChangeListener
                     i--;
                     continue;
                 } else if (AppConstants.RELEASE_BUILD &&
                            PREFS_DISPLAY_REFLOW_ON_ZOOM.equals(key)) {
                     // Remove UI for reflow on release builds.
                     preferences.removePreference(pref);
                     i--;
                     continue;
-                } else if ((AppConstants.RELEASE_BUILD || !HardwareUtils.isTablet()) &&
-                           PREFS_NEW_TABLET_UI.equals(key)) {
-                    // Remove toggle for new tablet UI on release builds and phones.
-                    preferences.removePreference(pref);
-                    i--;
-                    continue;
                 } else if (!AppConstants.MOZ_TELEMETRY_REPORTING &&
                            PREFS_TELEMETRY_ENABLED.equals(key)) {
                     preferences.removePreference(pref);
                     i--;
                     continue;
                 } else if (!AppConstants.MOZ_SERVICES_HEALTHREPORT &&
                            (PREFS_HEALTHREPORT_UPLOAD_ENABLED.equals(key) ||
                             PREFS_HEALTHREPORT_LINK.equals(key))) {
@@ -1009,18 +1002,16 @@ OnSharedPreferenceChangeListener
      */
     @Override
     public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
         if (PREFS_BROWSER_LOCALE.equals(key)) {
             onLocaleSelected(BrowserLocaleManager.getLanguageTag(lastLocale),
                              sharedPreferences.getString(key, null));
         } else if (PREFS_SUGGESTED_SITES.equals(key)) {
             refreshSuggestedSites();
-        } else if (PREFS_NEW_TABLET_UI.equals(key)) {
-            Toast.makeText(this, R.string.new_tablet_restart, Toast.LENGTH_SHORT).show();
         }
     }
 
     public interface PrefHandler {
         // Allows the pref to do any initialization it needs. Return false to have the pref removed
         // from the prefs screen entirely.
         public boolean setupPref(Context context, Preference pref);
         public void onChange(Context context, Preference pref, Object newValue);
--- a/mobile/android/base/resources/xml/preferences_display.xml
+++ b/mobile/android/base/resources/xml/preferences_display.xml
@@ -24,20 +24,16 @@
     <CheckBoxPreference android:key="browser.chrome.dynamictoolbar"
                         android:title="@string/pref_scroll_title_bar2"
                         android:summary="@string/pref_scroll_title_bar_summary" />
 
     <CheckBoxPreference android:key="media.autoplay.enabled"
                         android:title="@string/pref_media_autoplay_enabled"
                         android:summary="@string/pref_media_autoplay_enabled_summary" />
 
-    <CheckBoxPreference android:key="android.not_a_preference.new_tablet_ui"
-                        android:title="@string/new_tablet_pref"
-                        android:defaultValue="true" />
-
     <PreferenceCategory android:title="@string/pref_category_advanced">
 
         <CheckBoxPreference
                         android:key="browser.zoom.reflowOnZoom"
                         android:title="@string/pref_reflow_on_zoom"
                         android:defaultValue="false"
                         android:persistent="false" />
 
--- a/mobile/android/base/tests/StringHelper.java
+++ b/mobile/android/base/tests/StringHelper.java
@@ -162,17 +162,16 @@ public class StringHelper {
     public static final String SYNC_LABEL = "Sync";
     public static final String IMPORT_FROM_ANDROID_LABEL = "Import from Android";
     public static final String TABS_LABEL = "Tabs";
 
     // Display
     public static final String TEXT_SIZE_LABEL = "Text size";
     public static final String TITLE_BAR_LABEL = "Title bar";
     public static final String SCROLL_TITLE_BAR_LABEL = "Full-screen browsing";
-    public static final String NEW_TABLET_UI = "Enable new tablet UI";
     public static final String TEXT_REFLOW_LABEL = "Text reflow";
     public static final String CHARACTER_ENCODING_LABEL = "Character encoding";
     public static final String PLUGINS_LABEL = "Plugins";
 
     // Title bar
     public static final String SHOW_PAGE_TITLE_LABEL = "Show page title";
     public static final String SHOW_PAGE_ADDRESS_LABEL = "Show page address";
 
--- a/mobile/android/base/tests/testSettingsMenuItems.java
+++ b/mobile/android/base/tests/testSettingsMenuItems.java
@@ -154,24 +154,18 @@ public class testSettingsMenuItems exten
      */
     public void updateConditionalSettings(Map<String[], List<String[]>> settingsMap) {
         // Preferences dependent on RELEASE_BUILD
         if (!AppConstants.RELEASE_BUILD) {
             // Text reflow - only built if *not* release build
             String[] textReflowUi = { StringHelper.TEXT_REFLOW_LABEL };
             settingsMap.get(PATH_DISPLAY).add(textReflowUi);
 
-            // New tablet UI can only be enabled on tablets in non-release builds.
+            // Tablet: we don't allow a page title option.
             if (HardwareUtils.isTablet()) {
-                String[] newTabletUi = { StringHelper.NEW_TABLET_UI };
-                settingsMap.get(PATH_DISPLAY).add(newTabletUi);
-            }
-
-            // New tablet UI: we don't allow a page title option.
-            if (NewTabletUI.isEnabled(getActivity())) {
                 settingsMap.get(PATH_DISPLAY).remove(TITLE_BAR_LABEL_ARR);
             }
 
             if (AppConstants.MOZ_STUMBLER_BUILD_TIME_ENABLED) {
                 // Anonymous cell tower/wifi collection
                 String[] networkReportingUi = { "Mozilla Location Service", "Shares approximate Wi-Fi and cellular location of your device with Mozilla to improve our geolocation service" };
                 settingsMap.get(PATH_MOZILLA).add(networkReportingUi);