Cleaning up the overlay interface

Removing some unnecessary and unused methods

Bug: 25993953
Change-Id: I4d715cdee04eb7b0ebef673d885a4258c521ff1f
diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml
index aac0f83..63e460e 100644
--- a/res/layout-land/launcher.xml
+++ b/res/layout-land/launcher.xml
@@ -75,10 +75,4 @@
             android:visibility="invisible" />
     </com.android.launcher3.dragndrop.DragLayer>
 
-    <ViewStub
-        android:id="@+id/launcher_overlay_stub"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:inflatedId="@+id/launcher_overlay"
-        android:layout="@layout/launcher_overlay" />
 </com.android.launcher3.LauncherRootView>
diff --git a/res/layout-port/launcher.xml b/res/layout-port/launcher.xml
index fb015f8..39f5ac1 100644
--- a/res/layout-port/launcher.xml
+++ b/res/layout-port/launcher.xml
@@ -85,10 +85,4 @@
             android:visibility="invisible" />
     </com.android.launcher3.dragndrop.DragLayer>
 
-    <ViewStub
-        android:id="@+id/launcher_overlay_stub"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:inflatedId="@+id/launcher_overlay"
-        android:layout="@layout/launcher_overlay" />
 </com.android.launcher3.LauncherRootView>
diff --git a/res/layout-sw720dp/launcher.xml b/res/layout-sw720dp/launcher.xml
index a45858c..b572444 100644
--- a/res/layout-sw720dp/launcher.xml
+++ b/res/layout-sw720dp/launcher.xml
@@ -83,11 +83,4 @@
             android:visibility="invisible" />
     </com.android.launcher3.dragndrop.DragLayer>
 
-    <ViewStub
-        android:id="@+id/launcher_overlay_stub"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:inflatedId="@+id/launcher_overlay"
-        android:layout="@layout/launcher_overlay" />
-
 </com.android.launcher3.LauncherRootView>
diff --git a/res/layout/launcher_overlay.xml b/res/layout/launcher_overlay.xml
deleted file mode 100644
index b35a2d8..0000000
--- a/res/layout/launcher_overlay.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2008 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<com.android.launcher3.InsettableFrameLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent" />
diff --git a/res/layout/launcher_overlay_example.xml b/res/layout/launcher_overlay_example.xml
deleted file mode 100644
index 7d92d4f..0000000
--- a/res/layout/launcher_overlay_example.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2008 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<FrameLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:launcher="http://schemas.android.com/apk/res-auto"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    launcher:layout_ignoreInsets="true">
-
-    <FrameLayout
-        android:id="@+id/search_overlay"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:background="#ff00ff00"
-        android:visibility="invisible" />
-
-    <FrameLayout
-        android:id="@+id/search_box"
-        android:layout_width="match_parent"
-        android:layout_height="48dp"
-        android:layout_marginLeft="8dp"
-        android:layout_marginRight="8dp"
-        android:layout_marginTop="36dp"
-        android:background="#ffff0000" />
-</FrameLayout>
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 406a6f5..8c203f3 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -212,10 +212,6 @@
 
     private boolean mIsSafeModeEnabled;
 
-    LauncherOverlayCallbacks mLauncherOverlayCallbacks = new LauncherOverlayCallbacksImpl();
-    LauncherOverlay mLauncherOverlay;
-    InsettableFrameLayout mLauncherOverlayContainer;
-
     static final int APPWIDGET_HOST_ID = 1024;
     public static final int EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT = 300;
     private static final int ON_ACTIVITY_RESULT_ANIMATION_DELAY = 500;
@@ -495,13 +491,6 @@
 
         if (mLauncherCallbacks != null) {
             mLauncherCallbacks.onCreate(savedInstanceState);
-            if (mLauncherCallbacks.hasLauncherOverlay()) {
-                ViewStub stub = (ViewStub) findViewById(R.id.launcher_overlay_stub);
-                mLauncherOverlayContainer = (InsettableFrameLayout) stub.inflate();
-                mLauncherOverlay = mLauncherCallbacks.setLauncherOverlayView(
-                        mLauncherOverlayContainer, mLauncherOverlayCallbacks);
-                mWorkspace.setLauncherOverlay(mLauncherOverlay);
-            }
         }
 
         if (shouldShowIntroScreen()) {
@@ -531,6 +520,16 @@
         }
     }
 
+    /**
+     * Call this after onCreate to set or clear overlay.
+     */
+    public void setLauncherOverlay(LauncherOverlay overlay) {
+        if (overlay != null) {
+            overlay.setOverlayCallbacks(new LauncherOverlayCallbacksImpl());
+        }
+        mWorkspace.setLauncherOverlay(overlay);
+    }
+
     public boolean setLauncherCallbacks(LauncherCallbacks callbacks) {
         mLauncherCallbacks = callbacks;
         mLauncherCallbacks.setLauncherSearchCallback(new Launcher.LauncherSearchCallbacks() {
@@ -878,8 +877,7 @@
      * @return the new screen, or screenId if it exists
      */
     private long ensurePendingDropLayoutExists(long screenId) {
-        CellLayout dropLayout =
-                (CellLayout) mWorkspace.getScreenWithId(screenId);
+        CellLayout dropLayout = mWorkspace.getScreenWithId(screenId);
         if (dropLayout == null) {
             // it's possible that the add screen was removed because it was
             // empty and a re-bind occurred
@@ -1117,10 +1115,10 @@
         public void onScrollSettled();
 
         /**
-         * This method can be called by the Launcher in order to force the LauncherOverlay
-         * to exit fully immersive mode.
+         * Called when the launcher is ready to use the overlay
+         * @param callbacks A set of callbacks provided by Launcher in relation to the overlay
          */
-        public void forceExitFullImmersion();
+        public void setOverlayCallbacks(LauncherOverlayCallbacks callbacks);
     }
 
     public interface LauncherSearchCallbacks {
@@ -1136,51 +1134,11 @@
     }
 
     public interface LauncherOverlayCallbacks {
-        /**
-         * This method indicates whether a call to {@link #enterFullImmersion()} will succeed,
-         * however it doesn't modify any state within the launcher.
-         */
-        public boolean canEnterFullImmersion();
 
-        /**
-         * Should be called to tell Launcher that the LauncherOverlay will take over interaction,
-         * eg. by occupying the full screen and handling all touch events.
-         *
-         * @return true if Launcher allows the LauncherOverlay to become fully immersive. In this
-         *          case, Launcher will modify any necessary state and assumes the overlay is
-         *          handling all interaction. If false, the LauncherOverlay should cancel any
-         *
-         */
-        public boolean enterFullImmersion();
-
-        /**
-         * Must be called when exiting fully immersive mode. Indicates to Launcher that it has
-         * full control over UI and state.
-         */
-        public void exitFullImmersion();
     }
 
     class LauncherOverlayCallbacksImpl implements LauncherOverlayCallbacks {
 
-        @Override
-        public boolean canEnterFullImmersion() {
-            return mState == State.WORKSPACE;
-        }
-
-        @Override
-        public boolean enterFullImmersion() {
-            if (mState == State.WORKSPACE) {
-                // When fully immersed, disregard any touches which fall through.
-                mDragLayer.setBlockTouch(true);
-                return true;
-            }
-            return false;
-        }
-
-        @Override
-        public void exitFullImmersion() {
-            mDragLayer.setBlockTouch(false);
-        }
     }
 
     protected boolean hasSettings() {
@@ -4606,9 +4564,6 @@
         if (introScreen != null) {
             mDragLayer.showOverlayView(introScreen);
         }
-        if (mLauncherOverlayContainer != null) {
-            mLauncherOverlayContainer.setVisibility(View.INVISIBLE);
-        }
     }
 
     public void dismissIntroScreen() {
@@ -4620,17 +4575,11 @@
                 @Override
                 public void run() {
                     mDragLayer.dismissOverlayView();
-                    if (mLauncherOverlayContainer != null) {
-                        mLauncherOverlayContainer.setVisibility(View.VISIBLE);
-                    }
                     showFirstRunClings();
                 }
             }, ACTIVITY_START_DELAY);
         } else {
             mDragLayer.dismissOverlayView();
-            if (mLauncherOverlayContainer != null) {
-                mLauncherOverlayContainer.setVisibility(View.VISIBLE);
-            }
             showFirstRunClings();
         }
         changeWallpaperVisiblity(true);
diff --git a/src/com/android/launcher3/LauncherCallbacks.java b/src/com/android/launcher3/LauncherCallbacks.java
index 1d75752..591bd92 100644
--- a/src/com/android/launcher3/LauncherCallbacks.java
+++ b/src/com/android/launcher3/LauncherCallbacks.java
@@ -82,18 +82,11 @@
     @Deprecated
     public void onDragStarted(View view);
 
-    /*
-     * Extension points for replacing the search experience
-     */
-    @Deprecated
-    public boolean forceDisableVoiceButtonProxy();
     public boolean providesSearch();
     public boolean startSearch(String initialQuery, boolean selectInitialQuery,
             Bundle appSearchData, Rect sourceBounds);
     @Deprecated
     public boolean startSearchFromAllApps(String query);
-    @Deprecated
-    public void startVoice();
     public boolean hasCustomContentToLeft();
     public void populateCustomContentContainer();
     public View getQsbBar();
@@ -108,8 +101,6 @@
     public View getIntroScreen();
     public boolean shouldMoveToDefaultScreenOnHomeIntent();
     public boolean hasSettings();
-    @Deprecated
-    public ComponentName getWallpaperPickerComponent();
     public boolean overrideWallpaperDimensions();
     public boolean isLauncherPreinstalled();
     public AllAppsSearchBarController getAllAppsSearchBarController();
@@ -119,24 +110,6 @@
     public int getSearchBarHeight();
 
     /**
-     * Returning true will immediately result in a call to {@link #setLauncherOverlayView(ViewGroup,
-     * com.android.launcher3.Launcher.LauncherOverlayCallbacks)}.
-     *
-     * @return true if this launcher extension will provide an overlay
-     */
-    public boolean hasLauncherOverlay();
-
-    /**
-     * Handshake to establish an overlay relationship
-     *
-     * @param container Full screen overlay ViewGroup into which custom views can be placed.
-     * @param callbacks A set of callbacks provided by Launcher in relation to the overlay
-     * @return an interface used to make requests and notify the Launcher in relation to the overlay
-     */
-    public Launcher.LauncherOverlay setLauncherOverlayView(InsettableFrameLayout container,
-            Launcher.LauncherOverlayCallbacks callbacks);
-
-    /**
      * Sets the callbacks to allow reacting the actions of search overlays of the launcher.
      *
      * @param callbacks A set of callbacks to the Launcher, is actually a LauncherSearchCallback,
diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java
index 3128db2..f16a56c 100644
--- a/src/com/android/launcher3/dragndrop/DragLayer.java
+++ b/src/com/android/launcher3/dragndrop/DragLayer.java
@@ -110,8 +110,6 @@
     private Drawable mLeftHoverDrawableActive;
     private Drawable mRightHoverDrawableActive;
 
-    private boolean mBlockTouches = false;
-
     /**
      * Used to create a new DragLayer from XML.
      *
@@ -186,19 +184,11 @@
         return false;
     }
 
-    public void setBlockTouch(boolean block) {
-        mBlockTouches = block;
-    }
-
     private boolean handleTouchDown(MotionEvent ev, boolean intercept) {
         Rect hitRect = new Rect();
         int x = (int) ev.getX();
         int y = (int) ev.getY();
 
-        if (mBlockTouches) {
-            return true;
-        }
-
         for (AppWidgetResizeFrame child: mResizeFrames) {
             child.getHitRect(hitRect);
             if (hitRect.contains(x, y)) {
@@ -364,10 +354,6 @@
         int x = (int) ev.getX();
         int y = (int) ev.getY();
 
-        if (mBlockTouches) {
-            return true;
-        }
-
         if (action == MotionEvent.ACTION_DOWN) {
             if (handleTouchDown(ev, false)) {
                 return true;
diff --git a/src/com/android/launcher3/testing/LauncherExtension.java b/src/com/android/launcher3/testing/LauncherExtension.java
index 8982176..279be70 100644
--- a/src/com/android/launcher3/testing/LauncherExtension.java
+++ b/src/com/android/launcher3/testing/LauncherExtension.java
@@ -1,24 +1,16 @@
 package com.android.launcher3.testing;
 
-import android.animation.Animator;
-import android.animation.AnimatorListenerAdapter;
-import android.animation.ObjectAnimator;
-import android.content.ComponentName;
 import android.content.Intent;
 import android.graphics.Color;
 import android.graphics.Rect;
 import android.os.Bundle;
 import android.view.Menu;
 import android.view.View;
-import android.view.ViewGroup;
 import android.widget.FrameLayout;
 
 import com.android.launcher3.AppInfo;
-import com.android.launcher3.InsettableFrameLayout;
 import com.android.launcher3.Launcher;
-import com.android.launcher3.LauncherAnimUtils;
 import com.android.launcher3.LauncherCallbacks;
-import com.android.launcher3.R;
 import com.android.launcher3.allapps.AllAppsSearchBarController;
 import com.android.launcher3.util.ComponentKey;
 
@@ -42,8 +34,6 @@
 
     public class LauncherExtensionCallbacks implements LauncherCallbacks {
 
-        LauncherExtensionOverlay mLauncherOverlay = new LauncherExtensionOverlay();
-
         @Override
         public void preOnCreate() {
         }
@@ -116,10 +106,6 @@
 
         @Override
         public boolean handleBackPressed() {
-            if (mLauncherOverlay.isOverlayPanelShowing()) {
-                mLauncherOverlay.hideOverlayPanel();
-                return true;
-            }
             return false;
         }
 
@@ -188,13 +174,8 @@
         }
 
         @Override
-        public boolean forceDisableVoiceButtonProxy() {
-            return false;
-        }
-
-        @Override
         public boolean providesSearch() {
-            return true;
+            return false;
         }
 
         @Override
@@ -208,10 +189,6 @@
             return false;
         }
 
-        @Override
-        public void startVoice() {
-        }
-
         CustomContentCallbacks mCustomContentCallbacks = new CustomContentCallbacks() {
 
             // Custom content is completely shown. {@code fromResume} indicates whether this was caused
@@ -249,7 +226,7 @@
 
         @Override
         public View getQsbBar() {
-            return mLauncherOverlay.getSearchBox();
+            return null;
         }
 
         @Override
@@ -288,11 +265,6 @@
         }
 
         @Override
-        public ComponentName getWallpaperPickerComponent() {
-            return null;
-        }
-
-        @Override
         public boolean overrideWallpaperDimensions() {
             return false;
         }
@@ -318,114 +290,8 @@
         }
 
         @Override
-        public boolean hasLauncherOverlay() {
-            return false;
-        }
-
-        @Override
-        public LauncherOverlay setLauncherOverlayView(InsettableFrameLayout container,
-                LauncherOverlayCallbacks callbacks) {
-
-            mLauncherOverlay.setOverlayCallbacks(callbacks);
-            mLauncherOverlay.setOverlayContainer(container);
-
-            return mLauncherOverlay;
-        }
-
-        @Override
         public void setLauncherSearchCallback(Object callbacks) {
             // Do nothing
         }
-
-        class LauncherExtensionOverlay implements LauncherOverlay {
-            LauncherOverlayCallbacks mLauncherOverlayCallbacks;
-            ViewGroup mOverlayView;
-            View mSearchBox;
-            View mSearchOverlay;
-            boolean mShowOverlayFeedback;
-            int mProgress;
-            boolean mOverlayPanelShowing;
-
-            @Override
-            public void onScrollInteractionBegin() {
-                if (mLauncherOverlayCallbacks.canEnterFullImmersion()) {
-                    mShowOverlayFeedback = true;
-                    updatePanelOffset(0);
-                    mSearchOverlay.setVisibility(View.VISIBLE);
-                    mSearchOverlay.setLayerType(View.LAYER_TYPE_HARDWARE, null);
-                }
-            }
-
-            @Override
-            public void onScrollChange(int progress, boolean rtl) {
-                mProgress = progress;
-                if (mShowOverlayFeedback) {
-                    updatePanelOffset(progress);
-                }
-            }
-
-            private void updatePanelOffset(int progress) {
-                int panelWidth = mSearchOverlay.getMeasuredWidth();
-                int offset = (int) ((progress / 100f) * panelWidth);
-                mSearchOverlay.setTranslationX(- panelWidth + offset);
-            }
-
-            @Override
-            public void onScrollInteractionEnd() {
-                if (mProgress > 25 && mLauncherOverlayCallbacks.enterFullImmersion()) {
-                    ObjectAnimator oa = LauncherAnimUtils.ofFloat(
-                            mSearchOverlay, View.TRANSLATION_X, 0);
-                    oa.addListener(new AnimatorListenerAdapter() {
-                        @Override
-                        public void onAnimationEnd(Animator arg0) {
-                            mSearchOverlay.setLayerType(View.LAYER_TYPE_NONE, null);
-                        }
-                    });
-                    oa.start();
-                    mOverlayPanelShowing = true;
-                    mShowOverlayFeedback = false;
-                }
-            }
-
-            @Override
-            public void onScrollSettled() {
-                if (mShowOverlayFeedback) {
-                    mSearchOverlay.setVisibility(View.INVISIBLE);
-                    mSearchOverlay.setLayerType(View.LAYER_TYPE_NONE, null);
-                }
-                mShowOverlayFeedback = false;
-                mProgress = 0;
-            }
-
-            public void hideOverlayPanel() {
-                mLauncherOverlayCallbacks.exitFullImmersion();
-                mSearchOverlay.setVisibility(View.INVISIBLE);
-                mOverlayPanelShowing = false;
-            }
-
-            public boolean isOverlayPanelShowing() {
-                return mOverlayPanelShowing;
-            }
-
-            @Override
-            public void forceExitFullImmersion() {
-                hideOverlayPanel();
-            }
-
-            public void setOverlayContainer(InsettableFrameLayout container) {
-                mOverlayView = (ViewGroup) getLayoutInflater().inflate(
-                        R.layout.launcher_overlay_example, container);
-                mSearchOverlay = mOverlayView.findViewById(R.id.search_overlay);
-                mSearchBox = mOverlayView.findViewById(R.id.search_box);
-            }
-
-            public View getSearchBox() {
-                return mSearchBox;
-            }
-
-            public void setOverlayCallbacks(LauncherOverlayCallbacks callbacks) {
-                mLauncherOverlayCallbacks = callbacks;
-            }
-        };
     }
 }