Search in sources :

Example 1 with BaseDraggingActivity

use of com.android.launcher3.BaseDraggingActivity in project android_packages_apps_Launcher3 by crdroidandroid.

the class TouchInteractionService method onConfigurationChanged.

@Override
public void onConfigurationChanged(Configuration newConfig) {
    if (!mDeviceState.isUserUnlocked()) {
        return;
    }
    final BaseActivityInterface activityInterface = mOverviewComponentObserver.getActivityInterface();
    final BaseDraggingActivity activity = activityInterface.getCreatedActivity();
    if (activity == null || activity.isStarted()) {
        // We only care about the existing background activity.
        return;
    }
    if (mOverviewComponentObserver.canHandleConfigChanges(activity.getComponentName(), activity.getResources().getConfiguration().diff(newConfig))) {
        // Since navBar gestural height are different between portrait and landscape,
        // can handle orientation changes and refresh navigation gestural region through
        // onOneHandedModeChanged()
        int newGesturalHeight = ResourceUtils.getNavbarSize(ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, getApplicationContext().getResources());
        mDeviceState.onOneHandedModeChanged(newGesturalHeight);
        return;
    }
    preloadOverview(false);
}
Also used : BaseDraggingActivity(com.android.launcher3.BaseDraggingActivity) Point(android.graphics.Point)

Example 2 with BaseDraggingActivity

use of com.android.launcher3.BaseDraggingActivity in project android_packages_apps_Launcher3 by crdroidandroid.

the class PopupPopulator method createUpdateRunnable.

/**
 * Returns a runnable to update the provided shortcuts and notifications
 */
public static Runnable createUpdateRunnable(final BaseDraggingActivity launcher, final ItemInfo originalInfo, final Handler uiHandler, final PopupContainerWithArrow container, final List<DeepShortcutView> shortcutViews, final List<NotificationKeyData> notificationKeys) {
    final ComponentName activity = originalInfo.getTargetComponent();
    final UserHandle user = originalInfo.user;
    return () -> {
        if (!notificationKeys.isEmpty()) {
            NotificationListener notificationListener = NotificationListener.getInstanceIfConnected();
            final List<NotificationInfo> infos;
            if (notificationListener == null) {
                infos = Collections.emptyList();
            } else {
                infos = notificationListener.getNotificationsForKeys(notificationKeys).stream().map(sbn -> new NotificationInfo(launcher, sbn, originalInfo)).collect(Collectors.toList());
            }
            uiHandler.post(() -> container.applyNotificationInfos(infos));
        }
        List<ShortcutInfo> shortcuts = new ShortcutRequest(launcher, user).withContainer(activity).query(ShortcutRequest.PUBLISHED);
        String shortcutIdToDeDupe = notificationKeys.isEmpty() ? null : notificationKeys.get(0).shortcutId;
        shortcuts = PopupPopulator.sortAndFilterShortcuts(shortcuts, shortcutIdToDeDupe);
        IconCache cache = LauncherAppState.getInstance(launcher).getIconCache();
        for (int i = 0; i < shortcuts.size() && i < shortcutViews.size(); i++) {
            final ShortcutInfo shortcut = shortcuts.get(i);
            final WorkspaceItemInfo si = new WorkspaceItemInfo(shortcut, launcher);
            cache.getUnbadgedShortcutIcon(si, shortcut);
            si.rank = i;
            si.container = CONTAINER_SHORTCUTS;
            final DeepShortcutView view = shortcutViews.get(i);
            uiHandler.post(() -> view.applyShortcutInfo(si, shortcut, container));
        }
    };
}
Also used : Iterator(java.util.Iterator) ComponentName(android.content.ComponentName) ShortcutInfo(android.content.pm.ShortcutInfo) CONTAINER_SHORTCUTS(com.android.launcher3.LauncherSettings.Favorites.CONTAINER_SHORTCUTS) LauncherAppState(com.android.launcher3.LauncherAppState) ItemInfo(com.android.launcher3.model.data.ItemInfo) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView) BaseDraggingActivity(com.android.launcher3.BaseDraggingActivity) IconCache(com.android.launcher3.icons.IconCache) Collectors(java.util.stream.Collectors) NotificationInfo(com.android.launcher3.notification.NotificationInfo) NotificationKeyData(com.android.launcher3.notification.NotificationKeyData) ArrayList(java.util.ArrayList) List(java.util.List) Nullable(androidx.annotation.Nullable) NotificationListener(com.android.launcher3.notification.NotificationListener) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) Handler(android.os.Handler) UserHandle(android.os.UserHandle) ShortcutRequest(com.android.launcher3.shortcuts.ShortcutRequest) Comparator(java.util.Comparator) VisibleForTesting(androidx.annotation.VisibleForTesting) Collections(java.util.Collections) NotificationInfo(com.android.launcher3.notification.NotificationInfo) ShortcutInfo(android.content.pm.ShortcutInfo) UserHandle(android.os.UserHandle) IconCache(com.android.launcher3.icons.IconCache) ComponentName(android.content.ComponentName) ArrayList(java.util.ArrayList) List(java.util.List) ShortcutRequest(com.android.launcher3.shortcuts.ShortcutRequest) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView) NotificationListener(com.android.launcher3.notification.NotificationListener) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 3 with BaseDraggingActivity

use of com.android.launcher3.BaseDraggingActivity in project android_packages_apps_Launcher3 by crdroidandroid.

the class TaskMenuView method showForTask.

public static boolean showForTask(TaskView taskView) {
    BaseDraggingActivity activity = BaseDraggingActivity.fromContext(taskView.getContext());
    final TaskMenuView taskMenuView = (TaskMenuView) activity.getLayoutInflater().inflate(R.layout.task_menu, activity.getDragLayer(), false);
    return taskMenuView.populateAndShowForTask(taskView);
}
Also used : BaseDraggingActivity(com.android.launcher3.BaseDraggingActivity)

Example 4 with BaseDraggingActivity

use of com.android.launcher3.BaseDraggingActivity in project android_packages_apps_Launcher3 by crdroidandroid.

the class AssistantInputConsumer method startAssistantInternal.

private void startAssistantInternal() {
    BaseDraggingActivity launcherActivity = mActivityInterface.getCreatedActivity();
    if (launcherActivity != null) {
        launcherActivity.getRootView().performHapticFeedback(// HapticFeedbackConstants.GESTURE_END
        13, HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
    }
    Bundle args = new Bundle();
    args.putInt(OPA_BUNDLE_TRIGGER, OPA_BUNDLE_TRIGGER_DIAG_SWIPE_GESTURE);
    args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_GESTURE);
    SystemUiProxy.INSTANCE.get(mContext).startAssistant(args);
    mLaunchedAssistant = true;
}
Also used : BaseDraggingActivity(com.android.launcher3.BaseDraggingActivity) Bundle(android.os.Bundle)

Example 5 with BaseDraggingActivity

use of com.android.launcher3.BaseDraggingActivity in project android_packages_apps_Launcher3 by crdroidandroid.

the class Snackbar method show.

public static void show(BaseDraggingActivity activity, int labelStringResId, int actionStringResId, Runnable onDismissed, Runnable onActionClicked) {
    closeOpenViews(activity, true, TYPE_SNACKBAR);
    Snackbar snackbar = new Snackbar(activity, null);
    // Set some properties here since inflated xml only contains the children.
    snackbar.setOrientation(HORIZONTAL);
    snackbar.setGravity(Gravity.CENTER_VERTICAL);
    Resources res = activity.getResources();
    snackbar.setElevation(res.getDimension(R.dimen.snackbar_elevation));
    int padding = res.getDimensionPixelSize(R.dimen.snackbar_padding);
    snackbar.setPadding(padding, padding, padding, padding);
    snackbar.setBackgroundResource(R.drawable.round_rect_primary);
    snackbar.mIsOpen = true;
    BaseDragLayer dragLayer = activity.getDragLayer();
    dragLayer.addView(snackbar);
    DragLayer.LayoutParams params = (DragLayer.LayoutParams) snackbar.getLayoutParams();
    params.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
    params.height = res.getDimensionPixelSize(R.dimen.snackbar_height);
    int maxMarginLeftRight = res.getDimensionPixelSize(R.dimen.snackbar_max_margin_left_right);
    int minMarginLeftRight = res.getDimensionPixelSize(R.dimen.snackbar_min_margin_left_right);
    int marginBottom = res.getDimensionPixelSize(R.dimen.snackbar_margin_bottom);
    Rect insets = activity.getDeviceProfile().getInsets();
    int maxWidth = dragLayer.getWidth() - minMarginLeftRight * 2 - insets.left - insets.right;
    int minWidth = dragLayer.getWidth() - maxMarginLeftRight * 2 - insets.left - insets.right;
    params.width = minWidth;
    params.setMargins(0, 0, 0, marginBottom + insets.bottom);
    TextView labelView = snackbar.findViewById(R.id.label);
    TextView actionView = snackbar.findViewById(R.id.action);
    String labelText = res.getString(labelStringResId);
    String actionText = res.getString(actionStringResId);
    int totalContentWidth = (int) (labelView.getPaint().measureText(labelText) + actionView.getPaint().measureText(actionText)) + labelView.getPaddingRight() + labelView.getPaddingLeft() + actionView.getPaddingRight() + actionView.getPaddingLeft() + padding * 2;
    if (totalContentWidth > params.width) {
        // The text doesn't fit in our standard width so update width to accommodate.
        if (totalContentWidth <= maxWidth) {
            params.width = totalContentWidth;
        } else {
            // One line will be cut off, fallback to 2 lines and smaller font. (This should only
            // happen in some languages if system display and font size are set to largest.)
            int textHeight = res.getDimensionPixelSize(R.dimen.snackbar_content_height);
            float textSizePx = res.getDimension(R.dimen.snackbar_min_text_size);
            labelView.setLines(2);
            labelView.getLayoutParams().height = textHeight * 2;
            actionView.getLayoutParams().height = textHeight * 2;
            labelView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePx);
            actionView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePx);
            params.height += textHeight;
            params.width = maxWidth;
        }
    }
    labelView.setText(labelText);
    actionView.setText(actionText);
    actionView.setOnClickListener(v -> {
        if (onActionClicked != null) {
            onActionClicked.run();
        }
        snackbar.mOnDismissed = null;
        snackbar.close(true);
    });
    snackbar.mOnDismissed = onDismissed;
    snackbar.setAlpha(0);
    snackbar.setScaleX(0.8f);
    snackbar.setScaleY(0.8f);
    snackbar.animate().alpha(1f).withLayer().scaleX(1).scaleY(1).setDuration(SHOW_DURATION_MS).setInterpolator(Interpolators.ACCEL_DEACCEL).start();
    int timeout = AccessibilityManagerCompat.getRecommendedTimeoutMillis(activity, TIMEOUT_DURATION_MS, FLAG_CONTENT_TEXT | FLAG_CONTENT_CONTROLS);
    snackbar.postDelayed(() -> snackbar.close(true), timeout);
}
Also used : DragLayer(com.android.launcher3.dragndrop.DragLayer) Rect(android.graphics.Rect) TextView(android.widget.TextView) Resources(android.content.res.Resources)

Aggregations

BaseDraggingActivity (com.android.launcher3.BaseDraggingActivity)7 Bundle (android.os.Bundle)2 Nullable (androidx.annotation.Nullable)2 ItemInfo (com.android.launcher3.model.data.ItemInfo)2 SplitSelectSystemShortcut (com.android.quickstep.TaskShortcutFactory.SplitSelectSystemShortcut)2 ArrayList (java.util.ArrayList)2 RemoteAction (android.app.RemoteAction)1 ComponentName (android.content.ComponentName)1 ShortcutInfo (android.content.pm.ShortcutInfo)1 Resources (android.content.res.Resources)1 Point (android.graphics.Point)1 Rect (android.graphics.Rect)1 Handler (android.os.Handler)1 UserHandle (android.os.UserHandle)1 TextView (android.widget.TextView)1 MainThread (androidx.annotation.MainThread)1 VisibleForTesting (androidx.annotation.VisibleForTesting)1 LauncherAppState (com.android.launcher3.LauncherAppState)1 CONTAINER_SHORTCUTS (com.android.launcher3.LauncherSettings.Favorites.CONTAINER_SHORTCUTS)1 DragLayer (com.android.launcher3.dragndrop.DragLayer)1