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.Activity; 19 import android.content.Context; 20 import android.os.Parcel; 21 22 import com.android.wallpaper.R; 23 import com.android.wallpaper.asset.Asset; 24 import com.android.wallpaper.asset.BuiltInWallpaperAsset; 25 26 import java.util.Arrays; 27 import java.util.List; 28 29 /** 30 * Represents the default built-in wallpaper on the device. 31 */ 32 public class DefaultWallpaperInfo extends WallpaperInfo { 33 public static final Creator<DefaultWallpaperInfo> CREATOR = 34 new Creator<DefaultWallpaperInfo>() { 35 @Override 36 public DefaultWallpaperInfo createFromParcel(Parcel in) { 37 return new DefaultWallpaperInfo(in); 38 } 39 40 @Override 41 public DefaultWallpaperInfo[] newArray(int size) { 42 return new DefaultWallpaperInfo[size]; 43 } 44 }; 45 private Asset mAsset; 46 DefaultWallpaperInfo()47 public DefaultWallpaperInfo() {} 48 DefaultWallpaperInfo(Parcel in)49 protected DefaultWallpaperInfo(Parcel in) { 50 super(in); 51 } 52 53 @Override getAttributions(Context context)54 public List<String> getAttributions(Context context) { 55 return Arrays.asList(context.getResources().getString(R.string.fallback_wallpaper_title)); 56 } 57 58 @Override getAsset(Context context)59 public Asset getAsset(Context context) { 60 if (mAsset == null) { 61 mAsset = new BuiltInWallpaperAsset(context); 62 } 63 return mAsset; 64 } 65 66 @Override getThumbAsset(Context context)67 public Asset getThumbAsset(Context context) { 68 // Same asset as full size. 69 return getAsset(context); 70 } 71 72 @Override getCollectionId(Context context)73 public String getCollectionId(Context context) { 74 return context.getString(R.string.on_device_wallpaper_collection_id); 75 } 76 77 @Override getWallpaperId()78 public String getWallpaperId() { 79 return "built-in-wallpaper"; 80 } 81 82 @Override showPreview(Activity srcActivity, InlinePreviewIntentFactory factory, int requestCode, boolean isAssetIdPresent)83 public void showPreview(Activity srcActivity, InlinePreviewIntentFactory factory, 84 int requestCode, boolean isAssetIdPresent) { 85 srcActivity.startActivityForResult(factory.newIntent(srcActivity, this, 86 isAssetIdPresent), requestCode); 87 } 88 89 @Override 90 @BackupPermission getBackupPermission()91 public int getBackupPermission() { 92 return BACKUP_NOT_ALLOWED; 93 } 94 95 @Override writeToParcel(Parcel parcel, int i)96 public void writeToParcel(Parcel parcel, int i) { 97 super.writeToParcel(parcel, i); 98 } 99 } 100