去掉抽屉,去掉取消按钮

This commit is contained in:
2020-11-16 16:56:51 +08:00
parent 888ba814ea
commit 5ef06d1b3f
12 changed files with 170 additions and 62 deletions

View File

@@ -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);
}
}

View File

@@ -201,7 +201,8 @@ public class DropTargetBar extends FrameLayout
visibleCount++;
}
}
return visibleCount;
// return visibleCount;
return 1;
}
public void animateToVisibility(boolean isVisible) {

View File

@@ -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;

View File

@@ -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(

View File

@@ -1511,15 +1511,15 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
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);

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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<LauncherActivityInfo> 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<Pair<ItemInfo, Object>> installQueue = new ArrayList<>();
final List<UserHandle> profiles = mUserManager.getUserProfiles();
for (UserHandle user : profiles) {
final List<LauncherActivityInfo> apps = mLauncherApps.getActivityList(null, user);
ArrayList<InstallShortcutReceiver.PendingInstallShortcutInfo> added = new ArrayList<InstallShortcutReceiver.PendingInstallShortcutInfo>();
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();

View File

@@ -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<AppInfo> 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<Pair<ItemInfo, Object>> installQueue = new ArrayList<>();
final List<UserHandle> profiles = UserManagerCompat.getInstance(context).getUserProfiles();
ArrayList<InstallShortcutReceiver.PendingInstallShortcutInfo> added
= new ArrayList<InstallShortcutReceiver.PendingInstallShortcutInfo>();
for (UserHandle user : profiles) {
final List<LauncherActivityInfo> 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.