use of com.android.launcher3.BubbleTextView in project android_packages_apps_Launcher3 by crdroidandroid.
the class PopupContainerWithArrow method showForIcon.
/**
* Shows the notifications and deep shortcuts associated with {@param icon}.
* @return the container if shown or null.
*/
public static PopupContainerWithArrow showForIcon(BubbleTextView icon) {
Launcher launcher = Launcher.getLauncher(icon.getContext());
if (getOpen(launcher) != null) {
// There is already an items container open, so don't open this one.
icon.clearFocus();
return null;
}
ItemInfo item = (ItemInfo) icon.getTag();
if (!canShow(icon, item)) {
return null;
}
final PopupContainerWithArrow container = (PopupContainerWithArrow) launcher.getLayoutInflater().inflate(R.layout.popup_container, launcher.getDragLayer(), false);
container.configureForLauncher(launcher);
PopupDataProvider popupDataProvider = launcher.getPopupDataProvider();
container.populateAndShow(icon, popupDataProvider.getShortcutCountForItem(item), popupDataProvider.getNotificationKeysForItem(item), launcher.getSupportedShortcuts().map(s -> s.getShortcut(launcher, item)).filter(Objects::nonNull).collect(Collectors.toList()));
launcher.refreshAndBindWidgetsForPackageUser(PackageUserKey.fromItemInfo(item));
container.requestFocus();
return container;
}
use of com.android.launcher3.BubbleTextView in project android_packages_apps_Launcher3 by AOSPA.
the class PinnedAppsAdapter method getView.
/**
* {@inheritDoc}
*/
@Override
public View getView(int position, View view, ViewGroup parent) {
BubbleTextView icon;
if (view instanceof BubbleTextView) {
icon = (BubbleTextView) view;
} else {
icon = (BubbleTextView) LayoutInflater.from(parent.getContext()).inflate(R.layout.app_icon, parent, false);
icon.setOnClickListener(mOnClickListener);
icon.setOnLongClickListener(mOnLongClickListener);
icon.setLongPressTimeoutFactor(1f);
int padding = mLauncher.getDeviceProfile().edgeMarginPx;
icon.setPadding(padding, padding, padding, padding);
}
icon.applyFromApplicationInfo(mItems.get(position));
return icon;
}
use of com.android.launcher3.BubbleTextView in project android_packages_apps_Launcher3 by AOSPA.
the class PopupContainerWithArrow method populateAndShow.
@TargetApi(Build.VERSION_CODES.P)
public void populateAndShow(final BubbleTextView originalIcon, int shortcutCount, final List<NotificationKeyData> notificationKeys, List<SystemShortcut> systemShortcuts) {
mNumNotifications = notificationKeys.size();
mOriginalIcon = originalIcon;
boolean hasDeepShortcuts = shortcutCount > 0;
int containerWidth = (int) getResources().getDimension(R.dimen.bg_popup_item_width);
// horizontally laid out system shortcuts.
if (hasDeepShortcuts) {
containerWidth = (int) Math.max(containerWidth, systemShortcuts.size() * getResources().getDimension(R.dimen.system_shortcut_header_icon_touch_size));
}
// Add views
if (mNumNotifications > 0) {
// Add notification entries
if (mNotificationContainer == null) {
mNotificationContainer = findViewById(R.id.notification_container);
mNotificationContainer.setVisibility(VISIBLE);
mNotificationContainer.setPopupView(this);
} else {
mNotificationContainer.setVisibility(GONE);
}
updateNotificationHeader();
}
int viewsToFlip = getChildCount();
mSystemShortcutContainer = this;
if (mDeepShortcutContainer == null) {
mDeepShortcutContainer = findViewById(R.id.deep_shortcuts_container);
}
if (hasDeepShortcuts) {
mDeepShortcutContainer.setVisibility(View.VISIBLE);
for (int i = shortcutCount; i > 0; i--) {
DeepShortcutView v = inflateAndAdd(R.layout.deep_shortcut, mDeepShortcutContainer);
v.getLayoutParams().width = containerWidth;
mShortcuts.add(v);
}
updateHiddenShortcuts();
if (!systemShortcuts.isEmpty()) {
for (SystemShortcut shortcut : systemShortcuts) {
if (shortcut instanceof SystemShortcut.Widgets) {
if (mWidgetContainer == null) {
mWidgetContainer = inflateAndAdd(R.layout.widget_shortcut_container, this);
}
initializeSystemShortcut(R.layout.system_shortcut, mWidgetContainer, shortcut);
}
}
mSystemShortcutContainer = inflateAndAdd(R.layout.system_shortcut_icons, this);
for (SystemShortcut shortcut : systemShortcuts) {
if (!(shortcut instanceof SystemShortcut.Widgets)) {
initializeSystemShortcut(R.layout.system_shortcut_icon_only, mSystemShortcutContainer, shortcut);
}
}
}
} else {
mDeepShortcutContainer.setVisibility(View.GONE);
if (!systemShortcuts.isEmpty()) {
for (SystemShortcut shortcut : systemShortcuts) {
initializeSystemShortcut(R.layout.system_shortcut, this, shortcut);
}
}
}
reorderAndShow(viewsToFlip);
ItemInfo originalItemInfo = (ItemInfo) originalIcon.getTag();
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
setAccessibilityPaneTitle(getTitleForAccessibility());
}
mOriginalIcon.setForceHideDot(true);
// All views are added. Animate layout from now on.
setLayoutTransition(new LayoutTransition());
// Load the shortcuts on a background thread and update the container as it animates.
MODEL_EXECUTOR.getHandler().postAtFrontOfQueue(PopupPopulator.createUpdateRunnable(mActivityContext, originalItemInfo, new Handler(Looper.getMainLooper()), this, mShortcuts, notificationKeys));
}
use of com.android.launcher3.BubbleTextView in project android_packages_apps_Launcher3 by AOSPA.
the class PredictionRowView method applyPredictionApps.
private void applyPredictionApps() {
if (getChildCount() != mNumPredictedAppsPerRow) {
while (getChildCount() > mNumPredictedAppsPerRow) {
removeViewAt(0);
}
LayoutInflater inflater = mLauncher.getAppsView().getLayoutInflater();
while (getChildCount() < mNumPredictedAppsPerRow) {
BubbleTextView icon = (BubbleTextView) inflater.inflate(R.layout.all_apps_icon, this, false);
icon.setOnClickListener(ItemClickHandler.INSTANCE);
icon.setOnLongClickListener(ItemLongClickListener.INSTANCE_ALL_APPS);
icon.setLongPressTimeoutFactor(1f);
icon.setOnFocusChangeListener(mFocusHelper);
LayoutParams lp = (LayoutParams) icon.getLayoutParams();
// Ensure the all apps icon height matches the workspace icons in portrait mode.
lp.height = mLauncher.getDeviceProfile().allAppsCellHeightPx;
lp.width = 0;
lp.weight = 1;
addView(icon);
}
}
int predictionCount = mPredictedApps.size();
for (int i = 0; i < getChildCount(); i++) {
BubbleTextView icon = (BubbleTextView) getChildAt(i);
icon.reset();
if (predictionCount > i) {
icon.setVisibility(View.VISIBLE);
icon.applyFromWorkspaceItem(mPredictedApps.get(i));
} else {
icon.setVisibility(predictionCount == 0 ? GONE : INVISIBLE);
}
}
boolean predictionsEnabled = predictionCount > 0;
if (predictionsEnabled != mPredictionsEnabled) {
mPredictionsEnabled = predictionsEnabled;
mLauncher.reapplyUi(false);
updateVisibility();
}
mParent.onHeightUpdated();
}
use of com.android.launcher3.BubbleTextView in project android_packages_apps_Launcher3 by AOSPA.
the class HotseatEduController method showHotseatArrowTip.
/**
* Finds a child suitable child in hotseat and shows arrow tip pointing at it.
*
* @param usePinned used to determine target view. If true, will use the first matching pinned
* item. Otherwise, will use the first predicted child
* @param message String to be shown inside the arrowView
* @return whether suitable child was found and tip was shown
*/
private boolean showHotseatArrowTip(boolean usePinned, String message) {
int childCount = mHotseat.getShortcutsAndWidgets().getChildCount();
boolean isPortrait = !mLauncher.getDeviceProfile().isVerticalBarLayout();
BubbleTextView tipTargetView = null;
for (int i = childCount - 1; i > -1; i--) {
int x = isPortrait ? i : 0;
int y = isPortrait ? 0 : i;
View v = mHotseat.getShortcutsAndWidgets().getChildAt(x, y);
if (v instanceof BubbleTextView && v.getTag() instanceof WorkspaceItemInfo) {
ItemInfo info = (ItemInfo) v.getTag();
boolean isPinned = info.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT;
if (isPinned == usePinned) {
tipTargetView = (BubbleTextView) v;
break;
}
}
}
if (tipTargetView == null) {
Log.e(TAG, "Unable to find suitable view for ArrowTip");
return false;
}
Rect bounds = Utilities.getViewBounds(tipTargetView);
new ArrowTipView(mLauncher).show(message, Gravity.END, bounds.centerX(), bounds.top);
return true;
}
Aggregations