Android14 or 13 Launcher3 去掉All App抽屜显示功能,全部App显示到桌面上

QSSI.14/packages/apps/Launcher3/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java 
index 8368f9ca037..b613591342d 100644
@@ -21,6 +21,7 @@ import static com.android.launcher3.AbstractFloatingView.getTopOpenViewWithType;
 import static com.android.launcher3.LauncherState.ALL_APPS;
 import static com.android.launcher3.LauncherState.NORMAL;
 import static com.android.launcher3.LauncherState.OVERVIEW;
+import com.android.launcher3.config.FeatureFlags;
 
 import android.view.MotionEvent;
 
@@ -86,7 +87,11 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr
         if (getTopOpenViewWithType(mLauncher, TYPE_ACCESSIBLE | TYPE_ALL_APPS_EDU) != null) {
             return false;
         }
-        return true;
+        if(FeatureFlags.REMOVE_DRAWER){
+           return false;
+        }else{
+            return true;
+        }
     }
 
     @Override

--- QSSI.14/packages/apps/Launcher3/src/com/android/launcher3/Launcher.java ---
index 76a10050843..033f26f47db 100644
@@ -106,6 +106,7 @@ import android.os.StrictMode;
 import android.os.SystemClock;
 import android.os.Trace;
 import android.os.UserHandle;
+import android.os.UserManager;
 import android.text.TextUtils;
 import android.text.method.TextKeyListener;
 import android.util.AttributeSet;
@@ -243,6 +244,7 @@ import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverla
 import java.io.FileDescriptor;
 import java.io.PrintWriter;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -250,6 +252,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
+import java.util.Set;
 import java.util.function.Predicate;
 import java.util.function.Supplier;
 import java.util.stream.Stream;
@@ -426,10 +429,12 @@ public class Launcher extends StatefulActivity<LauncherState>
     private BaseSearchConfig mBaseSearchConfig;
     private StartupLatencyLogger mStartupLatencyLogger;
     private CellPosMapper mCellPosMapper = CellPosMapper.DEFAULT;
+    private Map<ItemInfo,View> homeIconMap;
 
     @Override
     @TargetApi(Build.VERSION_CODES.S)
     protected void onCreate(Bundle savedInstanceState) {
+        homeIconMap = new HashMap<>();
         mStartupLatencyLogger = createStartupLatencyLogger(
                 sIsNewProcess
                         ? LockedUserState.get(this).isUserUnlockedAtLauncherStartup()
@@ -2416,7 +2421,6 @@ public class Launcher extends StatefulActivity<LauncherState>
         bindItems(items, forceAnimateIcons, /* focusFirstItemForAccessibility= */ false);
     }
 
-
     /**
      * Bind the items start-end from the list.
      *
@@ -2452,12 +2456,14 @@ public class Launcher extends StatefulActivity<LauncherState>
                 case LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT: {
                     WorkspaceItemInfo info = (WorkspaceItemInfo) item;
                     view = createShortcut(info);
+                    homeIconMap.put(item,view);
                     break;
                 }
                 case LauncherSettings.Favorites.ITEM_TYPE_FOLDER: {
                     view = FolderIcon.inflateFolderAndIcon(R.layout.folder_icon, this,
                             (ViewGroup) workspace.getChildAt(workspace.getCurrentPage()),
                             (FolderInfo) item);
+                    homeIconMap.put(item,view);
                     break;
                 }
                 case LauncherSettings.Favorites.ITEM_TYPE_APP_PAIR: {
@@ -2987,6 +2993,7 @@ public class Launcher extends StatefulActivity<LauncherState>
     public void bindAllApplications(AppInfo[] apps, int flags,
             Map<PackageUserKey, Integer> packageUserKeytoUidMap) {
         Preconditions.assertUIThread();
+
         AllAppsStore appsStore = mAppsView.getAppsStore();
         appsStore.setApps(apps, flags, packageUserKeytoUidMap);
         PopupContainerWithArrow.dismissInvalidPopup(this);
@@ -2994,8 +3001,41 @@ public class Launcher extends StatefulActivity<LauncherState>
             Trace.endAsyncSection(DISPLAY_ALL_APPS_TRACE_METHOD_NAME,
                     DISPLAY_ALL_APPS_TRACE_COOKIE);
         }
+        if(FeatureFlags.ADD_ALLAPPS_TO_WORKSPACE){
+            changeWorkspaceItems(apps);
+        }
+    }
+
+    private void removeWorkspaceItmes(HashMap<ItemInfo,View> originItemsMap) {
+        Set<ItemInfo> itemInfos = originItemsMap.keySet();
+        for(ItemInfo info : itemInfos){
+            View icon = originItemsMap.get(info);
+            removeItem(icon,info,true);
+        }
+    }
+
+    private void addToWorkspace(List<AppInfo> appInfoList) {
+
+        UserManager userManager = getSystemService(UserManager.class);
+        final List<UserHandle> profiles = userManager.getUserProfiles();
+        for(AppInfo appInfo : appInfoList) {
+//            Log.e(TAG,"addToWorkspace in  getPackageName ========"+appInfo.componentName.getPackageName());
+//            Log.e(TAG,"addToWorkspace in title ========"+appInfo.title);
+
+            String packageName = appInfo.componentName.getPackageName();
+            ItemInstallQueue.INSTANCE.get(this).queueItem(packageName,profiles.get(0));
+
+        }
+
+    }
+
+    public void changeWorkspaceItems(AppInfo[] apps) {
+//        Log.e(TAG,"changeWorkspaceItems in ========");
+        addToWorkspace(Arrays.stream(mModel.getBgAllAppsList().copyData()).toList());
+//        Log.e(TAG,"changeWorkspaceItems end ========");
     }
 
+
     /**
      * Copies LauncherModel's map of activities to shortcut counts to Launcher's. This is necessary
      * because LauncherModel's map is updated in the background, while Launcher runs on the UI.

- QSSI.14/packages/apps/Launcher3/src/com/android/launcher3/LauncherModel.java -
index 4e066b09853..d665dbe2d44 100644
@@ -164,6 +164,10 @@ public class LauncherModel extends LauncherApps.Callback implements InstallSessi
                 isPrimaryInstance);
     }
 
+    public AllAppsList getBgAllAppsList() {
+        return mBgAllAppsList;
+    }
+
     @NonNull
     public ModelDelegate getModelDelegate() {
         return mModelDelegate;

 QSSI.14/packages/apps/Launcher3/src/com/android/launcher3/allapps/AllAppsTransitionController.java 
index d4f152aa0a6..829d68718d7 100644
@@ -333,6 +333,7 @@ public class AllAppsTransitionController
     @Override
     public void setStateWithAnimation(LauncherState toState,
             StateAnimationConfig config, PendingAnimation builder) {
+        if(!FeatureFlags.REMOVE_DRAWER){
         if (mLauncher.isInState(ALL_APPS) && !ALL_APPS.equals(toState)) {
             // For atomic animations, we close the keyboard immediately.
             if (!config.userControlled && mShouldControlKeyboard) {
@@ -393,6 +394,7 @@ public class AllAppsTransitionController
             mLauncher.getAppsView().performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY,
                     HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
         }
+        }
     }
 
     public Animator createSpringAnimation(float... progressValues) {

 QSSI.14/packages/apps/Launcher3/src/com/android/launcher3/config/FeatureFlags.java 
index 76574b69c79..6565d94a8dd 100644
@@ -50,6 +50,12 @@ public final class FeatureFlags {
     @VisibleForTesting
     public static ToIntFunction<IntFlag> sIntReader = f -> f.mCurrentValue;
 
+    public static final boolean REMOVE_DRAWER = true;
+
+    public static final boolean ADD_ALLAPPS_TO_WORKSPACE = true;
+
+    public static final boolean ADD_SYS_APPS_TO_WORKSPACE = true;
+
     private FeatureFlags() { }
 
     public static boolean showFlagTogglerUi(Context context) {

 QSSI.14/packages/apps/Launcher3/src/com/android/launcher3/model/AddWorkspaceItemsTask.java 
index 27d1f78fb55..09d9677d581 100644
@@ -20,6 +20,7 @@ import android.content.pm.LauncherActivityInfo;
 import android.content.pm.LauncherApps;
 import android.content.pm.PackageInstaller.SessionInfo;
 import android.os.UserHandle;
+import android.util.Log;
 import android.util.Pair;
 
 import androidx.annotation.NonNull;
@@ -28,6 +29,7 @@ import androidx.annotation.Nullable;
 import com.android.launcher3.LauncherAppState;
 import com.android.launcher3.LauncherModel.CallbackTask;
 import com.android.launcher3.LauncherSettings;
+import com.android.launcher3.config.FeatureFlags;
 import com.android.launcher3.logging.FileLog;
 import com.android.launcher3.model.BgDataModel.Callbacks;
 import com.android.launcher3.model.data.AppInfo;
@@ -99,10 +101,13 @@ public class AddWorkspaceItemsTask extends BaseModelUpdateTask {
                     }
 
                     // b/139663018 Short-circuit this logic if the icon is a system app
-                    if (PackageManagerHelper.isSystemApp(app.getContext(),
-                            Objects.requireNonNull(item.getIntent()))) {
-                        continue;
+                    if(!FeatureFlags.ADD_SYS_APPS_TO_WORKSPACE){
+                        if (PackageManagerHelper.isSystemApp(app.getContext(),
+                                Objects.requireNonNull(item.getIntent()))) {
+                            continue;
+                        }
                     }
+
                 }
 
                 if (item.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
@@ -200,7 +205,6 @@ public class AddWorkspaceItemsTask extends BaseModelUpdateTask {
                 FileLog.d(LOG, "Adding item info to workspace: " + itemInfo);
             }
         }
-
         if (!addedItemsFinal.isEmpty()) {
             scheduleCallbackTask(new CallbackTask() {
                 @Override

 QSSI.14/packages/apps/Launcher3/src/com/android/launcher3/model/BaseModelUpdateTask.java 
index 866e222592d..56966af1435 100644
@@ -28,6 +28,7 @@ import com.android.launcher3.LauncherModel;
 import com.android.launcher3.LauncherModel.CallbackTask;
 import com.android.launcher3.LauncherModel.ModelUpdateTask;
 import com.android.launcher3.celllayout.CellPosMapper;
+import com.android.launcher3.config.FeatureFlags;
 import com.android.launcher3.model.BgDataModel.Callbacks;
 import com.android.launcher3.model.BgDataModel.FixedContainerItems;
 import com.android.launcher3.model.data.AppInfo;
@@ -83,7 +84,10 @@ public abstract class BaseModelUpdateTask implements ModelUpdateTask {
                 Log.d(TAG, "Ignoring model task since loader is pending=" + this);
             }
             // Loader has not yet run.
-            return;
+            // 修改,这行注释掉
+            if(!FeatureFlags.REMOVE_DRAWER){
+                return;
+            }
         }
         execute(mApp, mDataModel, mAllAppsList);
     }

 QSSI.14/packages/apps/Launcher3/src/com/android/launcher3/model/ItemInstallQueue.java 
index fa0511cc567..bd176d01b94 100644
@@ -196,10 +196,10 @@ public class ItemInstallQueue {
                         "Adding PendingInstallShortcutInfo with no attached info to queue.",
                         stackTrace);
             } else {
-                FileLog.d(LOG,
-                        "Adding PendingInstallShortcutInfo to queue. Attached info: "
-                                + itemInfo.first,
-                        stackTrace);
+//                FileLog.d(LOG,
+//                        "Adding PendingInstallShortcutInfo to queue. Attached info: "
+//                                + itemInfo.first,
+//                        stackTrace);
             }
 
             addToQueue(info);
@@ -230,7 +230,7 @@ public class ItemInstallQueue {
         MODEL_EXECUTOR.post(this::flushQueueInBackground);
     }
 
-    private static class PendingInstallShortcutInfo extends ItemInfo {
+    public static class PendingInstallShortcutInfo extends ItemInfo {
 
         final Intent intent;
 

 QSSI.14/packages/apps/Launcher3/src/com/android/launcher3/model/LoaderTask.java 
index ca356b08b50..500b101a307 100644
@@ -52,6 +52,7 @@ import android.text.TextUtils;
 import android.util.ArrayMap;
 import android.util.Log;
 import android.util.LongSparseArray;
+import android.util.Pair;
 
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
@@ -220,6 +221,10 @@ public class LoaderTask implements Runnable {
                 logASplit("sanitizeData");
             }
 
+            allShortcuts.forEach(v ->{
+                Log.e("LoaderTask"," id :: "+v.getId()+" Package :: "+v.getPackage()+" getRank:: "+v.getRank());
+            });
+            Log.e("LoaderTask"," allShortcuts size :: "+allShortcuts.size());
             verifyNotStopped();
             mLauncherBinder.bindWorkspace(true /* incrementBindId */, /* isBindSync= */ false);
             logASplit("bindWorkspace");
@@ -236,12 +241,26 @@ public class LoaderTask implements Runnable {
 
             // second step
             Trace.beginSection("LoadAllApps");
+            if(FeatureFlags.ADD_ALLAPPS_TO_WORKSPACE){
+                binderAppsToWorkspace();
+            }
             List<LauncherActivityInfo> allActivityList;
             try {
                allActivityList = loadAllApps();
+//                if(FeatureFlags.ADD_ALLAPPS_TO_WORKSPACE) {
+//                    verifyApplications();
+//                }
             } finally {
                 Trace.endSection();
             }
+
+
+
+            allActivityList.forEach(v ->{
+                Log.e("LoaderTask"," name :: "+v.getName()+" Package :: "+v.getActivityInfo().packageName+" className :: "+v.getApplicationInfo().className);
+            });
+            Log.e("LoaderTask"," size :: "+allActivityList.size());
+
             logASplit("loadAllApps");
 
             if (FeatureFlags.CHANGE_MODEL_DELEGATE_LOADING_ORDER.get()) {
@@ -330,6 +349,53 @@ public class LoaderTask implements Runnable {
         TraceHelper.INSTANCE.endSection(traceToken);
     }
 
+
+    //add by yy
+//    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<ItemInstallQueue.PendingInstallShortcutInfo> added = new ArrayList<ItemInstallQueue.PendingInstallShortcutInfo>();
+//            synchronized (this) {
+//                for (LauncherActivityInfo app : apps) {
+//                    ItemInstallQueue.PendingInstallShortcutInfo pendingInstallShortcutInfo = new ItemInstallQueue.PendingInstallShortcutInfo(app.getComponentName().getPackageName(),user);
+//                    added.add(pendingInstallShortcutInfo);
+//                    installQueue.add(pendingInstallShortcutInfo.getItemInfo(context));
+//                }
+//            }
+//            if (!added.isEmpty()) {
+//                mApp.getModel().addAndBindAddedWorkspaceItems(installQueue);
+//            }
+//        }
+//    }
+    //end add by yy
+
+
+    private void binderAppsToWorkspace() {
+        Context context = mApp.getContext();
+        ArrayList<Pair<ItemInfo, Object>> iteminfo_list = new ArrayList<>();
+        final List<UserHandle> profiles = mUserManager.getUserProfiles();
+        for (UserHandle user : profiles) {
+            final List<LauncherActivityInfo> apps = mLauncherApps.getActivityList(null, user);
+            ArrayList<ItemInstallQueue.PendingInstallShortcutInfo> added = new ArrayList<ItemInstallQueue.PendingInstallShortcutInfo>();
+            synchronized (this) {
+                for (LauncherActivityInfo appinfo : apps) {
+                    ItemInstallQueue.PendingInstallShortcutInfo pendingInstallShortcutInfo = new ItemInstallQueue.PendingInstallShortcutInfo(appinfo.getComponentName().getPackageName(), appinfo.getUser());
+                    added.add(pendingInstallShortcutInfo);
+                    iteminfo_list.add(pendingInstallShortcutInfo.getItemInfo(context));
+                }
+            }
+
+            if (!added.isEmpty()) {
+                LauncherAppState.getInstance(context).getModel().addAndBindAddedWorkspaceItems(iteminfo_list);
+            }
+        }
+    }
+
+
+
     public synchronized void stopLocked() {
         mStopped = true;
         this.notify();

 QSSI.14/packages/apps/Launcher3/src/com/android/launcher3/model/PackageUpdatedTask.java 
index 8c938f41244..1baa33fb584 100644
@@ -28,6 +28,7 @@ import android.content.pm.ShortcutInfo;
 import android.os.UserHandle;
 import android.os.UserManager;
 import android.util.Log;
+import android.util.Pair;
 
 import androidx.annotation.NonNull;
 
@@ -38,6 +39,7 @@ import com.android.launcher3.LauncherSettings.Favorites;
 import com.android.launcher3.config.FeatureFlags;
 import com.android.launcher3.icons.IconCache;
 import com.android.launcher3.logging.FileLog;
+import com.android.launcher3.model.data.AppInfo;
 import com.android.launcher3.model.data.ItemInfo;
 import com.android.launcher3.model.data.LauncherAppWidgetInfo;
 import com.android.launcher3.model.data.WorkspaceItemInfo;
@@ -194,6 +196,8 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
 
         bindApplicationsIfNeeded();
 
+        updateToWorkSpace(context, app, appsList);
+
         final IntSet removedShortcuts = new IntSet();
         // Shortcuts to keep even if the corresponding app was removed
         final IntSet forceKeepShortcuts = new IntSet();
@@ -361,6 +365,9 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
         }
 
         if (mOp == OP_ADD) {
+            for(String pkg : mPackages) {
+                ItemInstallQueue.INSTANCE.get(context).queueItem(pkg,mUser);
+            }
             // Load widgets for the new package. Changes due to app updates are handled through
             // AppWidgetHost events, this is just to initialize the long-press options.
             for (int i = 0; i < N; i++) {
@@ -370,6 +377,36 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
         }
     }
 
+    public void updateToWorkSpace(Context context, LauncherAppState app , AllAppsList appsList){
+        Log.e(TAG,"updateToWorkSpace in ============");
+        ArrayList<Pair<ItemInfo, Object>> iteminfo_queue = new ArrayList<>();
+        final List<UserHandle> profiles = UserCache.INSTANCE.get(context).getUserProfiles();
+        ArrayList<ItemInstallQueue.PendingInstallShortcutInfo> added = new ArrayList<ItemInstallQueue.PendingInstallShortcutInfo>();
+        for (UserHandle user : profiles) {
+            final List<LauncherActivityInfo> applications = context.getSystemService(LauncherApps.class).getActivityList(null, user);
+            synchronized (this) {
+                for (LauncherActivityInfo info : applications) {
+                    Log.e(TAG,"updateToWorkSpace in ============  getName :: "+info.getName());
+                    Log.e(TAG,"updateToWorkSpace in ============  getComponentName :: "+info.getComponentName());
+                    for (AppInfo appInfo : appsList.data) {
+                        Log.e(TAG,"updateToWorkSpace in ============ title:: "+appInfo.title);
+                        if(info.getComponentName().equals(appInfo.componentName)){
+                            ItemInstallQueue.PendingInstallShortcutInfo mPendingInstallShortcutInfo =  new ItemInstallQueue.PendingInstallShortcutInfo(info.getComponentName().getPackageName(), info.getUser());
+                            added.add(mPendingInstallShortcutInfo);
+                            iteminfo_queue.add(mPendingInstallShortcutInfo.getItemInfo(context));
+                        }
+                    }
+                }
+            }
+        }
+        if (!added.isEmpty()) {
+            LauncherAppState.getInstance(context).getModel().addAndBindAddedWorkspaceItems(iteminfo_queue);
+        }
+        Log.e(TAG,"updateToWorkSpace out ============");
+    }
+
+
+
     /**
      * Updates {@param si}'s intent to point to a new ComponentName.
      * @return Whether the shortcut intent was changed.

將Launcher3的抽屜去掉,將所有的App顯示到桌面上。目前實現的是可控制的。通過修改开关可以显示All App抽屉. Launcher有个判断,如果是系统app则不显示到桌面上.需要把此判断也进行修改即可.以上代码Android13也可用。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值