Search code examples
androidandroid-layoutoperating-systemandroid-source

How to add multiple wallpapers for choose in wallpaper picker to set on homescreen in aosp build


I have build AOSP v10 and build it sucessfully. I want to add some wallpapers in the aosp to display in wallpaper picker to set wallpaper in home screen. I have no idea about at which directory I have to add my wallpapers which I want to add in the AOSP to use as a choice for set on homescreen.

I have this Source code on my device.

I want to add some wallpapers (Showing in the below picture ) which can be used by wallpaper picker to set on the home screen

I want to put my wallpaper here to use easily to set on screen


Solution

    1. Prepare your images

    Create a square, thumbnail image (560x560px, not sure if it needs to be this size). This image will be shown on the bottom row of the wallpaper picker (See your screenshot in your question).

    Your original image should have the same resolution as your screen. Give your image a file name, for example wallpaper.png. Then name your thumbnail the same file name plus _small, for example wallpaper_small.png.

    1. Copy the images to packages/apps/WallpaperPicker/res/drawable-nodpi/. Create this directory if necessary
    2. List the images in packages/apps/WallpaperPicker/res/values-nodpi/wallpapers.xml

    This file looks like this on unmodified AOSP.

    <?xml version="1.0" encoding="utf-8"?>
    <!--
     * Copyright (C) 2009 Google Inc.
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     *      http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     -->
    
    <resources>
        <string-array name="wallpapers" translatable="false">
        </string-array>
    </resources>
    

    Add <item> inside <string-array> tag. Each item should have the name of the wallpaper file name without extension. If you have multiple wallpapers, list them one by one. For example

    <resources>
        <string-array name="wallpapers" translatable="false">
            <item>wallpaper1</item>
            <item>wallpaper2</item>
        </string-array>
    </resources>