Search in sources :

Example 41 with FolderAdaptiveIcon

use of com.android.launcher3.dragndrop.FolderAdaptiveIcon in project android_packages_apps_Launcher3 by ArrowOS.

the class Launcher method getFirstMatchForAppClose.

/**
 * Similar to {@link #getFirstMatch} but optimized to finding a suitable view for the app close
 * animation.
 *
 * @param preferredItemId The id of the preferred item to match to if it exists.
 * @param packageName The package name of the app to match.
 * @param user The user of the app to match.
 */
public View getFirstMatchForAppClose(int preferredItemId, String packageName, UserHandle user) {
    final ItemInfoMatcher preferredItem = (info, cn) -> info != null && info.id == preferredItemId;
    final ItemInfoMatcher packageAndUserAndApp = (info, cn) -> info != null && info.itemType == ITEM_TYPE_APPLICATION && info.user.equals(user) && info.getTargetComponent() != null && TextUtils.equals(info.getTargetComponent().getPackageName(), packageName);
    if (isInState(LauncherState.ALL_APPS)) {
        return getFirstMatch(Collections.singletonList(mAppsView.getActiveRecyclerView()), preferredItem, packageAndUserAndApp);
    } else {
        List<ViewGroup> containers = new ArrayList<>(mWorkspace.getPanelCount() + 1);
        containers.add(mWorkspace.getHotseat().getShortcutsAndWidgets());
        mWorkspace.forEachVisiblePage(page -> containers.add(((CellLayout) page).getShortcutsAndWidgets()));
        // Order: Preferred item by itself or in folder, then by matching package/user
        if (ADAPTIVE_ICON_WINDOW_ANIM.get()) {
            return getFirstMatch(containers, preferredItem, forFolderMatch(preferredItem), packageAndUserAndApp, forFolderMatch(packageAndUserAndApp));
        } else {
            // FolderAdaptiveIcon as the background.
            return getFirstMatch(containers, preferredItem, packageAndUserAndApp);
        }
    }
}
Also used : Bundle(android.os.Bundle) BitmapRenderer(com.android.launcher3.icons.BitmapRenderer) NonNull(androidx.annotation.NonNull) PendingAddWidgetInfo(com.android.launcher3.widget.PendingAddWidgetInfo) AccessibilityManagerCompat(com.android.launcher3.compat.AccessibilityManagerCompat) CONFIG_ORIENTATION(android.content.pm.ActivityInfo.CONFIG_ORIENTATION) NO_OFFSET(com.android.launcher3.LauncherState.NO_OFFSET) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) LauncherAtom(com.android.launcher3.logger.LauncherAtom) Log(android.util.Log) ALPHA_INDEX_LAUNCHER_LOAD(com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_LAUNCHER_LOAD) IntentFilter(android.content.IntentFilter) UserCache(com.android.launcher3.pm.UserCache) ActivityTracker(com.android.launcher3.util.ActivityTracker) Stream(java.util.stream.Stream) LayoutParams(android.view.WindowManager.LayoutParams) AbstractFloatingView.getTopOpenViewWithType(com.android.launcher3.AbstractFloatingView.getTopOpenViewWithType) ItemInfoMatcher(com.android.launcher3.util.ItemInfoMatcher) QsbContainerView(com.android.launcher3.qsb.QsbContainerView) TextKeyListener(android.text.method.TextKeyListener) TYPE_REBIND_SAFE(com.android.launcher3.AbstractFloatingView.TYPE_REBIND_SAFE) ModelUtils(com.android.launcher3.model.ModelUtils) ViewGroupFocusHelper(com.android.launcher3.keyboard.ViewGroupFocusHelper) ITEM_TYPE_APPLICATION(com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) SystemClock(android.os.SystemClock) SystemUiController(com.android.launcher3.util.SystemUiController) Supplier(java.util.function.Supplier) LAUNCHER_ALLAPPS_EXIT(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_EXIT) PendingRequestArgs(com.android.launcher3.util.PendingRequestArgs) Toast(android.widget.Toast) TYPE_ALL(com.android.launcher3.AbstractFloatingView.TYPE_ALL) Menu(android.view.Menu) ItemInfoMatcher.forFolderMatch(com.android.launcher3.util.ItemInfoMatcher.forFolderMatch) LauncherAction(com.android.launcher3.accessibility.LauncherAccessibilityDelegate.LauncherAction) IntArray(com.android.launcher3.util.IntArray) Parcelable(android.os.Parcelable) InstanceId(com.android.launcher3.logging.InstanceId) DragController(com.android.launcher3.dragndrop.DragController) LAUNCHER_ALLAPPS_ENTRY_WITH_DEVICE_SEARCH(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_ENTRY_WITH_DEVICE_SEARCH) FLAG_DRAG_AND_DROP(com.android.launcher3.model.ItemInstallQueue.FLAG_DRAG_AND_DROP) CallSuper(androidx.annotation.CallSuper) ItemClickHandler(com.android.launcher3.touch.ItemClickHandler) IntSet(com.android.launcher3.util.IntSet) LauncherAppWidgetHost(com.android.launcher3.widget.LauncherAppWidgetHost) FolderGridOrganizer(com.android.launcher3.folder.FolderGridOrganizer) SharedPreferences(android.content.SharedPreferences) FLAG_CLOSE_POPUPS(com.android.launcher3.LauncherState.FLAG_CLOSE_POPUPS) TestLogging(com.android.launcher3.testing.TestLogging) ComponentKey(com.android.launcher3.util.ComponentKey) RunnableList(com.android.launcher3.util.RunnableList) DotInfo(com.android.launcher3.dot.DotInfo) Rect(android.graphics.Rect) Trace(android.os.Trace) PackageManager(android.content.pm.PackageManager) LAUNCHER_STATE_BACKGROUND(com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_BACKGROUND) Animator(android.animation.Animator) IconCache(com.android.launcher3.icons.IconCache) OptionsPopupView(com.android.launcher3.views.OptionsPopupView) SPRING_LOADED(com.android.launcher3.LauncherState.SPRING_LOADED) LauncherAccessibilityDelegate.getSupportedActions(com.android.launcher3.accessibility.LauncherAccessibilityDelegate.getSupportedActions) RotationHelper(com.android.launcher3.states.RotationHelper) OverlayPlugin(com.android.systemui.plugins.OverlayPlugin) FLAG_ACTIVITY_PAUSED(com.android.launcher3.model.ItemInstallQueue.FLAG_ACTIVITY_PAUSED) FolderInfo(com.android.launcher3.model.data.FolderInfo) RectF(android.graphics.RectF) AllAppsSwipeController(com.android.launcher3.touch.AllAppsSwipeController) LauncherExterns(com.android.systemui.plugins.shared.LauncherExterns) Collection(java.util.Collection) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) MultiValueAlpha(com.android.launcher3.util.MultiValueAlpha) DragOptions(com.android.launcher3.dragndrop.DragOptions) ALL_APPS(com.android.launcher3.LauncherState.ALL_APPS) WIDGETS(com.android.launcher3.popup.SystemShortcut.WIDGETS) ActivityNotFoundException(android.content.ActivityNotFoundException) Notification(android.app.Notification) ModelWriter(com.android.launcher3.model.ModelWriter) CONFIG_SCREEN_SIZE(android.content.pm.ActivityInfo.CONFIG_SCREEN_SIZE) AppInfo(com.android.launcher3.model.data.AppInfo) ActivityResultInfo(com.android.launcher3.util.ActivityResultInfo) LauncherOverlay(com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlay) ItemInfo(com.android.launcher3.model.data.ItemInfo) CustomWidgetManager(com.android.launcher3.widget.custom.CustomWidgetManager) PopupContainerWithArrow(com.android.launcher3.popup.PopupContainerWithArrow) HashSet(java.util.HashSet) Build(android.os.Build) ADAPTIVE_ICON_WINDOW_ANIM(com.android.launcher3.config.FeatureFlags.ADAPTIVE_ICON_WINDOW_ANIM) LayoutInflater(android.view.LayoutInflater) SafeCloseable(com.android.launcher3.util.SafeCloseable) OnboardingPrefs(com.android.launcher3.util.OnboardingPrefs) PendingAddShortcutInfo(com.android.launcher3.widget.PendingAddShortcutInfo) Bitmap(android.graphics.Bitmap) OvershootInterpolator(android.view.animation.OvershootInterpolator) IMPORTANT_FOR_ACCESSIBILITY_NO(android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO) DragView(com.android.launcher3.dragndrop.DragView) TraceHelper(com.android.launcher3.util.TraceHelper) LAUNCHER_ONRESUME(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ONRESUME) AllAppsTransitionController(com.android.launcher3.allapps.AllAppsTransitionController) LauncherDragController(com.android.launcher3.dragndrop.LauncherDragController) ViewOnDrawExecutor(com.android.launcher3.util.ViewOnDrawExecutor) TestProtocol(com.android.launcher3.testing.TestProtocol) ImageView(android.widget.ImageView) AnimatorListeners(com.android.launcher3.anim.AnimatorListeners) TYPE_WINDOW_STATE_CHANGED(android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) Process(android.os.Process) LAUNCHER_ALLAPPS_ENTRY(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_ENTRY) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) TargetApi(android.annotation.TargetApi) WidgetsModel(com.android.launcher3.model.WidgetsModel) PrintWriter(java.io.PrintWriter) KeyboardShortcutInfo(android.view.KeyboardShortcutInfo) AllAppsStore(com.android.launcher3.allapps.AllAppsStore) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) LauncherAccessibilityDelegate(com.android.launcher3.accessibility.LauncherAccessibilityDelegate) StringRes(androidx.annotation.StringRes) Nullable(androidx.annotation.Nullable) ItemInstallQueue(com.android.launcher3.model.ItemInstallQueue) TYPE_FOLDER(com.android.launcher3.AbstractFloatingView.TYPE_FOLDER) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) DiscoveryBounce(com.android.launcher3.allapps.DiscoveryBounce) NORMAL(com.android.launcher3.LauncherState.NORMAL) PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper) ArrowPopup(com.android.launcher3.popup.ArrowPopup) WidgetsFullSheet(com.android.launcher3.widget.picker.WidgetsFullSheet) FileLog(com.android.launcher3.logging.FileLog) FloatingSurfaceView(com.android.launcher3.views.FloatingSurfaceView) FLAG_NON_INTERACTIVE(com.android.launcher3.LauncherState.FLAG_NON_INTERACTIVE) ArrayList(java.util.ArrayList) FLAG_MULTI_PAGE(com.android.launcher3.LauncherState.FLAG_MULTI_PAGE) IntentSender(android.content.IntentSender) REQUEST_NONE(com.android.launcher3.states.RotationHelper.REQUEST_NONE) AppWidgetHostView(android.appwidget.AppWidgetHostView) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) UserHandle(android.os.UserHandle) DragObject(com.android.launcher3.DropTarget.DragObject) SystemShortcut(com.android.launcher3.popup.SystemShortcut) PluginListener(com.android.systemui.plugins.PluginListener) PopupDataProvider(com.android.launcher3.popup.PopupDataProvider) ActivityContext(com.android.launcher3.views.ActivityContext) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) StateManager(com.android.launcher3.statemanager.StateManager) TextUtils(android.text.TextUtils) FeatureFlags(com.android.launcher3.config.FeatureFlags) AppWidgetManager(android.appwidget.AppWidgetManager) ComponentCallbacks2(android.content.ComponentCallbacks2) TouchController(com.android.launcher3.util.TouchController) WidgetsListBaseEntry(com.android.launcher3.widget.model.WidgetsListBaseEntry) Configuration(android.content.res.Configuration) AlphaProperty(com.android.launcher3.util.MultiValueAlpha.AlphaProperty) LAUNCHER_ONSTOP(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ONSTOP) LauncherOverlayCallbacks(com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlayCallbacks) INSTALL(com.android.launcher3.popup.SystemShortcut.INSTALL) ValueAnimator(android.animation.ValueAnimator) Callbacks(com.android.launcher3.model.BgDataModel.Callbacks) SPRING_LOADED_EXIT_DELAY(com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY) PendingIntent(android.app.PendingIntent) KeyboardShortcutGroup(android.view.KeyboardShortcutGroup) NotificationChannel(android.app.NotificationChannel) View(android.view.View) NO_SCALE(com.android.launcher3.LauncherState.NO_SCALE) NotificationManager(android.app.NotificationManager) PinRequestHelper(com.android.launcher3.pm.PinRequestHelper) Predicate(java.util.function.Predicate) ObjectAnimator(android.animation.ObjectAnimator) CancellationSignal(android.os.CancellationSignal) BroadcastReceiver(android.content.BroadcastReceiver) PluginManagerWrapper(com.android.launcher3.uioverrides.plugins.PluginManagerWrapper) ViewGroup(android.view.ViewGroup) SparseArray(android.util.SparseArray) List(java.util.List) Utilities.postAsyncCallback(com.android.launcher3.Utilities.postAsyncCallback) LAUNCHER_STATE_HOME(com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME) NotificationListener(com.android.launcher3.notification.NotificationListener) REQUEST_LOCK(com.android.launcher3.states.RotationHelper.REQUEST_LOCK) LauncherAppWidgetProviderInfo(com.android.launcher3.widget.LauncherAppWidgetProviderInfo) LAUNCHER_WIDGET_RECONFIGURED(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WIDGET_RECONFIGURED) CONFIG_UI_MODE(android.content.pm.ActivityInfo.CONFIG_UI_MODE) AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) Themes(com.android.launcher3.util.Themes) Context(android.content.Context) KeyEvent(android.view.KeyEvent) WidgetAddFlowHandler(com.android.launcher3.widget.WidgetAddFlowHandler) TYPE_SNACKBAR(com.android.launcher3.AbstractFloatingView.TYPE_SNACKBAR) FolderIcon(com.android.launcher3.folder.FolderIcon) Intent(android.content.Intent) HashMap(java.util.HashMap) UiThreadHelper(com.android.launcher3.util.UiThreadHelper) InstanceIdSequence(com.android.launcher3.logging.InstanceIdSequence) MotionEvent(android.view.MotionEvent) AnimatorSet(android.animation.AnimatorSet) DragLayer(com.android.launcher3.dragndrop.DragLayer) TYPE_ICON_SURFACE(com.android.launcher3.AbstractFloatingView.TYPE_ICON_SURFACE) UNINSTALL(com.android.launcher3.popup.SystemShortcut.UNINSTALL) StatefulActivity(com.android.launcher3.statemanager.StatefulActivity) PackageUserKey(com.android.launcher3.util.PackageUserKey) APP_INFO(com.android.launcher3.popup.SystemShortcut.APP_INFO) WidgetManagerHelper(com.android.launcher3.widget.WidgetManagerHelper) PropertyListBuilder(com.android.launcher3.anim.PropertyListBuilder) StatsLogManager(com.android.launcher3.logging.StatsLogManager) StrictMode(android.os.StrictMode) LauncherOverlayManager(com.android.systemui.plugins.shared.LauncherOverlayManager) FileDescriptor(java.io.FileDescriptor) StateHandler(com.android.launcher3.statemanager.StateManager.StateHandler) ScrimView(com.android.launcher3.views.ScrimView) Thunk(com.android.launcher3.util.Thunk) VisibleForTesting(androidx.annotation.VisibleForTesting) Collections(java.util.Collections) ViewGroup(android.view.ViewGroup) ItemInfoMatcher(com.android.launcher3.util.ItemInfoMatcher) ArrayList(java.util.ArrayList)

Example 42 with FolderAdaptiveIcon

use of com.android.launcher3.dragndrop.FolderAdaptiveIcon in project android_packages_apps_Launcher3 by ArrowOS.

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(Context context, ItemInfo info, Object obj) {
    LauncherAppState appState = LauncherAppState.getInstance(context);
    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 context.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 43 with FolderAdaptiveIcon

use of com.android.launcher3.dragndrop.FolderAdaptiveIcon in project android_packages_apps_Launcher3 by ProtonAOSP.

the class Launcher method getFirstMatchForAppClose.

/**
 * Similar to {@link #getFirstMatch} but optimized to finding a suitable view for the app close
 * animation.
 *
 * @param preferredItemId The id of the preferred item to match to if it exists.
 * @param packageName The package name of the app to match.
 * @param user The user of the app to match.
 */
public View getFirstMatchForAppClose(int preferredItemId, String packageName, UserHandle user) {
    final ItemInfoMatcher preferredItem = (info, cn) -> info != null && info.id == preferredItemId;
    final ItemInfoMatcher packageAndUserAndApp = (info, cn) -> info != null && info.itemType == ITEM_TYPE_APPLICATION && info.user.equals(user) && info.getTargetComponent() != null && TextUtils.equals(info.getTargetComponent().getPackageName(), packageName);
    if (isInState(LauncherState.ALL_APPS)) {
        return getFirstMatch(Collections.singletonList(mAppsView.getActiveRecyclerView()), preferredItem, packageAndUserAndApp);
    } else {
        List<ViewGroup> containers = new ArrayList<>(mWorkspace.getPanelCount() + 1);
        containers.add(mWorkspace.getHotseat().getShortcutsAndWidgets());
        mWorkspace.forEachVisiblePage(page -> containers.add(((CellLayout) page).getShortcutsAndWidgets()));
        // Order: Preferred item by itself or in folder, then by matching package/user
        if (ADAPTIVE_ICON_WINDOW_ANIM.get()) {
            return getFirstMatch(containers, preferredItem, forFolderMatch(preferredItem), packageAndUserAndApp, forFolderMatch(packageAndUserAndApp));
        } else {
            // FolderAdaptiveIcon as the background.
            return getFirstMatch(containers, preferredItem, packageAndUserAndApp);
        }
    }
}
Also used : Bundle(android.os.Bundle) BitmapRenderer(com.android.launcher3.icons.BitmapRenderer) NonNull(androidx.annotation.NonNull) PendingAddWidgetInfo(com.android.launcher3.widget.PendingAddWidgetInfo) AccessibilityManagerCompat(com.android.launcher3.compat.AccessibilityManagerCompat) CONFIG_ORIENTATION(android.content.pm.ActivityInfo.CONFIG_ORIENTATION) NO_OFFSET(com.android.launcher3.LauncherState.NO_OFFSET) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) LauncherAtom(com.android.launcher3.logger.LauncherAtom) Log(android.util.Log) ALPHA_INDEX_LAUNCHER_LOAD(com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_LAUNCHER_LOAD) IntentFilter(android.content.IntentFilter) UserCache(com.android.launcher3.pm.UserCache) ActivityTracker(com.android.launcher3.util.ActivityTracker) Stream(java.util.stream.Stream) LayoutParams(android.view.WindowManager.LayoutParams) AbstractFloatingView.getTopOpenViewWithType(com.android.launcher3.AbstractFloatingView.getTopOpenViewWithType) ItemInfoMatcher(com.android.launcher3.util.ItemInfoMatcher) QsbContainerView(com.android.launcher3.qsb.QsbContainerView) TextKeyListener(android.text.method.TextKeyListener) TYPE_REBIND_SAFE(com.android.launcher3.AbstractFloatingView.TYPE_REBIND_SAFE) ModelUtils(com.android.launcher3.model.ModelUtils) ViewGroupFocusHelper(com.android.launcher3.keyboard.ViewGroupFocusHelper) ITEM_TYPE_APPLICATION(com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) SystemClock(android.os.SystemClock) SystemUiController(com.android.launcher3.util.SystemUiController) Supplier(java.util.function.Supplier) LAUNCHER_ALLAPPS_EXIT(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_EXIT) PendingRequestArgs(com.android.launcher3.util.PendingRequestArgs) Toast(android.widget.Toast) TYPE_ALL(com.android.launcher3.AbstractFloatingView.TYPE_ALL) Menu(android.view.Menu) ItemInfoMatcher.forFolderMatch(com.android.launcher3.util.ItemInfoMatcher.forFolderMatch) LauncherAction(com.android.launcher3.accessibility.LauncherAccessibilityDelegate.LauncherAction) IntArray(com.android.launcher3.util.IntArray) Parcelable(android.os.Parcelable) InstanceId(com.android.launcher3.logging.InstanceId) DragController(com.android.launcher3.dragndrop.DragController) LAUNCHER_ALLAPPS_ENTRY_WITH_DEVICE_SEARCH(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_ENTRY_WITH_DEVICE_SEARCH) FLAG_DRAG_AND_DROP(com.android.launcher3.model.ItemInstallQueue.FLAG_DRAG_AND_DROP) CallSuper(androidx.annotation.CallSuper) ItemClickHandler(com.android.launcher3.touch.ItemClickHandler) IntSet(com.android.launcher3.util.IntSet) LauncherAppWidgetHost(com.android.launcher3.widget.LauncherAppWidgetHost) FolderGridOrganizer(com.android.launcher3.folder.FolderGridOrganizer) SharedPreferences(android.content.SharedPreferences) FLAG_CLOSE_POPUPS(com.android.launcher3.LauncherState.FLAG_CLOSE_POPUPS) TestLogging(com.android.launcher3.testing.TestLogging) ComponentKey(com.android.launcher3.util.ComponentKey) RunnableList(com.android.launcher3.util.RunnableList) DotInfo(com.android.launcher3.dot.DotInfo) Rect(android.graphics.Rect) Trace(android.os.Trace) PackageManager(android.content.pm.PackageManager) LAUNCHER_STATE_BACKGROUND(com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_BACKGROUND) Animator(android.animation.Animator) IconCache(com.android.launcher3.icons.IconCache) OptionsPopupView(com.android.launcher3.views.OptionsPopupView) SPRING_LOADED(com.android.launcher3.LauncherState.SPRING_LOADED) LauncherAccessibilityDelegate.getSupportedActions(com.android.launcher3.accessibility.LauncherAccessibilityDelegate.getSupportedActions) RotationHelper(com.android.launcher3.states.RotationHelper) OverlayPlugin(com.android.systemui.plugins.OverlayPlugin) FLAG_ACTIVITY_PAUSED(com.android.launcher3.model.ItemInstallQueue.FLAG_ACTIVITY_PAUSED) FolderInfo(com.android.launcher3.model.data.FolderInfo) RectF(android.graphics.RectF) AllAppsSwipeController(com.android.launcher3.touch.AllAppsSwipeController) LauncherExterns(com.android.systemui.plugins.shared.LauncherExterns) Collection(java.util.Collection) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) MultiValueAlpha(com.android.launcher3.util.MultiValueAlpha) DragOptions(com.android.launcher3.dragndrop.DragOptions) ALL_APPS(com.android.launcher3.LauncherState.ALL_APPS) WIDGETS(com.android.launcher3.popup.SystemShortcut.WIDGETS) ActivityNotFoundException(android.content.ActivityNotFoundException) Notification(android.app.Notification) ModelWriter(com.android.launcher3.model.ModelWriter) CONFIG_SCREEN_SIZE(android.content.pm.ActivityInfo.CONFIG_SCREEN_SIZE) AppInfo(com.android.launcher3.model.data.AppInfo) ActivityResultInfo(com.android.launcher3.util.ActivityResultInfo) LauncherOverlay(com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlay) ItemInfo(com.android.launcher3.model.data.ItemInfo) CustomWidgetManager(com.android.launcher3.widget.custom.CustomWidgetManager) PopupContainerWithArrow(com.android.launcher3.popup.PopupContainerWithArrow) HashSet(java.util.HashSet) Build(android.os.Build) ADAPTIVE_ICON_WINDOW_ANIM(com.android.launcher3.config.FeatureFlags.ADAPTIVE_ICON_WINDOW_ANIM) LayoutInflater(android.view.LayoutInflater) SafeCloseable(com.android.launcher3.util.SafeCloseable) OnboardingPrefs(com.android.launcher3.util.OnboardingPrefs) PendingAddShortcutInfo(com.android.launcher3.widget.PendingAddShortcutInfo) Bitmap(android.graphics.Bitmap) OvershootInterpolator(android.view.animation.OvershootInterpolator) IMPORTANT_FOR_ACCESSIBILITY_NO(android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO) DragView(com.android.launcher3.dragndrop.DragView) TraceHelper(com.android.launcher3.util.TraceHelper) LAUNCHER_ONRESUME(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ONRESUME) AllAppsTransitionController(com.android.launcher3.allapps.AllAppsTransitionController) LauncherDragController(com.android.launcher3.dragndrop.LauncherDragController) ViewOnDrawExecutor(com.android.launcher3.util.ViewOnDrawExecutor) TestProtocol(com.android.launcher3.testing.TestProtocol) ImageView(android.widget.ImageView) AnimatorListeners(com.android.launcher3.anim.AnimatorListeners) TYPE_WINDOW_STATE_CHANGED(android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) Process(android.os.Process) LAUNCHER_ALLAPPS_ENTRY(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_ENTRY) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) TargetApi(android.annotation.TargetApi) WidgetsModel(com.android.launcher3.model.WidgetsModel) PrintWriter(java.io.PrintWriter) KeyboardShortcutInfo(android.view.KeyboardShortcutInfo) AllAppsStore(com.android.launcher3.allapps.AllAppsStore) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) LauncherAccessibilityDelegate(com.android.launcher3.accessibility.LauncherAccessibilityDelegate) StringRes(androidx.annotation.StringRes) Nullable(androidx.annotation.Nullable) ItemInstallQueue(com.android.launcher3.model.ItemInstallQueue) TYPE_FOLDER(com.android.launcher3.AbstractFloatingView.TYPE_FOLDER) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) DiscoveryBounce(com.android.launcher3.allapps.DiscoveryBounce) NORMAL(com.android.launcher3.LauncherState.NORMAL) PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper) ArrowPopup(com.android.launcher3.popup.ArrowPopup) WidgetsFullSheet(com.android.launcher3.widget.picker.WidgetsFullSheet) FileLog(com.android.launcher3.logging.FileLog) FloatingSurfaceView(com.android.launcher3.views.FloatingSurfaceView) FLAG_NON_INTERACTIVE(com.android.launcher3.LauncherState.FLAG_NON_INTERACTIVE) ArrayList(java.util.ArrayList) FLAG_MULTI_PAGE(com.android.launcher3.LauncherState.FLAG_MULTI_PAGE) IntentSender(android.content.IntentSender) REQUEST_NONE(com.android.launcher3.states.RotationHelper.REQUEST_NONE) AppWidgetHostView(android.appwidget.AppWidgetHostView) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) UserHandle(android.os.UserHandle) DragObject(com.android.launcher3.DropTarget.DragObject) SystemShortcut(com.android.launcher3.popup.SystemShortcut) PluginListener(com.android.systemui.plugins.PluginListener) PopupDataProvider(com.android.launcher3.popup.PopupDataProvider) ActivityContext(com.android.launcher3.views.ActivityContext) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) StateManager(com.android.launcher3.statemanager.StateManager) TextUtils(android.text.TextUtils) FeatureFlags(com.android.launcher3.config.FeatureFlags) AppWidgetManager(android.appwidget.AppWidgetManager) ComponentCallbacks2(android.content.ComponentCallbacks2) TouchController(com.android.launcher3.util.TouchController) WidgetsListBaseEntry(com.android.launcher3.widget.model.WidgetsListBaseEntry) Configuration(android.content.res.Configuration) AlphaProperty(com.android.launcher3.util.MultiValueAlpha.AlphaProperty) LAUNCHER_ONSTOP(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ONSTOP) LauncherOverlayCallbacks(com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlayCallbacks) INSTALL(com.android.launcher3.popup.SystemShortcut.INSTALL) ValueAnimator(android.animation.ValueAnimator) Callbacks(com.android.launcher3.model.BgDataModel.Callbacks) SPRING_LOADED_EXIT_DELAY(com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY) PendingIntent(android.app.PendingIntent) KeyboardShortcutGroup(android.view.KeyboardShortcutGroup) NotificationChannel(android.app.NotificationChannel) View(android.view.View) NO_SCALE(com.android.launcher3.LauncherState.NO_SCALE) NotificationManager(android.app.NotificationManager) PinRequestHelper(com.android.launcher3.pm.PinRequestHelper) Predicate(java.util.function.Predicate) ObjectAnimator(android.animation.ObjectAnimator) CancellationSignal(android.os.CancellationSignal) BroadcastReceiver(android.content.BroadcastReceiver) PluginManagerWrapper(com.android.launcher3.uioverrides.plugins.PluginManagerWrapper) ViewGroup(android.view.ViewGroup) SparseArray(android.util.SparseArray) List(java.util.List) Utilities.postAsyncCallback(com.android.launcher3.Utilities.postAsyncCallback) LAUNCHER_STATE_HOME(com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME) NotificationListener(com.android.launcher3.notification.NotificationListener) REQUEST_LOCK(com.android.launcher3.states.RotationHelper.REQUEST_LOCK) LauncherAppWidgetProviderInfo(com.android.launcher3.widget.LauncherAppWidgetProviderInfo) LAUNCHER_WIDGET_RECONFIGURED(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WIDGET_RECONFIGURED) CONFIG_UI_MODE(android.content.pm.ActivityInfo.CONFIG_UI_MODE) AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) Themes(com.android.launcher3.util.Themes) Context(android.content.Context) KeyEvent(android.view.KeyEvent) WidgetAddFlowHandler(com.android.launcher3.widget.WidgetAddFlowHandler) TYPE_SNACKBAR(com.android.launcher3.AbstractFloatingView.TYPE_SNACKBAR) FolderIcon(com.android.launcher3.folder.FolderIcon) Intent(android.content.Intent) HashMap(java.util.HashMap) UiThreadHelper(com.android.launcher3.util.UiThreadHelper) InstanceIdSequence(com.android.launcher3.logging.InstanceIdSequence) MotionEvent(android.view.MotionEvent) AnimatorSet(android.animation.AnimatorSet) DragLayer(com.android.launcher3.dragndrop.DragLayer) TYPE_ICON_SURFACE(com.android.launcher3.AbstractFloatingView.TYPE_ICON_SURFACE) StatefulActivity(com.android.launcher3.statemanager.StatefulActivity) PackageUserKey(com.android.launcher3.util.PackageUserKey) APP_INFO(com.android.launcher3.popup.SystemShortcut.APP_INFO) WidgetManagerHelper(com.android.launcher3.widget.WidgetManagerHelper) PropertyListBuilder(com.android.launcher3.anim.PropertyListBuilder) StatsLogManager(com.android.launcher3.logging.StatsLogManager) StrictMode(android.os.StrictMode) LauncherOverlayManager(com.android.systemui.plugins.shared.LauncherOverlayManager) FileDescriptor(java.io.FileDescriptor) StateHandler(com.android.launcher3.statemanager.StateManager.StateHandler) ScrimView(com.android.launcher3.views.ScrimView) Thunk(com.android.launcher3.util.Thunk) VisibleForTesting(androidx.annotation.VisibleForTesting) Collections(java.util.Collections) ViewGroup(android.view.ViewGroup) ItemInfoMatcher(com.android.launcher3.util.ItemInfoMatcher) ArrayList(java.util.ArrayList)

Example 44 with FolderAdaptiveIcon

use of com.android.launcher3.dragndrop.FolderAdaptiveIcon in project android_packages_apps_Launcher3 by ProtonAOSP.

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(Context context, ItemInfo info, Object obj) {
    LauncherAppState appState = LauncherAppState.getInstance(context);
    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 context.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 45 with FolderAdaptiveIcon

use of com.android.launcher3.dragndrop.FolderAdaptiveIcon in project android_packages_apps_Launcher3 by ProtonAOSP.

the class Utilities method loadFullDrawableWithoutTheme.

private static Drawable loadFullDrawableWithoutTheme(Context context, ItemInfo info, int width, int height, Object[] outObj) {
    ActivityContext activity = ActivityContext.lookupContext(context);
    LauncherAppState appState = LauncherAppState.getInstance(context);
    if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
        LauncherActivityInfo activityInfo = context.getSystemService(LauncherApps.class).resolveActivity(info.getIntent(), info.user);
        outObj[0] = activityInfo;
        return activityInfo == null ? null : LauncherAppState.getInstance(context).getIconProvider().getIcon(activityInfo, activity.getDeviceProfile().inv.fillResIconDpi);
    } else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
        if (info instanceof PendingAddShortcutInfo) {
            ShortcutConfigActivityInfo activityInfo = ((PendingAddShortcutInfo) info).activityInfo;
            outObj[0] = activityInfo;
            return activityInfo.getFullResIcon(appState.getIconCache());
        }
        List<ShortcutInfo> si = ShortcutKey.fromItemInfo(info).buildRequest(context).query(ShortcutRequest.ALL);
        if (si.isEmpty()) {
            return null;
        } else {
            outObj[0] = si.get(0);
            return ShortcutCachingLogic.getIcon(context, si.get(0), appState.getInvariantDeviceProfile().fillResIconDpi);
        }
    } else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_FOLDER) {
        FolderAdaptiveIcon icon = FolderAdaptiveIcon.createFolderAdaptiveIcon(activity, info.id, new Point(width, height));
        if (icon == null) {
            return null;
        }
        outObj[0] = icon;
        return icon;
    } else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_SEARCH_ACTION && info instanceof SearchActionItemInfo) {
        return new AdaptiveIconDrawable(new FastBitmapDrawable(((SearchActionItemInfo) info).bitmap), null);
    } else {
        return null;
    }
}
Also used : ActivityContext(com.android.launcher3.views.ActivityContext) FolderAdaptiveIcon(com.android.launcher3.dragndrop.FolderAdaptiveIcon) FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) PendingAddShortcutInfo(com.android.launcher3.widget.PendingAddShortcutInfo) ShortcutConfigActivityInfo(com.android.launcher3.pm.ShortcutConfigActivityInfo) LauncherApps(android.content.pm.LauncherApps) List(java.util.List) SearchActionItemInfo(com.android.launcher3.model.data.SearchActionItemInfo) Point(android.graphics.Point) AdaptiveIconDrawable(android.graphics.drawable.AdaptiveIconDrawable)

Aggregations

Point (android.graphics.Point)29 Bitmap (android.graphics.Bitmap)26 AdaptiveIconDrawable (android.graphics.drawable.AdaptiveIconDrawable)24 FolderAdaptiveIcon (com.android.launcher3.dragndrop.FolderAdaptiveIcon)20 PendingAddShortcutInfo (com.android.launcher3.widget.PendingAddShortcutInfo)20 Rect (android.graphics.Rect)19 TargetApi (android.annotation.TargetApi)18 ColorDrawable (android.graphics.drawable.ColorDrawable)16 Drawable (android.graphics.drawable.Drawable)16 Path (android.graphics.Path)14 FastBitmapDrawable (com.android.launcher3.icons.FastBitmapDrawable)14 LauncherIcons (com.android.launcher3.icons.LauncherIcons)14 View (android.view.View)13 Paint (android.graphics.Paint)12 List (java.util.List)11 Handler (android.os.Handler)9 PreviewBackground (com.android.launcher3.folder.PreviewBackground)9 FolderIcon (com.android.launcher3.folder.FolderIcon)8 ShortcutInfo (android.content.pm.ShortcutInfo)7 Matrix (android.graphics.Matrix)7