Search in sources :

Example 31 with ItemInfo

use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class SecondaryDropTarget method supportsAccessibilityDrop.

@Override
public boolean supportsAccessibilityDrop(ItemInfo info, View view) {
    if (view instanceof AppWidgetHostView) {
        if (getReconfigurableWidgetId(view) != INVALID_APPWIDGET_ID) {
            setupUi(RECONFIGURE);
            return true;
        }
        return false;
    } else if (FeatureFlags.ENABLE_PREDICTION_DISMISS.get() && info.isPredictedItem()) {
        setupUi(DISMISS_PREDICTION);
        return true;
    }
    setupUi(UNINSTALL);
    Boolean uninstallDisabled = mUninstallDisabledCache.get(info.user);
    if (uninstallDisabled == null) {
        UserManager userManager = (UserManager) getContext().getSystemService(Context.USER_SERVICE);
        Bundle restrictions = userManager.getUserRestrictions(info.user);
        uninstallDisabled = restrictions.getBoolean(UserManager.DISALLOW_APPS_CONTROL, false) || restrictions.getBoolean(UserManager.DISALLOW_UNINSTALL_APPS, false);
        mUninstallDisabledCache.put(info.user, uninstallDisabled);
    }
    // Cancel any pending alarm and set cache expiry after some time
    mCacheExpireAlarm.setAlarm(CACHE_EXPIRE_TIMEOUT);
    mCacheExpireAlarm.setOnAlarmListener(this);
    if (uninstallDisabled) {
        return false;
    }
    if (info instanceof ItemInfoWithIcon) {
        ItemInfoWithIcon iconInfo = (ItemInfoWithIcon) info;
        if ((iconInfo.runtimeStatusFlags & FLAG_SYSTEM_MASK) != 0) {
            return (iconInfo.runtimeStatusFlags & FLAG_SYSTEM_NO) != 0;
        }
    }
    return getUninstallTarget(info) != null;
}
Also used : AppWidgetHostView(android.appwidget.AppWidgetHostView) UserManager(android.os.UserManager) Bundle(android.os.Bundle) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon)

Example 32 with ItemInfo

use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class Utilities method getBadge.

/**
 * For apps icons and shortcut icons that have badges, this method creates a drawable that can
 * later on be rendered on top of the layers for the badges. For app icons, work profile badges
 * can only be applied. For deep shortcuts, when dragged from the pop up container, there's no
 * badge. When dragged from workspace or folder, it may contain app AND/OR work profile badge
 */
@TargetApi(Build.VERSION_CODES.O)
public static Drawable getBadge(Launcher launcher, ItemInfo info, Object obj) {
    LauncherAppState appState = LauncherAppState.getInstance(launcher);
    int iconSize = appState.getInvariantDeviceProfile().iconBitmapSize;
    if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
        boolean iconBadged = (info instanceof ItemInfoWithIcon) && (((ItemInfoWithIcon) info).runtimeStatusFlags & FLAG_ICON_BADGED) > 0;
        if ((info.id == ItemInfo.NO_ID && !iconBadged) || !(obj instanceof ShortcutInfo)) {
            // The item is not yet added on home screen.
            return new FixedSizeEmptyDrawable(iconSize);
        }
        ShortcutInfo si = (ShortcutInfo) obj;
        Bitmap badge = LauncherAppState.getInstance(appState.getContext()).getIconCache().getShortcutInfoBadge(si).icon;
        float badgeSize = LauncherIcons.getBadgeSizeForIconSize(iconSize);
        float insetFraction = (iconSize - badgeSize) / iconSize;
        return new InsetDrawable(new FastBitmapDrawable(badge), insetFraction, insetFraction, 0, 0);
    } else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_FOLDER) {
        return ((FolderAdaptiveIcon) obj).getBadge();
    } else {
        return launcher.getPackageManager().getUserBadgedIcon(new FixedSizeEmptyDrawable(iconSize), info.user);
    }
}
Also used : FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) Bitmap(android.graphics.Bitmap) ShortcutInfo(android.content.pm.ShortcutInfo) PendingAddShortcutInfo(com.android.launcher3.widget.PendingAddShortcutInfo) InsetDrawable(android.graphics.drawable.InsetDrawable) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon) Paint(android.graphics.Paint) Point(android.graphics.Point) TargetApi(android.annotation.TargetApi)

Example 33 with ItemInfo

use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class RecentsActivity method getActivityLaunchOptions.

@Override
public ActivityOptionsWrapper getActivityLaunchOptions(final View v, @Nullable ItemInfo item) {
    if (!(v instanceof TaskView)) {
        return super.getActivityLaunchOptions(v, item);
    }
    final TaskView taskView = (TaskView) v;
    RunnableList onEndCallback = new RunnableList();
    mActivityLaunchAnimationRunner = new RemoteAnimationFactory() {

        @Override
        public void onCreateAnimation(int transit, RemoteAnimationTargetCompat[] appTargets, RemoteAnimationTargetCompat[] wallpaperTargets, RemoteAnimationTargetCompat[] nonAppTargets, AnimationResult result) {
            AnimatorSet anim = composeRecentsLaunchAnimator(taskView, appTargets, wallpaperTargets, nonAppTargets);
            anim.addListener(resetStateListener());
            result.setAnimation(anim, RecentsActivity.this, onEndCallback::executeAllAndDestroy, true);
        }

        @Override
        public void onAnimationCancelled() {
            onEndCallback.executeAllAndDestroy();
        }
    };
    final LauncherAnimationRunner wrapper = new LauncherAnimationRunner(mUiHandler, mActivityLaunchAnimationRunner, true);
    RemoteAnimationAdapterCompat adapterCompat = new RemoteAnimationAdapterCompat(wrapper, RECENTS_LAUNCH_DURATION, RECENTS_LAUNCH_DURATION - STATUS_BAR_TRANSITION_DURATION - STATUS_BAR_TRANSITION_PRE_DELAY);
    final ActivityOptionsWrapper activityOptions = new ActivityOptionsWrapper(ActivityOptionsCompat.makeRemoteAnimation(adapterCompat), onEndCallback);
    activityOptions.options.setSplashscreenStyle(SplashScreen.SPLASH_SCREEN_STYLE_ICON);
    return activityOptions;
}
Also used : RemoteAnimationAdapterCompat(com.android.systemui.shared.system.RemoteAnimationAdapterCompat) TaskView(com.android.quickstep.views.TaskView) RemoteAnimationFactory(com.android.launcher3.LauncherAnimationRunner.RemoteAnimationFactory) RemoteAnimationTargetCompat(com.android.systemui.shared.system.RemoteAnimationTargetCompat) AnimationResult(com.android.launcher3.LauncherAnimationRunner.AnimationResult) ActivityOptionsWrapper(com.android.launcher3.util.ActivityOptionsWrapper) AnimatorSet(android.animation.AnimatorSet) LauncherAnimationRunner(com.android.launcher3.LauncherAnimationRunner) RunnableList(com.android.launcher3.util.RunnableList)

Example 34 with ItemInfo

use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class TaskbarActivityContext method onTaskbarIconClicked.

protected void onTaskbarIconClicked(View view) {
    Object tag = view.getTag();
    if (tag instanceof Task) {
        Task task = (Task) tag;
        ActivityManagerWrapper.getInstance().startActivityFromRecents(task.key, ActivityOptions.makeBasic());
    } else if (tag instanceof FolderInfo) {
        FolderIcon folderIcon = (FolderIcon) view;
        Folder folder = folderIcon.getFolder();
        setTaskbarWindowFullscreen(true);
        getDragLayer().post(() -> {
            folder.animateOpen();
            folder.iterateOverItems((itemInfo, itemView) -> {
                itemView.setOnClickListener(mOnTaskbarIconClickListener);
                itemView.setOnLongClickListener(mOnTaskbarIconLongClickListener);
                // To play haptic when dragging, like other Taskbar items do.
                itemView.setHapticFeedbackEnabled(true);
                return false;
            });
        });
    } else if (tag instanceof WorkspaceItemInfo) {
        WorkspaceItemInfo info = (WorkspaceItemInfo) tag;
        if (!(info.isDisabled() && ItemClickHandler.handleDisabledItemClicked(info, this))) {
            Intent intent = new Intent(info.getIntent()).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            try {
                if (mIsSafeModeEnabled && !PackageManagerHelper.isSystemApp(this, intent)) {
                    Toast.makeText(this, R.string.safemode_shortcut_error, Toast.LENGTH_SHORT).show();
                } else if (info.isPromise()) {
                    intent = new PackageManagerHelper(this).getMarketIntent(info.getTargetPackage()).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);
                } else if (info.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
                    String id = info.getDeepShortcutId();
                    String packageName = intent.getPackage();
                    getSystemService(LauncherApps.class).startShortcut(packageName, id, null, null, info.user);
                } else if (info.user.equals(Process.myUserHandle())) {
                    startActivity(intent);
                } else {
                    getSystemService(LauncherApps.class).startMainActivity(intent.getComponent(), info.user, intent.getSourceBounds(), null);
                }
            } catch (NullPointerException | ActivityNotFoundException | SecurityException e) {
                Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
                Log.e(TAG, "Unable to launch. tag=" + info + " intent=" + intent, e);
            }
        }
    } else {
        Log.e(TAG, "Unknown type clicked: " + tag);
    }
    AbstractFloatingView.closeAllOpenViews(this);
}
Also used : Rect(android.graphics.Rect) Task(com.android.systemui.shared.recents.model.Task) NonNull(androidx.annotation.NonNull) WindowManager(android.view.WindowManager) Drawable(android.graphics.drawable.Drawable) DraggableView(com.android.launcher3.dragndrop.DraggableView) Process(android.os.Process) ITYPE_BOTTOM_TAPPABLE_ELEMENT(com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_BOTTOM_TAPPABLE_ELEMENT) ActivityOptions(android.app.ActivityOptions) ActivityManagerWrapper(com.android.systemui.shared.system.ActivityManagerWrapper) WindowManagerWrapper(com.android.systemui.shared.system.WindowManagerWrapper) LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS(android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS) TYPE_APPLICATION_OVERLAY(android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY) ContextThemeWrapper(android.view.ContextThemeWrapper) FolderInfo(com.android.launcher3.model.data.FolderInfo) Display(android.view.Display) View(android.view.View) Log(android.util.Log) SysUINavigationMode(com.android.quickstep.SysUINavigationMode) Favorites(com.android.launcher3.LauncherSettings.Favorites) Mode(com.android.quickstep.SysUINavigationMode.Mode) LauncherApps(android.content.pm.LauncherApps) DeviceProfile(com.android.launcher3.DeviceProfile) DragOptions(com.android.launcher3.dragndrop.DragOptions) Nullable(androidx.annotation.Nullable) ActivityNotFoundException(android.content.ActivityNotFoundException) ITYPE_EXTRA_NAVIGATION_BAR(com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_EXTRA_NAVIGATION_BAR) Themes(com.android.launcher3.util.Themes) PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper) Folder(com.android.launcher3.folder.Folder) Context(android.content.Context) ItemInfo(com.android.launcher3.model.data.ItemInfo) FolderIcon(com.android.launcher3.folder.FolderIcon) Intent(android.content.Intent) PixelFormat(android.graphics.PixelFormat) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) Toast(android.widget.Toast) DragSource(com.android.launcher3.DragSource) ActivityContext(com.android.launcher3.views.ActivityContext) LayoutInflater(android.view.LayoutInflater) DropTarget(com.android.launcher3.DropTarget) DragController(com.android.launcher3.dragndrop.DragController) MATCH_PARENT(android.view.ViewGroup.LayoutParams.MATCH_PARENT) Point(android.graphics.Point) TaskbarButton(com.android.launcher3.taskbar.TaskbarNavButtonController.TaskbarButton) ItemClickHandler(com.android.launcher3.touch.ItemClickHandler) SystemProperties(android.os.SystemProperties) Gravity(android.view.Gravity) R(com.android.launcher3.R) AbstractFloatingView(com.android.launcher3.AbstractFloatingView) DragView(com.android.launcher3.dragndrop.DragView) TraceHelper(com.android.launcher3.util.TraceHelper) Task(com.android.systemui.shared.recents.model.Task) Intent(android.content.Intent) LauncherApps(android.content.pm.LauncherApps) Folder(com.android.launcher3.folder.Folder) FolderInfo(com.android.launcher3.model.data.FolderInfo) ActivityNotFoundException(android.content.ActivityNotFoundException) FolderIcon(com.android.launcher3.folder.FolderIcon) PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 35 with ItemInfo

use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class TaskbarHotseatController method onHotseatUpdated.

/**
 * Called when any Hotseat item changes, and reports the new list of items to TaskbarController.
 */
protected void onHotseatUpdated() {
    ShortcutAndWidgetContainer shortcutsAndWidgets = mHotseat.getShortcutsAndWidgets();
    ItemInfo[] hotseatItemInfos = new ItemInfo[mNumHotseatIcons];
    for (int i = 0; i < shortcutsAndWidgets.getChildCount(); i++) {
        View child = shortcutsAndWidgets.getChildAt(i);
        Object tag = shortcutsAndWidgets.getChildAt(i).getTag();
        if (tag instanceof ItemInfo) {
            ItemInfo itemInfo = (ItemInfo) tag;
            CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams();
            // Since the hotseat might be laid out vertically or horizontally, use whichever
            // index is higher.
            int index = Math.max(lp.cellX, lp.cellY);
            if (0 <= index && index < hotseatItemInfos.length) {
                hotseatItemInfos[index] = itemInfo;
            }
        }
    }
    mTaskbarCallbacks.accept(hotseatItemInfos);
}
Also used : CellLayout(com.android.launcher3.CellLayout) ItemInfo(com.android.launcher3.model.data.ItemInfo) ShortcutAndWidgetContainer(com.android.launcher3.ShortcutAndWidgetContainer) View(android.view.View)

Aggregations

ItemInfo (com.android.launcher3.model.data.ItemInfo)457 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)373 View (android.view.View)199 ArrayList (java.util.ArrayList)169 Point (android.graphics.Point)159 FolderInfo (com.android.launcher3.model.data.FolderInfo)113 SuppressLint (android.annotation.SuppressLint)110 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)100 DragView (com.android.launcher3.dragndrop.DragView)98 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)98 AppWidgetHostView (android.appwidget.AppWidgetHostView)94 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)94 BubbleTextView (com.android.launcher3.BubbleTextView)85 Context (android.content.Context)82 List (java.util.List)80 AppInfo (com.android.launcher3.model.data.AppInfo)79 Intent (android.content.Intent)78 Rect (android.graphics.Rect)76 DraggableView (com.android.launcher3.dragndrop.DraggableView)73 ComponentName (android.content.ComponentName)72