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 17 package com.android.launcher3; 18 19 import android.graphics.Bitmap; 20 21 /** 22 * Represents an ItemInfo which also holds an icon. 23 */ 24 public abstract class ItemInfoWithIcon extends ItemInfo { 25 26 /** 27 * A bitmap version of the application icon. 28 */ 29 public Bitmap iconBitmap; 30 31 /** 32 * Dominant color in the {@link #iconBitmap}. 33 */ 34 public int iconColor; 35 36 /** 37 * Indicates whether we're using a low res icon 38 */ 39 public boolean usingLowResIcon; 40 41 /** 42 * Indicates that the icon is disabled due to safe mode restrictions. 43 */ 44 public static final int FLAG_DISABLED_SAFEMODE = 1 << 0; 45 46 /** 47 * Indicates that the icon is disabled as the app is not available. 48 */ 49 public static final int FLAG_DISABLED_NOT_AVAILABLE = 1 << 1; 50 51 /** 52 * Indicates that the icon is disabled as the app is suspended 53 */ 54 public static final int FLAG_DISABLED_SUSPENDED = 1 << 2; 55 56 /** 57 * Indicates that the icon is disabled as the user is in quiet mode. 58 */ 59 public static final int FLAG_DISABLED_QUIET_USER = 1 << 3; 60 61 /** 62 * Indicates that the icon is disabled as the publisher has disabled the actual shortcut. 63 */ 64 public static final int FLAG_DISABLED_BY_PUBLISHER = 1 << 4; 65 66 /** 67 * Indicates that the icon is disabled as the user partition is currently locked. 68 */ 69 public static final int FLAG_DISABLED_LOCKED_USER = 1 << 5; 70 71 public static final int FLAG_DISABLED_MASK = FLAG_DISABLED_SAFEMODE | 72 FLAG_DISABLED_NOT_AVAILABLE | FLAG_DISABLED_SUSPENDED | 73 FLAG_DISABLED_QUIET_USER | FLAG_DISABLED_BY_PUBLISHER | FLAG_DISABLED_LOCKED_USER; 74 75 /** 76 * The item points to a system app. 77 */ 78 public static final int FLAG_SYSTEM_YES = 1 << 6; 79 80 /** 81 * The item points to a non system app. 82 */ 83 public static final int FLAG_SYSTEM_NO = 1 << 7; 84 85 public static final int FLAG_SYSTEM_MASK = FLAG_SYSTEM_YES | FLAG_SYSTEM_NO; 86 87 /** 88 * Flag indicating that the icon is an {@link android.graphics.drawable.AdaptiveIconDrawable} 89 * that can be optimized in various way. 90 */ 91 public static final int FLAG_ADAPTIVE_ICON = 1 << 8; 92 93 /** 94 * Flag indicating that the icon is badged. 95 */ 96 public static final int FLAG_ICON_BADGED = 1 << 9; 97 98 /** 99 * Status associated with the system state of the underlying item. This is calculated every 100 * time a new info is created and not persisted on the disk. 101 */ 102 public int runtimeStatusFlags = 0; 103 104 protected ItemInfoWithIcon() { } 105 106 protected ItemInfoWithIcon(ItemInfoWithIcon info) { 107 super(info); 108 iconBitmap = info.iconBitmap; 109 iconColor = info.iconColor; 110 usingLowResIcon = info.usingLowResIcon; 111 runtimeStatusFlags = info.runtimeStatusFlags; 112 } 113 114 @Override 115 public boolean isDisabled() { 116 return (runtimeStatusFlags & FLAG_DISABLED_MASK) != 0; 117 } 118 } 119