Skip to content

Commit

Permalink
Modify hotseat.
Browse files Browse the repository at this point in the history
  • Loading branch information
PureAway committed Apr 13, 2018
1 parent 5b8a181 commit e39aa29
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/com/android/launcher3/CellLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -3401,7 +3401,9 @@ public int[] findNearestArea(int pixelX, int pixelY, int spanX, int spanY, int[]

public void setIsFromDesktop(boolean fromDesktop) {
this.fromDesktop = fromDesktop;
mShortcutsAndWidgets.setIsFromDesktop(fromDesktop);
if (isHotseat()) {
mShortcutsAndWidgets.setIsFromDesktop(fromDesktop);
}
}

boolean existsEmptyCell(int itemType) {
Expand Down Expand Up @@ -3664,7 +3666,9 @@ public void setup(int cellWidth, int cellHeight, int widthGap, int heightGap,
public void setupForHotSeat(int cellWidth, int cellHeight, int widthGap, int heightGap,
boolean invertHorizontally, int colCount, boolean fromDesktop) {

if (fromDesktop) {
final int maxColCount = 9;

if (fromDesktop && colCount < maxColCount) {
colCount++;
}

Expand All @@ -3681,7 +3685,6 @@ public void setupForHotSeat(int cellWidth, int cellHeight, int widthGap, int hei
leftMargin - rightMargin;
height = myCellVSpan * cellHeight + ((myCellVSpan - 1) * heightGap) -
topMargin - bottomMargin + 30;
final int maxColCount = 9;
int startX = (maxColCount - colCount) * width / 2;
x = startX + myCellX * (cellWidth + widthGap) + leftMargin;
y = -30;
Expand Down
11 changes: 8 additions & 3 deletions src/com/android/launcher3/Workspace.java
Original file line number Diff line number Diff line change
Expand Up @@ -2640,10 +2640,12 @@ public void prepareAccessibilityDrop() {
}

public void onDrop(final DragObject d) {

boolean dropToDeskTop = false;

mDragViewVisualCenter = d.getVisualCenter(mDragViewVisualCenter);
CellLayout dropTargetLayout = mDropToLayout;


// We want the point to be mapped to the dragTarget.
if (dropTargetLayout != null) {
if (mLauncher.isHotseatLayout(dropTargetLayout)) {
Expand Down Expand Up @@ -2715,6 +2717,8 @@ public void onDrop(final DragObject d) {
foundCell = false;
}

dropToDeskTop = !foundCell && isHotseat;

// if the widget resizes on drop
if (foundCell && (cell instanceof AppWidgetHostView) &&
(resultSpan[0] != item.spanX || resultSpan[1] != item.spanY)) {
Expand Down Expand Up @@ -2808,7 +2812,8 @@ public void run() {
onCompleteRunnable, animationType, cell, false);
} else {
int duration = snapScreen < 0 ? -1 : ADJACENT_SCREEN_DROP_DURATION;
if (isFromDesktop && mLauncher.isHotseatLayout(dropTargetLayout)) {
if (isFromDesktop && mLauncher.isHotseatLayout(dropTargetLayout) && !dropToDeskTop
&& mLauncher.getHotseat().getLayout().getShortcutsAndWidgets().getChildCount() != 9) {
mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, cell, duration,
onCompleteRunnable, this, true);
} else {
Expand Down Expand Up @@ -3722,13 +3727,13 @@ void setup(DragController dragController) {
*/
public void onDropCompleted(final View target, final DragObject d,
final boolean isFlingToDelete, final boolean success) {

itemType = -1;

isFromDesktop = false;

mLauncher.getHotseat().getLayout().setIsFromDesktop(isFromDesktop);


if (mDeferDropAfterUninstall) {
mDeferredAction = new Runnable() {
public void run() {
Expand Down

0 comments on commit e39aa29

Please sign in to comment.