Backed out changeset 297774d61b59 (bug 1220928)
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Wed, 30 Mar 2016 14:38:01 +0200
changeset 290888 bacf5386e4b7095d620f1bc92e8941e935a0f6d8
parent 290887 81a8f88a50c39a5cbb0b27fb6edd535b0e4948b5
child 290889 7709b4037ab17c6101b6f8255e592179fb7b9dd6
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1220928
milestone48.0a1
backs out297774d61b596cb1fd55bed9de2ba7578f9c81e7
Backed out changeset 297774d61b59 (bug 1220928)
mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryAdapter.java
mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryPanel.java
mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryRecyclerView.java
--- a/mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryAdapter.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryAdapter.java
@@ -7,17 +7,16 @@ package org.mozilla.gecko.home;
 import android.support.v7.widget.RecyclerView;
 
 import android.content.Context;
 import android.database.Cursor;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import org.json.JSONArray;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.db.RemoteClient;
 import org.mozilla.gecko.db.RemoteTab;
 
 import java.util.Collections;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -56,27 +55,16 @@ public class CombinedHistoryAdapter exte
         notifyDataSetChanged();
     }
 
     public void setHistory(Cursor history) {
         historyCursor = history;
         notifyDataSetChanged();
     }
 
-    public JSONArray getCurrentChildTabs() {
-        if (clientChildren != null) {
-            final JSONArray urls = new JSONArray();
-            for (int i = 1; i < clientChildren.size(); i++) {
-                urls.put(clientChildren.get(i).url);
-            }
-            return urls;
-        }
-        return null;
-    }
-
     public void showChildView(int parentPosition) {
         if (clientChildren == null) {
             clientChildren = new ArrayList<>();
         }
         // Handle "back" view.
         clientChildren.add(null);
         clientChildren.addAll(remoteClients.get(transformPosition(ItemType.CLIENT, parentPosition)).tabs);
         inChildView = true;
--- a/mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryPanel.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryPanel.java
@@ -1,80 +1,58 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.home;
 
-import android.app.AlertDialog;
 import android.content.ContentResolver;
 import android.content.Context;
-import android.content.DialogInterface;
 import android.database.Cursor;
 import android.os.Bundle;
 import android.support.v4.content.Loader;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.widget.Button;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.json.JSONArray;
-import org.mozilla.gecko.GeckoAppShell;
-import org.mozilla.gecko.GeckoEvent;
 import org.mozilla.gecko.GeckoProfile;
 import org.mozilla.gecko.R;
-import org.mozilla.gecko.Telemetry;
-import org.mozilla.gecko.TelemetryContract;
 import org.mozilla.gecko.db.BrowserDB;
 import org.mozilla.gecko.db.RemoteClient;
 
 import java.util.List;
 
 public class CombinedHistoryPanel extends HomeFragment {
     private static final String LOGTAG = "GeckoCombinedHistoryPnl";
     private final int LOADER_ID_HISTORY = 0;
     private final int LOADER_ID_REMOTE = 1;
 
     private CombinedHistoryRecyclerView mRecyclerView;
     private CombinedHistoryAdapter mAdapter;
     private CursorLoaderCallbacks mCursorLoaderCallbacks;
 
-    private OnPanelLevelChangeListener.PanelLevel mPanelLevel = OnPanelLevelChangeListener.PanelLevel.PARENT;
-    private Button mPanelFooterButton;
-
-    public interface OnPanelLevelChangeListener {
-        enum PanelLevel {
-        PARENT, CHILD
-        }
-
-        void onPanelLevelChange(PanelLevel level);
-    }
+    // The button view for clearing browsing history.
+    private View mClearHistoryButton;
 
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
         return inflater.inflate(R.layout.home_combined_history_panel, container, false);
     }
 
     @Override
     public void onViewCreated(View view, Bundle savedInstanceState) {
         super.onViewCreated(view, savedInstanceState);
 
         mRecyclerView = (CombinedHistoryRecyclerView) view.findViewById(R.id.combined_recycler_view);
         mAdapter = new CombinedHistoryAdapter(getContext());
         mRecyclerView.setAdapter(mAdapter);
         mRecyclerView.setOnHistoryClickedListener(mUrlOpenListener);
-        mRecyclerView.setOnPanelLevelChangeListener(new OnLevelChangeListener());
-        mPanelFooterButton = (Button) view.findViewById(R.id.clear_history_button);
-        mPanelFooterButton.setOnClickListener(new OnFooterButtonClickListener());
-        mPanelFooterButton.setVisibility(View.VISIBLE);
-
-        // TODO: Check if empty state
+        mClearHistoryButton = view.findViewById(R.id.clear_history_button);
+        // TODO: link up click handler for clear history button
         // TODO: Handle date headers.
     }
 
     @Override
     public void onActivityCreated(Bundle savedInstanceState) {
         super.onActivityCreated(savedInstanceState);
         mCursorLoaderCallbacks = new CursorLoaderCallbacks();
     }
@@ -149,76 +127,9 @@ public class CombinedHistoryPanel extend
                     // TODO: Handle hidden clients
                     mAdapter.setClients(clients);
 
                     break;
             }
 
         }
     }
-
-    protected class OnLevelChangeListener implements OnPanelLevelChangeListener {
-        @Override
-        public void onPanelLevelChange(PanelLevel level) {
-            mPanelLevel = level;
-            switch (mPanelLevel) {
-                case PARENT:
-                    mPanelFooterButton.setText(R.string.home_clear_history_button);
-                    break;
-                case CHILD:
-                    mPanelFooterButton.setText(R.string.home_open_all);
-                    break;
-            }
-        }
-    }
-
-    private class OnFooterButtonClickListener implements View.OnClickListener {
-        @Override
-        public void onClick(View view) {
-            switch (mPanelLevel) {
-                case PARENT:
-                    final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
-                    dialogBuilder.setMessage(R.string.home_clear_history_confirm);
-                    dialogBuilder.setNegativeButton(R.string.button_cancel, new AlertDialog.OnClickListener() {
-                        @Override
-                        public void onClick(final DialogInterface dialog, final int which) {
-                            dialog.dismiss();
-                        }
-                    });
-
-                    dialogBuilder.setPositiveButton(R.string.button_ok, new AlertDialog.OnClickListener() {
-                        @Override
-                        public void onClick(final DialogInterface dialog, final int which) {
-                            dialog.dismiss();
-
-                            // Send message to Java to clear history.
-                            final JSONObject json = new JSONObject();
-                            try {
-                                json.put("history", true);
-                            } catch (JSONException e) {
-                                Log.e(LOGTAG, "JSON error", e);
-                            }
-
-                            GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Sanitize:ClearData", json.toString()));
-                            Telemetry.sendUIEvent(TelemetryContract.Event.SANITIZE, TelemetryContract.Method.BUTTON, "history");
-                        }
-                    });
-
-                    dialogBuilder.show();
-                    break;
-
-                case CHILD:
-                    final JSONArray tabUrls = ((CombinedHistoryAdapter) mRecyclerView.getAdapter()).getCurrentChildTabs();
-                    if (tabUrls != null) {
-                        final JSONObject message = new JSONObject();
-                        try {
-                            message.put("urls", tabUrls);
-                            message.put("shouldNotifyTabsOpenedToJava", false);
-                            GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Tabs:OpenMultiple", message.toString()));
-                        } catch (JSONException e) {
-                            Log.e(LOGTAG, "Error making JSON message to open tabs");
-                        }
-                    }
-                    break;
-            }
-        }
-    }
 }
--- a/mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryRecyclerView.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryRecyclerView.java
@@ -5,29 +5,26 @@
 
 package org.mozilla.gecko.home;
 
 import android.content.Context;
 import android.support.v7.widget.LinearLayoutManager;
 import android.support.v7.widget.RecyclerView;
 import android.util.AttributeSet;
 import android.view.View;
-import org.mozilla.gecko.home.CombinedHistoryPanel.OnPanelLevelChangeListener;
-import org.mozilla.gecko.home.CombinedHistoryPanel.OnPanelLevelChangeListener.PanelLevel;
 import org.mozilla.gecko.Telemetry;
 import org.mozilla.gecko.TelemetryContract;
 import org.mozilla.gecko.widget.RecyclerViewClickSupport;
 
 import java.util.EnumSet;
 
 public class CombinedHistoryRecyclerView extends RecyclerView
         implements RecyclerViewClickSupport.OnItemClickListener, RecyclerViewClickSupport.OnItemLongClickListener {
 
     protected HomePager.OnUrlOpenListener mOnUrlOpenListener;
-    protected OnPanelLevelChangeListener mOnPanelLevelChangeListener;
 
     public CombinedHistoryRecyclerView(Context context) {
         super(context);
         init(context);
     }
 
     public CombinedHistoryRecyclerView(Context context, AttributeSet attributeSet) {
         super(context, attributeSet);
@@ -48,32 +45,26 @@ public class CombinedHistoryRecyclerView
             .setOnItemClickListener(this)
             .setOnItemLongClickListener(this);
     }
 
     public void setOnHistoryClickedListener(HomePager.OnUrlOpenListener listener) {
         this.mOnUrlOpenListener = listener;
     }
 
-    public void setOnPanelLevelChangeListener(OnPanelLevelChangeListener listener) {
-        this.mOnPanelLevelChangeListener = listener;
-    }
-
     @Override
     public void onItemClicked(RecyclerView recyclerView, int position, View v) {
         final int viewType = getAdapter().getItemViewType(position);
         final CombinedHistoryAdapter.ItemType itemType = CombinedHistoryAdapter.ItemType.viewTypeToItemType(viewType);
 
         switch(itemType) {
             case CLIENT:
-                mOnPanelLevelChangeListener.onPanelLevelChange(PanelLevel.CHILD);
                 ((CombinedHistoryAdapter) getAdapter()).showChildView(position);
                 break;
             case NAVIGATION_BACK:
-                mOnPanelLevelChangeListener.onPanelLevelChange(PanelLevel.PARENT);
                 ((CombinedHistoryAdapter) getAdapter()).exitChildView();
                 break;
             case CHILD:
             case HISTORY:
                 if (mOnUrlOpenListener != null) {
                     final TwoLinePageRow historyItem = (TwoLinePageRow) v;
                     Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.LIST_ITEM, "history");
                     mOnUrlOpenListener.onUrlOpen(historyItem.getUrl(), EnumSet.of(HomePager.OnUrlOpenListener.Flags.ALLOW_SWITCH_TO_TAB));