Bug 1042951 - Part 3: record searches from SearchActivity. r=margaret

This commit is contained in:
Richard Newman 2014-10-07 17:52:21 -07:00
parent 6d7da5da76
commit 27b2ab20c2
2 changed files with 22 additions and 12 deletions

View File

@ -4,12 +4,24 @@
package org.mozilla.search;
import org.mozilla.gecko.LocaleAware;
import org.mozilla.gecko.Telemetry;
import org.mozilla.gecko.TelemetryContract;
import org.mozilla.gecko.db.BrowserContract.SearchHistory;
import org.mozilla.gecko.health.BrowserHealthRecorder;
import org.mozilla.search.autocomplete.SearchBar;
import org.mozilla.search.autocomplete.SuggestionsFragment;
import org.mozilla.search.providers.SearchEngine;
import org.mozilla.search.providers.SearchEngineManager;
import org.mozilla.search.providers.SearchEngineManager.SearchEngineCallback;
import android.content.AsyncQueryHandler;
import android.content.ContentValues;
import android.content.Intent;
import android.graphics.Rect;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Interpolator;
@ -18,16 +30,6 @@ import com.nineoldandroids.animation.Animator;
import com.nineoldandroids.animation.AnimatorSet;
import com.nineoldandroids.animation.ObjectAnimator;
import org.mozilla.gecko.LocaleAware;
import org.mozilla.gecko.Telemetry;
import org.mozilla.gecko.TelemetryContract;
import org.mozilla.gecko.db.BrowserContract.SearchHistory;
import org.mozilla.search.autocomplete.SearchBar;
import org.mozilla.search.autocomplete.SuggestionsFragment;
import org.mozilla.search.providers.SearchEngine;
import org.mozilla.search.providers.SearchEngineManager;
import org.mozilla.search.providers.SearchEngineManager.SearchEngineCallback;
/**
* The main entrance for the Android search intent.
* <p/>
@ -37,6 +39,8 @@ import org.mozilla.search.providers.SearchEngineManager.SearchEngineCallback;
public class SearchActivity extends LocaleAware.LocaleAwareFragmentActivity
implements AcceptsSearchQuery, SearchEngineCallback {
private static final String LOGTAG = "GeckoSearchActivity";
private static final String KEY_SEARCH_STATE = "search_state";
private static final String KEY_EDIT_STATE = "edit_state";
private static final String KEY_QUERY = "query";
@ -234,6 +238,14 @@ public class SearchActivity extends LocaleAware.LocaleAwareFragmentActivity
public void onSearch(String query, SuggestionAnimation suggestionAnimation) {
storeQuery(query);
try {
BrowserHealthRecorder.recordSearchDelayed("activity", engine.getIdentifier());
} catch (Exception e) {
// This should never happen: it'll only throw if the
// search location is wrong. But let's not tempt fate.
Log.w(LOGTAG, "Unable to record search.");
}
startSearch(query);
if (suggestionAnimation != null) {

View File

@ -18,10 +18,8 @@ import android.appwidget.AppWidgetProviderInfo;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.widget.RemoteViews;
import android.util.Log;
/* Provides a really simple widget with two buttons, one to launch Fennec
* and one to launch the search activity. All intents are actually sent back