mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-04 01:46:49 +00:00
Implemnet methods to drag a icon to given Workspace cell
The CL implements public methods to drag an Icon from AllApps to a given cell in the workspace. Bug: 199120092 Test: Launcher3Tests:com.android.launcher3.ui.TaplTestsLauncher3#testDragAppIconToWorkspaceCell Test: https://android-build.googleplex.com/builds/abtd/run/L89300000953052361 Test: https://android-build.googleplex.com/builds/abtd/run/L44500000953013792 Change-Id: Ife16d1f1b55b809763dd40f5afee6711049a4729
This commit is contained in:
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.
|
||||
*/
|
||||
|
||||
package com.android.launcher3.testing;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* Request object for querying a workspace cell region in Rect.
|
||||
*/
|
||||
public class WorkspaceCellCenterRequest implements TestInformationRequest {
|
||||
public final int cellX;
|
||||
public final int cellY;
|
||||
public final int spanX;
|
||||
public final int spanY;
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(cellX);
|
||||
dest.writeInt(cellY);
|
||||
dest.writeInt(spanX);
|
||||
dest.writeInt(spanY);
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<WorkspaceCellCenterRequest> CREATOR =
|
||||
new Parcelable.Creator<WorkspaceCellCenterRequest>() {
|
||||
|
||||
@Override
|
||||
public WorkspaceCellCenterRequest createFromParcel(Parcel source) {
|
||||
return new WorkspaceCellCenterRequest(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorkspaceCellCenterRequest[] newArray(int size) {
|
||||
return new WorkspaceCellCenterRequest[size];
|
||||
}
|
||||
};
|
||||
|
||||
private WorkspaceCellCenterRequest(int cellX, int cellY, int spanX, int spanY) {
|
||||
this.cellX = cellX;
|
||||
this.cellY = cellY;
|
||||
this.spanX = spanX;
|
||||
this.spanY = spanY;
|
||||
}
|
||||
|
||||
private WorkspaceCellCenterRequest(Parcel in) {
|
||||
this(in.readInt(), in.readInt(), in.readInt(), in.readInt());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder for WorkspaceCellRectRequest.
|
||||
*
|
||||
* @return WorkspaceCellRectRequest builder.
|
||||
*/
|
||||
public static WorkspaceCellCenterRequest.Builder builder() {
|
||||
return new WorkspaceCellCenterRequest.Builder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequestName() {
|
||||
return TestProtocol.REQUEST_WORKSPACE_CELL_CENTER;
|
||||
}
|
||||
|
||||
/**
|
||||
* WorkspaceCellRectRequest Builder.
|
||||
*/
|
||||
public static final class Builder {
|
||||
private int mCellX;
|
||||
private int mCellY;
|
||||
private int mSpanX;
|
||||
private int mSpanY;
|
||||
|
||||
private Builder() {
|
||||
this.mCellX = 0;
|
||||
this.mCellY = 0;
|
||||
this.mSpanX = 1;
|
||||
this.mSpanY = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set X coordinate of upper left corner expressed as a cell position
|
||||
*/
|
||||
public WorkspaceCellCenterRequest.Builder setCellX(int x) {
|
||||
this.mCellX = x;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Y coordinate of upper left corner expressed as a cell position
|
||||
*/
|
||||
public WorkspaceCellCenterRequest.Builder setCellY(int y) {
|
||||
this.mCellY = y;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set span Width in cells
|
||||
*/
|
||||
public WorkspaceCellCenterRequest.Builder setSpanX(int x) {
|
||||
this.mSpanX = x;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set span Height in cells
|
||||
*/
|
||||
public WorkspaceCellCenterRequest.Builder setSpanY(int y) {
|
||||
this.mCellY = y;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* build the WorkspaceCellRectRequest.
|
||||
*/
|
||||
public WorkspaceCellCenterRequest build() {
|
||||
return new WorkspaceCellCenterRequest(mCellX, mCellY, mSpanX, mSpanY);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user