Search in sources :

Example 76 with Hotseat

use of com.android.launcher3.Hotseat in project android_packages_apps_Launcher3 by ProtonAOSP.

the class FirstScreenBroadcast method sendBroadcastToInstaller.

/**
 * @param installerPackageName Package name of the package installer.
 * @param packages List of packages with active sessions for this package installer.
 * @param firstScreenItems List of items on the first screen.
 */
private void sendBroadcastToInstaller(Context context, String installerPackageName, Set<String> packages, List<ItemInfo> firstScreenItems) {
    Set<String> folderItems = new HashSet<>();
    Set<String> workspaceItems = new HashSet<>();
    Set<String> hotseatItems = new HashSet<>();
    Set<String> widgetItems = new HashSet<>();
    for (ItemInfo info : firstScreenItems) {
        if (info instanceof FolderInfo) {
            FolderInfo folderInfo = (FolderInfo) info;
            String folderItemInfoPackage;
            for (ItemInfo folderItemInfo : folderInfo.contents) {
                folderItemInfoPackage = getPackageName(folderItemInfo);
                if (folderItemInfoPackage != null && packages.contains(folderItemInfoPackage)) {
                    folderItems.add(folderItemInfoPackage);
                }
            }
        }
        String packageName = getPackageName(info);
        if (packageName == null || !packages.contains(packageName)) {
            continue;
        }
        if (info instanceof LauncherAppWidgetInfo) {
            widgetItems.add(packageName);
        } else if (info.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
            hotseatItems.add(packageName);
        } else if (info.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
            workspaceItems.add(packageName);
        }
    }
    if (DEBUG) {
        printList(installerPackageName, "Folder item", folderItems);
        printList(installerPackageName, "Workspace item", workspaceItems);
        printList(installerPackageName, "Hotseat item", hotseatItems);
        printList(installerPackageName, "Widget item", widgetItems);
    }
    context.sendBroadcast(new Intent(ACTION_FIRST_SCREEN_ACTIVE_INSTALLS).setPackage(installerPackageName).putStringArrayListExtra(FOLDER_ITEM_EXTRA, new ArrayList<>(folderItems)).putStringArrayListExtra(WORKSPACE_ITEM_EXTRA, new ArrayList<>(workspaceItems)).putStringArrayListExtra(HOTSEAT_ITEM_EXTRA, new ArrayList<>(hotseatItems)).putStringArrayListExtra(WIDGET_ITEM_EXTRA, new ArrayList<>(widgetItems)).putExtra(VERIFICATION_TOKEN_EXTRA, PendingIntent.getActivity(context, 0, new Intent(), FLAG_ONE_SHOT | FLAG_IMMUTABLE)));
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) ArrayList(java.util.ArrayList) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) FolderInfo(com.android.launcher3.model.data.FolderInfo) HashSet(java.util.HashSet)

Example 77 with Hotseat

use of com.android.launcher3.Hotseat in project android_packages_apps_404Launcher by P-404.

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;
}
Also used : Rect(android.graphics.Rect) ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) BubbleTextView(com.android.launcher3.BubbleTextView) BubbleTextView(com.android.launcher3.BubbleTextView) View(android.view.View) ArrowTipView(com.android.launcher3.views.ArrowTipView) ArrowTipView(com.android.launcher3.views.ArrowTipView) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 78 with Hotseat

use of com.android.launcher3.Hotseat in project android_packages_apps_404Launcher by P-404.

the class HotseatEduController method migrateHotseatWhole.

/**
 * This migration option attempts to move the entire hotseat up to the first workspace that
 * has space to host items. If no such page is found, it moves items to a new page.
 *
 * @return pageId where items are migrated
 */
private int migrateHotseatWhole() {
    Workspace workspace = mLauncher.getWorkspace();
    int pageId = -1;
    int toRow = 0;
    for (int i = 0; i < workspace.getPageCount(); i++) {
        CellLayout target = workspace.getScreenWithId(workspace.getScreenIdForPageIndex(i));
        if (target.makeSpaceForHotseatMigration(true)) {
            toRow = mLauncher.getDeviceProfile().inv.numRows - 1;
            pageId = i;
            break;
        }
    }
    if (pageId == -1) {
        pageId = LauncherSettings.Settings.call(mLauncher.getContentResolver(), LauncherSettings.Settings.METHOD_NEW_SCREEN_ID).getInt(LauncherSettings.Settings.EXTRA_VALUE);
        mNewScreens = IntArray.wrap(pageId);
    }
    boolean isPortrait = !mLauncher.getDeviceProfile().isVerticalBarLayout();
    int hotseatItemsNum = mLauncher.getDeviceProfile().numShownHotseatIcons;
    for (int i = 0; i < hotseatItemsNum; i++) {
        int x = isPortrait ? i : 0;
        int y = isPortrait ? 0 : hotseatItemsNum - i - 1;
        View child = mHotseat.getChildAt(x, y);
        if (child == null || child.getTag() == null)
            continue;
        ItemInfo tag = (ItemInfo) child.getTag();
        if (tag.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION)
            continue;
        mLauncher.getModelWriter().moveItemInDatabase(tag, LauncherSettings.Favorites.CONTAINER_DESKTOP, pageId, i, toRow);
        mNewItems.add(tag);
    }
    return pageId;
}
Also used : CellLayout(com.android.launcher3.CellLayout) ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) BubbleTextView(com.android.launcher3.BubbleTextView) View(android.view.View) ArrowTipView(com.android.launcher3.views.ArrowTipView) Workspace(com.android.launcher3.Workspace)

Example 79 with Hotseat

use of com.android.launcher3.Hotseat in project android_packages_apps_404Launcher by P-404.

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 {
        if (showHotseatArrowTip(requiresMigration, mLauncher.getString(requiresMigration ? R.string.hotseat_tip_no_empty_slots : R.string.hotseat_auto_enrolled))) {
            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) BubbleTextView(com.android.launcher3.BubbleTextView) View(android.view.View) ArrowTipView(com.android.launcher3.views.ArrowTipView)

Example 80 with Hotseat

use of com.android.launcher3.Hotseat in project android_packages_apps_404Launcher by P-404.

the class LauncherUnfoldAnimationController method onResume.

/**
 * Called when launcher is resumed
 */
public void onResume() {
    Hotseat hotseat = mLauncher.getHotseat();
    if (hotseat != null && hotseat.getQsb() instanceof HorizontalInsettableView) {
        mQsbInsettable = (HorizontalInsettableView) hotseat.getQsb();
    }
    OneShotPreDrawListener.add(mLauncher.getWorkspace(), () -> mProgressProvider.setReadyToHandleTransition(true));
}
Also used : Hotseat(com.android.launcher3.Hotseat) HorizontalInsettableView(com.android.launcher3.util.HorizontalInsettableView)

Aggregations

ItemInfo (com.android.launcher3.model.data.ItemInfo)67 View (android.view.View)66 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)46 Point (android.graphics.Point)27 ArrayList (java.util.ArrayList)27 CellLayout (com.android.launcher3.CellLayout)26 ViewGroup (android.view.ViewGroup)23 BubbleTextView (com.android.launcher3.BubbleTextView)23 FolderInfo (com.android.launcher3.model.data.FolderInfo)23 ArrowTipView (com.android.launcher3.views.ArrowTipView)22 FolderIcon (com.android.launcher3.folder.FolderIcon)20 SuppressLint (android.annotation.SuppressLint)19 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)19 Hotseat (com.android.launcher3.Hotseat)16 Intent (android.content.Intent)15 IntArray (com.android.launcher3.util.IntArray)13 Workspace (com.android.launcher3.Workspace)12 DraggableView (com.android.launcher3.dragndrop.DraggableView)12 HashSet (java.util.HashSet)12 AppWidgetHostView (android.appwidget.AppWidgetHostView)11