Implement the work scheduler view and update colors of FAB
Update colors of the FAB to spec: https://www.figma.com/design/uMzPkNMZpb7EyfHDo8usIa/V-%E2%80%A2-Toast-Butter?node-id=3784-112229&node-type=instance&m=dev Exported the brief case icon from figma since it is not available on go/icons. Color of the brief case icon is onPrimary. Have place holder string in launcher but implement the actual string in NL. bug:361589193 Test - manual: video: https://drive.google.com/file/d/1CIs8qdtV1jUvbq57CcgAXDBPPHHX5CKJ/view?usp=sharing Flag: com.android.launcher3.work_scheduler_in_work_profile Change-Id: Ia98e9c4394f6ddfa7009653034929f9afbfeac8c
This commit is contained in:
1 parent
4674c3bb2b
commit
bfd02bb36a
17 files changed
+246
-94
No files matched your search
@@ -58,7 +58,7 @@ public class WorkProfileManager extends UserProfileManager
|
||||
implements PersonalWorkSlidingTabStrip.OnActivePageChangedListener {
|
||||
private static final String TAG = "WorkProfileManager";
|
||||
private final ActivityAllAppsContainerView<?> mAllApps;
|
||||
private WorkModeSwitch mWorkModeSwitch;
|
||||
private WorkUtilityView mWorkUtilityView;
|
||||
private final Predicate<UserHandle> mWorkProfileMatcher;
|
||||
|
||||
public WorkProfileManager(
|
||||
@@ -79,15 +79,15 @@ public class WorkProfileManager extends UserProfileManager
|
||||
|
||||
@Override
|
||||
public void onActivePageChanged(int page) {
|
||||
updateWorkFAB(page);
|
||||
updateWorkUtilityViews(page);
|
||||
}
|
||||
|
||||
private void updateWorkFAB(int page) {
|
||||
if (mWorkModeSwitch != null) {
|
||||
private void updateWorkUtilityViews(int page) {
|
||||
if (mWorkUtilityView != null) {
|
||||
if (page == MAIN || page == SEARCH) {
|
||||
mWorkModeSwitch.animateVisibility(false);
|
||||
mWorkUtilityView.animateVisibility(false);
|
||||
} else if (page == WORK && getCurrentState() == STATE_ENABLED) {
|
||||
mWorkModeSwitch.animateVisibility(true);
|
||||
mWorkUtilityView.animateVisibility(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,10 +104,10 @@ public class WorkProfileManager extends UserProfileManager
|
||||
}
|
||||
boolean isEnabled = !mAllApps.getAppsStore().hasModelFlag(quietModeFlag);
|
||||
updateCurrentState(isEnabled ? STATE_ENABLED : STATE_DISABLED);
|
||||
if (mWorkModeSwitch != null) {
|
||||
if (mWorkUtilityView != null) {
|
||||
// reset the position of the button and clear IME insets.
|
||||
mWorkModeSwitch.getImeInsets().setEmpty();
|
||||
mWorkModeSwitch.updateTranslationY();
|
||||
mWorkUtilityView.getImeInsets().setEmpty();
|
||||
mWorkUtilityView.updateTranslationY();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,54 +116,54 @@ public class WorkProfileManager extends UserProfileManager
|
||||
if (getAH() != null) {
|
||||
getAH().mAppsList.updateAdapterItems();
|
||||
}
|
||||
if (mWorkModeSwitch != null) {
|
||||
updateWorkFAB(mAllApps.getCurrentPage());
|
||||
if (mWorkUtilityView != null) {
|
||||
updateWorkUtilityViews(mAllApps.getCurrentPage());
|
||||
}
|
||||
if (getCurrentState() == STATE_ENABLED) {
|
||||
attachWorkModeSwitch();
|
||||
attachWorkUtilityViews();
|
||||
} else if (getCurrentState() == STATE_DISABLED) {
|
||||
detachWorkModeSwitch();
|
||||
detachWorkUtilityViews();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and attaches for profile toggle button to {@link ActivityAllAppsContainerView}
|
||||
*/
|
||||
public boolean attachWorkModeSwitch() {
|
||||
public boolean attachWorkUtilityViews() {
|
||||
if (!mAllApps.getAppsStore().hasModelFlag(
|
||||
FLAG_HAS_SHORTCUT_PERMISSION | FLAG_QUIET_MODE_CHANGE_PERMISSION)) {
|
||||
Log.e(TAG, "unable to attach work mode switch; Missing required permissions");
|
||||
return false;
|
||||
}
|
||||
if (mWorkModeSwitch == null) {
|
||||
mWorkModeSwitch = (WorkModeSwitch) mAllApps.getLayoutInflater().inflate(
|
||||
R.layout.work_mode_fab, mAllApps, false);
|
||||
if (mWorkUtilityView == null) {
|
||||
mWorkUtilityView = (WorkUtilityView) mAllApps.getLayoutInflater().inflate(
|
||||
R.layout.work_mode_utility_view, mAllApps, false);
|
||||
}
|
||||
if (mWorkModeSwitch.getParent() == null) {
|
||||
mAllApps.addView(mWorkModeSwitch);
|
||||
if (mWorkUtilityView.getParent() == null) {
|
||||
mAllApps.addView(mWorkUtilityView);
|
||||
}
|
||||
if (mAllApps.getCurrentPage() != WORK) {
|
||||
mWorkModeSwitch.animateVisibility(false);
|
||||
mWorkUtilityView.animateVisibility(false);
|
||||
}
|
||||
if (getAH() != null) {
|
||||
getAH().applyPadding();
|
||||
}
|
||||
mWorkModeSwitch.setOnClickListener(this::onWorkFabClicked);
|
||||
mWorkUtilityView.setOnClickListener(this::onWorkFabClicked);
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Removes work profile toggle button from {@link ActivityAllAppsContainerView}
|
||||
*/
|
||||
public void detachWorkModeSwitch() {
|
||||
if (mWorkModeSwitch != null && mWorkModeSwitch.getParent() == mAllApps) {
|
||||
mAllApps.removeView(mWorkModeSwitch);
|
||||
public void detachWorkUtilityViews() {
|
||||
if (mWorkUtilityView != null && mWorkUtilityView.getParent() == mAllApps) {
|
||||
mAllApps.removeView(mWorkUtilityView);
|
||||
}
|
||||
mWorkModeSwitch = null;
|
||||
mWorkUtilityView = null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public WorkModeSwitch getWorkModeSwitch() {
|
||||
return mWorkModeSwitch;
|
||||
public WorkUtilityView getWorkUtilityView() {
|
||||
return mWorkUtilityView;
|
||||
}
|
||||
|
||||
private ActivityAllAppsContainerView.AdapterHolder getAH() {
|
||||
@@ -199,7 +199,7 @@ public class WorkProfileManager extends UserProfileManager
|
||||
}
|
||||
|
||||
private void onWorkFabClicked(View view) {
|
||||
if (getCurrentState() == STATE_ENABLED && mWorkModeSwitch.isEnabled()) {
|
||||
if (getCurrentState() == STATE_ENABLED && mWorkUtilityView.isEnabled()) {
|
||||
logEvents(LAUNCHER_TURN_OFF_WORK_APPS_TAP);
|
||||
setWorkProfileEnabled(false);
|
||||
}
|
||||
@@ -216,7 +216,7 @@ public class WorkProfileManager extends UserProfileManager
|
||||
}
|
||||
@Override
|
||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||
WorkModeSwitch fab = getWorkModeSwitch();
|
||||
WorkUtilityView fab = getWorkUtilityView();
|
||||
if (fab == null){
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user