Refactor all apps to depend on activity context.

The current AllAppsContainerView has been split into a base class and a
subclass for activities. The base class allows using all apps with an
activity context. A-Z and work profile tabs are supported, but search
and the hotseat still require an Activity.

Test: Manual. All apps should work the same.
Bug: 204696617
Change-Id: I3b146714bc11b3b3555d97623aab5d78ac836482
This commit is contained in:
Brian Isganitis
2022-01-14 23:15:47 -05:00
parent 46728f6481
commit 1664c9f418
26 changed files with 534 additions and 387 deletions
@@ -39,7 +39,8 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* Companion class for {@link AllAppsContainerView} to manage work tab and personal tab related
* Companion class for {@link BaseAllAppsContainerView} to manage work tab and personal tab
* related
* logic based on {@link WorkProfileState}?
*/
public class WorkProfileManager implements PersonalWorkSlidingTabStrip.OnActivePageChangedListener {
@@ -50,7 +51,6 @@ public class WorkProfileManager implements PersonalWorkSlidingTabStrip.OnActiveP
public static final int STATE_DISABLED = 2;
public static final int STATE_TRANSITION = 3;
private final UserManager mUserManager;
/**
@@ -65,7 +65,7 @@ public class WorkProfileManager implements PersonalWorkSlidingTabStrip.OnActiveP
public @interface WorkProfileState {
}
private final AllAppsContainerView mAllApps;
private final BaseAllAppsContainerView<?> mAllApps;
private final WorkAdapterProvider mAdapterProvider;
private final ItemInfoMatcher mMatcher;
@@ -75,7 +75,7 @@ public class WorkProfileManager implements PersonalWorkSlidingTabStrip.OnActiveP
private int mCurrentState;
public WorkProfileManager(UserManager userManager, AllAppsContainerView allApps,
public WorkProfileManager(UserManager userManager, BaseAllAppsContainerView<?> allApps,
SharedPreferences preferences) {
mUserManager = userManager;
mAllApps = allApps;
@@ -118,7 +118,7 @@ public class WorkProfileManager implements PersonalWorkSlidingTabStrip.OnActiveP
mCurrentState = currentState;
mAdapterProvider.updateCurrentState(currentState);
if (getAH() != null) {
getAH().appsList.updateAdapterItems();
getAH().mAppsList.updateAdapterItems();
}
if (mWorkModeSwitch != null) {
mWorkModeSwitch.updateCurrentState(currentState == STATE_ENABLED);
@@ -126,7 +126,7 @@ public class WorkProfileManager implements PersonalWorkSlidingTabStrip.OnActiveP
}
/**
* Creates and attaches for profile toggle button to {@link AllAppsContainerView}
* Creates and attaches for profile toggle button to {@link BaseAllAppsContainerView}
*/
public boolean attachWorkModeSwitch() {
if (!mAllApps.getAppsStore().hasModelFlag(
@@ -149,7 +149,7 @@ public class WorkProfileManager implements PersonalWorkSlidingTabStrip.OnActiveP
}
/**
* Removes work profile toggle button from {@link AllAppsContainerView}
* Removes work profile toggle button from {@link BaseAllAppsContainerView}
*/
public void detachWorkModeSwitch() {
if (mWorkModeSwitch != null && mWorkModeSwitch.getParent() == mAllApps) {
@@ -172,8 +172,8 @@ public class WorkProfileManager implements PersonalWorkSlidingTabStrip.OnActiveP
return mWorkModeSwitch;
}
private AllAppsContainerView.AdapterHolder getAH() {
return mAllApps.mAH[AllAppsContainerView.AdapterHolder.WORK];
private BaseAllAppsContainerView<?>.AdapterHolder getAH() {
return mAllApps.mAH.get(BaseAllAppsContainerView.AdapterHolder.WORK);
}
public int getCurrentState() {