use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by AOSPA.
the class QuickstepModelDelegate method registerSnapshotLoggingCallback.
/**
* Registers a callback to log launcher workspace layout using Statsd pulled atom.
*/
protected void registerSnapshotLoggingCallback() {
if (mStatsManager == null) {
Log.d(TAG, "Failed to get StatsManager");
}
try {
mStatsManager.setPullAtomCallback(SysUiStatsLog.LAUNCHER_LAYOUT_SNAPSHOT, null, /* PullAtomMetadata */
MODEL_EXECUTOR, (i, eventList) -> {
InstanceId instanceId = new InstanceIdSequence().newInstanceId();
IntSparseArrayMap<ItemInfo> itemsIdMap;
synchronized (mDataModel) {
itemsIdMap = mDataModel.itemsIdMap.clone();
}
for (ItemInfo info : itemsIdMap) {
FolderInfo parent = getContainer(info, itemsIdMap);
LauncherAtom.ItemInfo itemInfo = info.buildProto(parent);
Log.d(TAG, itemInfo.toString());
StatsEvent statsEvent = StatsLogCompatManager.buildStatsEvent(itemInfo, instanceId);
eventList.add(statsEvent);
}
Log.d(TAG, String.format("Successfully logged %d workspace items with instanceId=%d", itemsIdMap.size(), instanceId.getId()));
additionalSnapshotEvents(instanceId);
SettingsChangeLogger.INSTANCE.get(mContext).logSnapshot(instanceId);
return StatsManager.PULL_SUCCESS;
});
Log.d(TAG, "Successfully registered for launcher snapshot logging!");
} catch (RuntimeException e) {
Log.e(TAG, "Failed to register launcher snapshot logging callback with StatsManager", e);
}
}
use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by AOSPA.
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;
}
use of com.android.launcher3.ItemInfo 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;
}
use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by AOSPA.
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();
}
}
use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by AOSPA.
the class HotseatPredictionController method logLaunchedAppRankingInfo.
/**
* Logs rank info based on current list of predicted items
*/
public void logLaunchedAppRankingInfo(@NonNull ItemInfo itemInfo, InstanceId instanceId) {
ComponentName targetCN = itemInfo.getTargetComponent();
if (targetCN == null) {
return;
}
int rank = -1;
for (int i = mPredictedItems.size() - 1; i >= 0; i--) {
ItemInfo info = mPredictedItems.get(i);
if (targetCN.equals(info.getTargetComponent()) && itemInfo.user.equals(info.user)) {
rank = i;
break;
}
}
if (rank < 0) {
return;
}
int cardinality = 0;
for (PredictedAppIcon icon : getPredictedIcons()) {
ItemInfo info = (ItemInfo) icon.getTag();
cardinality |= 1 << info.screenId;
}
PredictedHotseatContainer.Builder containerBuilder = PredictedHotseatContainer.newBuilder();
containerBuilder.setCardinality(cardinality);
if (itemInfo.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION) {
containerBuilder.setIndex(rank);
}
mLauncher.getStatsLogManager().logger().withInstanceId(instanceId).withRank(rank).withContainerInfo(ContainerInfo.newBuilder().setPredictedHotseatContainer(containerBuilder).build()).log(LAUNCHER_HOTSEAT_RANKED);
}
Aggregations