mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 23:36:47 +00:00
Merge "Cleaning up the overlay interface" into ub-launcher3-calgary
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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" />
|
||||
@@ -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>
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
@@ -118,24 +109,6 @@ public interface LauncherCallbacks {
|
||||
/** Must return one of {@link #SEARCH_BAR_HEIGHT_NORMAL} or {@link #SEARCH_BAR_HEIGHT_TALL} */
|
||||
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.
|
||||
*
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -187,14 +173,9 @@ public class LauncherExtension extends Launcher {
|
||||
public void onInteractionEnd() {
|
||||
}
|
||||
|
||||
@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
|
||||
@@ -287,11 +264,6 @@ public class LauncherExtension extends Launcher {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComponentName getWallpaperPickerComponent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean overrideWallpaperDimensions() {
|
||||
return false;
|
||||
@@ -317,115 +289,9 @@ public class LauncherExtension extends Launcher {
|
||||
return false;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user