Filter recents view instances by package name

Filter instances of GroupTasks based on package name
as a part of support for multi-instance

Add a feature flag to toggle multi-instance features

See the video below for how to use the demo.
Note: some extra UI elements were added since video
was recorded, but the filtering process is the same.
http://recall/-/da585DRwKRZK3S2xxcQrSm/gW9HZnbCvGyH1DQiVizOW2

See go/multi-instance for more info about the feature

Bug: 253520408

Test: manually tested the instance filtering

Change-Id: I19c947ca353699096388b9fbbdca6d75cb0041a7
This commit is contained in:
Ikram Gabiyev
2022-10-20 06:56:25 +00:00
parent 1f155d6fd7
commit 448e0ade10
13 changed files with 410 additions and 9 deletions

View File

@@ -526,6 +526,50 @@ public class TaskView extends FrameLayout implements Reusable {
setOrientationState(orientedState);
}
/**
* Sets up an on-click listener and the visibility for show_windows icon on top of the task.
*/
public void setUpShowAllInstancesListener() {
String taskPackageName = mTaskIdAttributeContainer[0].mTask.key.getPackageName();
// icon of the top/left task
View showWindowsView = findViewById(R.id.show_windows);
updateFilterCallback(showWindowsView, getFilterUpdateCallback(taskPackageName));
}
/**
* Returns a callback that updates the state of the filter and the recents overview
*
* @param taskPackageName package name of the task to filter by
*/
@Nullable
protected View.OnClickListener getFilterUpdateCallback(String taskPackageName) {
View.OnClickListener cb = (view) -> {
// update and apply a new filter
getRecentsView().setAndApplyFilter(taskPackageName);
};
if (!getRecentsView().getFilterState().shouldShowFilterUI(taskPackageName)) {
cb = null;
}
return cb;
}
/**
* Sets the correct visibility and callback on the provided filterView based on whether
* the callback is null or not
*/
protected void updateFilterCallback(@NonNull View filterView,
@Nullable View.OnClickListener callback) {
if (callback == null) {
filterView.setVisibility(GONE);
} else {
filterView.setVisibility(VISIBLE);
}
filterView.setOnClickListener(callback);
}
public TaskIdAttributeContainer[] getTaskIdAttributeContainers() {
return mTaskIdAttributeContainer;
}