Search in sources :

Example 1 with FolderAdaptiveIcon

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

the class DragView method setItemInfo.

/**
 * Initialize {@code #mIconDrawable} if the item can be represented using
 * an {@link AdaptiveIconDrawable} or {@link FolderAdaptiveIcon}.
 */
@TargetApi(Build.VERSION_CODES.O)
public void setItemInfo(final ItemInfo info) {
    if (info.itemType != LauncherSettings.Favorites.ITEM_TYPE_APPLICATION && info.itemType != LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT && info.itemType != LauncherSettings.Favorites.ITEM_TYPE_FOLDER) {
        return;
    }
    // Load the adaptive icon on a background thread and add the view in ui thread.
    MODEL_EXECUTOR.getHandler().postAtFrontOfQueue(() -> {
        Object[] outObj = new Object[1];
        int w = mWidth;
        int h = mHeight;
        Drawable dr = Utilities.getFullDrawable(mLauncher, info, w, h, outObj);
        if (dr instanceof AdaptiveIconDrawable) {
            int blurMargin = (int) mLauncher.getResources().getDimension(R.dimen.blur_size_medium_outline) / 2;
            Rect bounds = new Rect(0, 0, w, h);
            bounds.inset(blurMargin, blurMargin);
            // Badge is applied after icon normalization so the bounds for badge should not
            // be scaled down due to icon normalization.
            Rect badgeBounds = new Rect(bounds);
            mBadge = getBadge(mLauncher, info, outObj[0]);
            mBadge.setBounds(badgeBounds);
            // Do not draw the background in case of folder as its translucent
            final boolean shouldDrawBackground = !(dr instanceof FolderAdaptiveIcon);
            try (LauncherIcons li = LauncherIcons.obtain(mLauncher)) {
                // drawable to be normalized
                Drawable nDr;
                if (shouldDrawBackground) {
                    nDr = dr;
                } else {
                    // Since we just want the scale, avoid heavy drawing operations
                    nDr = new AdaptiveIconDrawable(new ColorDrawable(Color.BLACK), null);
                }
                Utilities.scaleRectAboutCenter(bounds, li.getNormalizer().getScale(nDr, null, null, null));
            }
            AdaptiveIconDrawable adaptiveIcon = (AdaptiveIconDrawable) dr;
            // Shrink very tiny bit so that the clip path is smaller than the original bitmap
            // that has anti aliased edges and shadows.
            Rect shrunkBounds = new Rect(bounds);
            Utilities.scaleRectAboutCenter(shrunkBounds, 0.98f);
            adaptiveIcon.setBounds(shrunkBounds);
            final Path mask = adaptiveIcon.getIconMask();
            mTranslateX = new SpringFloatValue(DragView.this, w * AdaptiveIconDrawable.getExtraInsetFraction());
            mTranslateY = new SpringFloatValue(DragView.this, h * AdaptiveIconDrawable.getExtraInsetFraction());
            bounds.inset((int) (-bounds.width() * AdaptiveIconDrawable.getExtraInsetFraction()), (int) (-bounds.height() * AdaptiveIconDrawable.getExtraInsetFraction()));
            mBgSpringDrawable = adaptiveIcon.getBackground();
            if (mBgSpringDrawable == null) {
                mBgSpringDrawable = new ColorDrawable(Color.TRANSPARENT);
            }
            mBgSpringDrawable.setBounds(bounds);
            mFgSpringDrawable = adaptiveIcon.getForeground();
            if (mFgSpringDrawable == null) {
                mFgSpringDrawable = new ColorDrawable(Color.TRANSPARENT);
            }
            mFgSpringDrawable.setBounds(bounds);
            new Handler(Looper.getMainLooper()).post(() -> mOnDragStartCallback.add(() -> {
                // TODO: Consider fade-in animation
                // Assign the variable on the UI thread to avoid race conditions.
                mScaledMaskPath = mask;
                // Avoid relayout as we do not care about children affecting layout
                removeAllViewsInLayout();
                if (info.isDisabled()) {
                    FastBitmapDrawable d = new FastBitmapDrawable((Bitmap) null);
                    d.setIsDisabled(true);
                    mBgSpringDrawable.setColorFilter(d.getColorFilter());
                    mFgSpringDrawable.setColorFilter(d.getColorFilter());
                    mBadge.setColorFilter(d.getColorFilter());
                }
                invalidate();
            }));
        }
    });
}
Also used : Path(android.graphics.Path) Rect(android.graphics.Rect) AdaptiveIconDrawable(android.graphics.drawable.AdaptiveIconDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) PictureDrawable(android.graphics.drawable.PictureDrawable) Handler(android.os.Handler) Point(android.graphics.Point) FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) Bitmap(android.graphics.Bitmap) ColorDrawable(android.graphics.drawable.ColorDrawable) LauncherIcons(com.android.launcher3.icons.LauncherIcons) AdaptiveIconDrawable(android.graphics.drawable.AdaptiveIconDrawable) TargetApi(android.annotation.TargetApi)

Example 2 with FolderAdaptiveIcon

use of com.android.launcher3.dragndrop.FolderAdaptiveIcon 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 3 with FolderAdaptiveIcon

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

the class ClipIconView method setIcon.

/**
 * Sets the icon for this view as part of initial setup
 */
public void setIcon(@Nullable Drawable drawable, int iconOffset, MarginLayoutParams lp, boolean isOpening, boolean isVerticalBarLayout, DeviceProfile dp) {
    mIsAdaptiveIcon = drawable instanceof AdaptiveIconDrawable;
    if (mIsAdaptiveIcon) {
        boolean isFolderIcon = drawable instanceof FolderAdaptiveIcon;
        AdaptiveIconDrawable adaptiveIcon = (AdaptiveIconDrawable) drawable;
        Drawable background = adaptiveIcon.getBackground();
        if (background == null) {
            background = new ColorDrawable(Color.TRANSPARENT);
        }
        mBackground = background;
        Drawable foreground = adaptiveIcon.getForeground();
        if (foreground == null) {
            foreground = new ColorDrawable(Color.TRANSPARENT);
        }
        mForeground = foreground;
        final int originalHeight = lp.height;
        final int originalWidth = lp.width;
        int blurMargin = mBlurSizeOutline / 2;
        mFinalDrawableBounds.set(0, 0, originalWidth, originalHeight);
        if (!isFolderIcon) {
            mFinalDrawableBounds.inset(iconOffset - blurMargin, iconOffset - blurMargin);
        }
        mForeground.setBounds(mFinalDrawableBounds);
        mBackground.setBounds(mFinalDrawableBounds);
        mStartRevealRect.set(0, 0, originalWidth, originalHeight);
        if (!isFolderIcon) {
            Utilities.scaleRectAboutCenter(mStartRevealRect, IconShape.getNormalizationScale());
        }
        if (isVerticalBarLayout) {
            lp.width = (int) Math.max(lp.width, lp.height * dp.aspectRatio);
        } else {
            lp.height = (int) Math.max(lp.height, lp.width * dp.aspectRatio);
        }
        int left = mIsRtl ? dp.widthPx - lp.getMarginStart() - lp.width : lp.leftMargin;
        layout(left, lp.topMargin, left + lp.width, lp.topMargin + lp.height);
        float scale = Math.max((float) lp.height / originalHeight, (float) lp.width / originalWidth);
        float bgDrawableStartScale;
        if (isOpening) {
            bgDrawableStartScale = 1f;
            mOutline.set(0, 0, originalWidth, originalHeight);
        } else {
            bgDrawableStartScale = scale;
            mOutline.set(0, 0, lp.width, lp.height);
        }
        setBackgroundDrawableBounds(bgDrawableStartScale, isVerticalBarLayout);
        mEndRevealRect.set(0, 0, lp.width, lp.height);
        setOutlineProvider(new ViewOutlineProvider() {

            @Override
            public void getOutline(View view, Outline outline) {
                outline.setRoundRect(mOutline, mTaskCornerRadius);
            }
        });
        setClipToOutline(true);
    } else {
        setBackground(drawable);
        setClipToOutline(false);
    }
    invalidate();
    invalidateOutline();
}
Also used : FolderAdaptiveIcon(com.android.launcher3.dragndrop.FolderAdaptiveIcon) ColorDrawable(android.graphics.drawable.ColorDrawable) AdaptiveIconDrawable(android.graphics.drawable.AdaptiveIconDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) Outline(android.graphics.Outline) AdaptiveIconDrawable(android.graphics.drawable.AdaptiveIconDrawable) ViewOutlineProvider(android.view.ViewOutlineProvider) View(android.view.View)

Example 4 with FolderAdaptiveIcon

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

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 5 with FolderAdaptiveIcon

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

the class FloatingIconView method getOffsetForIconBounds.

@WorkerThread
@SuppressWarnings("WrongThread")
private static int getOffsetForIconBounds(Launcher l, Drawable drawable, RectF position) {
    if (!(drawable instanceof AdaptiveIconDrawable) || (drawable instanceof FolderAdaptiveIcon)) {
        return 0;
    }
    int blurSizeOutline = l.getResources().getDimensionPixelSize(R.dimen.blur_size_medium_outline);
    Rect bounds = new Rect(0, 0, (int) position.width() + blurSizeOutline, (int) position.height() + blurSizeOutline);
    bounds.inset(blurSizeOutline / 2, blurSizeOutline / 2);
    try (LauncherIcons li = LauncherIcons.obtain(l)) {
        Utilities.scaleRectAboutCenter(bounds, li.getNormalizer().getScale(drawable, null, null, null));
    }
    bounds.inset((int) (-bounds.width() * AdaptiveIconDrawable.getExtraInsetFraction()), (int) (-bounds.height() * AdaptiveIconDrawable.getExtraInsetFraction()));
    return bounds.left;
}
Also used : FolderAdaptiveIcon(com.android.launcher3.dragndrop.FolderAdaptiveIcon) Rect(android.graphics.Rect) LauncherIcons(com.android.launcher3.icons.LauncherIcons) AdaptiveIconDrawable(android.graphics.drawable.AdaptiveIconDrawable) WorkerThread(androidx.annotation.WorkerThread)

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