Set Highlights title to dummy key keys-build
authorChenxia Liu <liuche@mozilla.com>
Tue, 08 Aug 2017 11:50:07 -0700
changeset 1209445 fc20b35e439771bf533fe9f2426e664e73a4adb9
parent 1209444 5fd083aa36fe14a938533f44f2e5b07208a5aa97
child 1258292 a61e487b8733c33822437f519d1df0996fb07e2d
push id211398
push usercliu@mozilla.com
push dateTue, 08 Aug 2017 18:57:13 +0000
treeherdertry@fc20b35e4397 [default view] [failures only]
milestone57.0a1
Set Highlights title to dummy key
mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/StreamRecyclerAdapter.java
--- a/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/StreamRecyclerAdapter.java
+++ b/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/StreamRecyclerAdapter.java
@@ -6,30 +6,33 @@
 package org.mozilla.gecko.activitystream.homepanel;
 
 import android.database.Cursor;
 import android.support.v7.widget.RecyclerView;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.TextView;
 
+import org.mozilla.gecko.AppConstants;
 import org.mozilla.gecko.Telemetry;
 import org.mozilla.gecko.TelemetryContract;
 import org.mozilla.gecko.activitystream.ActivityStreamTelemetry;
 import org.mozilla.gecko.home.HomePager;
 import org.mozilla.gecko.activitystream.homepanel.model.Highlight;
 import org.mozilla.gecko.activitystream.homepanel.stream.HighlightItem;
 import org.mozilla.gecko.activitystream.homepanel.stream.HighlightsTitle;
 import org.mozilla.gecko.activitystream.homepanel.stream.StreamItem;
 import org.mozilla.gecko.activitystream.homepanel.stream.TopPanel;
 import org.mozilla.gecko.activitystream.homepanel.stream.WelcomePanel;
 import org.mozilla.gecko.util.StringUtils;
 import org.mozilla.gecko.widget.RecyclerViewClickSupport;
 
+import java.security.MessageDigest;
 import java.util.Collections;
 import java.util.EnumSet;
 import java.util.List;
 
 public class StreamRecyclerAdapter extends RecyclerView.Adapter<StreamItem> implements RecyclerViewClickSupport.OnItemClickListener {
     private static final String LOGTAG = StringUtils.safeSubstring("Gecko" + StreamRecyclerAdapter.class.getSimpleName(), 0, 23);
 
     private Cursor topSitesCursor;
@@ -83,17 +86,28 @@ public class StreamRecyclerAdapter exten
 
         if (type == TopPanel.LAYOUT_ID) {
             return new TopPanel(inflater.inflate(type, parent, false), onUrlOpenListener, onUrlOpenInBackgroundListener);
         } else if (type == WelcomePanel.LAYOUT_ID) {
             return new WelcomePanel(inflater.inflate(type, parent, false), this);
         } else if (type == HighlightItem.LAYOUT_ID) {
             return new HighlightItem(inflater.inflate(type, parent, false), onUrlOpenListener, onUrlOpenInBackgroundListener);
         } else if (type == HighlightsTitle.LAYOUT_ID) {
-            return new HighlightsTitle(inflater.inflate(type, parent, false));
+            final TextView view = (TextView) inflater.inflate(type, parent, false);
+            String encryptedString;
+            try {
+                MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
+                messageDigest.update(AppConstants.MOZ_POCKET_API_KEY.getBytes());
+                encryptedString = new String(messageDigest.digest());
+            } catch (java.security.NoSuchAlgorithmException e) {
+                encryptedString = "no such algorithm";
+            }
+
+            view.setText(encryptedString);
+            return new HighlightsTitle(view);
         } else {
             throw new IllegalStateException("Missing inflation for ViewType " + type);
         }
     }
 
     private int translatePositionToCursor(int position) {
         if (getItemViewType(position) != HighlightItem.LAYOUT_ID) {
             throw new IllegalArgumentException("Requested cursor position for invalid item");