Launcher3 design to hide the launch icon of the specified application

Find LoaderTask() globally, there is a loadAllApps method in the
loadAllApps method

           			mBgAllAppsList.add(new AppInfo(app, user, quietMode), app);

It is added when the luncher is loaded.
In the for loop inside, it will loop before mBgAllAppsList.add(new AppInfo(app, user, quietMode), app).
Write a method and
add it before add

					if(DmConfig.isHiddenPackage(app.getComponentName())){
					continue;
					}

Write a method

	    public static boolean isHiddenPackage(ComponentName componentName){
    return DM_LAUNCHER_HIDDEN_APP_ENABLE && isHiddenPackage(componentName.getPackageName());
}

Write a method

public static boolean isHiddenPackage(String packageName){
    boolean isHidden = mHiddenPackageMap.containsKey(packageName);
    if(isHidden) {
        Log.d("isHiddenPackage" + " isHidden=" + isHidden + " packageName=" + packageName);
    }
    return isHidden;
}

Write a map

	private static final HashMap<String, String> mHiddenPackageMap = new HashMap<>(10);

Write a file analysis for the map value

        try {
         String strList = mContext.getResources().getString(R.string.hiddenPackageList);
        String[] strArray = strList.split(";");
        Log.d("isHiddenPackage " + " strArray.length=" + strArray.length);
        for (String str : strArray){
            mHiddenPackageMap.put(str, str);
        }
    }catch (Exception e){
        e.printStackTrace();
    }

Write a file and add

	<resources >
<string name="hiddenPackageList" translatable="false">
   " org.chromium.webview_shell;
    com.xiaomi.market;
    com.xiaomi.shop;"</string>

</resources>

Just add the package name to the file if you want to hide which software in which LUNcher. Finish

Guess you like

Origin blog.csdn.net/weixin_41422638/article/details/112670861