1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.wallpaper.model; 17 18 import android.app.WallpaperInfo; 19 20 import androidx.annotation.DrawableRes; 21 import androidx.annotation.Nullable; 22 import androidx.annotation.StringRes; 23 24 import java.util.List; 25 26 /** 27 * Lightweight wrapper for user-facing wallpaper metadata. 28 */ 29 public class WallpaperMetadata { 30 31 private final List<String> mAttributions; 32 private final String mActionUrl; 33 private final String mCollectionId; 34 private final String mBackingFileName; 35 private final android.app.WallpaperInfo mWallpaperComponent; 36 @StringRes private final int mActionLabelRes; 37 @DrawableRes private final int mActionIconRes; 38 WallpaperMetadata(List<String> attributions, String actionUrl, @StringRes int actionLabelRes, @DrawableRes int actionIconRes, String collectionId, String backingFileName, android.app.WallpaperInfo wallpaperComponent)39 public WallpaperMetadata(List<String> attributions, String actionUrl, 40 @StringRes int actionLabelRes, 41 @DrawableRes int actionIconRes, String collectionId, 42 String backingFileName, 43 android.app.WallpaperInfo wallpaperComponent) { 44 mAttributions = attributions; 45 mActionUrl = actionUrl; 46 mActionLabelRes = actionLabelRes; 47 mActionIconRes = actionIconRes; 48 mCollectionId = collectionId; 49 mBackingFileName = backingFileName; 50 mWallpaperComponent = wallpaperComponent; 51 } 52 53 /** 54 * Returns wallpaper's attributions. 55 */ getAttributions()56 public List<String> getAttributions() { 57 return mAttributions; 58 } 59 60 /** 61 * Returns the wallpaper's action URL or null if there is none. 62 */ getActionUrl()63 public String getActionUrl() { 64 return mActionUrl; 65 } 66 67 /** 68 * Returns the wallpaper's action label. 69 */ 70 @StringRes getActionLabelRes()71 public int getActionLabelRes() { 72 return mActionLabelRes; 73 } 74 75 /** 76 * Returns the wallpaper's action icon. 77 */ 78 @DrawableRes getActionIconRes()79 public int getActionIconRes() { 80 return mActionIconRes; 81 } 82 83 /** 84 * Returns the wallpaper's collection ID or null if there is none. 85 */ getCollectionId()86 public String getCollectionId() { 87 return mCollectionId; 88 } 89 90 /** 91 * Returns the name of a private file corresponding to a copy of the full image used as 92 * wallpaper if this is a static wallpaper. 93 */ 94 @Nullable getBackingFileName()95 public String getBackingFileName() { 96 return mBackingFileName; 97 } 98 99 /** 100 * Returns the {@link android.app.WallpaperInfo} if a live wallpaper, or null if the metadata 101 * describes an image wallpaper. 102 */ getWallpaperComponent()103 public WallpaperInfo getWallpaperComponent() { 104 return mWallpaperComponent; 105 } 106 } 107