зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1065123 - Don't crash if the default engine isn't found. r=nalexander
This commit is contained in:
Родитель
4dc874dcbd
Коммит
119f41aa64
|
@ -16,11 +16,10 @@ package org.mozilla.search;
|
|||
*/
|
||||
public class Constants {
|
||||
|
||||
public static final String POSTSEARCH_FRAGMENT = "org.mozilla.search.POSTSEARCH_FRAGMENT";
|
||||
public static final String PRESEARCH_FRAGMENT = "org.mozilla.search.PRESEARCH_FRAGMENT";
|
||||
public static final String SEARCH_FRAGMENT = "org.mozilla.search.SEARCH_FRAGMENT";
|
||||
|
||||
public static final int SUGGESTION_MAX = 5;
|
||||
|
||||
public static final String ABOUT_BLANK = "about:blank";
|
||||
|
||||
// TODO: Localize this with region.properties (or a similar solution). See bug 1065306.
|
||||
public static final String DEFAULT_ENGINE_IDENTIFIER = "yahoo";
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ public class SearchPreferenceActivity extends PreferenceActivity
|
|||
searchEnginePref.setEntryValues(entryValues);
|
||||
|
||||
if (searchEnginePref.getValue() == null) {
|
||||
searchEnginePref.setValue(getResources().getString(R.string.default_engine_identifier));
|
||||
searchEnginePref.setValue(Constants.DEFAULT_ENGINE_IDENTIFIER);
|
||||
}
|
||||
searchEnginePref.setSummary(searchEnginePref.getEntry());
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.mozilla.gecko.AppConstants;
|
|||
import org.mozilla.gecko.BrowserLocaleManager;
|
||||
import org.mozilla.gecko.GeckoSharedPrefs;
|
||||
import org.mozilla.gecko.util.GeckoJarReader;
|
||||
import org.mozilla.search.Constants;
|
||||
import org.mozilla.search.R;
|
||||
import org.mozilla.search.SearchPreferenceActivity;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
@ -96,16 +97,24 @@ public class SearchEngineManager implements SharedPreferences.OnSharedPreference
|
|||
}
|
||||
}
|
||||
|
||||
identifier = context.getResources().getString(R.string.default_engine_identifier);
|
||||
return createEngine(identifier);
|
||||
try {
|
||||
return createEngine(Constants.DEFAULT_ENGINE_IDENTIFIER);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.e(LOG_TAG, "Exception creating search engine from default identifier. " +
|
||||
"This will happen if the locale doesn't contain the default search plugin.", e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(SearchEngine engine) {
|
||||
// Only touch engine on the main thread.
|
||||
SearchEngineManager.this.engine = engine;
|
||||
if (callback != null) {
|
||||
callback.execute(engine);
|
||||
if (engine != null) {
|
||||
// Only touch engine on the main thread.
|
||||
SearchEngineManager.this.engine = engine;
|
||||
if (callback != null) {
|
||||
callback.execute(engine);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -23,9 +23,5 @@
|
|||
|
||||
<!ENTITY search_widget_button_label 'Search'>
|
||||
|
||||
<!-- Localization note (default_engine_identifier): Search engine identifier for the default
|
||||
engine. This should be one of the identifiers listed in /searchplugins/list.txt -->
|
||||
<!ENTITY default_engine_identifier 'yahoo'>
|
||||
|
||||
<!ENTITY network_error_title 'No internet connection'>
|
||||
<!ENTITY network_error_message 'Tap here to check your network settings'>
|
||||
|
|
|
@ -18,7 +18,5 @@
|
|||
<string name="search_widget_name">&search_app_name;</string>
|
||||
<string name="search_widget_button_label">&search_widget_button_label;</string>
|
||||
|
||||
<string name="default_engine_identifier">&default_engine_identifier;</string>
|
||||
|
||||
<string name="network_error_title">&network_error_title;</string>
|
||||
<string name="network_error_message">&network_error_message;</string>
|
||||
|
|
Загрузка…
Ссылка в новой задаче