Add smartspace to widgets picker
This commit is contained in:
@@ -130,6 +130,8 @@ import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import app.lawnchair.smartspace.SmartspaceAppWidgetProvider;
|
||||
|
||||
/**
|
||||
* The workspace is a wide area with a wallpaper and a finite number of pages.
|
||||
* Each page contains a number of icons, folders or widgets the user can
|
||||
@@ -1078,6 +1080,29 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
} else {
|
||||
mIsEventOverQsb = false;
|
||||
}
|
||||
if (!mIsEventOverQsb) {
|
||||
mIsEventOverQsb = isEventOverQsb(mXDown, mYDown);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isEventOverQsb(float x, float y) {
|
||||
CellLayout target = (CellLayout) getChildAt(mCurrentPage);
|
||||
ShortcutAndWidgetContainer container = target.getShortcutsAndWidgets();
|
||||
mTempFXY[0] = x;
|
||||
mTempFXY[1] = y;
|
||||
Utilities.mapCoordInSelfToDescendant(container, this, mTempFXY);
|
||||
for (int i = 0; i < container.getChildCount(); i++) {
|
||||
View child = container.getChildAt(i);
|
||||
Object tag = child.getTag();
|
||||
if (!(tag instanceof LauncherAppWidgetInfo)) continue;
|
||||
LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) tag;
|
||||
if (!info.providerName.equals(SmartspaceAppWidgetProvider.componentName)) continue;
|
||||
|
||||
boolean isOverQsb = child.getLeft() <= mTempFXY[0] && child.getRight() >= mTempFXY[0]
|
||||
&& child.getTop() <= mTempFXY[1] && child.getBottom() >= mTempFXY[1];
|
||||
if (isOverQsb) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -46,6 +46,8 @@ import com.android.launcher3.widget.custom.CustomWidgetManager;
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.IntConsumer;
|
||||
|
||||
import app.lawnchair.LawnchairAppWidgetHostView;
|
||||
|
||||
|
||||
/**
|
||||
* Specific {@link AppWidgetHost} that creates our {@link LauncherAppWidgetHostView}
|
||||
@@ -96,7 +98,7 @@ public class LauncherAppWidgetHost extends AppWidgetHost {
|
||||
view = mPendingViews.get(appWidgetId);
|
||||
mPendingViews.remove(appWidgetId);
|
||||
} else {
|
||||
view = new LauncherAppWidgetHostView(context);
|
||||
view = new LawnchairAppWidgetHostView(context);
|
||||
}
|
||||
mViews.put(appWidgetId, view);
|
||||
return view;
|
||||
@@ -216,7 +218,7 @@ public class LauncherAppWidgetHost extends AppWidgetHost {
|
||||
public AppWidgetHostView createView(Context context, int appWidgetId,
|
||||
LauncherAppWidgetProviderInfo appWidget) {
|
||||
if (appWidget.isCustomWidget()) {
|
||||
LauncherAppWidgetHostView lahv = new LauncherAppWidgetHostView(context);
|
||||
LauncherAppWidgetHostView lahv = new LawnchairAppWidgetHostView(context);
|
||||
lahv.setAppWidget(0, appWidget);
|
||||
CustomWidgetManager.INSTANCE.get(context).onViewCreated(lahv);
|
||||
return lahv;
|
||||
|
||||
@@ -46,6 +46,8 @@ import com.android.launcher3.testing.TestProtocol;
|
||||
import com.android.launcher3.widget.dragndrop.AppWidgetHostViewDragListener;
|
||||
import com.android.launcher3.widget.util.WidgetSizes;
|
||||
|
||||
import app.lawnchair.LawnchairAppWidgetHostView;
|
||||
|
||||
/**
|
||||
* Extension of {@link DragPreviewProvider} with logic specific to pending widgets/shortcuts
|
||||
* dragged from the widget tray.
|
||||
@@ -121,7 +123,7 @@ public class PendingItemDragHelper extends DragPreviewProvider {
|
||||
int[] previewSizeBeforeScale = new int[1];
|
||||
|
||||
if (mRemoteViewsPreview != null) {
|
||||
mAppWidgetHostViewPreview = new LauncherAppWidgetHostView(launcher);
|
||||
mAppWidgetHostViewPreview = new LawnchairAppWidgetHostView(launcher);
|
||||
mAppWidgetHostViewPreview.setAppWidget(/* appWidgetId= */ -1,
|
||||
((PendingAddWidgetInfo) mAddInfo).info);
|
||||
DeviceProfile deviceProfile = launcher.getDeviceProfile();
|
||||
|
||||
@@ -58,6 +58,8 @@ import com.android.launcher3.widget.util.WidgetSizes;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import app.lawnchair.LawnchairAppWidgetHostView;
|
||||
|
||||
/**
|
||||
* Represents the individual cell of the widget inside the widget tray. The preview is drawn
|
||||
* horizontally centered, and scaled down if needed.
|
||||
@@ -299,7 +301,7 @@ public class WidgetCell extends LinearLayout {
|
||||
// a preview during drag & drop. And thus, we should use LauncherAppWidgetHostView, which
|
||||
// supports applying local color extraction during drag & drop.
|
||||
mAppWidgetHostViewPreview = isLauncherContext(context)
|
||||
? new LauncherAppWidgetHostView(context)
|
||||
? new LawnchairAppWidgetHostView(context)
|
||||
: createAppWidgetHostView(context);
|
||||
LauncherAppWidgetProviderInfo launcherAppWidgetProviderInfo =
|
||||
LauncherAppWidgetProviderInfo.fromProviderInfo(context, item.widgetInfo.clone());
|
||||
|
||||
Reference in New Issue
Block a user