diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2015-12-03 15:31:25 -0800 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2016-02-23 12:06:16 -0800 |
commit | 32554d1c6169df944f651846c64096f8bb57fb31 (patch) | |
tree | 8b40acce1d9e5a3e43d715fac10a4ddf86aec87f /src/com/android | |
parent | 261194387beebaa7927ec4e310274218b651494d (diff) | |
download | android_packages_apps_Trebuchet-32554d1c6169df944f651846c64096f8bb57fb31.tar.gz android_packages_apps_Trebuchet-32554d1c6169df944f651846c64096f8bb57fb31.tar.bz2 android_packages_apps_Trebuchet-32554d1c6169df944f651846c64096f8bb57fb31.zip |
Cleaning up the overlay interface
Removing some unnecessary and unused methods
Bug: 25993953
Change-Id: I4d715cdee04eb7b0ebef673d885a4258c521ff1f
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 79 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherCallbacks.java | 27 | ||||
-rw-r--r-- | src/com/android/launcher3/dragndrop/DragLayer.java | 14 | ||||
-rw-r--r-- | src/com/android/launcher3/testing/LauncherExtension.java | 138 |
4 files changed, 16 insertions, 242 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 406a6f563..8c203f393 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -212,10 +212,6 @@ public class Launcher extends Activity 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 @@ public class Launcher extends Activity 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 @@ public class Launcher extends Activity } } + /** + * 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 @@ public class Launcher extends Activity * @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 class Launcher extends Activity 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 class Launcher extends Activity } 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 @@ public class Launcher extends Activity if (introScreen != null) { mDragLayer.showOverlayView(introScreen); } - if (mLauncherOverlayContainer != null) { - mLauncherOverlayContainer.setVisibility(View.INVISIBLE); - } } public void dismissIntroScreen() { @@ -4620,17 +4575,11 @@ public class Launcher extends Activity @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 1d7575253..591bd9206 100644 --- a/src/com/android/launcher3/LauncherCallbacks.java +++ b/src/com/android/launcher3/LauncherCallbacks.java @@ -82,18 +82,11 @@ public interface LauncherCallbacks { @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 interface LauncherCallbacks { 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 interface LauncherCallbacks { 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 3128db21e..f16a56c8b 100644 --- a/src/com/android/launcher3/dragndrop/DragLayer.java +++ b/src/com/android/launcher3/dragndrop/DragLayer.java @@ -110,8 +110,6 @@ public class DragLayer extends InsettableFrameLayout { private Drawable mLeftHoverDrawableActive; private Drawable mRightHoverDrawableActive; - private boolean mBlockTouches = false; - /** * Used to create a new DragLayer from XML. * @@ -186,19 +184,11 @@ public class DragLayer extends InsettableFrameLayout { 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 @@ public class DragLayer extends InsettableFrameLayout { 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 89821768c..279be7037 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 LauncherExtension extends Launcher { public class LauncherExtensionCallbacks implements LauncherCallbacks { - LauncherExtensionOverlay mLauncherOverlay = new LauncherExtensionOverlay(); - @Override public void preOnCreate() { } @@ -116,10 +106,6 @@ public class LauncherExtension extends Launcher { @Override public boolean handleBackPressed() { - if (mLauncherOverlay.isOverlayPanelShowing()) { - mLauncherOverlay.hideOverlayPanel(); - return true; - } return false; } @@ -188,13 +174,8 @@ public class LauncherExtension extends Launcher { } @Override - public boolean forceDisableVoiceButtonProxy() { - return false; - } - - @Override public boolean providesSearch() { - return true; + return false; } @Override @@ -208,10 +189,6 @@ public class LauncherExtension extends Launcher { 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 @@ public class LauncherExtension extends Launcher { @Override public View getQsbBar() { - return mLauncherOverlay.getSearchBox(); + return null; } @Override @@ -288,11 +265,6 @@ public class LauncherExtension extends Launcher { } @Override - public ComponentName getWallpaperPickerComponent() { - return null; - } - - @Override public boolean overrideWallpaperDimensions() { return false; } @@ -318,114 +290,8 @@ public class LauncherExtension extends Launcher { } @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; - } - }; } } |