Bug 1105011 - Include locale in tiles payload. r=rnewman
authorBrian Nicholson <thebnich@gmail.com>
Tue, 02 Dec 2014 15:33:21 -0800
changeset 218467 012715b4c18bf1f6baac2cdf598136c71b090ff0
parent 218466 aec38e8b60daaee96a559cdcc6f37efee4bb09a5
child 218468 e419afb0dba7ec727d4a8f5f2ec7fcd15ffc2550
push idunknown
push userunknown
push dateunknown
reviewersrnewman
bugs1105011
milestone37.0a1
Bug 1105011 - Include locale in tiles payload. r=rnewman
mobile/android/base/home/TopSitesPanel.java
mobile/android/base/tiles/TilesRecorder.java
--- a/mobile/android/base/home/TopSitesPanel.java
+++ b/mobile/android/base/home/TopSitesPanel.java
@@ -7,18 +7,20 @@ package org.mozilla.gecko.home;
 
 import static org.mozilla.gecko.db.URLMetadataTable.TILE_COLOR_COLUMN;
 import static org.mozilla.gecko.db.URLMetadataTable.TILE_IMAGE_URL_COLUMN;
 
 import java.util.ArrayList;
 import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 
+import org.mozilla.gecko.BrowserLocaleManager;
 import org.mozilla.gecko.GeckoProfile;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.Tab;
 import org.mozilla.gecko.Tabs;
 import org.mozilla.gecko.Telemetry;
 import org.mozilla.gecko.TelemetryContract;
 import org.mozilla.gecko.db.BrowserContract.Thumbnails;
 import org.mozilla.gecko.db.BrowserContract.TopSites;
@@ -230,17 +232,19 @@ public class TopSitesPanel extends HomeF
                         } else {
                             method = TelemetryContract.Method.GRID_ITEM;
                         }
                         Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, method, Integer.toString(position));
 
                         // Record tile click events on non-private tabs.
                         final Tab tab = Tabs.getInstance().getSelectedTab();
                         if (!tab.isPrivate()) {
-                            mTilesRecorder.recordAction(tab, TilesRecorder.ACTION_CLICK, position, getTilesSnapshot());
+                            final Locale locale = Locale.getDefault();
+                            final String localeTag = BrowserLocaleManager.getLanguageTag(locale);
+                            mTilesRecorder.recordAction(tab, TilesRecorder.ACTION_CLICK, position, getTilesSnapshot(), localeTag);
                         }
 
                         mUrlOpenListener.onUrlOpen(url, EnumSet.noneOf(OnUrlOpenListener.Flags.class));
                     }
                 } else {
                     if (mEditPinnedSiteListener != null) {
                         mEditPinnedSiteListener.onEditPinnedSite(position, "");
                     }
--- a/mobile/android/base/tiles/TilesRecorder.java
+++ b/mobile/android/base/tiles/TilesRecorder.java
@@ -17,17 +17,17 @@ import org.mozilla.gecko.Tab;
 import android.util.Log;
 
 public class TilesRecorder {
     public static final String ACTION_CLICK = "click";
 
     private static final String LOG_TAG = "GeckoTilesRecorder";
     private static final String EVENT_TILES_CLICK = "Tiles:Click";
 
-    public void recordAction(Tab tab, String action, int index, List<Tile> tiles) {
+    public void recordAction(Tab tab, String action, int index, List<Tile> tiles, String locale) {
         final Tile clickedTile = tiles.get(index);
 
         if (tab == null || clickedTile == null) {
             throw new IllegalArgumentException("Tab and tile cannot be null");
         }
 
         if (clickedTile.id == -1) {
             // User clicked a non-distribution tile, so we don't need to report it.
@@ -62,16 +62,17 @@ public class TilesRecorder {
 
             if (clickedTileIndex == -1) {
                 throw new IllegalStateException("Clicked tile index not set");
             }
 
             final JSONObject payload = new JSONObject();
             payload.put(action, clickedTileIndex);
             payload.put("tiles", tilesJSON);
+            payload.put("locale", locale);
 
             final JSONObject data = new JSONObject();
             data.put("tabId", tab.getId());
             data.put("payload", payload.toString());
 
             GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent(EVENT_TILES_CLICK, data.toString()));
         } catch (JSONException e) {
             Log.e(LOG_TAG, "JSON error", e);