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 import android.graphics.Point; 20 import android.graphics.Rect; 21 import android.net.Uri; 22 23 import androidx.annotation.Nullable; 24 25 import java.util.List; 26 import java.util.Map; 27 28 /** 29 * Lightweight wrapper for user-facing wallpaper metadata. 30 */ 31 public class WallpaperMetadata { 32 33 private final List<String> mAttributions; 34 private final String mActionUrl; 35 private final String mCollectionId; 36 @Nullable private final Map<Point, Rect> mCropHints; 37 @Nullable private final Uri mImageUri; 38 protected final android.app.WallpaperInfo mWallpaperComponent; 39 WallpaperMetadata(List<String> attributions, String actionUrl, String collectionId, android.app.WallpaperInfo wallpaperComponent, @Nullable Map<Point, Rect> cropHints, @Nullable Uri imageUri)40 public WallpaperMetadata(List<String> attributions, String actionUrl, String collectionId, 41 android.app.WallpaperInfo wallpaperComponent, @Nullable Map<Point, Rect> cropHints, 42 @Nullable Uri imageUri) { 43 mAttributions = attributions; 44 mActionUrl = actionUrl; 45 mCollectionId = collectionId; 46 mWallpaperComponent = wallpaperComponent; 47 mCropHints = cropHints; 48 mImageUri = imageUri; 49 } 50 51 /** 52 * Returns wallpaper's attributions. 53 */ getAttributions()54 public List<String> getAttributions() { 55 return mAttributions; 56 } 57 58 /** 59 * Returns the wallpaper's action URL or null if there is none. 60 */ getActionUrl()61 public String getActionUrl() { 62 return mActionUrl; 63 } 64 65 /** 66 * Returns the wallpaper's collection ID or null if there is none. 67 */ getCollectionId()68 public String getCollectionId() { 69 return mCollectionId; 70 } 71 72 /** 73 * Returns the {@link android.app.WallpaperInfo} if a live wallpaper, or null if the metadata 74 * describes an image wallpaper. 75 */ getWallpaperComponent()76 public WallpaperInfo getWallpaperComponent() { 77 throw new UnsupportedOperationException("Not implemented for static wallpapers"); 78 } 79 80 /** 81 * Returns the crop {@link Rect} of each display size for this wallpaper. 82 * 83 * <p>Live wallpaper metadata should return null. 84 */ 85 @Nullable getWallpaperCropHints()86 public Map<Point, Rect> getWallpaperCropHints() { 87 return mCropHints; 88 } 89 90 /** 91 * Returns the uri of the wallpaper image file. 92 * 93 * <p>Live wallpaper metadata should return null. 94 */ 95 @Nullable getWallpaperImageUri()96 public Uri getWallpaperImageUri() { 97 return mImageUri; 98 } 99 } 100