use of com.android.launcher3.allapps.WorkModeSwitch in project android_packages_apps_Launcher3 by crdroidandroid.
the class WorkTabTest method toggleWorks.
@Ignore("b/182844465")
@Test
public void toggleWorks() {
mDevice.pressHome();
waitForLauncherCondition("Launcher didn't start", Objects::nonNull);
executeOnLauncher(launcher -> launcher.getStateManager().goToState(ALL_APPS));
waitForState("Launcher internal state didn't switch to All Apps", () -> ALL_APPS);
getOnceNotNull("Apps view did not bind", launcher -> launcher.getAppsView().getWorkModeSwitch(), 60000);
UserManager userManager = getFromLauncher(l -> l.getSystemService(UserManager.class));
assertEquals(2, userManager.getUserProfiles().size());
UserHandle workProfile = getFromLauncher(l -> {
UserHandle myHandle = Process.myUserHandle();
List<UserHandle> userProfiles = userManager.getUserProfiles();
return userProfiles.get(0) == myHandle ? userProfiles.get(1) : userProfiles.get(0);
});
waitForLauncherCondition("work profile can't be turned off", l -> userManager.requestQuietModeEnabled(true, workProfile));
assertTrue(userManager.isQuietModeEnabled(workProfile));
executeOnLauncher(launcher -> {
WorkModeSwitch wf = launcher.getAppsView().getWorkModeSwitch();
((AllAppsPagedView) launcher.getAppsView().getContentView()).snapToPageImmediately(AllAppsContainerView.AdapterHolder.WORK);
wf.toggle();
});
waitForLauncherCondition("Work toggle did not work", l -> l.getSystemService(UserManager.class).isQuietModeEnabled(workProfile));
}
use of com.android.launcher3.allapps.WorkModeSwitch in project Neo-Launcher by NeoApplications.
the class AllAppsGridAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
switch(holder.getItemViewType()) {
case VIEW_TYPE_ICON:
AppInfo info = mApps.getAdapterItems().get(position).appInfo;
BubbleTextView icon = (BubbleTextView) holder.itemView;
icon.reset();
icon.applyFromApplicationInfo(info);
break;
case VIEW_TYPE_EMPTY_SEARCH:
TextView emptyViewText = (TextView) holder.itemView;
emptyViewText.setText(mEmptySearchMessage);
emptyViewText.setGravity(mApps.hasNoFilteredResults() ? Gravity.CENTER : Gravity.START | Gravity.CENTER_VERTICAL);
break;
case VIEW_TYPE_SEARCH_MARKET:
TextView searchView = (TextView) holder.itemView;
if (mMarketSearchIntent != null) {
searchView.setVisibility(View.VISIBLE);
} else {
searchView.setVisibility(View.GONE);
}
break;
case VIEW_TYPE_ALL_APPS_DIVIDER:
// nothing to do
break;
case VIEW_TYPE_WORK_TAB_FOOTER:
WorkModeSwitch workModeToggle = holder.itemView.findViewById(R.id.work_mode_toggle);
workModeToggle.refresh();
TextView managedByLabel = holder.itemView.findViewById(R.id.managed_by_label);
boolean anyProfileQuietModeEnabled = UserManagerCompat.getInstance(managedByLabel.getContext()).isAnyProfileQuietModeEnabled();
managedByLabel.setText(anyProfileQuietModeEnabled ? R.string.work_mode_off_label : R.string.work_mode_on_label);
break;
case VIEW_TYPE_FOLDER:
ViewGroup container = (ViewGroup) holder.itemView;
FolderIcon folderIcon = mApps.getAdapterItems().get(position).folderItem.getFolderIcon(mLauncher, container);
container.removeAllViews();
container.addView(folderIcon);
folderIcon.verifyHighRes();
break;
case VIEW_TYPE_SEARCH_SUGGESTION:
int color = getDrawerTextColor();
ViewGroup group = (ViewGroup) holder.itemView;
TextView textView = group.findViewById(R.id.suggestion);
String suggestion = mApps.getAdapterItems().get(position).suggestion;
textView.setText(suggestion);
textView.setTextColor(color);
((ImageView) group.findViewById(android.R.id.icon)).getDrawable().setTint(color);
group.setOnClickListener(v -> {
SearchProvider provider = getSearchProvider();
if (provider instanceof WebSearchProvider) {
((WebSearchProvider) provider).openResults(suggestion);
}
});
break;
}
if (mBindViewCallback != null) {
mBindViewCallback.onBindView(holder);
}
}
use of com.android.launcher3.allapps.WorkModeSwitch in project android_packages_apps_Trebuchet by LineageOS.
the class WorkTabTest method toggleWorks.
@Test
public void toggleWorks() {
mDevice.pressHome();
waitForLauncherCondition("Launcher didn't start", Objects::nonNull);
executeOnLauncher(launcher -> launcher.getStateManager().goToState(ALL_APPS));
waitForState("Launcher internal state didn't switch to All Apps", () -> ALL_APPS);
getOnceNotNull("Apps view did not bind", launcher -> launcher.getAppsView().getWorkModeSwitch(), 60000);
UserManager userManager = getFromLauncher(l -> l.getSystemService(UserManager.class));
assertEquals(2, userManager.getUserProfiles().size());
UserHandle workProfile = getFromLauncher(l -> {
UserHandle myHandle = Process.myUserHandle();
List<UserHandle> userProfiles = userManager.getUserProfiles();
return userProfiles.get(0) == myHandle ? userProfiles.get(1) : userProfiles.get(0);
});
waitForLauncherCondition("work profile can't be turned off", l -> userManager.requestQuietModeEnabled(true, workProfile));
assertTrue(userManager.isQuietModeEnabled(workProfile));
executeOnLauncher(launcher -> {
WorkModeSwitch wf = launcher.getAppsView().getWorkModeSwitch();
((AllAppsPagedView) launcher.getAppsView().getContentView()).snapToPageImmediately(AllAppsContainerView.AdapterHolder.WORK);
wf.toggle();
});
waitForLauncherCondition("Work toggle did not work", l -> l.getSystemService(UserManager.class).isQuietModeEnabled(workProfile));
}
Aggregations