Bug 1095278 - Part 1: assume new tablet UI. r=rnewman

This commit is contained in:
Michael Comella 2014-12-15 18:23:25 +00:00
parent 0fd52a5906
commit 639a6fc37d
5 changed files with 6 additions and 43 deletions

View File

@ -5,30 +5,13 @@
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();
}
}
}

View File

@ -132,7 +132,6 @@ OnSharedPreferenceChangeListener
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;
@ -673,12 +672,6 @@ OnSharedPreferenceChangeListener
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.NIGHTLY_BUILD &&
(PREFS_TRACKING_PROTECTION.equals(key) ||
PREFS_TRACKING_PROTECTION_LEARN_MORE.equals(key))) {
@ -1018,8 +1011,6 @@ OnSharedPreferenceChangeListener
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();
}
}

View File

@ -23,10 +23,6 @@
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

View File

@ -167,7 +167,6 @@ public class StringHelper {
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";

View File

@ -160,14 +160,8 @@ public class testSettingsMenuItems extends PixelTest {
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);
}