Search code examples
androidandroid-source

How to set favourite apps for Launcher3 Default Workspace - Android Source


I am building my own custom ROM and trying to put some app shortcuts in the default workspace of my Pixel 2.

I have modified the default_workspace_XxX.xml files in packages/apps/Launcher3/res/xml but no changes are being implemented when I recompile and flash my device.

On top of that, I am not 100% sure how to add a favorite, this is the code I have so far. But note that the app is just an APK file within the Android build, it's pre-compiled.

<!-- Hotseat -->
<include launcher:workspace="@xml/dw_phone_hotseat" />

<resolve
    launcher:screen="0"
    launcher:x="4"
    launcher:y="-1" >
    <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" />
</resolve>

<favorite
    launcher:packageName="com.csipsimple"
    launcher:className="com.csipsimple.ui.SipHome"
    launcher:screen="3"
    launcher:x="1"
    launcher:y="3" />


Solution

  • I discovered that when I compiled, the changes weren't being implemented. After doing a make clean the changes were applied, however, I had to wait over an hour for the new ROMs to build.

    By using the following commands, I was able to quickly rebuild the ROMs without needing to wait an excessive amount of time for a small change.

    make installclean
    make -j$(nproc)  # Compile using all processors of your computer
    

    In relation to adding custom default favourites in Launcher3, the above code in my question was correct. However, I moved it to the bottom 'hotseat' section with the following code in packages/apps/Launcher3/res/xml/dw_phone_hotseat.xml

    <favorite
        launcher:container="-101"
        launcher:screen="2"
        launcher:x="2"
        launcher:y="0"
        launcher:packageName="com.packagename"
        launcher:className="com.packagename.MainActivity" />