use of com.android.launcher3.tapl.AllApps in project android_packages_apps_Launcher3 by crdroidandroid.
the class LauncherModel method startLoader.
/**
* Starts the loader. Tries to bind {@params synchronousBindPage} synchronously if possible.
* @return true if the page could be bound synchronously.
*/
public boolean startLoader() {
// Enable queue before starting loader. It will get disabled in Launcher#finishBindingItems
ItemInstallQueue.INSTANCE.get(mApp.getContext()).pauseModelPush(ItemInstallQueue.FLAG_LOADER_RUNNING);
synchronized (mLock) {
// Don't bother to start the thread if we know it's not going to do anything
final Callbacks[] callbacksList = getCallbacks();
if (callbacksList.length > 0) {
// Clear any pending bind-runnables from the synchronized load process.
for (Callbacks cb : callbacksList) {
MAIN_EXECUTOR.execute(cb::clearPendingBinds);
}
// If there is already one running, tell it to stop.
stopLoader();
LoaderResults loaderResults = new LoaderResults(mApp, mBgDataModel, mBgAllAppsList, callbacksList);
if (mModelLoaded && !mIsLoaderTaskRunning) {
// Divide the set of loaded items into those that we are binding synchronously,
// and everything else that is to be bound normally (asynchronously).
loaderResults.bindWorkspace();
// For now, continue posting the binding of AllApps as there are other
// issues that arise from that.
loaderResults.bindAllApps();
loaderResults.bindDeepShortcuts();
loaderResults.bindWidgets();
return true;
} else {
stopLoader();
mLoaderTask = new LoaderTask(mApp, mBgAllAppsList, mBgDataModel, mModelDelegate, loaderResults);
// Always post the loader task, instead of running directly
// (even on same thread) so that we exit any nested synchronized blocks
MODEL_EXECUTOR.post(mLoaderTask);
}
}
}
return false;
}
use of com.android.launcher3.tapl.AllApps in project android_packages_apps_Launcher3 by crdroidandroid.
the class CellLayout method commitTempPlacement.
private void commitTempPlacement() {
mTmpOccupied.copyTo(mOccupied);
int screenId = Launcher.cast(mActivity).getWorkspace().getIdForScreen(this);
int container = Favorites.CONTAINER_DESKTOP;
if (mContainerType == HOTSEAT) {
screenId = -1;
container = Favorites.CONTAINER_HOTSEAT;
}
int childCount = mShortcutsAndWidgets.getChildCount();
for (int i = 0; i < childCount; i++) {
View child = mShortcutsAndWidgets.getChildAt(i);
LayoutParams lp = (LayoutParams) child.getLayoutParams();
ItemInfo info = (ItemInfo) child.getTag();
// AllApps button in the hotseat.
if (info != null) {
final boolean requiresDbUpdate = (info.cellX != lp.tmpCellX || info.cellY != lp.tmpCellY || info.spanX != lp.cellHSpan || info.spanY != lp.cellVSpan);
info.cellX = lp.cellX = lp.tmpCellX;
info.cellY = lp.cellY = lp.tmpCellY;
info.spanX = lp.cellHSpan;
info.spanY = lp.cellVSpan;
if (requiresDbUpdate) {
Launcher.cast(mActivity).getModelWriter().modifyItemInDatabase(info, container, screenId, info.cellX, info.cellY, info.spanX, info.spanY);
}
}
}
}
use of com.android.launcher3.tapl.AllApps in project android_packages_apps_Launcher3 by crdroidandroid.
the class TaplTestsQuickstep method testOverview.
@Test
@PortraitLandscape
public void testOverview() throws Exception {
startTestAppsWithCheck();
// mLauncher.pressHome() also tests an important case of pressing home while in background.
Overview overview = mLauncher.pressHome().switchToOverview();
assertTrue("Launcher internal state didn't switch to Overview", isInState(() -> LauncherState.OVERVIEW));
executeOnLauncher(launcher -> assertTrue("Don't have at least 3 tasks", getTaskCount(launcher) >= 3));
// Test flinging forward and backward.
executeOnLauncher(launcher -> assertEquals("Current task in Overview is not 0", 0, getCurrentOverviewPage(launcher)));
overview.flingForward();
assertTrue("Launcher internal state is not Overview", isInState(() -> LauncherState.OVERVIEW));
final Integer currentTaskAfterFlingForward = getFromLauncher(launcher -> getCurrentOverviewPage(launcher));
executeOnLauncher(launcher -> assertTrue("Current task in Overview is still 0", currentTaskAfterFlingForward > 0));
overview.flingBackward();
assertTrue("Launcher internal state is not Overview", isInState(() -> LauncherState.OVERVIEW));
executeOnLauncher(launcher -> assertTrue("Flinging back in Overview did nothing", getCurrentOverviewPage(launcher) < currentTaskAfterFlingForward));
// Test opening a task.
OverviewTask task = mLauncher.pressHome().switchToOverview().getCurrentTask();
assertNotNull("overview.getCurrentTask() returned null (1)", task);
assertNotNull("OverviewTask.open returned null", task.open());
assertTrue("Test activity didn't open from Overview", mDevice.wait(Until.hasObject(By.pkg(getAppPackageName()).text("TestActivity2")), DEFAULT_UI_TIMEOUT));
executeOnLauncher(launcher -> assertTrue("Launcher activity is the top activity; expecting another activity to be the top " + "one", isInBackground(launcher)));
// Test dismissing a task.
overview = mLauncher.pressHome().switchToOverview();
assertTrue("Launcher internal state didn't switch to Overview", isInState(() -> LauncherState.OVERVIEW));
final Integer numTasks = getFromLauncher(launcher -> getTaskCount(launcher));
task = overview.getCurrentTask();
assertNotNull("overview.getCurrentTask() returned null (2)", task);
task.dismiss();
executeOnLauncher(launcher -> assertEquals("Dismissing a task didn't remove 1 task from Overview", numTasks - 1, getTaskCount(launcher)));
// Test UIDevice.pressHome, once we are in AllApps.
mDevice.pressHome();
waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL);
// Test dismissing all tasks.
mLauncher.getWorkspace().switchToOverview().dismissAllTasks();
waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL);
executeOnLauncher(launcher -> assertEquals("Still have tasks after dismissing all", 0, getTaskCount(launcher)));
}
use of com.android.launcher3.tapl.AllApps 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.tapl.AllApps in project android_packages_apps_Launcher3 by crdroidandroid.
the class TaplTestsLauncher3 method testPressHomeOnAllAppsContextMenu.
@Test
public void testPressHomeOnAllAppsContextMenu() throws Exception {
final AllApps allApps = mLauncher.getWorkspace().switchToAllApps();
allApps.freeze();
try {
allApps.getAppIcon("TestActivity7").openMenu();
} finally {
allApps.unfreeze();
}
mLauncher.pressHome();
}
Aggregations