Backed out 3 changesets (bug 910189) for breaking android builds

Backed out changeset 119e40b61023 (bug 910189)
Backed out changeset 1c778892acc6 (bug 910189)
Backed out changeset 96816b5d7299 (bug 910189)
This commit is contained in:
Wes Kocher 2013-12-19 17:10:26 -08:00
Родитель f6d32a33ed
Коммит 994f51b53f
11 изменённых файлов: 68 добавлений и 180 удалений

Просмотреть файл

@ -73,9 +73,6 @@
<!ENTITY pref_category_datareporting "Data choices">
<!ENTITY pref_category_installed_search_engines "Installed search engines">
<!ENTITY pref_category_add_search_providers "Add more search providers">
<!ENTITY pref_category_search_restore_defaults "Restore search engines">
<!ENTITY pref_search_restore_defaults "Restore defaults">
<!ENTITY pref_search_restore_defaults_summary "Restore defaults">
<!-- Localization note (pref_search_tip) : "TIP" as in "hint", "clue" etc. Displayed as an
advisory message on the customise search providers settings page explaining how to add new
search providers.-->

Просмотреть файл

@ -5,12 +5,9 @@
package org.mozilla.gecko.preferences;
import java.lang.reflect.Field;
import org.mozilla.gecko.R;
import org.mozilla.gecko.PrefsHelper;
import android.app.Activity;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory;
@ -18,10 +15,6 @@ import android.preference.PreferenceFragment;
import android.preference.PreferenceScreen;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.ViewConfiguration;
/* A simple implementation of PreferenceFragment for large screen devices
* This will strip category headers (so that they aren't shown to the user twice)
@ -35,14 +28,23 @@ public class GeckoPreferenceFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String resourceName = getArguments().getString("resource");
int res = getResource();
// Display a menu for Search preferences.
if (res == R.xml.preferences_search) {
setHasOptionsMenu(true);
int res = 0;
if (resourceName != null) {
// Fetch resource id by resource name.
res = getActivity().getResources().getIdentifier(resourceName,
"xml",
getActivity().getPackageName());
}
if (res == 0) {
// The resource was invalid. Use the default resource.
Log.e(LOGTAG, "Failed to find resource: " + resourceName + ". Displaying default settings.");
boolean isMultiPane = ((PreferenceActivity) getActivity()).onIsMultiPane();
res = isMultiPane ? R.xml.preferences_customize_tablet : R.xml.preferences;
}
addPreferencesFromResource(res);
PreferenceScreen screen = getPreferenceScreen();
@ -50,39 +52,6 @@ public class GeckoPreferenceFragment extends PreferenceFragment {
mPrefsRequestId = ((GeckoPreferences)getActivity()).setupPreferences(screen);
}
/*
* Get the resource from Fragment arguments and return it.
*
* If no resource can be found, return the resource id of the default preference screen.
*/
private int getResource() {
int resid = 0;
String resourceName = getArguments().getString("resource");
if (resourceName != null) {
// Fetch resource id by resource name.
resid = getActivity().getResources().getIdentifier(resourceName,
"xml",
getActivity().getPackageName());
}
if (resid == 0) {
// The resource was invalid. Use the default resource.
Log.e(LOGTAG, "Failed to find resource: " + resourceName + ". Displaying default settings.");
boolean isMultiPane = ((PreferenceActivity) getActivity()).onIsMultiPane();
resid = isMultiPane ? R.xml.preferences_customize_tablet : R.xml.preferences;
}
return resid;
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.preferences_search_menu, menu);
}
@Override
public void onDestroy() {
super.onDestroy();
@ -90,29 +59,4 @@ public class GeckoPreferenceFragment extends PreferenceFragment {
PrefsHelper.removeObserver(mPrefsRequestId);
}
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
showOverflowMenu(activity);
}
/*
* Force the overflow 3-dot menu to be displayed if it isn't already displayed.
*
* This is an ugly hack for 4.0+ Android devices that don't have a dedicated menu button
* because Android does not provide a public API to display the ActionBar overflow menu.
*/
private void showOverflowMenu(Activity activity) {
try {
ViewConfiguration config = ViewConfiguration.get(activity);
Field menuOverflow = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
if (menuOverflow != null) {
menuOverflow.setAccessible(true);
menuOverflow.setBoolean(config, false);
}
} catch (Exception e) {
Log.d(LOGTAG, "Failed to force overflow menu, ignoring.");
}
}
}

Просмотреть файл

@ -77,9 +77,7 @@ public class GeckoPreferences
private boolean mInitialized = false;
private int mPrefsRequestId = 0;
// These match keys in resources/xml*/preferences*.xml
private static String PREFS_SEARCH_RESTORE_DEFAULTS = NON_PREF_PREFIX + "search.restore_defaults";
// These match keys in resources/xml/preferences.xml.in.
private static String PREFS_ANNOUNCEMENTS_ENABLED = NON_PREF_PREFIX + "privacy.announcements.enabled";
private static String PREFS_DATA_REPORTING_PREFERENCES = NON_PREF_PREFIX + "datareporting.preferences";
private static String PREFS_TELEMETRY_ENABLED = "datareporting.telemetry.enabled";
@ -391,14 +389,6 @@ public class GeckoPreferences
preferences.removePreference(pref);
i--;
continue;
} else if (PREFS_SEARCH_RESTORE_DEFAULTS.equals(key)) {
pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
GeckoPreferences.this.restoreDefaultSearchEngines();
return true;
}
});
}
// Some Preference UI elements are not actually preferences,
@ -414,31 +404,14 @@ public class GeckoPreferences
}
}
/**
* Restore default search engines in Gecko and retrigger a search engine refresh.
*/
protected void restoreDefaultSearchEngines() {
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("SearchEngines:RestoreDefaults", null));
// Send message to Gecko to get engines. SearchPreferenceCategory listens for the response.
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("SearchEngines:GetVisible", null));
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();
switch (itemId) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
}
// Generated R.id.* apparently aren't constant expressions, so they can't be switched.
if (itemId == R.id.restore_defaults) {
restoreDefaultSearchEngines();
return true;
}
return super.onOptionsItemSelected(item);
}

Просмотреть файл

@ -40,6 +40,8 @@ public class SearchEnginePreference extends Preference implements View.OnLongCli
// Specifies if this engine is configured as the default search engine.
private boolean mIsDefaultEngine;
// Specifies if this engine is one of the ones bundled with the app, which cannot be deleted.
private boolean mIsImmutableEngine;
// Dialog element labels.
private String[] mDialogItems;
@ -119,7 +121,12 @@ public class SearchEnginePreference extends Preference implements View.OnLongCli
public void setSearchEngineFromJSON(JSONObject geckoEngineJSON) throws JSONException {
final String engineName = geckoEngineJSON.getString("name");
final SpannableString titleSpannable = new SpannableString(engineName);
mIsImmutableEngine = geckoEngineJSON.getBoolean("immutable");
if (mIsImmutableEngine) {
// Delete the "Remove" option from the menu.
mDialogItems = new String[] { getContext().getResources().getString(R.string.pref_search_set_default) };
}
setTitle(titleSpannable);
final String iconURI = geckoEngineJSON.getString("iconURI");
@ -169,6 +176,11 @@ public class SearchEnginePreference extends Preference implements View.OnLongCli
return;
}
// If we are both default and immutable, we have no enabled items to show on the menu - abort.
if (mIsDefaultEngine && mIsImmutableEngine) {
return;
}
final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(getTitle().toString());
builder.setItems(mDialogItems, new DialogInterface.OnClickListener() {

Просмотреть файл

@ -43,19 +43,18 @@ public class SearchPreferenceCategory extends PreferenceCategory implements Geck
// Ensures default engine remains at top of list.
setOrderingAsAdded(true);
// Register for SearchEngines messages and request list of search engines from Gecko.
// Request list of search engines from Gecko.
GeckoAppShell.registerEventListener("SearchEngines:Data", this);
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("SearchEngines:GetVisible", null));
}
@Override
protected void onPrepareForRemoval() {
GeckoAppShell.unregisterEventListener("SearchEngines:Data", this);
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("SearchEngines:Get", null));
}
@Override
public void handleMessage(String event, final JSONObject data) {
if (event.equals("SearchEngines:Data")) {
// We are no longer interested in this event from Gecko, as we do not request it again with
// this instance.
GeckoAppShell.unregisterEventListener("SearchEngines:Data", this);
// Parse engines array from JSON.
JSONArray engines;
try {
@ -65,9 +64,6 @@ public class SearchPreferenceCategory extends PreferenceCategory implements Geck
return;
}
// Clear the preferences category from this thread.
this.removeAll();
// Create an element in this PreferenceCategory for each engine.
for (int i = 0; i < engines.length(); i++) {
try {

Просмотреть файл

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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/. -->
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/restore_defaults"
android:title="@string/pref_search_restore_defaults" />
</menu>

Просмотреть файл

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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/. -->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:gecko="http://schemas.android.com/apk/res-auto"
android:title="@string/pref_category_search"
android:enabled="false">
<CheckBoxPreference android:key="browser.search.suggest.enabled"
android:title="@string/pref_search_suggestions"
android:defaultValue="false"
android:persistent="false" />
<org.mozilla.gecko.preferences.SearchPreferenceCategory
android:title="@string/pref_category_installed_search_engines"/>
<PreferenceCategory android:title="@string/pref_category_add_search_providers">
<Preference android:layout="@layout/preference_search_tip"
android:enabled="false"
android:selectable="false"/>
</PreferenceCategory>
</PreferenceScreen>

Просмотреть файл

@ -16,13 +16,6 @@
<org.mozilla.gecko.preferences.SearchPreferenceCategory
android:title="@string/pref_category_installed_search_engines"/>
<PreferenceCategory android:title="@string/pref_category_search_restore_defaults">
<Preference android:key="android.not_a_preference.search.restore_defaults"
android:title="@string/pref_search_restore_defaults_summary" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_category_add_search_providers">
<Preference android:layout="@layout/preference_search_tip"

Просмотреть файл

@ -89,11 +89,7 @@
<string name="pref_category_datareporting">&pref_category_datareporting;</string>
<string name="pref_category_installed_search_engines">&pref_category_installed_search_engines;</string>
<string name="pref_category_add_search_providers">&pref_category_add_search_providers;</string>
<string name="pref_category_search_restore_defaults">&pref_category_search_restore_defaults;</string>
<string name="pref_search_restore_defaults">&pref_search_restore_defaults;</string>
<string name="pref_search_restore_defaults_summary">&pref_search_restore_defaults_summary;</string>
<string name="pref_search_tip">&pref_search_tip;</string>
<string name="pref_category_devtools">&pref_category_devtools;</string>
<string name="pref_developer_remotedebugging">&pref_developer_remotedebugging;</string>
<string name="pref_developer_remotedebugging_docs">&pref_developer_remotedebugging_docs;</string>

Просмотреть файл

@ -159,7 +159,7 @@ public class testDistribution extends ContentProviderTest {
private void checkSearchPlugin() {
Actions.RepeatedEventExpecter eventExpecter = mActions.expectGeckoEvent("SearchEngines:Data");
mActions.sendGeckoEvent("SearchEngines:GetVisible", null);
mActions.sendGeckoEvent("SearchEngines:Get", null);
try {
JSONObject data = new JSONObject(eventExpecter.blockForEventData());

Просмотреть файл

@ -6608,10 +6608,10 @@ var SearchEngines = {
init: function init() {
Services.obs.addObserver(this, "SearchEngines:Add", false);
Services.obs.addObserver(this, "SearchEngines:Get", false);
Services.obs.addObserver(this, "SearchEngines:GetVisible", false);
Services.obs.addObserver(this, "SearchEngines:Remove", false);
Services.obs.addObserver(this, "SearchEngines:RestoreDefaults", false);
Services.obs.addObserver(this, "SearchEngines:SetDefault", false);
Services.obs.addObserver(this, "SearchEngines:Remove", false);
let filter = {
matches: function (aElement) {
@ -6651,28 +6651,37 @@ var SearchEngines = {
uninit: function uninit() {
Services.obs.removeObserver(this, "SearchEngines:Add");
Services.obs.removeObserver(this, "SearchEngines:Get");
Services.obs.removeObserver(this, "SearchEngines:GetVisible");
Services.obs.removeObserver(this, "SearchEngines:Remove");
Services.obs.removeObserver(this, "SearchEngines:RestoreDefaults");
Services.obs.removeObserver(this, "SearchEngines:SetDefault");
Services.obs.removeObserver(this, "SearchEngines:Remove");
if (this._contextMenuId != null)
NativeWindow.contextmenus.remove(this._contextMenuId);
},
// Fetch list of search engines. all ? All engines : Visible engines only.
_handleSearchEnginesGetVisible: function _handleSearchEnginesGetVisible(rv, all) {
_handleSearchEnginesGet: function _handleSearchEnginesGet(rv, all) {
if (!Components.isSuccessCode(rv)) {
Cu.reportError("Could not initialize search service, bailing out.");
return;
}
let engineData;
if (all) {
engineData = Services.search.getEngines({});
} else {
engineData = Services.search.getVisibleEngines({});
}
// These engines are the bundled ones - they may not be uninstalled.
let immutableEngines = Services.search.getDefaultEngines();
let engineData = Services.search.getVisibleEngines({});
let searchEngines = engineData.map(function (engine) {
return {
name: engine.name,
identifier: engine.identifier,
iconURI: (engine.iconURI ? engine.iconURI.spec : null),
hidden: engine.hidden
hidden: engine.hidden,
immutable: immutableEngines.indexOf(engine) != -1
};
});
@ -6709,6 +6718,13 @@ var SearchEngines = {
} catch (e) {}
},
_handleSearchEnginesGetAll: function _handleSearchEnginesGetAll(rv) {
this._handleSearchEnginesGet(rv, true);
},
_handleSearchEnginesGetVisible: function _handleSearchEnginesGetVisible(rv) {
this._handleSearchEnginesGet(rv, false)
},
// Helper method to extract the engine name from a JSON. Simplifies the observe function.
_extractEngineFromJSON: function _extractEngineFromJSON(aData) {
let data = JSON.parse(aData);
@ -6724,16 +6740,9 @@ var SearchEngines = {
case "SearchEngines:GetVisible":
Services.search.init(this._handleSearchEnginesGetVisible.bind(this));
break;
case "SearchEngines:Remove":
// Make sure the engine isn't hidden before removing it, to make sure it's
// visible if the user later re-adds it (works around bug 341833)
engine = this._extractEngineFromJSON(aData);
engine.hidden = false;
Services.search.removeEngine(engine);
break;
case "SearchEngines:RestoreDefaults":
// Un-hides all default engines.
Services.search.restoreDefaultEngines();
case "SearchEngines:Get":
// Return a list of all engines, including "Hidden" ones.
Services.search.init(this._handleSearchEnginesGetAll.bind(this));
break;
case "SearchEngines:SetDefault":
engine = this._extractEngineFromJSON(aData);
@ -6741,7 +6750,13 @@ var SearchEngines = {
Services.search.moveEngine(engine, 0);
Services.search.defaultEngine = engine;
break;
case "SearchEngines:Remove":
// Make sure the engine isn't hidden before removing it, to make sure it's
// visible if the user later re-adds it (works around bug 341833)
engine = this._extractEngineFromJSON(aData);
engine.hidden = false;
Services.search.removeEngine(engine);
break;
default:
dump("Unexpected message type observed: " + aTopic);
break;