mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1007523 - Add UI telemetry for managing search engines. r=liuche
This commit is contained in:
parent
6b4e192114
commit
255afb6f8e
@ -67,6 +67,15 @@ public interface TelemetryContract {
|
||||
// Perform a search -- currently used when starting a search in the search activity.
|
||||
SEARCH("search.1"),
|
||||
|
||||
// Remove a search engine.
|
||||
SEARCH_REMOVE("search.remove.1"),
|
||||
|
||||
// Restore default search engines.
|
||||
SEARCH_RESTORE_DEFAULTS("search.restoredefaults.1"),
|
||||
|
||||
// Set default search engine.
|
||||
SEARCH_SET_DEFAULT("search.setdefault.1"),
|
||||
|
||||
// Sharing content.
|
||||
SHARE("share.1"),
|
||||
|
||||
|
@ -698,6 +698,7 @@ OnSharedPreferenceChangeListener
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
GeckoPreferences.this.restoreDefaultSearchEngines();
|
||||
Telemetry.sendUIEvent(TelemetryContract.Event.SEARCH_RESTORE_DEFAULTS, Method.LIST_ITEM);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@ -757,6 +758,7 @@ OnSharedPreferenceChangeListener
|
||||
// Generated R.id.* apparently aren't constant expressions, so they can't be switched.
|
||||
if (itemId == R.id.restore_defaults) {
|
||||
restoreDefaultSearchEngines();
|
||||
Telemetry.sendUIEvent(TelemetryContract.Event.SEARCH_RESTORE_DEFAULTS, Method.MENU);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,10 @@ public class SearchEnginePreference extends CustomListPreference {
|
||||
|
||||
private FaviconView mFaviconView;
|
||||
|
||||
// Search engine identifier specified by the gecko search service. This will be null
|
||||
// for engines that are not shipped with the app.
|
||||
private String mIdentifier;
|
||||
|
||||
public SearchEnginePreference(Context context, SearchPreferenceCategory parentCategory) {
|
||||
super(context, parentCategory);
|
||||
}
|
||||
@ -113,7 +117,14 @@ public class SearchEnginePreference extends CustomListPreference {
|
||||
Log.w(LOGTAG, "Selected index out of range.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Identifier of built-in search engine, or "other" if engine is not built-in.
|
||||
*/
|
||||
public String getIdentifier() {
|
||||
return (mIdentifier == null) ? "other" : mIdentifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure this Preference object from the Gecko search engine JSON object.
|
||||
@ -121,6 +132,8 @@ public class SearchEnginePreference extends CustomListPreference {
|
||||
* @throws JSONException If the JSONObject is invalid.
|
||||
*/
|
||||
public void setSearchEngineFromJSON(JSONObject geckoEngineJSON) throws JSONException {
|
||||
mIdentifier = geckoEngineJSON.getString("identifier");
|
||||
|
||||
final String engineName = geckoEngineJSON.getString("name");
|
||||
final SpannableString titleSpannable = new SpannableString(engineName);
|
||||
|
||||
|
@ -16,6 +16,9 @@ import org.json.JSONObject;
|
||||
import org.mozilla.gecko.EventDispatcher;
|
||||
import org.mozilla.gecko.GeckoAppShell;
|
||||
import org.mozilla.gecko.GeckoEvent;
|
||||
import org.mozilla.gecko.Telemetry;
|
||||
import org.mozilla.gecko.TelemetryContract;
|
||||
import org.mozilla.gecko.TelemetryContract.Method;
|
||||
import org.mozilla.gecko.util.GeckoEventListener;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
|
||||
@ -45,6 +48,8 @@ public class SearchPreferenceCategory extends CustomListCategory implements Geck
|
||||
|
||||
@Override
|
||||
protected void onPrepareForRemoval() {
|
||||
super.onPrepareForRemoval();
|
||||
|
||||
EventDispatcher.getInstance().unregisterGeckoThreadListener(this, "SearchEngines:Data");
|
||||
}
|
||||
|
||||
@ -53,6 +58,9 @@ public class SearchPreferenceCategory extends CustomListCategory implements Geck
|
||||
super.setDefault(item);
|
||||
|
||||
sendGeckoEngineEvent("SearchEngines:SetDefault", item.getTitle().toString());
|
||||
|
||||
final String identifier = ((SearchEnginePreference) item).getIdentifier();
|
||||
Telemetry.sendUIEvent(TelemetryContract.Event.SEARCH_SET_DEFAULT, Method.DIALOG, identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -60,6 +68,9 @@ public class SearchPreferenceCategory extends CustomListCategory implements Geck
|
||||
super.uninstall(item);
|
||||
|
||||
sendGeckoEngineEvent("SearchEngines:Remove", item.getTitle().toString());
|
||||
|
||||
final String identifier = ((SearchEnginePreference) item).getIdentifier();
|
||||
Telemetry.sendUIEvent(TelemetryContract.Event.SEARCH_REMOVE, Method.DIALOG, identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -80,8 +91,7 @@ public class SearchPreferenceCategory extends CustomListCategory implements Geck
|
||||
// Create an element in this PreferenceCategory for each engine.
|
||||
for (int i = 0; i < engines.length(); i++) {
|
||||
try {
|
||||
JSONObject engineJSON = engines.getJSONObject(i);
|
||||
final String engineName = engineJSON.getString("name");
|
||||
final JSONObject engineJSON = engines.getJSONObject(i);
|
||||
|
||||
final SearchEnginePreference enginePreference = new SearchEnginePreference(getContext(), this);
|
||||
enginePreference.setSearchEngineFromJSON(engineJSON);
|
||||
|
Loading…
Reference in New Issue
Block a user