去掉抽屉,去掉取消按钮

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

@@ -29,6 +29,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:visibility="gone"
android:gravity="center" android:gravity="center"
android:text="@string/remove_drop_target_label" /> android:text="@string/remove_drop_target_label" />

View File

@@ -68,30 +68,38 @@
<favorite launcher:uri="#Intent;action=android.intent.action.CAMERA_BUTTON;end" /> <favorite launcher:uri="#Intent;action=android.intent.action.CAMERA_BUTTON;end" />
</resolve> </resolve>
<resolve
launcher:container="-101"
launcher:screen="5"
launcher:x="5"
launcher:y="0" >
<favorite launcher:uri="#Intent;action=android.intent.action.MAIN;component=com.android.deskclock/.DeskClock;end" />
</resolve>
<!-- Bottom row --> <!-- Bottom row -->
<resolve <!-- <resolve-->
launcher:screen="0" <!-- launcher:screen="0"-->
launcher:x="0" <!-- launcher:x="0"-->
launcher:y="-1" > <!-- launcher:y="-1" >-->
<favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_EMAIL;end" /> <!-- <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_EMAIL;end" />-->
<favorite launcher:uri="mailto:" /> <!-- <favorite launcher:uri="mailto:" />-->
</resolve> <!-- </resolve>-->
<resolve <!-- <resolve-->
launcher:screen="0" <!-- launcher:screen="0"-->
launcher:x="1" <!-- launcher:x="1"-->
launcher:y="-1" > <!-- launcher:y="-1" >-->
<favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_GALLERY;end" /> <!-- <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_GALLERY;end" />-->
<favorite launcher:uri="#Intent;type=images/*;end" /> <!-- <favorite launcher:uri="#Intent;type=images/*;end" />-->
</resolve> <!-- </resolve>-->
<resolve <!-- <resolve-->
launcher:screen="0" <!-- launcher:screen="0"-->
launcher:x="4" <!-- launcher:x="4"-->
launcher:y="-1" > <!-- launcher:y="-1" >-->
<favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_MARKET;end" /> <!-- <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_MARKET;end" />-->
<favorite launcher:uri="market://details?id=com.android.launcher" /> <!-- <favorite launcher:uri="market://details?id=com.android.launcher" />-->
</resolve> <!-- </resolve>-->
</favorites> </favorites>

View File

@@ -89,11 +89,20 @@ public class DeleteDropTarget extends ButtonDropTarget {
*/ */
private void setTextBasedOnDragSource(ItemInfo item) { private void setTextBasedOnDragSource(ItemInfo item) {
if (!TextUtils.isEmpty(mText)) { if (!TextUtils.isEmpty(mText)) {
mText = getResources().getString(canRemove(item) // 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 ? R.string.remove_drop_target_label
: android.R.string.cancel); : android.R.string.cancel);
}
setContentDescription(mText); setContentDescription(mText);
requestLayout(); requestLayout();
setVisibility(View.GONE);
} }
} }
@@ -105,9 +114,14 @@ public class DeleteDropTarget extends ButtonDropTarget {
* Set mControlType depending on the drag item. * Set mControlType depending on the drag item.
*/ */
private void setControlTypeBasedOnDragSource(ItemInfo item) { private void setControlTypeBasedOnDragSource(ItemInfo item) {
mControlType = item.id != ItemInfo.NO_ID ? ControlType.REMOVE_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; : ControlType.CANCEL_TARGET;
} }
}
@Override @Override
public void onDrop(DragObject d, DragOptions options) { public void onDrop(DragObject d, DragOptions options) {
@@ -128,8 +142,8 @@ public class DeleteDropTarget extends ButtonDropTarget {
modelWriter.abortDelete(itemPage); modelWriter.abortDelete(itemPage);
mLauncher.getUserEventDispatcher().logActionOnControl(TAP, UNDO); mLauncher.getUserEventDispatcher().logActionOnControl(TAP, UNDO);
}; };
Snackbar.show(mLauncher, R.string.item_removed, R.string.undo, // Snackbar.show(mLauncher, R.string.item_removed, R.string.undo,
modelWriter::commitDelete, onUndoClicked); // modelWriter::commitDelete, onUndoClicked);
} }
} }
@@ -141,11 +155,13 @@ public class DeleteDropTarget extends ButtonDropTarget {
// Remove the item from launcher and the db, we can ignore the containerInfo in this call // 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 // because we already remove the drag view from the folder (if the drag originated from
// a folder) in Folder.beginDrag() // a folder) in Folder.beginDrag()
if (!LauncherAppState.isDisableAllApps() || isCanDrop(item)) {
mLauncher.removeItem(view, item, true /* deleteFromDb */); mLauncher.removeItem(view, item, true /* deleteFromDb */);
mLauncher.getWorkspace().stripEmptyScreens(); mLauncher.getWorkspace().stripEmptyScreens();
mLauncher.getDragLayer() mLauncher.getDragLayer()
.announceForAccessibility(getContext().getString(R.string.item_removed)); .announceForAccessibility(getContext().getString(R.string.item_removed));
} }
}
@Override @Override
public Target getDropTargetForLogging() { public Target getDropTargetForLogging() {
@@ -153,4 +169,9 @@ public class DeleteDropTarget extends ButtonDropTarget {
t.controlType = mControlType; t.controlType = mControlType;
return t; 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++; visibleCount++;
} }
} }
return visibleCount; // return visibleCount;
return 1;
} }
public void animateToVisibility(boolean isVisible) { public void animateToVisibility(boolean isVisible) {

View File

@@ -324,7 +324,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
return name; return name;
} }
private static class PendingInstallShortcutInfo { public static class PendingInstallShortcutInfo {
final LauncherActivityInfo activityInfo; final LauncherActivityInfo activityInfo;
final ShortcutInfo shortcutInfo; final ShortcutInfo shortcutInfo;

View File

@@ -67,6 +67,10 @@ public class LauncherAppState {
return mContext; return mContext;
} }
public static boolean isDisableAllApps() {
return true;
}
private LauncherAppState(Context context) { private LauncherAppState(Context context) {
if (getLocalProvider(context) == null) { if (getLocalProvider(context) == null) {
throw new RuntimeException( throw new RuntimeException(

View File

@@ -1511,15 +1511,15 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
mDragSourceInternal = (ShortcutAndWidgetContainer) child.getParent(); mDragSourceInternal = (ShortcutAndWidgetContainer) child.getParent();
} }
if (child instanceof BubbleTextView && !dragOptions.isAccessibleDrag) { // if (child instanceof BubbleTextView && !dragOptions.isAccessibleDrag) {
PopupContainerWithArrow popupContainer = PopupContainerWithArrow // PopupContainerWithArrow popupContainer = PopupContainerWithArrow
.showForIcon((BubbleTextView) child); // .showForIcon((BubbleTextView) child);
if (popupContainer != null) { // if (popupContainer != null) {
dragOptions.preDragCondition = popupContainer.createPreDragCondition(); // dragOptions.preDragCondition = popupContainer.createPreDragCondition();
//
mLauncher.getUserEventDispatcher().resetElapsedContainerMillis("dragging started"); // mLauncher.getUserEventDispatcher().resetElapsedContainerMillis("dragging started");
} // }
} // }
DragView dv = mDragController.startDrag(b, dragLayerX, dragLayerY, source, DragView dv = mDragController.startDrag(b, dragLayerX, dragLayerY, source,
dragObject, dragVisualizeOffset, dragRect, scale * iconScale, scale, dragOptions); dragObject, dragVisualizeOffset, dragRect, scale * iconScale, scale, dragOptions);

View File

@@ -35,10 +35,13 @@ import android.view.MotionEvent;
import android.view.View; import android.view.View;
import com.android.uiuios.AbstractFloatingView; import com.android.uiuios.AbstractFloatingView;
import com.android.uiuios.DeleteDropTarget;
import com.android.uiuios.DragSource; import com.android.uiuios.DragSource;
import com.android.uiuios.DropTarget; import com.android.uiuios.DropTarget;
import com.android.uiuios.ItemInfo; import com.android.uiuios.ItemInfo;
import com.android.uiuios.Launcher; import com.android.uiuios.Launcher;
import com.android.uiuios.LauncherAppState;
import com.android.uiuios.LauncherSettings;
import com.android.uiuios.R; import com.android.uiuios.R;
import com.android.uiuios.WorkspaceItemInfo; import com.android.uiuios.WorkspaceItemInfo;
import com.android.uiuios.accessibility.DragViewStateAnnouncer; import com.android.uiuios.accessibility.DragViewStateAnnouncer;
@@ -635,6 +638,12 @@ public class DragController implements DragDriver.EventListener, TouchController
dropTarget.onDrop(mDragObject, mOptions); dropTarget.onDrop(mDragObject, mOptions);
} }
accepted = true; 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; final View dropTargetAsView = dropTarget instanceof View ? (View) dropTarget : null;
@@ -642,6 +651,11 @@ public class DragController implements DragDriver.EventListener, TouchController
dispatchDropComplete(dropTargetAsView, accepted); 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) { private DropTarget findDropTarget(int x, int y, int[] dropCoordinates) {
mDragObject.x = x; mDragObject.x = x;
mDragObject.y = y; 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); Log.d(TAG, "Ignoring model task since loader is pending=" + this);
} }
// Loader has not yet run. // Loader has not yet run.
return; // return;
} }
execute(mApp, mDataModel, mAllAppsList); execute(mApp, mDataModel, mAllAppsList);
} }

View File

@@ -38,6 +38,7 @@ import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.util.LongSparseArray; import android.util.LongSparseArray;
import android.util.MutableInt; import android.util.MutableInt;
import android.util.Pair;
import com.android.uiuios.AllAppsList; import com.android.uiuios.AllAppsList;
import com.android.uiuios.AppInfo; import com.android.uiuios.AppInfo;
@@ -187,6 +188,8 @@ public class LoaderTask implements Runnable {
TraceHelper.partitionSection(TAG, "step 2.1: loading all apps"); TraceHelper.partitionSection(TAG, "step 2.1: loading all apps");
List<LauncherActivityInfo> allActivityList = loadAllApps(); List<LauncherActivityInfo> allActivityList = loadAllApps();
verifyApplications();
TraceHelper.partitionSection(TAG, "step 2.2: Binding all apps"); TraceHelper.partitionSection(TAG, "step 2.2: Binding all apps");
verifyNotStopped(); verifyNotStopped();
mResults.bindAllApps(); mResults.bindAllApps();
@@ -242,6 +245,27 @@ public class LoaderTask implements Runnable {
TraceHelper.endSection(TAG); 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() { public synchronized void stopLocked() {
mStopped = true; mStopped = true;
this.notify(); this.notify();

View File

@@ -18,10 +18,12 @@ package com.android.uiuios.model;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.LauncherActivityInfo;
import android.content.pm.ShortcutInfo; import android.content.pm.ShortcutInfo;
import android.os.Process; import android.os.Process;
import android.os.UserHandle; import android.os.UserHandle;
import android.util.Log; import android.util.Log;
import android.util.Pair;
import com.android.uiuios.AllAppsList; import com.android.uiuios.AllAppsList;
import com.android.uiuios.AppInfo; import com.android.uiuios.AppInfo;
@@ -155,6 +157,9 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
final ArrayList<AppInfo> addedOrModified = new ArrayList<>(); final ArrayList<AppInfo> addedOrModified = new ArrayList<>();
addedOrModified.addAll(appsList.added); addedOrModified.addAll(appsList.added);
updateToWorkSpace(context, app, appsList);
appsList.added.clear(); appsList.added.clear();
addedOrModified.addAll(appsList.modified); addedOrModified.addAll(appsList.modified);
appsList.modified.clear(); 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. * Updates {@param si}'s intent to point to a new ComponentName.
* @return Whether the shortcut intent was changed. * @return Whether the shortcut intent was changed.

View File

@@ -26,24 +26,27 @@ public class AllAppsSwipeController extends AbstractStateChangeTouchController {
@Override @Override
protected boolean canInterceptTouch(MotionEvent ev) { 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; return false;
}
if (!mLauncher.isInState(NORMAL) && !mLauncher.isInState(ALL_APPS)) { // if (ev.getAction() == MotionEvent.ACTION_DOWN) {
// Don't listen for the swipe gesture if we are already in some other state. // mTouchDownEvent = ev;
return false; // }
} // if (mCurrentAnimation != null) {
if (mLauncher.isInState(ALL_APPS) && !mLauncher.getAppsView().shouldContainerScroll(ev)) { // // If we are already animating from a previous state, we can intercept.
return false; // return true;
} // }
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 @Override