diff --git a/res/layout/drop_target_bar.xml b/res/layout/drop_target_bar.xml index b4fed04..2d87a72 100644 --- a/res/layout/drop_target_bar.xml +++ b/res/layout/drop_target_bar.xml @@ -29,6 +29,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" + android:visibility="gone" android:gravity="center" android:text="@string/remove_drop_target_label" /> diff --git a/res/xml/default_workspace_6x4.xml b/res/xml/default_workspace_6x4.xml index 97d7475..292ed39 100644 --- a/res/xml/default_workspace_6x4.xml +++ b/res/xml/default_workspace_6x4.xml @@ -68,30 +68,38 @@ + + + + - - - + + + + + + - + - - - + + + + + + - + - - - - + + + + + + + diff --git a/src/com/android/uiuios/DeleteDropTarget.java b/src/com/android/uiuios/DeleteDropTarget.java index 4b461e8..ed8c362 100644 --- a/src/com/android/uiuios/DeleteDropTarget.java +++ b/src/com/android/uiuios/DeleteDropTarget.java @@ -89,11 +89,20 @@ public class DeleteDropTarget extends ButtonDropTarget { */ private void setTextBasedOnDragSource(ItemInfo item) { if (!TextUtils.isEmpty(mText)) { - mText = getResources().getString(canRemove(item) - ? R.string.remove_drop_target_label - : android.R.string.cancel); +// mText = getResources().getString(canRemove(item) +//// ? R.string.remove_drop_target_label +//// : android.R.string.cancel); + //add for hide deletedroptarget + if (LauncherAppState.isDisableAllApps()) { + android.util.Log.e("Launcher3", "hide delete drop target"); + mText = getResources().getString(isCanDrop(item) + ? R.string.remove_drop_target_label + : android.R.string.cancel); + } setContentDescription(mText); requestLayout(); + setVisibility(View.GONE); + } } @@ -105,8 +114,13 @@ public class DeleteDropTarget extends ButtonDropTarget { * Set mControlType depending on the drag item. */ private void setControlTypeBasedOnDragSource(ItemInfo item) { - mControlType = item.id != ItemInfo.NO_ID ? ControlType.REMOVE_TARGET - : ControlType.CANCEL_TARGET; +// mControlType = item.id != ItemInfo.NO_ID ? ControlType.REMOVE_TARGET +// : ControlType.CANCEL_TARGET; + //add for hide deletedroptarget [S] + if (LauncherAppState.isDisableAllApps()) { + mControlType = isCanDrop(item) ? ControlType.REMOVE_TARGET + : ControlType.CANCEL_TARGET; + } } @Override @@ -128,8 +142,8 @@ public class DeleteDropTarget extends ButtonDropTarget { modelWriter.abortDelete(itemPage); mLauncher.getUserEventDispatcher().logActionOnControl(TAP, UNDO); }; - Snackbar.show(mLauncher, R.string.item_removed, R.string.undo, - modelWriter::commitDelete, onUndoClicked); +// Snackbar.show(mLauncher, R.string.item_removed, R.string.undo, +// modelWriter::commitDelete, onUndoClicked); } } @@ -141,10 +155,12 @@ public class DeleteDropTarget extends ButtonDropTarget { // Remove the item from launcher and the db, we can ignore the containerInfo in this call // because we already remove the drag view from the folder (if the drag originated from // a folder) in Folder.beginDrag() - mLauncher.removeItem(view, item, true /* deleteFromDb */); - mLauncher.getWorkspace().stripEmptyScreens(); - mLauncher.getDragLayer() - .announceForAccessibility(getContext().getString(R.string.item_removed)); + if (!LauncherAppState.isDisableAllApps() || isCanDrop(item)) { + mLauncher.removeItem(view, item, true /* deleteFromDb */); + mLauncher.getWorkspace().stripEmptyScreens(); + mLauncher.getDragLayer() + .announceForAccessibility(getContext().getString(R.string.item_removed)); + } } @Override @@ -153,4 +169,9 @@ public class DeleteDropTarget extends ButtonDropTarget { t.controlType = mControlType; return t; } + + private boolean isCanDrop(ItemInfo item) { + return !(item.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION || + item.itemType == LauncherSettings.Favorites.ITEM_TYPE_FOLDER); + } } diff --git a/src/com/android/uiuios/DropTargetBar.java b/src/com/android/uiuios/DropTargetBar.java index 4f6319a..292f83c 100644 --- a/src/com/android/uiuios/DropTargetBar.java +++ b/src/com/android/uiuios/DropTargetBar.java @@ -201,7 +201,8 @@ public class DropTargetBar extends FrameLayout visibleCount++; } } - return visibleCount; +// return visibleCount; + return 1; } public void animateToVisibility(boolean isVisible) { diff --git a/src/com/android/uiuios/InstallShortcutReceiver.java b/src/com/android/uiuios/InstallShortcutReceiver.java index 780e02f..07dc2c0 100644 --- a/src/com/android/uiuios/InstallShortcutReceiver.java +++ b/src/com/android/uiuios/InstallShortcutReceiver.java @@ -324,7 +324,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver { return name; } - private static class PendingInstallShortcutInfo { + public static class PendingInstallShortcutInfo { final LauncherActivityInfo activityInfo; final ShortcutInfo shortcutInfo; diff --git a/src/com/android/uiuios/LauncherAppState.java b/src/com/android/uiuios/LauncherAppState.java index 7093b6e..b86b8a4 100644 --- a/src/com/android/uiuios/LauncherAppState.java +++ b/src/com/android/uiuios/LauncherAppState.java @@ -67,6 +67,10 @@ public class LauncherAppState { return mContext; } + public static boolean isDisableAllApps() { + return true; + } + private LauncherAppState(Context context) { if (getLocalProvider(context) == null) { throw new RuntimeException( diff --git a/src/com/android/uiuios/Workspace.java b/src/com/android/uiuios/Workspace.java index d41fd6d..5d82d5c 100644 --- a/src/com/android/uiuios/Workspace.java +++ b/src/com/android/uiuios/Workspace.java @@ -1511,15 +1511,15 @@ public class Workspace extends PagedView mDragSourceInternal = (ShortcutAndWidgetContainer) child.getParent(); } - if (child instanceof BubbleTextView && !dragOptions.isAccessibleDrag) { - PopupContainerWithArrow popupContainer = PopupContainerWithArrow - .showForIcon((BubbleTextView) child); - if (popupContainer != null) { - dragOptions.preDragCondition = popupContainer.createPreDragCondition(); - - mLauncher.getUserEventDispatcher().resetElapsedContainerMillis("dragging started"); - } - } +// if (child instanceof BubbleTextView && !dragOptions.isAccessibleDrag) { +// PopupContainerWithArrow popupContainer = PopupContainerWithArrow +// .showForIcon((BubbleTextView) child); +// if (popupContainer != null) { +// dragOptions.preDragCondition = popupContainer.createPreDragCondition(); +// +// mLauncher.getUserEventDispatcher().resetElapsedContainerMillis("dragging started"); +// } +// } DragView dv = mDragController.startDrag(b, dragLayerX, dragLayerY, source, dragObject, dragVisualizeOffset, dragRect, scale * iconScale, scale, dragOptions); diff --git a/src/com/android/uiuios/dragndrop/DragController.java b/src/com/android/uiuios/dragndrop/DragController.java index e56d956..14eeccf 100644 --- a/src/com/android/uiuios/dragndrop/DragController.java +++ b/src/com/android/uiuios/dragndrop/DragController.java @@ -35,10 +35,13 @@ import android.view.MotionEvent; import android.view.View; import com.android.uiuios.AbstractFloatingView; +import com.android.uiuios.DeleteDropTarget; import com.android.uiuios.DragSource; import com.android.uiuios.DropTarget; import com.android.uiuios.ItemInfo; import com.android.uiuios.Launcher; +import com.android.uiuios.LauncherAppState; +import com.android.uiuios.LauncherSettings; import com.android.uiuios.R; import com.android.uiuios.WorkspaceItemInfo; import com.android.uiuios.accessibility.DragViewStateAnnouncer; @@ -635,6 +638,12 @@ public class DragController implements DragDriver.EventListener, TouchController dropTarget.onDrop(mDragObject, mOptions); } accepted = true; + + //add for cancel canceldroptarget handle + if (LauncherAppState.isDisableAllApps() && dropTarget instanceof DeleteDropTarget && + isNeedCancelDrag(mDragObject.dragInfo)) { + cancelDrag(); + } } } final View dropTargetAsView = dropTarget instanceof View ? (View) dropTarget : null; @@ -642,6 +651,11 @@ public class DragController implements DragDriver.EventListener, TouchController dispatchDropComplete(dropTargetAsView, accepted); } + private boolean isNeedCancelDrag(ItemInfo item){ + return (item.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION || + item.itemType == LauncherSettings.Favorites.ITEM_TYPE_FOLDER); + } + private DropTarget findDropTarget(int x, int y, int[] dropCoordinates) { mDragObject.x = x; mDragObject.y = y; diff --git a/src/com/android/uiuios/model/BaseModelUpdateTask.java b/src/com/android/uiuios/model/BaseModelUpdateTask.java index b9923fc..151e10f 100644 --- a/src/com/android/uiuios/model/BaseModelUpdateTask.java +++ b/src/com/android/uiuios/model/BaseModelUpdateTask.java @@ -62,7 +62,7 @@ public abstract class BaseModelUpdateTask implements ModelUpdateTask { Log.d(TAG, "Ignoring model task since loader is pending=" + this); } // Loader has not yet run. - return; +// return; } execute(mApp, mDataModel, mAllAppsList); } diff --git a/src/com/android/uiuios/model/LoaderTask.java b/src/com/android/uiuios/model/LoaderTask.java index bcb1d83..ace1a2f 100644 --- a/src/com/android/uiuios/model/LoaderTask.java +++ b/src/com/android/uiuios/model/LoaderTask.java @@ -38,6 +38,7 @@ import android.text.TextUtils; import android.util.Log; import android.util.LongSparseArray; import android.util.MutableInt; +import android.util.Pair; import com.android.uiuios.AllAppsList; import com.android.uiuios.AppInfo; @@ -187,6 +188,8 @@ public class LoaderTask implements Runnable { TraceHelper.partitionSection(TAG, "step 2.1: loading all apps"); List allActivityList = loadAllApps(); + verifyApplications(); + TraceHelper.partitionSection(TAG, "step 2.2: Binding all apps"); verifyNotStopped(); mResults.bindAllApps(); @@ -242,6 +245,27 @@ public class LoaderTask implements Runnable { TraceHelper.endSection(TAG); } + //add for load all app on workspace + private void verifyApplications() { + final Context context = mApp.getContext(); + ArrayList> installQueue = new ArrayList<>(); + final List profiles = mUserManager.getUserProfiles(); + for (UserHandle user : profiles) { + final List apps = mLauncherApps.getActivityList(null, user); + ArrayList added = new ArrayList(); + synchronized (this) { + for (LauncherActivityInfo app : apps) { + InstallShortcutReceiver.PendingInstallShortcutInfo pendingInstallShortcutInfo = new InstallShortcutReceiver.PendingInstallShortcutInfo(app, context); + added.add(pendingInstallShortcutInfo); + installQueue.add(pendingInstallShortcutInfo.getItemInfo()); + } + } + if (!added.isEmpty()) { + mApp.getModel().addAndBindAddedWorkspaceItems(installQueue); + } + } + } + public synchronized void stopLocked() { mStopped = true; this.notify(); diff --git a/src/com/android/uiuios/model/PackageUpdatedTask.java b/src/com/android/uiuios/model/PackageUpdatedTask.java index 3041f3f..316674f 100644 --- a/src/com/android/uiuios/model/PackageUpdatedTask.java +++ b/src/com/android/uiuios/model/PackageUpdatedTask.java @@ -18,10 +18,12 @@ package com.android.uiuios.model; import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.content.pm.LauncherActivityInfo; import android.content.pm.ShortcutInfo; import android.os.Process; import android.os.UserHandle; import android.util.Log; +import android.util.Pair; import com.android.uiuios.AllAppsList; import com.android.uiuios.AppInfo; @@ -155,6 +157,9 @@ public class PackageUpdatedTask extends BaseModelUpdateTask { final ArrayList addedOrModified = new ArrayList<>(); addedOrModified.addAll(appsList.added); + + updateToWorkSpace(context, app, appsList); + appsList.added.clear(); addedOrModified.addAll(appsList.modified); appsList.modified.clear(); @@ -352,6 +357,33 @@ public class PackageUpdatedTask extends BaseModelUpdateTask { } } + //add for load new install app on workspace + public void updateToWorkSpace(Context context, LauncherAppState app , AllAppsList appsList){ + ArrayList> installQueue = new ArrayList<>(); + final List profiles = UserManagerCompat.getInstance(context).getUserProfiles(); + ArrayList added + = new ArrayList(); + + for (UserHandle user : profiles) { + final List apps = LauncherAppsCompat.getInstance(context).getActivityList(null, user); + synchronized (this) { + for (LauncherActivityInfo info : apps) { + for (AppInfo appInfo : appsList.added) { + if(info.getComponentName().equals(appInfo.componentName)){ + InstallShortcutReceiver.PendingInstallShortcutInfo mPendingInstallShortcutInfo + = new InstallShortcutReceiver.PendingInstallShortcutInfo(info,context); + added.add(mPendingInstallShortcutInfo); + installQueue.add(mPendingInstallShortcutInfo.getItemInfo()); + } + } + } + } + } + if (!added.isEmpty()) { + app.getModel().addAndBindAddedWorkspaceItems(installQueue); + } + } + /** * Updates {@param si}'s intent to point to a new ComponentName. * @return Whether the shortcut intent was changed. diff --git a/src_ui_overrides/com/android/uiuios/uioverrides/AllAppsSwipeController.java b/src_ui_overrides/com/android/uiuios/uioverrides/AllAppsSwipeController.java index d5d208c..a625125 100644 --- a/src_ui_overrides/com/android/uiuios/uioverrides/AllAppsSwipeController.java +++ b/src_ui_overrides/com/android/uiuios/uioverrides/AllAppsSwipeController.java @@ -26,24 +26,27 @@ public class AllAppsSwipeController extends AbstractStateChangeTouchController { @Override protected boolean canInterceptTouch(MotionEvent ev) { - if (ev.getAction() == MotionEvent.ACTION_DOWN) { - mTouchDownEvent = ev; - } - if (mCurrentAnimation != null) { - // If we are already animating from a previous state, we can intercept. - return true; - } - if (AbstractFloatingView.getTopOpenView(mLauncher) != null) { - return false; - } - if (!mLauncher.isInState(NORMAL) && !mLauncher.isInState(ALL_APPS)) { - // Don't listen for the swipe gesture if we are already in some other state. - return false; - } - if (mLauncher.isInState(ALL_APPS) && !mLauncher.getAppsView().shouldContainerScroll(ev)) { - return false; - } - return true; + + return false; + +// if (ev.getAction() == MotionEvent.ACTION_DOWN) { +// mTouchDownEvent = ev; +// } +// if (mCurrentAnimation != null) { +// // If we are already animating from a previous state, we can intercept. +// return true; +// } +// if (AbstractFloatingView.getTopOpenView(mLauncher) != null) { +// return false; +// } +// if (!mLauncher.isInState(NORMAL) && !mLauncher.isInState(ALL_APPS)) { +// // Don't listen for the swipe gesture if we are already in some other state. +// return false; +// } +// if (mLauncher.isInState(ALL_APPS) && !mLauncher.getAppsView().shouldContainerScroll(ev)) { +// return false; +// } +// return true; } @Override