mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 00:06:47 +00:00
Converting widget panel into a floating view
> The widget panel is only inflated when needed > Using the swipe up/down interaction for widgets tray > Removing additional view wrappers from all-apps > Widget tray is preserved across activity recreation > Launcher no longer has WIDGET state, the actual code around the states will be removed in a follow-up cl Bug: 67678570 Bug: 67585158 Change-Id: Ia29a7c33ec81e6c53cc24e2906b7022b6f41755b
This commit is contained in:
@@ -16,10 +16,8 @@
|
||||
package com.android.launcher3.allapps;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.InsetDrawable;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.text.Selection;
|
||||
import android.text.SpannableStringBuilder;
|
||||
@@ -28,10 +26,11 @@ import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.android.launcher3.AppInfo;
|
||||
import com.android.launcher3.BaseContainerView;
|
||||
import com.android.launcher3.BubbleTextView;
|
||||
import com.android.launcher3.ClickShadowView;
|
||||
import com.android.launcher3.DeleteDropTarget;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.DragSource;
|
||||
@@ -41,7 +40,6 @@ import com.android.launcher3.ItemInfo;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.PromiseAppInfo;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.anim.SpringAnimationHandler;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.dragndrop.DragController;
|
||||
@@ -49,9 +47,8 @@ import com.android.launcher3.dragndrop.DragOptions;
|
||||
import com.android.launcher3.folder.Folder;
|
||||
import com.android.launcher3.keyboard.FocusedItemDecorator;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
|
||||
import com.android.launcher3.util.ComponentKey;
|
||||
import com.android.launcher3.util.ComponentKeyMapper;
|
||||
import com.android.launcher3.util.PackageUserKey;
|
||||
import com.android.launcher3.util.TransformingTouchDelegate;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -59,13 +56,17 @@ import java.util.Set;
|
||||
/**
|
||||
* The all apps view container.
|
||||
*/
|
||||
public class AllAppsContainerView extends BaseContainerView implements DragSource,
|
||||
View.OnLongClickListener, Insettable {
|
||||
public class AllAppsContainerView extends RelativeLayout implements DragSource,
|
||||
View.OnLongClickListener, Insettable, DeviceProfile.LauncherLayoutChangeListener,
|
||||
BubbleTextView.BubbleTextShadowHandler {
|
||||
|
||||
protected final Rect mBasePadding = new Rect();
|
||||
|
||||
private final Launcher mLauncher;
|
||||
private final AlphabeticalAppsList mApps;
|
||||
private final AllAppsGridAdapter mAdapter;
|
||||
private final LinearLayoutManager mLayoutManager;
|
||||
private final ClickShadowView mTouchFeedbackView;
|
||||
|
||||
private AllAppsRecyclerView mAppsRecyclerView;
|
||||
private SearchUiManager mSearchUiManager;
|
||||
@@ -78,6 +79,8 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
|
||||
|
||||
private SpringAnimationHandler mSpringAnimationHandler;
|
||||
|
||||
private TransformingTouchDelegate mTouchDelegate;
|
||||
|
||||
public AllAppsContainerView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
@@ -98,19 +101,69 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
|
||||
mSearchQueryBuilder = new SpannableStringBuilder();
|
||||
|
||||
Selection.setSelection(mSearchQueryBuilder, 0);
|
||||
|
||||
mTouchFeedbackView = new ClickShadowView(context);
|
||||
// Make the feedback view large enough to hold the blur bitmap.
|
||||
int size = mLauncher.getDeviceProfile().allAppsIconSizePx
|
||||
+ mTouchFeedbackView.getExtraSize();
|
||||
addView(mTouchFeedbackView, size, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateBackground(
|
||||
int paddingLeft, int paddingTop, int paddingRight, int paddingBottom) {
|
||||
if (mLauncher.getDeviceProfile().isVerticalBarLayout()) {
|
||||
getRevealView().setBackground(new InsetDrawable(mBaseDrawable,
|
||||
paddingLeft, paddingTop, paddingRight, paddingBottom));
|
||||
getContentView().setBackground(
|
||||
new InsetDrawable(new ColorDrawable(Color.TRANSPARENT),
|
||||
paddingLeft, paddingTop, paddingRight, paddingBottom));
|
||||
} else {
|
||||
getRevealView().setBackground(mBaseDrawable);
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
|
||||
DeviceProfile grid = Launcher.getLauncher(getContext()).getDeviceProfile();
|
||||
grid.addLauncherLayoutChangedListener(this);
|
||||
|
||||
mTouchDelegate = new TransformingTouchDelegate(mAppsRecyclerView);
|
||||
setTouchDelegate(mTouchDelegate);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
|
||||
DeviceProfile grid = Launcher.getLauncher(getContext()).getDeviceProfile();
|
||||
grid.removeLauncherLayoutChangedListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the background padding as it can change due to insets/content padding change.
|
||||
*/
|
||||
@Override
|
||||
public void onLauncherLayoutChanged() {
|
||||
DeviceProfile grid = mLauncher.getDeviceProfile();
|
||||
if (!grid.isVerticalBarLayout()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int[] padding = grid.getContainerPadding();
|
||||
int paddingLeft = padding[0];
|
||||
int paddingRight = padding[1];
|
||||
mBasePadding.set(paddingLeft, 0, paddingRight, 0);
|
||||
setPadding(paddingLeft, 0, paddingRight, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
mTouchDelegate.setBounds(
|
||||
mAppsRecyclerView.getLeft() - mBasePadding.left,
|
||||
mAppsRecyclerView.getTop() - mBasePadding.top,
|
||||
mAppsRecyclerView.getRight() + mBasePadding.right,
|
||||
mAppsRecyclerView.getBottom() + mBasePadding.bottom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPressedIcon(BubbleTextView icon, Bitmap background) {
|
||||
if (icon == null || background == null) {
|
||||
mTouchFeedbackView.setBitmap(null);
|
||||
mTouchFeedbackView.animate().cancel();
|
||||
} else if (mTouchFeedbackView.setBitmap(background)) {
|
||||
View rv = findViewById(R.id.apps_list_view);
|
||||
mTouchFeedbackView.alignWithIconView(icon, (ViewGroup) icon.getParent(), rv);
|
||||
mTouchFeedbackView.animateShadow();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,23 +210,7 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
|
||||
if (mLauncher.getDragLayer().isEventOverView(mSearchContainer, ev)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int[] point = new int[2];
|
||||
point[0] = (int) ev.getX();
|
||||
point[1] = (int) ev.getY();
|
||||
Utilities.mapCoordInSelfToDescendant(
|
||||
mAppsRecyclerView.getScrollBar(), mLauncher.getDragLayer(), point);
|
||||
// IF the MotionEvent is inside the thumb, container should not be pulled down.
|
||||
if (mAppsRecyclerView.getScrollBar().shouldBlockIntercept(point[0], point[1])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// IF scroller is at the very top OR there is no scroll bar because there is probably not
|
||||
// enough items to scroll, THEN it's okay for the container to be pulled down.
|
||||
if (mAppsRecyclerView.getCurrentScrollY() == 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return mAppsRecyclerView.shouldContainerScroll(ev, mLauncher.getDragLayer());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -191,7 +228,7 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
|
||||
|
||||
// This is a focus listener that proxies focus from a view into the list view. This is to
|
||||
// work around the search box from getting first focus and showing the cursor.
|
||||
getContentView().setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
if (hasFocus) {
|
||||
@@ -222,20 +259,13 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
|
||||
mAppsRecyclerView.preMeasureViews(mAdapter);
|
||||
mAdapter.setIconFocusListener(focusedItemDecorator.getFocusListener());
|
||||
|
||||
getRevealView().setVisibility(View.VISIBLE);
|
||||
getContentView().setVisibility(View.VISIBLE);
|
||||
getContentView().setBackground(null);
|
||||
onLauncherLayoutChanged();
|
||||
}
|
||||
|
||||
public SearchUiManager getSearchUiManager() {
|
||||
return mSearchUiManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getTouchDelegateTargetView() {
|
||||
return mAppsRecyclerView;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
DeviceProfile grid = mLauncher.getDeviceProfile();
|
||||
|
||||
Reference in New Issue
Block a user