Search in sources :

Example 6 with Folder

use of com.android.launcher3.tapl.Folder in project android_packages_apps_Launcher3 by crdroidandroid.

the class FolderIcon method setLabelSuggestion.

/**
 * Set the suggested folder name.
 */
public void setLabelSuggestion(FolderNameInfos nameInfos, InstanceId instanceId) {
    if (!FeatureFlags.FOLDER_NAME_SUGGEST.get()) {
        return;
    }
    if (!mInfo.getLabelState().equals(LabelState.UNLABELED)) {
        return;
    }
    if (nameInfos == null || !nameInfos.hasSuggestions()) {
        StatsLogManager.newInstance(getContext()).logger().withInstanceId(instanceId).withItemInfo(mInfo).log(LAUNCHER_FOLDER_AUTO_LABELING_SKIPPED_EMPTY_SUGGESTIONS);
        return;
    }
    if (!nameInfos.hasPrimary()) {
        StatsLogManager.newInstance(getContext()).logger().withInstanceId(instanceId).withItemInfo(mInfo).log(LAUNCHER_FOLDER_AUTO_LABELING_SKIPPED_EMPTY_PRIMARY);
        return;
    }
    CharSequence newTitle = nameInfos.getLabels()[0];
    FromState fromState = mInfo.getFromLabelState();
    mInfo.setTitle(newTitle, mFolder.mLauncherDelegate.getModelWriter());
    onTitleChanged(mInfo.title);
    mFolder.mFolderName.setText(mInfo.title);
    // Logging for folder creation flow
    StatsLogManager.newInstance(getContext()).logger().withInstanceId(instanceId).withItemInfo(mInfo).withFromState(fromState).withToState(ToState.TO_SUGGESTION0).withEditText(newTitle.toString()).log(LAUNCHER_FOLDER_AUTO_LABELED);
}
Also used : FromState(com.android.launcher3.logger.LauncherAtom.FromState)

Example 7 with Folder

use of com.android.launcher3.tapl.Folder in project android_packages_apps_Launcher3 by crdroidandroid.

the class FolderIcon method performCreateAnimation.

public void performCreateAnimation(final WorkspaceItemInfo destInfo, final View destView, final WorkspaceItemInfo srcInfo, final DragObject d, Rect dstRect, float scaleRelativeToDragLayer) {
    final DragView srcView = d.dragView;
    prepareCreateAnimation(destView);
    addItem(destInfo);
    // This will animate the first item from it's position as an icon into its
    // position as the first item in the preview
    mPreviewItemManager.createFirstItemAnimation(false, /* reverse */
    null).start();
    // This will animate the dragView (srcView) into the new folder
    onDrop(srcInfo, d, dstRect, scaleRelativeToDragLayer, 1, false);
}
Also used : DragView(com.android.launcher3.dragndrop.DragView)

Example 8 with Folder

use of com.android.launcher3.tapl.Folder in project android_packages_apps_Launcher3 by crdroidandroid.

the class Folder method updateTextViewFocus.

// This method keeps track of the first and last item in the folder for the purposes
// of keyboard focus
public void updateTextViewFocus() {
    final View firstChild = mContent.getFirstItem();
    final View lastChild = mContent.getLastItem();
    if (firstChild != null && lastChild != null) {
        mFolderName.setNextFocusDownId(lastChild.getId());
        mFolderName.setNextFocusRightId(lastChild.getId());
        mFolderName.setNextFocusLeftId(lastChild.getId());
        mFolderName.setNextFocusUpId(lastChild.getId());
        // Hitting TAB from the folder name wraps around to the first item on the current
        // folder page, and hitting SHIFT+TAB from that item wraps back to the folder name.
        mFolderName.setNextFocusForwardId(firstChild.getId());
        // When clicking off the folder when editing the name, this Folder gains focus. When
        // pressing an arrow key from that state, give the focus to the first item.
        this.setNextFocusDownId(firstChild.getId());
        this.setNextFocusRightId(firstChild.getId());
        this.setNextFocusLeftId(firstChild.getId());
        this.setNextFocusUpId(firstChild.getId());
        // When pressing shift+tab in the above state, give the focus to the last item.
        setOnKeyListener(new OnKeyListener() {

            @Override
            public boolean onKey(View v, int keyCode, KeyEvent event) {
                boolean isShiftPlusTab = keyCode == KeyEvent.KEYCODE_TAB && event.hasModifiers(KeyEvent.META_SHIFT_ON);
                if (isShiftPlusTab && Folder.this.isFocused()) {
                    return lastChild.requestFocus();
                }
                return false;
            }
        });
    } else {
        setOnKeyListener(null);
    }
}
Also used : KeyEvent(android.view.KeyEvent) ClipPathView(com.android.launcher3.views.ClipPathView) BubbleTextView(com.android.launcher3.BubbleTextView) View(android.view.View) TextView(android.widget.TextView) AppWidgetHostView(android.appwidget.AppWidgetHostView) PagedView(com.android.launcher3.PagedView) AbstractFloatingView(com.android.launcher3.AbstractFloatingView) SuppressLint(android.annotation.SuppressLint)

Example 9 with Folder

use of com.android.launcher3.tapl.Folder in project android_packages_apps_Launcher3 by crdroidandroid.

the class Folder method animateOpen.

/**
 * Opens the user folder described by the specified tag. The opening of the folder
 * is animated relative to the specified View. If the View is null, no animation
 * is played.
 */
private void animateOpen(List<WorkspaceItemInfo> items, int pageNo) {
    Folder openFolder = getOpen(mActivityContext);
    if (openFolder != null && openFolder != this) {
        // Close any open folder before opening a folder.
        openFolder.close(true);
    }
    mContent.bindItems(items);
    centerAboutIcon();
    mItemsInvalidated = true;
    updateTextViewFocus();
    mIsOpen = true;
    BaseDragLayer dragLayer = mActivityContext.getDragLayer();
    // There was a one-off crash where the folder had a parent already.
    if (getParent() == null) {
        dragLayer.addView(this);
        mDragController.addDropTarget(this);
    } else {
        if (FeatureFlags.IS_STUDIO_BUILD) {
            Log.e(TAG, "Opening folder (" + this + ") which already has a parent:" + getParent());
        }
    }
    mContent.completePendingPageChanges();
    mContent.setCurrentPage(pageNo);
    // This is set to true in close(), but isn't reset to false until onDropCompleted(). This
    // leads to an inconsistent state if you drag out of the folder and drag back in without
    // dropping. One resulting issue is that replaceFolderWithFinalItem() can be called twice.
    mDeleteFolderOnDropCompleted = false;
    cancelRunningAnimations();
    FolderAnimationManager fam = new FolderAnimationManager(this, true);
    AnimatorSet anim = fam.getAnimator();
    anim.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animation) {
            mFolderIcon.setIconVisible(false);
            mFolderIcon.drawLeaveBehindIfExists();
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            mState = STATE_OPEN;
            announceAccessibilityChanges();
            mContent.setFocusOnFirstChild();
        }
    });
    // Footer animation
    if (mContent.getPageCount() > 1 && !mInfo.hasOption(FolderInfo.FLAG_MULTI_PAGE_ANIMATION)) {
        int footerWidth = mContent.getDesiredWidth() - mFooter.getPaddingLeft() - mFooter.getPaddingRight();
        float textWidth = mFolderName.getPaint().measureText(mFolderName.getText().toString());
        float translation = (footerWidth - textWidth) / 2;
        mFolderName.setTranslationX(mContent.mIsRtl ? -translation : translation);
        mPageIndicator.prepareEntryAnimation();
        // Do not update the flag if we are in drag mode. The flag will be updated, when we
        // actually drop the icon.
        final boolean updateAnimationFlag = !mDragInProgress;
        anim.addListener(new AnimatorListenerAdapter() {

            @SuppressLint("InlinedApi")
            @Override
            public void onAnimationEnd(Animator animation) {
                mFolderName.animate().setDuration(FOLDER_NAME_ANIMATION_DURATION).translationX(0).setInterpolator(AnimationUtils.loadInterpolator(getContext(), android.R.interpolator.fast_out_slow_in));
                mPageIndicator.playEntryAnimation();
                if (updateAnimationFlag) {
                    mInfo.setOption(FolderInfo.FLAG_MULTI_PAGE_ANIMATION, true, mLauncherDelegate.getModelWriter());
                }
            }
        });
    } else {
        mFolderName.setTranslationX(0);
    }
    mPageIndicator.stopAllAnimations();
    startAnimation(anim);
    // Because t=0 has the folder match the folder icon, we can skip the
    // first frame and have the same movement one frame earlier.
    anim.setCurrentPlayTime(Math.min(getSingleFrameMs(getContext()), anim.getTotalDuration()));
    // Make sure the folder picks up the last drag move even if the finger doesn't move.
    if (mDragController.isDragging()) {
        mDragController.forceTouchMove();
    }
    mContent.verifyVisibleHighResIcons(mContent.getNextPage());
}
Also used : BaseDragLayer(com.android.launcher3.views.BaseDragLayer) Animator(android.animation.Animator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) SuppressLint(android.annotation.SuppressLint) AnimatorSet(android.animation.AnimatorSet) SuppressLint(android.annotation.SuppressLint)

Example 10 with Folder

use of com.android.launcher3.tapl.Folder in project android_packages_apps_Launcher3 by crdroidandroid.

the class Folder method onDropCompleted.

@Override
public void onDropCompleted(final View target, final DragObject d, final boolean success) {
    if (success) {
        if (mDeleteFolderOnDropCompleted && !mItemAddedBackToSelfViaIcon && target != this) {
            replaceFolderWithFinalItem();
        }
    } else {
        // The drag failed, we need to return the item to the folder
        WorkspaceItemInfo info = (WorkspaceItemInfo) d.dragInfo;
        View icon = (mCurrentDragView != null && mCurrentDragView.getTag() == info) ? mCurrentDragView : mContent.createNewView(info);
        ArrayList<View> views = getIconsInReadingOrder();
        info.rank = Utilities.boundToRange(info.rank, 0, views.size());
        views.add(info.rank, icon);
        mContent.arrangeChildren(views);
        mItemsInvalidated = true;
        try (SuppressInfoChanges s = new SuppressInfoChanges()) {
            mFolderIcon.onDrop(d, true);
        }
    }
    if (target != this) {
        if (mOnExitAlarm.alarmPending()) {
            mOnExitAlarm.cancelAlarm();
            if (!success) {
                mSuppressFolderDeletion = true;
            }
            mScrollPauseAlarm.cancelAlarm();
            completeDragExit();
        }
    }
    mDeleteFolderOnDropCompleted = false;
    mDragInProgress = false;
    mItemAddedBackToSelfViaIcon = false;
    mCurrentDragView = null;
    // Reordering may have occured, and we need to save the new item locations. We do this once
    // at the end to prevent unnecessary database operations.
    updateItemLocationsInDatabaseBatch(false);
    // been refreshed yet.
    if (getItemCount() <= mContent.itemsPerPage()) {
        // Show the animation, next time something is added to the folder.
        mInfo.setOption(FolderInfo.FLAG_MULTI_PAGE_ANIMATION, false, mLauncherDelegate.getModelWriter());
    }
}
Also used : ClipPathView(com.android.launcher3.views.ClipPathView) BubbleTextView(com.android.launcher3.BubbleTextView) View(android.view.View) TextView(android.widget.TextView) AppWidgetHostView(android.appwidget.AppWidgetHostView) PagedView(com.android.launcher3.PagedView) AbstractFloatingView(com.android.launcher3.AbstractFloatingView) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Aggregations

View (android.view.View)119 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)112 FolderInfo (com.android.launcher3.model.data.FolderInfo)93 ItemInfo (com.android.launcher3.model.data.ItemInfo)86 Point (android.graphics.Point)83 FolderIcon (com.android.launcher3.folder.FolderIcon)83 Folder (com.android.launcher3.folder.Folder)82 AppWidgetHostView (android.appwidget.AppWidgetHostView)80 SuppressLint (android.annotation.SuppressLint)73 DragView (com.android.launcher3.dragndrop.DragView)64 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)64 Rect (android.graphics.Rect)63 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)61 BubbleTextView (com.android.launcher3.BubbleTextView)56 ArrayList (java.util.ArrayList)49 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)47 Animator (android.animation.Animator)40 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)40 Drawable (android.graphics.drawable.Drawable)37 CellLayout (com.android.launcher3.CellLayout)37