Automatically adding managed profile shortcuts to homescreen.

When the managed profile is created, a "Work" folder is created
and added to the homescreen. All work profile apps are added to this
folder and icons for subsequent installs (withing a fixed time frame)
are automatically added to this folder.
If this folder get deleted or the time-frame expires, icon for any new
install is placed on the homescreen.

Bug: 17410319
Change-Id: I49f4e437707d5eabe4eec85320765bf6ba7fde97
This commit is contained in:
Sunny Goyal
2015-04-08 18:13:46 -07:00
parent d9760ee2de
commit 18bf8e2ffd
12 changed files with 370 additions and 87 deletions

View File

@@ -24,7 +24,9 @@ import android.graphics.Bitmap;
import android.util.Log;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.compat.LauncherActivityInfoCompat;
import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
import java.util.ArrayList;
import java.util.Arrays;
@@ -274,5 +276,19 @@ public class ShortcutInfo extends ItemInfo {
public boolean shouldUseLowResIcon() {
return usingLowResIcon && container >= 0 && rank >= FolderIcon.NUM_ITEMS_IN_PREVIEW;
}
public static ShortcutInfo fromActivityInfo(LauncherActivityInfoCompat info, Context context) {
final ShortcutInfo shortcut = new ShortcutInfo();
shortcut.user = info.getUser();
shortcut.title = info.getLabel().toString();
shortcut.contentDescription = UserManagerCompat.getInstance(context)
.getBadgedLabelForUser(info.getLabel(), info.getUser());
shortcut.customIcon = false;
shortcut.intent = AppInfo.makeLaunchIntent(context, info, info.getUser());
shortcut.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
shortcut.flags = AppInfo.initFlags(info);
shortcut.firstInstallTime = info.getFirstInstallTime();
return shortcut;
}
}