1、Android13 修改Launcher3抽屉改成为滑动模式:
.../PortraitStatesTouchController.java | 5 +
.../android/launcher3/DeleteDropTarget.java | 6 +
.../android/launcher3/LauncherAppState.java | 3 +
.../model/AddWorkspaceItemsTask.java | 8 +-
.../android/launcher3/model/BgDataModel.java | 7 ++
.../launcher3/model/ItemInstallQueue.java | 54 +++++++++
.../android/launcher3/model/LoaderTask.java | 114 +++++++++++++++++-
.../model/WorkspaceItemSpaceFinder.java | 2 +-
.../model/data/WorkspaceItemInfo.java | 16 +++
.../touch/AllAppsSwipeController.java | 0
10 files changed, 212 insertions(+), 3 deletions(-)
mode change 100644 => 100755 vendor/mediatek/proprietary/packages/apps/Launcher3/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java
mode change 100644 => 100755 vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/DeleteDropTarget.java
mode change 100644 => 100755 vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/LauncherAppState.java
mode change 100644 => 100755 vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/AddWorkspaceItemsTask.java
mode change 100644 => 100755 vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/BgDataModel.java
mode change 100644 => 100755 vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/ItemInstallQueue.java
mode change 100644 => 100755 vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/LoaderTask.java
mode change 100644 => 100755 vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/WorkspaceItemSpaceFinder.java
mode change 100644 => 100755 vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/data/WorkspaceItemInfo.java
mode change 100644 => 100755 vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/touch/AllAppsSwipeController.java
diff --git a/vendor/mediatek/proprietary/packages/apps/Launcher3/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java b/vendor/mediatek/proprietary/packages/apps/Launcher3/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java
old mode 100644
new mode 100755
index e56c90c20cb..c539b06c633
--- a/vendor/mediatek/proprietary/packages/apps/Launcher3/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java
+++ b/vendor/mediatek/proprietary/packages/apps/Launcher3/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java
@@ -34,6 +34,8 @@ import static com.android.launcher3.states.StateAnimationConfig.ANIM_VERTICAL_PR
import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_SCALE;
+import com.android.launcher3.LauncherAppState;
import android.view.MotionEvent;
import android.view.animation.Interpolator;
@@ -155,6 +157,9 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr
} else if (fromState == OVERVIEW) {
return isDragTowardPositive ? OVERVIEW : NORMAL;
} else if (fromState == NORMAL && isDragTowardPositive) {
if (LauncherAppState.isUserSingleLayerStyle()) {
return fromState;
} return ALL_APPS; } return fromState;
diff --git a/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/DeleteDropTarget.java b/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/DeleteDropTarget.java
old mode 100644
new mode 100755
index 95d3ad9dbb7..5f0c8ad1e9a
--- a/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/DeleteDropTarget.java
+++ b/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/DeleteDropTarget.java
@@ -89,6 +89,12 @@ public class DeleteDropTarget extends ButtonDropTarget {
@Override
protected boolean supportsDrop(ItemInfo info) {
if (info != null &&
info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION
&& LauncherAppState.isUserSingleLayerStyle()) {
return false;
-
}} return true;
diff --git a/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/LauncherAppState.java b/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/LauncherAppState.java
old mode 100644
new mode 100755
index 597bc8da3a4..24f0eb1eb71
--- a/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/LauncherAppState.java
+++ b/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/LauncherAppState.java
@@ -68,6 +68,9 @@ public class LauncherAppState implements SafeCloseable {
private final IconCache mIconCache;
private final InvariantDeviceProfile mInvariantDeviceProfile;
private final RunnableList mOnTerminateCallback = new RunnableList();
public static boolean isUserSingleLayerStyle() {
return true;
-
}
public static LauncherAppState getInstance(final Context context) {
return INSTANCE.get(context);
diff --git a/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/AddWorkspaceItemsTask.java b/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/AddWorkspaceItemsTask.java
old mode 100644
new mode 100755
index 31ef2e5ea67..1ff1f228532
--- a/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/AddWorkspaceItemsTask.java
+++ b/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/AddWorkspaceItemsTask.java
@@ -97,8 +97,14 @@ public class AddWorkspaceItemsTask extends BaseModelUpdateTask {
continue;
} boolean mForceAdd = false;
if (item.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION
&& item instanceof WorkspaceItemInfo) {
mForceAdd = ((WorkspaceItemInfo) item).hasExtraFlag(WorkspaceItemInfo.EXTRA_FLAG_FORCE_ADD);
}
// b/139663018 Short-circuit this logic if the icon is a system app
if (PackageManagerHelper.isSystemApp(app.getContext(), item.getIntent())) {
if (!mForceAdd && PackageManagerHelper.isSystemApp(app.getContext(), item.getIntent())) { if (TestProtocol.sDebugTracing) { Log.d(TestProtocol.MISSING_PROMISE_ICON, LOG + " Item is a system app.");
diff --git a/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/BgDataModel.java b/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/BgDataModel.java
old mode 100644
new mode 100755
index de23c4b31f4..ca5b6de3dfc
--- a/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/BgDataModel.java
+++ b/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/BgDataModel.java
@@ -403,6 +403,13 @@ public class BgDataModel {
items.addAll(appWidgets);
return items;
}
public synchronized ArrayList<ItemInfo> getAllWorkspaceItemsWithoutAppWidget() {
ArrayList<ItemInfo> items = new ArrayList<>(workspaceItems.size());
items.addAll(workspaceItems);
return items;
-
}
/**
- Calls the provided {@code op} for all workspaceItems in the in-memory model (both persisted
diff --git a/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/ItemInstallQueue.java b/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/ItemInstallQueue.java
old mode 100644
new mode 100755
index 5a220f74c73..2f98689b66a
--- a/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/ItemInstallQueue.java
+++ b/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/ItemInstallQueue.java
@@ -186,6 +186,15 @@ public class ItemInstallQueue {
public void queueItem(String packageName, UserHandle userHandle) {
queuePendingShortcutInfo(new PendingInstallShortcutInfo(packageName, userHandle));
}
- Calls the provided {@code op} for all workspaceItems in the in-memory model (both persisted
/**
* Adds an item to the install queue
*/
public void queueItem(LauncherActivityInfo launcherActivityInfo, UserHandle userHandle) {
queuePendingShortcutInfo(new PendingInstallShortcutInfo(launcherActivityInfo, userHandle));
}
-
/**
* Returns a stream of all pending shortcuts in the queue
@@ -250,9 +259,18 @@ public class ItemInstallQueue {
private static class PendingInstallShortcutInfo extends ItemInfo {final Intent intent;
LauncherActivityInfo activityInfo = null; @Nullable ShortcutInfo shortcutInfo; @Nullable AppWidgetProviderInfo providerInfo;
public PendingInstallShortcutInfo(LauncherActivityInfo activityInfo, UserHandle userHandle) {
itemType = Favorites.ITEM_TYPE_APPLICATION;
intent = new Intent().setComponent(activityInfo.getComponentName());
this.activityInfo = activityInfo;
user = userHandle;
} /** * Initializes a PendingInstallShortcutInfo to represent a pending launcher target.
@@ -305,6 +323,12 @@ public class ItemInstallQueue {
si.itemType = ITEM_TYPE_APPLICATION;
LauncherActivityInfo lai;
if (activityInfo != null) {
laiList.clear();
laiList.add(activityInfo);
si.addExtraFlag(WorkspaceItemInfo.EXTRA_FLAG_FORCE_ADD);
}
boolean usePackageIcon = laiList.isEmpty(); if (usePackageIcon) { lai = null;
@@ -343,6 +367,34 @@ public class ItemInstallQueue {
return null;
}
/*@Override
public boolean equals(Object obj) {
if (obj instanceof PendingInstallShortcutInfo) {
PendingInstallShortcutInfo other = (PendingInstallShortcutInfo) obj;
boolean userMatches = user.equals(other.user);
boolean itemTypeMatches = itemType == other.itemType;
boolean intentMatches = intent.toUri(0).equals(other.intent.toUri(0));
boolean shortcutInfoMatches = shortcutInfo == null
? other.shortcutInfo == null
: other.shortcutInfo != null
&& shortcutInfo.getId().equals(other.shortcutInfo.getId())
&& shortcutInfo.getPackage().equals(other.shortcutInfo.getPackage());
boolean providerInfoMatches = providerInfo == null
? other.providerInfo == null
: other.providerInfo != null
&& providerInfo.provider.equals(other.providerInfo.provider);
return userMatches
&& itemTypeMatches
&& intentMatches
&& shortcutInfoMatches
&& providerInfoMatches;
}
return false;
}*/
@Override public boolean equals(Object obj) { if (obj instanceof PendingInstallShortcutInfo) {
@@ -369,6 +421,8 @@ public class ItemInstallQueue {
}
return false;
}
-
}
private static String getIntentPackage(Intent intent) {
diff --git a/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/LoaderTask.java b/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/LoaderTask.java
old mode 100644
new mode 100755
index f1c5d59fc8f..2ba26da8cb8
--- a/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/LoaderTask.java
+++ b/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/LoaderTask.java
@@ -117,6 +117,7 @@ public class LoaderTask implements Runnable {
private static final String TAG = "LoaderTask";private static final boolean DEBUG = true;
-
private static final boolean DEBUG_BOBO = true;
protected final LauncherAppState mApp;
private final AllAppsList mBgAllAppsList;
@@ -186,6 +187,22 @@ public class LoaderTask implements Runnable {filterCurrentWorkspaceItems(firstScreens, allItems, firstScreenItems, new ArrayList<>() /* otherScreenItems are ignored */);
if (DEBUG_BOBO) {
Log.d(TAG, "sendFirstScreenActiveInstallsBroadcast firstScreenItems size: "
+ firstScreenItems.size());
for (ItemInfo itemInfo : firstScreenItems) {
Log.d(TAG, "firstScreenItems: " + itemInfo);
}
Log.d(TAG, "sendFirstScreenActiveInstallsBroadcast firstScreenItems end");
Log.d(TAG, "sendFirstScreenActiveInstallsBroadcast allItems size: "
+ allItems.size());
for (ItemInfo itemInfo : allItems) {
Log.d(TAG, "allItems: " + itemInfo);
}
Log.d(TAG, "sendFirstScreenActiveInstallsBroadcast allItems end");
-
} mFirstScreenBroadcast.sendBroadcasts(mApp.getContext(), firstScreenItems);
}
@@ -196,6 +213,10 @@ public class LoaderTask implements Runnable {
return;
}
}
if (DEBUG_BOBO) {
Log.d(TAG, "run start");
} Object traceToken = TraceHelper.INSTANCE.beginSection(TAG); TimingLogger logger = new TimingLogger(TAG, "run");
@@ -208,6 +229,14 @@ public class LoaderTask implements Runnable {
} finally {
Trace.endSection();
}
if (DEBUG_BOBO) {
Log.d(TAG, "shortcutInfo size: " + allShortcuts.size());
for (ShortcutInfo shortcutInfo : allShortcuts) {
Log.d(TAG, "shortcutInfo: " + shortcutInfo);
}
Log.d(TAG, "shortcutInfo end");
} logASplit(logger, "loadWorkspace"); // Sanitize data re-syncs widgets/shortcuts based on the workspace loaded from db.
@@ -242,6 +271,14 @@ public class LoaderTask implements Runnable {
} finally {
Trace.endSection();
}
if (DEBUG_BOBO) {
Log.d(TAG, "allActivityList size: " + allActivityList.size());
for (LauncherActivityInfo activityInfo : allActivityList) {
Log.d(TAG, "activityInfo: " + activityInfo.getComponentName());
}
Log.d(TAG, "allActivityList end");
} logASplit(logger, "loadAllApps"); verifyNotStopped();
@@ -270,6 +307,14 @@ public class LoaderTask implements Runnable {
// third step
List<ShortcutInfo> allDeepShortcuts = loadDeepShortcuts();
if (DEBUG_BOBO) {
Log.d(TAG, "allDeepShortcuts size: " + allDeepShortcuts.size());
for (ShortcutInfo shortcutInfo : allDeepShortcuts) {
Log.d(TAG, "shortcutInfo: " + shortcutInfo);
}
Log.d(TAG, "allDeepShortcuts end");
} logASplit(logger, "loadDeepShortcuts"); verifyNotStopped();
@@ -290,7 +335,14 @@ public class LoaderTask implements Runnable {
// fourth step
- mBgDataModel.widgetsModel.update(mApp, null);
+ mBgDataModel.widgetsModel.update(mApp, null);
+ if (DEBUG_BOBO) {
+ Log.d(TAG, "allWidgetsList size: " + allWidgetsList.size());
+ for (ComponentWithLabelAndIcon componentWithLabelAndIcon : allWidgetsList) {
+ Log.d(TAG, "componentWithLabelAndIcon: " + componentWithLabelAndIcon.getComponent());
+ }
+ Log.d(TAG, "allWidgetsList end");
+ }
logASplit(logger, "load widgets");
verifyNotStopped();
@@ -312,6 +364,9 @@ public class LoaderTask implements Runnable {
updateHandler.finish();
logASplit(logger, "finish icon update");
+ // add apps for single layer--bobo
+ updateForSingleLayerStyle(allActivityList);
+
mModelDelegate.modelLoadComplete();
transaction.commit();
memoryLogger.clearLogs();
@@ -324,9 +379,57 @@ public class LoaderTask implements Runnable {
} finally {
logger.dumpToLog();
}
+
+ if (DEBUG_BOBO) {
+ Log.d(TAG, "run end");
+ }
TraceHelper.INSTANCE.endSection(traceToken);
}
+ private void updateForSingleLayerStyle(List<LauncherActivityInfo> allActivityList) {
+ if (!LauncherAppState.isUserSingleLayerStyle()) {
+ return;
+ }
+ if (allActivityList == null || allActivityList.size() <= 0) {
+ return;
+ }
+ Map<String, LauncherActivityInfo> newAppsMap = new HashMap<>();
+ for (LauncherActivityInfo info : allActivityList) {
+ newAppsMap.put(getComponentKey(info.getComponentName(), info.getUser().getIdentifier()),
+ info);
+ }
+ ArrayList<ItemInfo> addedItems = mBgDataModel.getAllWorkspaceItemsWithoutAppWidget();
+ for (ItemInfo info : addedItems) {
+ if (info.getTargetComponent() == null) continue;
+ if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
+ newAppsMap.remove(getComponentKey(info.getTargetComponent(), info.user.getIdentifier()));
+ } else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_FOLDER) {
+ //TODO
+ }
+ }
+ if (DEBUG_BOBO) {
+ Log.d(TAG, "updateForSingleLayerStyle newAppsMap:" + newAppsMap.size());
+ newAppsMap.values().stream().forEach(item->{
+ Log.d(TAG, "updateForSingleLayerStyle activityInfo: " + item.getComponentName());
+ });
+ }
+ ItemInstallQueue.INSTANCE.get(mApp.getContext())
+ .pauseModelPush(ItemInstallQueue.FLAG_LOADER_RUNNING);
+ newAppsMap.values().stream().forEach(item->{
+ ItemInstallQueue.INSTANCE.get(mApp.getContext())
+ .queueItem(item, item.getUser());
+ });
+ ItemInstallQueue.INSTANCE.get(mApp.getContext())
+ .resumeModelPush(ItemInstallQueue.FLAG_LOADER_RUNNING);
+ if (DEBUG_BOBO) {
+ Log.d(TAG, "updateForSingleLayerStyle end");
+ }
+ }
+
+ private String getComponentKey(ComponentName componentName, int userId) {
+ return componentName.toString() + "_" + userId;
+ }
+
public synchronized void stopLocked() {
mStopped = true;
this.notify();
@@ -1058,6 +1161,15 @@ public class LoaderTask implements Runnable {
suggestionInfos);
info.suggestedFolderNames = suggestionInfos;
}
+ }
+ if (DEBUG_BOBO) {
+ Log.d(TAG, "loadFolderNames mBgDataModel.folders size: " + mBgDataModel.folders.size());
+ for (int i = 0; i < mBgDataModel.folders.size(); i++) {
+ FolderInfo info = mBgDataModel.folders.valueAt(i);
+ Log.d(TAG, "info: " +
+ info.suggestedFolderNames);
+ }
+ Log.d(TAG, "loadFolderNames end");
}
}
}
diff --git a/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/WorkspaceItemSpaceFinder.java b/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/WorkspaceItemSpaceFinder.java
old mode 100644
new mode 100755
index 93fc6a539f1..ec685f7902b
--- a/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/WorkspaceItemSpaceFinder.java
+++ b/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/WorkspaceItemSpaceFinder.java
@@ -66,7 +66,7 @@ public class WorkspaceItemSpaceFinder {
int screenCount = workspaceScreens.size();
// First check the preferred screen.
IntSet screensToExclude = new IntSet();
- if (FeatureFlags.QSB_ON_FIRST_SCREEN) {
+ if (FeatureFlags.QSB_ON_FIRST_SCREEN || LauncherAppState.isUserSingleLayerStyle()) {
screensToExclude.add(FIRST_SCREEN_ID);
}
diff --git a/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/data/WorkspaceItemInfo.java b/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/data/WorkspaceItemInfo.java
old mode 100644
new mode 100755
index 2b3da335c37..3f4be285775
--- a/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/data/WorkspaceItemInfo.java
+++ b/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/model/data/WorkspaceItemInfo.java
@@ -111,6 +111,7 @@ public class WorkspaceItemInfo extends ItemInfoWithIcon {
iconResource = info.iconResource;
status = info.status;
personKeys = info.personKeys.clone();
+ mExtraFlags = info.mExtraFlags;
}
/** TODO: Remove this. It's only called by ApplicationInfo.makeWorkspaceItem. */
@@ -228,4 +229,19 @@ public class WorkspaceItemInfo extends ItemInfoWithIcon {
public WorkspaceItemInfo clone() {
return new WorkspaceItemInfo(this);
}
+
+ public static final int EXTRA_FLAG_FORCE_ADD = 1;
+ private int mExtraFlags = 0;
+ public void addExtraFlag(int flag) {
+ mExtraFlags |= flag;
+ }
+
+ public void removeExtraFlag(int flag) {
+ mExtraFlags &= ~flag;
+ }
+
+ public boolean hasExtraFlag(int flag) {
+ return (mExtraFlags & flag) == flag;
+ }
+
}
diff --git a/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/touch/AllAppsSwipeController.java b/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/touch/AllAppsSwipeController.java
old mode 100644
new mode 100755
--
2.17.1