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();
}
}
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;
}
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);
}
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;
}
Aggregations