use of com.android.launcher3.Hotseat in project android_packages_apps_Trebuchet by LineageOS.
the class HotseatPredictionController method mapToWorkspaceItemInfo.
private List<WorkspaceItemInfo> mapToWorkspaceItemInfo(List<ComponentKeyMapper> components) {
AllAppsStore allAppsStore = mLauncher.getAppsView().getAppsStore();
if (allAppsStore.getApps().length == 0) {
return Collections.emptyList();
}
List<WorkspaceItemInfo> predictedApps = new ArrayList<>();
for (ComponentKeyMapper mapper : components) {
ItemInfoWithIcon info = mapper.getApp(allAppsStore);
if (info instanceof AppInfo) {
WorkspaceItemInfo predictedApp = new WorkspaceItemInfo((AppInfo) info);
predictedApp.container = LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION;
predictedApps.add(predictedApp);
} else if (info instanceof WorkspaceItemInfo) {
WorkspaceItemInfo predictedApp = new WorkspaceItemInfo((WorkspaceItemInfo) info);
predictedApp.container = LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION;
predictedApps.add(predictedApp);
} else {
if (DEBUG) {
Log.e(TAG, "Predicted app not found: " + mapper);
}
}
// Stop at the number of hotseat items
if (predictedApps.size() == mHotSeatItemsCount) {
break;
}
}
return predictedApps;
}
use of com.android.launcher3.Hotseat in project android_packages_apps_Trebuchet by LineageOS.
the class OverviewState method getHotseatScaleAndTranslation.
@Override
public ScaleAndTranslation getHotseatScaleAndTranslation(Launcher launcher) {
if ((getVisibleElements(launcher) & HOTSEAT_ICONS) != 0) {
DeviceProfile dp = launcher.getDeviceProfile();
if (dp.allAppsIconSizePx >= dp.iconSizePx) {
return new ScaleAndTranslation(1, 0, 0);
} else {
float scale = ((float) dp.allAppsIconSizePx) / dp.iconSizePx;
// Distance between the screen center (which is the pivotY for hotseat) and the
// bottom of the hotseat (which we want to preserve)
float distanceFromBottom = dp.heightPx / 2 - dp.hotseatBarBottomPaddingPx;
// On scaling, the bottom edge is moved closer to the pivotY. We move the
// hotseat back down so that the bottom edge's position is preserved.
float translationY = distanceFromBottom * (1 - scale);
return new ScaleAndTranslation(scale, 0, translationY);
}
}
return getWorkspaceScaleAndTranslation(launcher);
}
use of com.android.launcher3.Hotseat in project android_packages_apps_Trebuchet by LineageOS.
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);
}
for (int i = 0; i < mLauncher.getDeviceProfile().inv.numHotseatIcons; i++) {
View child = mHotseat.getChildAt(i, 0);
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;
}
use of com.android.launcher3.Hotseat in project android_packages_apps_Trebuchet by LineageOS.
the class DiscoveryBounce method showForHomeIfNeeded.
private static void showForHomeIfNeeded(Launcher launcher, boolean withDelay) {
OnboardingPrefs onboardingPrefs = launcher.getOnboardingPrefs();
if (!launcher.isInState(NORMAL) || onboardingPrefs.getBoolean(OnboardingPrefs.HOME_BOUNCE_SEEN) || AbstractFloatingView.getTopOpenView(launcher) != null || launcher.getSystemService(UserManager.class).isDemoUser() || Utilities.IS_RUNNING_IN_TEST_HARNESS) {
return;
}
if (withDelay) {
new Handler().postDelayed(() -> showForHomeIfNeeded(launcher, false), DELAY_MS);
return;
}
onboardingPrefs.incrementEventCount(OnboardingPrefs.HOME_BOUNCE_COUNT);
new DiscoveryBounce(launcher, 0).show(HOTSEAT);
}
use of com.android.launcher3.Hotseat in project android_packages_apps_Trebuchet by LineageOS.
the class Folder method replaceFolderWithFinalItem.
@Thunk
void replaceFolderWithFinalItem() {
// Add the last remaining child to the workspace in place of the folder
Runnable onCompleteRunnable = new Runnable() {
@Override
public void run() {
int itemCount = getItemCount();
if (itemCount <= 1) {
View newIcon = null;
WorkspaceItemInfo finalItem = null;
if (itemCount == 1) {
// Move the item from the folder to the workspace, in the position of the
// folder
CellLayout cellLayout = mLauncher.getCellLayout(mInfo.container, mInfo.screenId);
finalItem = mInfo.contents.remove(0);
newIcon = mLauncher.createShortcut(cellLayout, finalItem);
mLauncher.getModelWriter().addOrMoveItemInDatabase(finalItem, mInfo.container, mInfo.screenId, mInfo.cellX, mInfo.cellY);
}
// Remove the folder
mLauncher.removeItem(mFolderIcon, mInfo, true);
if (mFolderIcon instanceof DropTarget) {
mDragController.removeDropTarget((DropTarget) mFolderIcon);
}
if (newIcon != null) {
// We add the child after removing the folder to prevent both from existing
// at the same time in the CellLayout. We need to add the new item with
// addInScreenFromBind() to ensure that hotseat items are placed correctly.
mLauncher.getWorkspace().addInScreenFromBind(newIcon, mInfo);
// Focus the newly created child
newIcon.requestFocus();
}
if (finalItem != null) {
mLauncher.folderConvertedToItem(mFolderIcon.getFolder(), finalItem);
}
}
}
};
View finalChild = mContent.getLastItem();
if (finalChild != null) {
mFolderIcon.performDestroyAnimation(onCompleteRunnable);
} else {
onCompleteRunnable.run();
}
mDestroyed = true;
}
Aggregations