Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 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 | |
Daniel Sandler | 325dc23 | 2013-06-05 22:57:57 -0400 | [diff] [blame] | 17 | package com.android.launcher3; |
Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 18 | |
Sunny Goyal | 3494262 | 2014-08-29 17:20:55 -0700 | [diff] [blame] | 19 | import android.content.ComponentName; |
Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 20 | import android.content.ContentValues; |
Michael Jurka | 1e2f465 | 2013-07-08 18:03:46 -0700 | [diff] [blame] | 21 | import android.content.Context; |
Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 22 | import android.content.Intent; |
| 23 | import android.graphics.Bitmap; |
Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 24 | import android.util.Log; |
| 25 | |
Sunny Goyal | 4fbc382 | 2015-02-18 16:46:50 -0800 | [diff] [blame] | 26 | import com.android.launcher3.LauncherSettings.Favorites; |
Sunny Goyal | 18bf8e2 | 2015-04-08 18:13:46 -0700 | [diff] [blame] | 27 | import com.android.launcher3.compat.LauncherActivityInfoCompat; |
Kenny Guy | ed13187 | 2014-04-30 03:02:21 +0100 | [diff] [blame] | 28 | import com.android.launcher3.compat.UserHandleCompat; |
Sunny Goyal | 18bf8e2 | 2015-04-08 18:13:46 -0700 | [diff] [blame] | 29 | import com.android.launcher3.compat.UserManagerCompat; |
Kenny Guy | ed13187 | 2014-04-30 03:02:21 +0100 | [diff] [blame] | 30 | |
Michael Jurka | 1e2f465 | 2013-07-08 18:03:46 -0700 | [diff] [blame] | 31 | import java.util.ArrayList; |
Sameer Padala | be3e410 | 2014-04-21 19:36:14 -0700 | [diff] [blame] | 32 | import java.util.Arrays; |
Michael Jurka | 1e2f465 | 2013-07-08 18:03:46 -0700 | [diff] [blame] | 33 | |
Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 34 | /** |
| 35 | * Represents a launchable icon on the workspaces and in folders. |
| 36 | */ |
Anjali Koppal | 7b168a1 | 2014-03-04 17:16:11 -0800 | [diff] [blame] | 37 | public class ShortcutInfo extends ItemInfo { |
Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 38 | |
Sunny Goyal | 3494262 | 2014-08-29 17:20:55 -0700 | [diff] [blame] | 39 | public static final int DEFAULT = 0; |
Chris Wren | aeff7ea | 2014-02-14 16:59:24 -0500 | [diff] [blame] | 40 | |
Sunny Goyal | 3494262 | 2014-08-29 17:20:55 -0700 | [diff] [blame] | 41 | /** |
| 42 | * The shortcut was restored from a backup and it not ready to be used. This is automatically |
| 43 | * set during backup/restore |
| 44 | */ |
| 45 | public static final int FLAG_RESTORED_ICON = 1; |
Chris Wren | aeff7ea | 2014-02-14 16:59:24 -0500 | [diff] [blame] | 46 | |
Sunny Goyal | 3494262 | 2014-08-29 17:20:55 -0700 | [diff] [blame] | 47 | /** |
| 48 | * The icon was added as an auto-install app, and is not ready to be used. This flag can't |
| 49 | * be present along with {@link #FLAG_RESTORED_ICON}, and is set during default layout |
| 50 | * parsing. |
| 51 | */ |
Sunny Goyal | bb3b02f | 2015-01-15 12:00:14 -0800 | [diff] [blame] | 52 | public static final int FLAG_AUTOINTALL_ICON = 2; //0B10; |
Chris Wren | aeff7ea | 2014-02-14 16:59:24 -0500 | [diff] [blame] | 53 | |
Sunny Goyal | 3494262 | 2014-08-29 17:20:55 -0700 | [diff] [blame] | 54 | /** |
| 55 | * The icon is being installed. If {@link FLAG_RESTORED_ICON} or {@link FLAG_AUTOINTALL_ICON} |
| 56 | * is set, then the icon is either being installed or is in a broken state. |
| 57 | */ |
Sunny Goyal | bb3b02f | 2015-01-15 12:00:14 -0800 | [diff] [blame] | 58 | public static final int FLAG_INSTALL_SESSION_ACTIVE = 4; // 0B100; |
Chris Wren | aeff7ea | 2014-02-14 16:59:24 -0500 | [diff] [blame] | 59 | |
Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 60 | /** |
Sunny Goyal | 9448536 | 2014-09-18 16:13:58 -0700 | [diff] [blame] | 61 | * Indicates that the widget restore has started. |
| 62 | */ |
Sunny Goyal | bb3b02f | 2015-01-15 12:00:14 -0800 | [diff] [blame] | 63 | public static final int FLAG_RESTORE_STARTED = 8; //0B1000; |
| 64 | |
| 65 | /** |
| 66 | * Indicates if it represents a common type mentioned in {@link CommonAppTypeParser}. |
| 67 | * Upto 15 different types supported. |
| 68 | */ |
| 69 | public static final int FLAG_RESTORED_APP_TYPE = 0B0011110000; |
Sunny Goyal | 9448536 | 2014-09-18 16:13:58 -0700 | [diff] [blame] | 70 | |
| 71 | /** |
Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 72 | * The intent used to start the application. |
| 73 | */ |
| 74 | Intent intent; |
| 75 | |
| 76 | /** |
| 77 | * Indicates whether the icon comes from an application's resource (if false) |
| 78 | * or from a custom Bitmap (if true.) |
| 79 | */ |
| 80 | boolean customIcon; |
| 81 | |
| 82 | /** |
Joe Onorato | 56d8291 | 2010-03-07 14:32:10 -0500 | [diff] [blame] | 83 | * Indicates whether we're using the default fallback icon instead of something from the |
| 84 | * app. |
| 85 | */ |
| 86 | boolean usingFallbackIcon; |
| 87 | |
| 88 | /** |
Sunny Goyal | 34b6527 | 2015-03-11 16:56:52 -0700 | [diff] [blame] | 89 | * Indicates whether we're using a low res icon |
| 90 | */ |
| 91 | boolean usingLowResIcon; |
| 92 | |
| 93 | /** |
Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 94 | * If isShortcut=true and customIcon=false, this contains a reference to the |
| 95 | * shortcut icon as an application's resource. |
| 96 | */ |
| 97 | Intent.ShortcutIconResource iconResource; |
| 98 | |
| 99 | /** |
| 100 | * The application icon. |
| 101 | */ |
| 102 | private Bitmap mIcon; |
| 103 | |
Chris Wren | 40c5ed3 | 2014-06-24 18:24:23 -0400 | [diff] [blame] | 104 | /** |
Sunny Goyal | 1a745e8 | 2014-10-02 15:58:31 -0700 | [diff] [blame] | 105 | * Indicates that the icon is disabled due to safe mode restrictions. |
| 106 | */ |
| 107 | public static final int FLAG_DISABLED_SAFEMODE = 1; |
| 108 | |
| 109 | /** |
| 110 | * Indicates that the icon is disabled as the app is not available. |
| 111 | */ |
| 112 | public static final int FLAG_DISABLED_NOT_AVAILABLE = 2; |
| 113 | |
| 114 | /** |
Sunny Goyal | c5c60ad | 2014-07-14 12:02:01 -0700 | [diff] [blame] | 115 | * Could be disabled, if the the app is installed but unavailable (eg. in safe mode or when |
| 116 | * sd-card is not available). |
| 117 | */ |
Sunny Goyal | 1a745e8 | 2014-10-02 15:58:31 -0700 | [diff] [blame] | 118 | int isDisabled = DEFAULT; |
Sunny Goyal | c5c60ad | 2014-07-14 12:02:01 -0700 | [diff] [blame] | 119 | |
Sunny Goyal | 3494262 | 2014-08-29 17:20:55 -0700 | [diff] [blame] | 120 | int status; |
Chris Wren | 40c5ed3 | 2014-06-24 18:24:23 -0400 | [diff] [blame] | 121 | |
Sunny Goyal | e755d46 | 2014-07-22 13:48:29 -0700 | [diff] [blame] | 122 | /** |
| 123 | * The installation progress [0-100] of the package that this shortcut represents. |
| 124 | */ |
Sunny Goyal | 3494262 | 2014-08-29 17:20:55 -0700 | [diff] [blame] | 125 | private int mInstallProgress; |
Sunny Goyal | e755d46 | 2014-07-22 13:48:29 -0700 | [diff] [blame] | 126 | |
Sunny Goyal | 3494262 | 2014-08-29 17:20:55 -0700 | [diff] [blame] | 127 | /** |
| 128 | * Refer {@link AppInfo#firstInstallTime}. |
| 129 | */ |
Michael Jurka | 1e2f465 | 2013-07-08 18:03:46 -0700 | [diff] [blame] | 130 | long firstInstallTime; |
Sunny Goyal | 3494262 | 2014-08-29 17:20:55 -0700 | [diff] [blame] | 131 | |
| 132 | /** |
| 133 | * TODO move this to {@link status} |
| 134 | */ |
Michael Jurka | 1e2f465 | 2013-07-08 18:03:46 -0700 | [diff] [blame] | 135 | int flags = 0; |
| 136 | |
Chris Wren | b6d4c28 | 2014-01-27 14:17:08 -0500 | [diff] [blame] | 137 | /** |
| 138 | * If this shortcut is a placeholder, then intent will be a market intent for the package, and |
| 139 | * this will hold the original intent from the database. Otherwise, null. |
Sunny Goyal | 3494262 | 2014-08-29 17:20:55 -0700 | [diff] [blame] | 140 | * Refer {@link #FLAG_RESTORE_PENDING}, {@link #FLAG_INSTALL_PENDING} |
Chris Wren | b6d4c28 | 2014-01-27 14:17:08 -0500 | [diff] [blame] | 141 | */ |
Sunny Goyal | 3494262 | 2014-08-29 17:20:55 -0700 | [diff] [blame] | 142 | Intent promisedIntent; |
Sunny Goyal | 3484638 | 2014-07-09 00:09:28 -0700 | [diff] [blame] | 143 | |
Michael Jurka | c9d95c5 | 2011-08-29 14:03:34 -0700 | [diff] [blame] | 144 | ShortcutInfo() { |
Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 145 | itemType = LauncherSettings.BaseLauncherColumns.ITEM_TYPE_SHORTCUT; |
| 146 | } |
Winson Chung | 997a923 | 2013-07-24 15:33:46 -0700 | [diff] [blame] | 147 | |
Anjali Koppal | e3e646e | 2014-03-17 09:34:39 -0700 | [diff] [blame] | 148 | public Intent getIntent() { |
Winson Chung | 997a923 | 2013-07-24 15:33:46 -0700 | [diff] [blame] | 149 | return intent; |
| 150 | } |
Mathew Inwood | 72fbec1 | 2013-11-19 15:45:07 +0000 | [diff] [blame] | 151 | |
Kenny Guy | d6fe526 | 2014-07-21 17:11:41 +0100 | [diff] [blame] | 152 | ShortcutInfo(Intent intent, CharSequence title, CharSequence contentDescription, |
Kenny Guy | c2bd810 | 2014-06-30 12:30:31 +0100 | [diff] [blame] | 153 | Bitmap icon, UserHandleCompat user) { |
Mathew Inwood | 72fbec1 | 2013-11-19 15:45:07 +0000 | [diff] [blame] | 154 | this(); |
| 155 | this.intent = intent; |
Winson Chung | 82b016c | 2015-05-08 17:00:10 -0700 | [diff] [blame^] | 156 | this.title = Utilities.trim(title); |
Kenny Guy | c2bd810 | 2014-06-30 12:30:31 +0100 | [diff] [blame] | 157 | this.contentDescription = contentDescription; |
Mathew Inwood | 72fbec1 | 2013-11-19 15:45:07 +0000 | [diff] [blame] | 158 | mIcon = icon; |
Kenny Guy | ed13187 | 2014-04-30 03:02:21 +0100 | [diff] [blame] | 159 | this.user = user; |
Mathew Inwood | 72fbec1 | 2013-11-19 15:45:07 +0000 | [diff] [blame] | 160 | } |
| 161 | |
Michael Jurka | 1e2f465 | 2013-07-08 18:03:46 -0700 | [diff] [blame] | 162 | public ShortcutInfo(Context context, ShortcutInfo info) { |
Michael Jurka | c9d95c5 | 2011-08-29 14:03:34 -0700 | [diff] [blame] | 163 | super(info); |
Winson Chung | 82b016c | 2015-05-08 17:00:10 -0700 | [diff] [blame^] | 164 | title = Utilities.trim(info.title); |
Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 165 | intent = new Intent(info.intent); |
| 166 | if (info.iconResource != null) { |
| 167 | iconResource = new Intent.ShortcutIconResource(); |
| 168 | iconResource.packageName = info.iconResource.packageName; |
| 169 | iconResource.resourceName = info.iconResource.resourceName; |
| 170 | } |
| 171 | mIcon = info.mIcon; // TODO: should make a copy here. maybe we don't need this ctor at all |
| 172 | customIcon = info.customIcon; |
Kenny Guy | ed13187 | 2014-04-30 03:02:21 +0100 | [diff] [blame] | 173 | flags = info.flags; |
| 174 | firstInstallTime = info.firstInstallTime; |
| 175 | user = info.user; |
Sunny Goyal | 3494262 | 2014-08-29 17:20:55 -0700 | [diff] [blame] | 176 | status = info.status; |
Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | /** TODO: Remove this. It's only called by ApplicationInfo.makeShortcut. */ |
Michael Jurka | eadbfc5 | 2013-09-04 00:45:37 +0200 | [diff] [blame] | 180 | public ShortcutInfo(AppInfo info) { |
Michael Jurka | c9d95c5 | 2011-08-29 14:03:34 -0700 | [diff] [blame] | 181 | super(info); |
Winson Chung | 82b016c | 2015-05-08 17:00:10 -0700 | [diff] [blame^] | 182 | title = Utilities.trim(info.title); |
Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 183 | intent = new Intent(info.intent); |
| 184 | customIcon = false; |
Michael Jurka | 1e2f465 | 2013-07-08 18:03:46 -0700 | [diff] [blame] | 185 | flags = info.flags; |
| 186 | firstInstallTime = info.firstInstallTime; |
| 187 | } |
| 188 | |
Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 189 | public void setIcon(Bitmap b) { |
| 190 | mIcon = b; |
| 191 | } |
| 192 | |
| 193 | public Bitmap getIcon(IconCache iconCache) { |
| 194 | if (mIcon == null) { |
Michael Jurka | e384aff | 2012-03-09 15:59:25 -0800 | [diff] [blame] | 195 | updateIcon(iconCache); |
Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 196 | } |
| 197 | return mIcon; |
| 198 | } |
| 199 | |
Michael Jurka | e384aff | 2012-03-09 15:59:25 -0800 | [diff] [blame] | 200 | public void updateIcon(IconCache iconCache) { |
Sunny Goyal | 4fbc382 | 2015-02-18 16:46:50 -0800 | [diff] [blame] | 201 | if (itemType == Favorites.ITEM_TYPE_APPLICATION) { |
Sunny Goyal | 34b6527 | 2015-03-11 16:56:52 -0700 | [diff] [blame] | 202 | iconCache.getTitleAndIcon(this, promisedIntent != null ? promisedIntent : intent, user, |
| 203 | shouldUseLowResIcon()); |
Sunny Goyal | 4fbc382 | 2015-02-18 16:46:50 -0800 | [diff] [blame] | 204 | } |
Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | @Override |
Kenny Guy | ed13187 | 2014-04-30 03:02:21 +0100 | [diff] [blame] | 208 | void onAddToDatabase(Context context, ContentValues values) { |
| 209 | super.onAddToDatabase(context, values); |
Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 210 | |
| 211 | String titleStr = title != null ? title.toString() : null; |
| 212 | values.put(LauncherSettings.BaseLauncherColumns.TITLE, titleStr); |
| 213 | |
Sunny Goyal | 3494262 | 2014-08-29 17:20:55 -0700 | [diff] [blame] | 214 | String uri = promisedIntent != null ? promisedIntent.toUri(0) |
Sunny Goyal | 9623a99 | 2014-07-23 15:06:44 -0700 | [diff] [blame] | 215 | : (intent != null ? intent.toUri(0) : null); |
Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 216 | values.put(LauncherSettings.BaseLauncherColumns.INTENT, uri); |
Sunny Goyal | 756adbc | 2015-04-16 15:20:51 -0700 | [diff] [blame] | 217 | values.put(LauncherSettings.Favorites.RESTORED, status); |
Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 218 | |
| 219 | if (customIcon) { |
| 220 | values.put(LauncherSettings.BaseLauncherColumns.ICON_TYPE, |
| 221 | LauncherSettings.BaseLauncherColumns.ICON_TYPE_BITMAP); |
Joe Onorato | 56d8291 | 2010-03-07 14:32:10 -0500 | [diff] [blame] | 222 | writeBitmap(values, mIcon); |
Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 223 | } else { |
Joe Onorato | ddc9c1f | 2010-08-30 18:30:15 -0700 | [diff] [blame] | 224 | if (!usingFallbackIcon) { |
Joe Onorato | 56d8291 | 2010-03-07 14:32:10 -0500 | [diff] [blame] | 225 | writeBitmap(values, mIcon); |
| 226 | } |
Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 227 | if (iconResource != null) { |
Sunny Goyal | 4fbc382 | 2015-02-18 16:46:50 -0800 | [diff] [blame] | 228 | values.put(LauncherSettings.BaseLauncherColumns.ICON_TYPE, |
| 229 | LauncherSettings.BaseLauncherColumns.ICON_TYPE_RESOURCE); |
Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 230 | values.put(LauncherSettings.BaseLauncherColumns.ICON_PACKAGE, |
| 231 | iconResource.packageName); |
| 232 | values.put(LauncherSettings.BaseLauncherColumns.ICON_RESOURCE, |
| 233 | iconResource.resourceName); |
| 234 | } |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | @Override |
| 239 | public String toString() { |
Kenny Guy | ed13187 | 2014-04-30 03:02:21 +0100 | [diff] [blame] | 240 | return "ShortcutInfo(title=" + title + "intent=" + intent + "id=" + this.id |
Adam Cohen | dcd297f | 2013-06-18 13:13:40 -0700 | [diff] [blame] | 241 | + " type=" + this.itemType + " container=" + this.container + " screen=" + screenId |
Winson Chung | db8a894 | 2012-04-03 14:08:41 -0700 | [diff] [blame] | 242 | + " cellX=" + cellX + " cellY=" + cellY + " spanX=" + spanX + " spanY=" + spanY |
Kenny Guy | ed13187 | 2014-04-30 03:02:21 +0100 | [diff] [blame] | 243 | + " dropPos=" + Arrays.toString(dropPos) + " user=" + user + ")"; |
Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 244 | } |
| 245 | |
Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 246 | public static void dumpShortcutInfoList(String tag, String label, |
| 247 | ArrayList<ShortcutInfo> list) { |
| 248 | Log.d(tag, label + " size=" + list.size()); |
| 249 | for (ShortcutInfo info: list) { |
| 250 | Log.d(tag, " title=\"" + info.title + " icon=" + info.mIcon |
| 251 | + " customIcon=" + info.customIcon); |
| 252 | } |
| 253 | } |
Chris Wren | aeff7ea | 2014-02-14 16:59:24 -0500 | [diff] [blame] | 254 | |
Sunny Goyal | 3494262 | 2014-08-29 17:20:55 -0700 | [diff] [blame] | 255 | public ComponentName getTargetComponent() { |
| 256 | return promisedIntent != null ? promisedIntent.getComponent() : intent.getComponent(); |
Chris Wren | aeff7ea | 2014-02-14 16:59:24 -0500 | [diff] [blame] | 257 | } |
| 258 | |
Sunny Goyal | 3494262 | 2014-08-29 17:20:55 -0700 | [diff] [blame] | 259 | public boolean hasStatusFlag(int flag) { |
| 260 | return (status & flag) != 0; |
Chris Wren | aeff7ea | 2014-02-14 16:59:24 -0500 | [diff] [blame] | 261 | } |
Chris Wren | 40c5ed3 | 2014-06-24 18:24:23 -0400 | [diff] [blame] | 262 | |
Sunny Goyal | 3494262 | 2014-08-29 17:20:55 -0700 | [diff] [blame] | 263 | |
| 264 | public final boolean isPromise() { |
| 265 | return hasStatusFlag(FLAG_RESTORED_ICON | FLAG_AUTOINTALL_ICON); |
Chris Wren | 40c5ed3 | 2014-06-24 18:24:23 -0400 | [diff] [blame] | 266 | } |
| 267 | |
Sunny Goyal | 3494262 | 2014-08-29 17:20:55 -0700 | [diff] [blame] | 268 | public int getInstallProgress() { |
| 269 | return mInstallProgress; |
Sunny Goyal | e755d46 | 2014-07-22 13:48:29 -0700 | [diff] [blame] | 270 | } |
| 271 | |
Sunny Goyal | 3494262 | 2014-08-29 17:20:55 -0700 | [diff] [blame] | 272 | public void setInstallProgress(int progress) { |
| 273 | mInstallProgress = progress; |
| 274 | status |= FLAG_INSTALL_SESSION_ACTIVE; |
Sunny Goyal | e755d46 | 2014-07-22 13:48:29 -0700 | [diff] [blame] | 275 | } |
Sunny Goyal | 34b6527 | 2015-03-11 16:56:52 -0700 | [diff] [blame] | 276 | |
| 277 | public boolean shouldUseLowResIcon() { |
| 278 | return usingLowResIcon && container >= 0 && rank >= FolderIcon.NUM_ITEMS_IN_PREVIEW; |
| 279 | } |
Sunny Goyal | 18bf8e2 | 2015-04-08 18:13:46 -0700 | [diff] [blame] | 280 | |
| 281 | public static ShortcutInfo fromActivityInfo(LauncherActivityInfoCompat info, Context context) { |
| 282 | final ShortcutInfo shortcut = new ShortcutInfo(); |
| 283 | shortcut.user = info.getUser(); |
Winson Chung | 82b016c | 2015-05-08 17:00:10 -0700 | [diff] [blame^] | 284 | shortcut.title = Utilities.trim(info.getLabel()); |
Sunny Goyal | 18bf8e2 | 2015-04-08 18:13:46 -0700 | [diff] [blame] | 285 | shortcut.contentDescription = UserManagerCompat.getInstance(context) |
| 286 | .getBadgedLabelForUser(info.getLabel(), info.getUser()); |
| 287 | shortcut.customIcon = false; |
| 288 | shortcut.intent = AppInfo.makeLaunchIntent(context, info, info.getUser()); |
| 289 | shortcut.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION; |
| 290 | shortcut.flags = AppInfo.initFlags(info); |
| 291 | shortcut.firstInstallTime = info.getFirstInstallTime(); |
| 292 | return shortcut; |
| 293 | } |
Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 294 | } |
| 295 | |