use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.
the class LoaderCursorTest method newItemInfo.
private ItemInfo newItemInfo(int cellX, int cellY, int spanX, int spanY, int container, int screenId) {
ItemInfo info = new ItemInfo();
info.cellX = cellX;
info.cellY = cellY;
info.spanX = spanX;
info.spanY = spanY;
info.container = container;
info.screenId = screenId;
return info;
}
use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.
the class LauncherModelHelper method initializeData.
/**
* Initializes mock data for the test.
*/
public void initializeData(String resourceName) throws Exception {
Context targetContext = RuntimeEnvironment.application;
BgDataModel bgDataModel = getBgDataModel();
AllAppsList allAppsList = getAllAppsList();
MODEL_EXECUTOR.submit(() -> {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(this.getClass().getResourceAsStream(resourceName)))) {
String line;
HashMap<String, Class> classMap = new HashMap<>();
while ((line = reader.readLine()) != null) {
line = line.trim();
if (line.startsWith("#") || line.isEmpty()) {
continue;
}
String[] commands = line.split(" ");
switch(commands[0]) {
case "classMap":
classMap.put(commands[1], Class.forName(commands[2]));
break;
case "bgItem":
bgDataModel.addItem(targetContext, (ItemInfo) initItem(classMap.get(commands[1]), commands, 2), false);
break;
case "allApps":
allAppsList.add((AppInfo) initItem(AppInfo.class, commands, 1), null);
break;
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}).get();
}
use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.
the class WidgetUtils method addItemToScreen.
/**
* Adds {@param item} on the homescreen on the 0th screen
*/
public static void addItemToScreen(ItemInfo item, Context targetContext) {
ContentResolver resolver = targetContext.getContentResolver();
int screenId = FIRST_SCREEN_ID;
// Update the screen id counter for the provider.
LauncherSettings.Settings.call(resolver, LauncherSettings.Settings.METHOD_NEW_SCREEN_ID);
if (screenId > FIRST_SCREEN_ID) {
screenId = FIRST_SCREEN_ID;
}
// Insert the item
ContentWriter writer = new ContentWriter(targetContext);
item.id = LauncherSettings.Settings.call(resolver, LauncherSettings.Settings.METHOD_NEW_ITEM_ID).getInt(LauncherSettings.Settings.EXTRA_VALUE);
item.screenId = screenId;
item.onAddToDatabase(writer);
writer.put(LauncherSettings.Favorites._ID, item.id);
resolver.insert(LauncherSettings.Favorites.CONTENT_URI, writer.getValues(targetContext));
}
use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.
the class TaskView method onInitializeAccessibilityNodeInfo.
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
info.addAction(new AccessibilityNodeInfo.AccessibilityAction(R.string.accessibility_close, getContext().getText(R.string.accessibility_close)));
final Context context = getContext();
for (SystemShortcut s : TaskOverlayFactory.getEnabledShortcuts(this, mActivity.getDeviceProfile())) {
info.addAction(s.createAccessibilityAction(context));
}
if (mDigitalWellBeingToast.hasLimit()) {
info.addAction(new AccessibilityNodeInfo.AccessibilityAction(R.string.accessibility_app_usage_settings, getContext().getText(R.string.accessibility_app_usage_settings)));
}
final RecentsView recentsView = getRecentsView();
final AccessibilityNodeInfo.CollectionItemInfo itemInfo = AccessibilityNodeInfo.CollectionItemInfo.obtain(0, 1, recentsView.getTaskViewCount() - recentsView.indexOfChild(this) - 1, 1, false);
info.setCollectionItemInfo(itemInfo);
}
use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.
the class ItemClickHandler method startMarketIntentForPackage.
private static void startMarketIntentForPackage(View v, Launcher launcher, String packageName) {
ItemInfo item = (ItemInfo) v.getTag();
if (Utilities.ATLEAST_Q) {
SessionInfo sessionInfo = InstallSessionHelper.INSTANCE.get(launcher).getActiveSessionInfo(item.user, packageName);
if (sessionInfo != null) {
LauncherApps launcherApps = launcher.getSystemService(LauncherApps.class);
try {
launcherApps.startPackageInstallerSessionDetailsActivity(sessionInfo, null, launcher.getActivityLaunchOptions(v, item).toBundle());
return;
} catch (Exception e) {
Log.e(TAG, "Unable to launch market intent for package=" + packageName, e);
}
}
}
// Fallback to using custom market intent.
Intent intent = new PackageManagerHelper(launcher).getMarketIntent(packageName);
launcher.startActivitySafely(v, intent, item);
}
Aggregations