-
Notifications
You must be signed in to change notification settings - Fork 3k
Wallpapers
The wallpaper feature allows users to set a FireFox provided wallpaper as their background on the FireFox Homepage of the application. Once selected, the wallpaper will remain as the background even if that particular wallpaper was part of a limited time collection and is no longer available.
At the time of this writing, the user cannot upload their own wallpapers.
Most of the work that's required in code is handled through the WallpaperManager
's public interfaces.
There are two types of wallpapers, as outlined in the WallpaperResourceType
enum: bundled
and downloaded
and they are, respectively, bundled with the application or downloaded. By default, all FireFox wallpapers
Wallpapers belong to collections, whether they are default firefox wallpapers or belong to a special collection. To create a new collection, it must be defined in the appropriate place in the WallpaperDataManager
. If adding a default firefox wallpaper, this can be added in the firefoxDefaultCollection()
; if adding a special collection, this should be added in the allSpecialCollections()
function.
Here is what the code looks like for adding an example special limited time (available from Jan 1, 2022 until April 30, 2022) & locale (only available in the US) collection in the allSpecialCollections()
function of the WallpaperDataManager
:
let exampleShipDate = Calendar.current.date(from: DateComponents(year: 2022, month: 1, day:1))
let exampleExpiryDate = Calendar.current.date(from: DateComponents(year: 2022, month: 5, day:1))
let exampleLocales = ["en_US"]
let exampleCollection = WallpaperCollection(wallpaperFileNames: ["exampleWallpaperName",
"secondExampleWallpaperName"],
ofType: .themed(type: .exampleProjectType),
shippingOn: exampleShipDate,
expiringOn: exampleHouseDate,
limitedToLocales: exampleLocales)
specialCollections.append(projectHouse)
All bundled wallpapers must include, as part of the image asset, four files with the following naming schema and characteristics:
-
example
- the portrait iPhone wallpaper (no suffix) -
example_ls
- the landscape iPhone wallpaper (_ls
suffix) -
example_pad
- the portrait iPad wallpaper (_pad
suffix) -
example_pad_ls
- the landscape iPad wallpaper (_pad_ls
suffix)
-
Wallpaper
- Base wallpaper class that has information such as wallpaper name, type, locale availability, and ship/expiration dates
- Does not include images as the requirement for the feature was to be able to store images separately
-
WallpaperCollections
- A collection of wallpapers defining the wallpaper names, type, locale availability, and ship/expration dates
- When creating wallpapers, collections are the main interface used, rather than individual wallpapers
-
WallpaperManager
- Responsible for delegating storage, maintenance of selected wallpapers, and verification of resources
-
WallpaperDataManager
- Responsible for managing the available wallpapers objects, given locale/date/resource availability, for collections
-
WallpaperResourceManager
- Responsible for managing resources for available wallpapers
- Removes wallpapers saved to disk based on expiry date/local restrictions
-
WallpaperFilePathProtocol
- Allows you to get a file path to a specified key under the
wallpapers
folder of the application's documents directory - Path is:
.../wallpapers/key-as-folder/key-as-file
- Allows you to get a file path to a specified key under the
-
WallpaperStorageUtility
- Responsible for storing, retrieving, and deleting images to the documents directory.
-
WallpaperNetworkUtility
- Responsible for fetching images over the network, if the application doesn't already have those resources, given a specified url
- At the time of this writing, the user cannot change the URL