Fix history click/longpress events

 Bug: 3368898
 The recent history UI change forgot to hook up the old event handling
 to the new list view layout.

Change-Id: I470b30b748608c9e7ec05aa3ca399ca7b39f0849
diff --git a/src/com/android/browser/BrowserHistoryPage.java b/src/com/android/browser/BrowserHistoryPage.java
index f3c7a7f..5d8d153 100644
--- a/src/com/android/browser/BrowserHistoryPage.java
+++ b/src/com/android/browser/BrowserHistoryPage.java
@@ -55,11 +55,9 @@
 import android.view.ViewStub;
 import android.webkit.WebIconDatabase.IconListener;
 import android.widget.AdapterView;
+import android.widget.AdapterView.AdapterContextMenuInfo;
 import android.widget.AdapterView.OnItemClickListener;
 import android.widget.BaseAdapter;
-import android.widget.ExpandableListView;
-import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
-import android.widget.ExpandableListView.OnChildClickListener;
 import android.widget.ListView;
 import android.widget.TextView;
 import android.widget.Toast;
@@ -69,7 +67,7 @@
  * days of viewing.
  */
 public class BrowserHistoryPage extends Fragment
-        implements LoaderCallbacks<Cursor>, OnChildClickListener {
+        implements LoaderCallbacks<Cursor> {
 
     static final int LOADER_HISTORY = 1;
     static final int LOADER_MOST_VISITED = 2;
@@ -250,6 +248,8 @@
         mChildWrapper = new HistoryChildWrapper(mAdapter);
         mChildList = new ListView(getActivity());
         mChildList.setAdapter(mChildWrapper);
+        mChildList.setOnItemClickListener(mChildItemClickListener);
+        registerForContextMenu(mChildList);
         ViewGroup prefs = (ViewGroup) mRoot.findViewById(com.android.internal.R.id.prefs);
         prefs.addView(mChildList);
 
@@ -272,6 +272,14 @@
         }
     };
 
+    private OnItemClickListener mChildItemClickListener = new OnItemClickListener() {
+        @Override
+        public void onItemClick(
+                AdapterView<?> parent, View view, int position, long id) {
+            mCallbacks.onUrlSelected(((HistoryItem) view).getUrl(), false);
+        }
+    };
+
     @Override
     public void onDestroy() {
         super.onDestroy();
@@ -337,11 +345,7 @@
 
     @Override
     public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
-        ExpandableListContextMenuInfo i = (ExpandableListContextMenuInfo) menuInfo;
-        // Do not allow a context menu to come up from the group views.
-        if (!(i.targetView instanceof HistoryItem)) {
-            return;
-        }
+        AdapterContextMenuInfo i = (AdapterContextMenuInfo) menuInfo;
 
         // Inflate the menu
         Activity parent = getActivity();
@@ -380,8 +384,8 @@
 
     @Override
     public boolean onContextItemSelected(MenuItem item) {
-        ExpandableListContextMenuInfo i =
-            (ExpandableListContextMenuInfo) item.getMenuInfo();
+        AdapterContextMenuInfo i =
+            (AdapterContextMenuInfo) item.getMenuInfo();
         if (i == null) {
             return false;
         }
@@ -424,16 +428,6 @@
         return super.onContextItemSelected(item);
     }
 
-    @Override
-    public boolean onChildClick(ExpandableListView parent, View v,
-            int groupPosition, int childPosition, long id) {
-        if (v instanceof HistoryItem) {
-            mCallbacks.onUrlSelected(((HistoryItem) v).getUrl(), false);
-            return true;
-        }
-        return false;
-    }
-
     private static abstract class HistoryWrapper extends BaseAdapter {
 
         protected HistoryAdapter mAdapter;