Search in sources :

Example 1 with ArrowTipView

use of com.android.launcher3.views.ArrowTipView in project android_packages_apps_Launcher3 by crdroidandroid.

the class HotseatEduController method showEdu.

void showEdu() {
    int childCount = mHotseat.getShortcutsAndWidgets().getChildCount();
    CellLayout cellLayout = mLauncher.getWorkspace().getScreenWithId(Workspace.FIRST_SCREEN_ID);
    // hotseat is already empty and does not require migration. show edu tip
    boolean requiresMigration = IntStream.range(0, childCount).anyMatch(i -> {
        View v = mHotseat.getShortcutsAndWidgets().getChildAt(i);
        return v != null && v.getTag() != null && ((ItemInfo) v.getTag()).container != LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION;
    });
    boolean canMigrateToFirstPage = cellLayout.makeSpaceForHotseatMigration(false);
    if (requiresMigration && canMigrateToFirstPage) {
        showDialog();
    } else {
        new ArrowTipView(mLauncher).show(mLauncher.getString(requiresMigration ? R.string.hotseat_tip_no_empty_slots : R.string.hotseat_auto_enrolled), mHotseat.getTop());
        mLauncher.getStatsLogManager().logger().log(LAUNCHER_HOTSEAT_EDU_ONLY_TIP);
        finishOnboarding();
    }
}
Also used : CellLayout(com.android.launcher3.CellLayout) ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) ArrowTipView(com.android.launcher3.views.ArrowTipView) View(android.view.View) ArrowTipView(com.android.launcher3.views.ArrowTipView)

Example 2 with ArrowTipView

use of com.android.launcher3.views.ArrowTipView in project android_packages_apps_Launcher3 by crdroidandroid.

the class BaseWidgetSheet method showEducationTipOnViewIfPossible.

/**
 * Shows education tip on top center of {@code view} if view is laid out.
 */
@Nullable
protected ArrowTipView showEducationTipOnViewIfPossible(@Nullable View view) {
    if (view == null || !ViewCompat.isLaidOut(view)) {
        return null;
    }
    int[] coords = new int[2];
    view.getLocationOnScreen(coords);
    ArrowTipView arrowTipView = new ArrowTipView(mActivityContext, /* isPointingUp= */
    false).showAtLocation(getContext().getString(R.string.long_press_widget_to_add), /* arrowXCoord= */
    coords[0] + view.getWidth() / 2, /* yCoord= */
    coords[1]);
    if (arrowTipView != null) {
        mActivityContext.getSharedPrefs().edit().putBoolean(KEY_WIDGETS_EDUCATION_TIP_SEEN, true).apply();
    }
    return arrowTipView;
}
Also used : ArrowTipView(com.android.launcher3.views.ArrowTipView) Nullable(androidx.annotation.Nullable)

Example 3 with ArrowTipView

use of com.android.launcher3.views.ArrowTipView in project android_packages_apps_Launcher3 by crdroidandroid.

the class AppWidgetResizeFrame method showReconfigurableWidgetEducationTip.

@Nullable
private ArrowTipView showReconfigurableWidgetEducationTip() {
    Rect rect = new Rect();
    if (!mReconfigureButton.getGlobalVisibleRect(rect)) {
        return null;
    }
    @Px int tipMargin = mLauncher.getResources().getDimensionPixelSize(R.dimen.widget_reconfigure_tip_top_margin);
    return new ArrowTipView(mLauncher, /* isPointingUp= */
    true).showAroundRect(getContext().getString(R.string.reconfigurable_widget_education_tip), /* arrowXCoord= */
    rect.left + mReconfigureButton.getWidth() / 2, /* rect= */
    rect, /* margin= */
    tipMargin);
}
Also used : Rect(android.graphics.Rect) Px(androidx.annotation.Px) ArrowTipView(com.android.launcher3.views.ArrowTipView) Nullable(androidx.annotation.Nullable)

Example 4 with ArrowTipView

use of com.android.launcher3.views.ArrowTipView in project android_packages_apps_Launcher3 by crdroidandroid.

the class ArrowTipView method show.

/**
 * Show the ArrowTipView (tooltip) center, start, or end aligned.
 *
 * @param text The text to be shown in the tooltip.
 * @param gravity The gravity aligns the tooltip center, start, or end.
 * @param arrowMarginStart The margin from start to place arrow (ignored if center)
 * @param top The Y coordinate of the bottom of tooltip.
 * @return The tooltip.
 */
public ArrowTipView show(String text, int gravity, int arrowMarginStart, int top) {
    ((TextView) findViewById(R.id.text)).setText(text);
    ViewGroup parent = mActivity.getDragLayer();
    parent.addView(this);
    DragLayer.LayoutParams params = (DragLayer.LayoutParams) getLayoutParams();
    params.gravity = gravity;
    LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mArrowView.getLayoutParams();
    lp.gravity = gravity;
    if (parent.getLayoutDirection() == LAYOUT_DIRECTION_RTL) {
        arrowMarginStart = parent.getMeasuredWidth() - arrowMarginStart;
    }
    if (gravity == Gravity.END) {
        lp.setMarginEnd(parent.getMeasuredWidth() - arrowMarginStart - mArrowWidth);
    } else if (gravity == Gravity.START) {
        lp.setMarginStart(arrowMarginStart - mArrowWidth / 2);
    }
    requestLayout();
    params.leftMargin = mActivity.getDeviceProfile().workspacePadding.left;
    params.rightMargin = mActivity.getDeviceProfile().workspacePadding.right;
    post(() -> setY(top - (mIsPointingUp ? 0 : getHeight())));
    mIsOpen = true;
    mHandler.postDelayed(() -> handleClose(true), AUTO_CLOSE_TIMEOUT_MILLIS);
    setAlpha(0);
    animate().alpha(1f).withLayer().setStartDelay(SHOW_DELAY_MS).setDuration(SHOW_DURATION_MS).setInterpolator(Interpolators.DEACCEL).start();
    return this;
}
Also used : DragLayer(com.android.launcher3.dragndrop.DragLayer) ViewGroup(android.view.ViewGroup) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout)

Aggregations

ArrowTipView (com.android.launcher3.views.ArrowTipView)3 Nullable (androidx.annotation.Nullable)2 Rect (android.graphics.Rect)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 Px (androidx.annotation.Px)1 CellLayout (com.android.launcher3.CellLayout)1 DragLayer (com.android.launcher3.dragndrop.DragLayer)1 ItemInfo (com.android.launcher3.model.data.ItemInfo)1 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)1