Search in sources :

Example 1 with AllAppsPagedView

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();
    }
}
Also used : View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) ScrimView(com.android.launcher3.views.ScrimView) Paint(android.graphics.Paint) Point(android.graphics.Point)

Example 2 with AllAppsPagedView

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));
    });
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Objects(java.util.Objects) AllAppsPagedView(com.android.launcher3.allapps.AllAppsPagedView) WorkEduView(com.android.launcher3.views.WorkEduView) Ignore(org.junit.Ignore) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Example 3 with AllAppsPagedView

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)));
}
Also used : Objects(java.util.Objects) AllAppsPagedView(com.android.launcher3.allapps.AllAppsPagedView) WorkEduView(com.android.launcher3.views.WorkEduView) Test(org.junit.Test) LargeTest(androidx.test.filters.LargeTest)

Example 4 with AllAppsPagedView

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);
}
Also used : ShadowUserManager(org.robolectric.shadows.ShadowUserManager) AllAppsRecyclerView(com.android.launcher3.allapps.AllAppsRecyclerView) ShadowUserManager(org.robolectric.shadows.ShadowUserManager) UserManager(android.os.UserManager) AllAppsPagedView(com.android.launcher3.allapps.AllAppsPagedView) Test(org.junit.Test)

Example 5 with AllAppsPagedView

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);
}
Also used : AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) AllAppsPagedView(com.android.launcher3.allapps.AllAppsPagedView) WorkProfileManager(com.android.launcher3.allapps.WorkProfileManager) AllAppsPagedView(com.android.launcher3.allapps.AllAppsPagedView) View(android.view.View) AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) Test(org.junit.Test)

Aggregations

AllAppsPagedView (com.android.launcher3.allapps.AllAppsPagedView)12 Test (org.junit.Test)12 View (android.view.View)10 Paint (android.graphics.Paint)6 Point (android.graphics.Point)6 RecyclerView (androidx.recyclerview.widget.RecyclerView)6 LargeTest (androidx.test.filters.LargeTest)6 Objects (java.util.Objects)6 ScrimView (com.android.launcher3.views.ScrimView)5 UserManager (android.os.UserManager)4 AllAppsContainerView (com.android.launcher3.allapps.AllAppsContainerView)4 WorkProfileManager (com.android.launcher3.allapps.WorkProfileManager)4 WorkEduView (com.android.launcher3.views.WorkEduView)4 Ignore (org.junit.Ignore)3 UserHandle (android.os.UserHandle)2 TextView (android.widget.TextView)2 AllAppsRecyclerView (com.android.launcher3.allapps.AllAppsRecyclerView)2 WorkModeSwitch (com.android.launcher3.allapps.WorkModeSwitch)2 ShadowUserManager (org.robolectric.shadows.ShadowUserManager)2 BottomUserEducationView (com.android.launcher3.views.BottomUserEducationView)1