use of com.android.launcher3.allapps.AllAppsPagedView in project android_packages_apps_Launcher3 by crdroidandroid.
the class AllAppsContainerView method replaceRVContainer.
private void replaceRVContainer(boolean showTabs) {
for (int i = 0; i < mAH.length; i++) {
AllAppsRecyclerView rv = mAH[i].recyclerView;
if (rv != null) {
rv.setLayoutManager(null);
rv.setAdapter(null);
}
}
View oldView = getRecyclerViewContainer();
int index = indexOfChild(oldView);
removeView(oldView);
int layout = showTabs ? R.layout.all_apps_tabs : R.layout.all_apps_rv_layout;
View newView = getLayoutInflater().inflate(layout, this, false);
addView(newView, index);
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.WORK_PROFILE_REMOVED, "should show tabs:" + showTabs, new Exception());
}
if (showTabs) {
mViewPager = (AllAppsPagedView) newView;
mViewPager.initParentViews(this);
mViewPager.getPageIndicator().setOnActivePageChangedListener(this);
setupWorkToggle();
} else {
mViewPager = null;
removeWorkToggle();
}
}
use of com.android.launcher3.allapps.AllAppsPagedView in project android_packages_apps_Launcher3 by crdroidandroid.
the class WorkTabTest method testWorkEduFlow.
@Ignore("b/182844465")
@Test
public void testWorkEduFlow() {
mDevice.pressHome();
waitForLauncherCondition("Launcher didn't start", Objects::nonNull);
executeOnLauncher(launcher -> launcher.getSharedPrefs().edit().remove(WorkEduView.KEY_WORK_EDU_STEP).remove(WorkEduView.KEY_LEGACY_WORK_EDU_SEEN).commit());
waitForLauncherCondition("Work tab not setup", launcher -> {
if (launcher.getAppsView().getContentView() instanceof AllAppsPagedView) {
launcher.getAppsView().getAppsStore().enableDeferUpdates(DEFER_UPDATES_TEST);
return true;
}
return false;
}, LauncherInstrumentation.WAIT_TIME_MS);
executeOnLauncher(launcher -> launcher.getStateManager().goToState(ALL_APPS));
WorkEduView workEduView = getEduView();
// verify personal app edu is seen first and click "next"
executeOnLauncher(l -> {
assertEquals(((TextView) workEduView.findViewById(R.id.content_text)).getText(), l.getResources().getString(R.string.work_profile_edu_personal_apps));
workEduView.findViewById(R.id.proceed).callOnClick();
});
AtomicInteger attempt = new AtomicInteger(0);
// verify work edu is seen next
waitForLauncherCondition("Launcher did not show the next edu screen", l -> {
Log.d(TestProtocol.WORK_PROFILE_REMOVED, "running test attempt" + attempt.getAndIncrement());
if (!(l.getAppsView().getContentView() instanceof AllAppsPagedView)) {
Log.d(TestProtocol.WORK_PROFILE_REMOVED, "Work tab not setup. Skipping test");
return false;
}
if (((AllAppsPagedView) l.getAppsView().getContentView()).getCurrentPage() != WORK_PAGE) {
Log.d(TestProtocol.WORK_PROFILE_REMOVED, "Work page not highlighted");
}
return ((TextView) workEduView.findViewById(R.id.content_text)).getText().equals(l.getResources().getString(R.string.work_profile_edu_work_apps));
});
}
use of com.android.launcher3.allapps.AllAppsPagedView in project android_packages_apps_Trebuchet by LineageOS.
the class WorkTabTest method testWorkEduFlow.
@Test
public void testWorkEduFlow() {
mDevice.pressHome();
waitForLauncherCondition("Launcher didn't start", Objects::nonNull);
executeOnLauncher(launcher -> launcher.getSharedPrefs().edit().remove(WorkEduView.KEY_WORK_EDU_STEP).remove(WorkEduView.KEY_LEGACY_WORK_EDU_SEEN).commit());
waitForLauncherCondition("Work tab not setup", launcher -> launcher.getAppsView().getContentView() instanceof AllAppsPagedView, 60000);
executeOnLauncher(launcher -> launcher.getStateManager().goToState(ALL_APPS));
WorkEduView workEduView = getEduView();
// verify personal app edu is seen first and click "next"
executeOnLauncher(l -> {
assertEquals(((TextView) workEduView.findViewById(R.id.content_text)).getText(), l.getResources().getString(R.string.work_profile_edu_personal_apps));
workEduView.findViewById(R.id.proceed).callOnClick();
});
executeOnLauncher(launcher -> Log.d(TestProtocol.WORK_PROFILE_REMOVED, "Work profile status: " + launcher.getAppsView().isPersonalTabVisible()));
// verify work edu is seen next
waitForLauncherCondition("Launcher did not show the next edu screen", l -> ((AllAppsPagedView) l.getAppsView().getContentView()).getCurrentPage() == WORK_PAGE && ((TextView) workEduView.findViewById(R.id.content_text)).getText().equals(l.getResources().getString(R.string.work_profile_edu_work_apps)));
}
use of com.android.launcher3.allapps.AllAppsPagedView in project android_packages_apps_Trebuchet by LineageOS.
the class SDWorkModeTest method testAllAppsList_workProfile.
@Test
public void testAllAppsList_workProfile() throws Exception {
ShadowUserManager sum = Shadow.extract(mTargetContext.getSystemService(UserManager.class));
sum.addUser(SYSTEM_USER, "me", FLAG_SYSTEM);
sum.addUser(WORK_PROFILE_ID, "work", FLAG_PROFILE);
SecondaryDisplayLauncher launcher = loadLauncher();
launcher.showAppDrawer(true);
doLayout(launcher);
AllAppsRecyclerView rv1 = launcher.getAppsView().getActiveRecyclerView();
verifyRecyclerViewCount(rv1);
assertNotNull(launcher.getAppsView().getWorkModeSwitch());
assertTrue(launcher.getAppsView().getRecyclerViewContainer() instanceof AllAppsPagedView);
AllAppsPagedView pagedView = (AllAppsPagedView) launcher.getAppsView().getRecyclerViewContainer();
pagedView.snapToPageImmediately(1);
doLayout(launcher);
AllAppsRecyclerView rv2 = launcher.getAppsView().getActiveRecyclerView();
verifyRecyclerViewCount(rv2);
assertNotSame(rv1, rv2);
}
use of com.android.launcher3.allapps.AllAppsPagedView in project android_packages_apps_Launcher3 by ProtonAOSP.
the class WorkProfileTest method toggleWorks.
@Test
public void toggleWorks() {
waitForWorkTabSetup();
executeOnLauncher(launcher -> {
AllAppsPagedView pagedView = (AllAppsPagedView) launcher.getAppsView().getContentView();
pagedView.setCurrentPage(WORK_PAGE);
});
WorkProfileManager manager = getFromLauncher(l -> l.getAppsView().getWorkManager());
waitForLauncherCondition("work profile initial state check failed", launcher -> manager.getWorkModeSwitch() != null && manager.getCurrentState() == WorkProfileManager.STATE_ENABLED && manager.getWorkModeSwitch().isEnabled(), LauncherInstrumentation.WAIT_TIME_MS);
// start work profile toggle OFF test
executeOnLauncher(l -> l.getAppsView().getWorkManager().getWorkModeSwitch().performClick());
waitForLauncherCondition("Work profile toggle OFF failed", launcher -> {
// pulls current state from system
manager.reset();
return manager.getCurrentState() == WorkProfileManager.STATE_DISABLED;
}, LauncherInstrumentation.WAIT_TIME_MS);
// start work profile toggle ON test
executeOnLauncher(l -> {
AllAppsContainerView allApps = l.getAppsView();
assertEquals("Work tab is not focused", allApps.getCurrentPage(), WORK_PAGE);
View workPausedCard = allApps.getActiveRecyclerView().findViewHolderForAdapterPosition(0).itemView;
workPausedCard.findViewById(R.id.enable_work_apps).performClick();
});
waitForLauncherCondition("Work profile toggle ON failed", launcher -> {
// pulls current state from system
manager.reset();
return manager.getCurrentState() == WorkProfileManager.STATE_ENABLED;
}, LauncherInstrumentation.WAIT_TIME_MS);
}
Aggregations