Cleaning up the overlay interface
Overlays are supposed to use their own UI and not interfere with the
Launcher UI. If the UI needs to be put inside the Launcher, use customContent
instead.
Removing some unnecessary and unused methods related to overlays
Bug: 25993953
Change-Id: I4d715cdee04eb7b0ebef673d885a4258c521ff1f
diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml
index 1a951f1..b1f85b4 100644
--- a/res/layout-land/launcher.xml
+++ b/res/layout-land/launcher.xml
@@ -72,10 +72,4 @@
android:visibility="invisible" />
</com.android.launcher3.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 8bf9d64..962b5ce 100644
--- a/res/layout-port/launcher.xml
+++ b/res/layout-port/launcher.xml
@@ -82,10 +82,4 @@
android:visibility="invisible" />
</com.android.launcher3.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 2fc62c5..50daaa9 100644
--- a/res/layout-sw720dp/launcher.xml
+++ b/res/layout-sw720dp/launcher.xml
@@ -80,11 +80,4 @@
android:visibility="invisible" />
</com.android.launcher3.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/DragLayer.java b/src/com/android/launcher3/DragLayer.java
index ad9063c..9886c3f 100644
--- a/src/com/android/launcher3/DragLayer.java
+++ b/src/com/android/launcher3/DragLayer.java
@@ -95,8 +95,6 @@
private Drawable mLeftHoverDrawableActive;
private Drawable mRightHoverDrawableActive;
- private boolean mBlockTouches = false;
-
/**
* Used to create a new DragLayer from XML.
*
@@ -166,19 +164,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)) {
@@ -343,10 +333,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/Launcher.java b/src/com/android/launcher3/Launcher.java
index 95e639a..1bf2341 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -216,10 +216,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;
@@ -501,13 +497,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()) {
@@ -537,6 +526,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() {
@@ -889,8 +888,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
@@ -1133,10 +1131,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 {
@@ -1152,51 +1150,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() {
@@ -4645,9 +4603,6 @@
if (introScreen != null) {
mDragLayer.showOverlayView(introScreen);
}
- if (mLauncherOverlayContainer != null) {
- mLauncherOverlayContainer.setVisibility(View.INVISIBLE);
- }
}
public void dismissIntroScreen() {
@@ -4659,17 +4614,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 772fbf3..74833e3 100644
--- a/src/com/android/launcher3/LauncherCallbacks.java
+++ b/src/com/android/launcher3/LauncherCallbacks.java
@@ -69,18 +69,11 @@
public void onInteractionBegin();
public void onInteractionEnd();
- /*
- * 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();
@@ -95,8 +88,6 @@
public View getIntroScreen();
public boolean shouldMoveToDefaultScreenOnHomeIntent();
public boolean hasSettings();
- @Deprecated
- public ComponentName getWallpaperPickerComponent();
public boolean overrideWallpaperDimensions();
public boolean isLauncherPreinstalled();
public AllAppsSearchBarController getAllAppsSearchBarController();
@@ -106,24 +97,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/testing/LauncherExtension.java b/src/com/android/launcher3/testing/LauncherExtension.java
index 1bb5787..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,113 +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, "translationX", 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;
- }
- };
}
}