Skip to content

Wallpaper JSON

Leif Niemczik edited this page Oct 16, 2019 · 7 revisions

This is the Default Wallpaper JSON Structure of CandyBar

[
  {
    "name": "Toyota Rock Car",
    "author": "JC Falcon",
    "url": "https://images.unsplash.com/photo-1564844159766-f1565806300b?ixlib=rb-1.2.1&q=80",
    "thumbUrl": "https://images.unsplash.com/photo-1564844159766-f1565806300b?ixlib=rb-1.2.1&q=80&w=200"
  },
  {
    "name": "Tasty Fruit",
    "author": "Alexandra Kikot",
    "url": "https://images.unsplash.com/photo-1564750497011-ead0ce4b9448?ixlib=rb-1.2.1&q=80",
    "thumbUrl": "https://images.unsplash.com/photo-1564750497011-ead0ce4b9448?ixlib=rb-1.2.1&q=80&w=200"
  },
  {
    "name": "Coral Coast",
    "author": "Seaside Feel",
    "url": "https://images.unsplash.com/photo-1564639566047-dc4a1b86a90f?ixlib=rb-1.2.1&q=80",
    "thumbUrl": "https://images.unsplash.com/photo-1564639566047-dc4a1b86a90f?ixlib=rb-1.2.1&q=80&w=200"
  },
  {
    "name": "Duotone Dahlias",
    "author": "Annie Spratt",
    "url": "https://images.unsplash.com/photo-1513682322455-ea8b2d81d418?ixlib=rb-1.2.1&q=80",
    "thumbUrl": "https://images.unsplash.com/photo-1513682322455-ea8b2d81d418?ixlib=rb-1.2.1&q=80&w=200"
  }
]
  • name: Name of Wallpaper
  • author: Author of Wallpaper
  • url: Image URL of your Wallpaper, use raw link.
  • thumbUrl: Image URL of your wallpaper's thumbnail, use raw link.

Changing JSON Structure

  1. Open CandyBar.java inside apps\java\...\applications\.
  2. Use setWallpaperJsonStructure() from Configuration to define your own json structure. Be careful, array name, name, author, url, and thumbUrl are case sensitive.

Here an example

import candybar.lib.utils.JsonStructure;

public class CandyBar extends CandyBarApplication {

    @NonNull
    @Override
    public Configuration onInit() {
        Configuration configuration = new Configuration();

        // This is Default JSON Structure
        configuration.setWallpaperJsonStructure(
                new JsonStructure.Builder(null)   //-->  Array's Name
                        .name("name")             //-->  Wallpaper's Name
                        .author("author")         //-->  Author's Name
                        .url("url")               //-->  Wallpaper's URL
                        .thumbUrl("thumbUrl")     //-->  Wallpaper's Thumbnail's URL
                        .build());

        return configuration;
    }
}

NOTE: If you are following Default JSON structure, you don't need to add this.

More Examples

With Array Name

{
  "wallpapers": [ //--> This is Array
    {
      "name": "Sample 1",
      "author": "Sample Maker",
      "url": "https://samplemaker.com/sample-1.jpg",
      "thumbUrl": "https://samplemaker.com/sample-1-thumb.jpg"
    },
    {
      "name": "Sample 2",
      "author": "Sample Maker",
      "url": "https://samplemaker.com/sample-2.jpg",
      "thumbUrl": "https://samplemaker.com/sample-2-thumb.jpg"
    }
  ]
}

The Configuration

configuration.setWallpaperJsonStructure(
        new JsonStructure.Builder("wallpapers")   //--> Array Name Changed
                .name("name")
                .author("author")
                .url("url")
                .thumbUrl("thumbUrl")
                .build());

With Different names and no thumnail

[
  {
    "name": "Sample 1",
    "creator": "Sample Maker",
    "link": "https://samplemaker.com/sample-1.jpg",  //--> Different url Name
    //--> No Thumbnails
  },
  {
    "name": "Sample 2",
    "creator": "Sample Maker",
    "link": "https://samplemaker.com/sample-2.jpg",  //--> Different url Name
    //--> No Thumbnails
  }
]

The Configuration

configuration.setWallpaperJsonStructure(
        new JsonStructure.Builder(null)
                .name("name")
                .author("creator")     //--> Author's Name Changed
                .url("link")           //--> Wallpaper's URL Name Changed
                .thumbUrl(null)        //--> Wallpaper's Thumbnail's URL Name Changed
                .build());

The Bare Minimum Structure

[
  {
    //--> No Name
    "maker": "Sample Maker",
    "src": "https://samplemaker.com/sample-1.jpg",  //--> Different url Name
    //--> No Thumbnails
  },
  {
    //--> No Name
    "maker": "Sample Maker",
    "src": "https://samplemaker.com/sample-2.jpg",  //--> Different url Name
    //--> No Thumbnails
  }
]

The Configuration

configuration.setWallpaperJsonStructure(
        new JsonStructure.Builder(null)
                .name(null)          //--> No Name
                .author("maker")     //--> Author's Name Changed
                .url("src")          //--> Wallpaper's URL Name Changed
                .thumbUrl(null)
                .build());
Clone this wiki locally