[7/n] Pin ActivityStack
Implements Unpin ActivityStack. Also prevents top ActivityStack to be pinned if the display is not large enough. Bug: 208573140 Test: atest PinActivityStackTests Change-Id: I504ab532a251f29cd83b53f03466db49191dd11f
This commit is contained in:
@@ -242,9 +242,20 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
|
||||
return false;
|
||||
}
|
||||
|
||||
// Abort if no space to split.
|
||||
final SplitAttributes calculatedSplitAttributes = mPresenter.computeSplitAttributes(
|
||||
task.getTaskProperties(), splitPinRule,
|
||||
splitPinRule.getDefaultSplitAttributes(),
|
||||
getActivitiesMinDimensionsPair(primaryContainer.getTopNonFinishingActivity(),
|
||||
topContainer.getTopNonFinishingActivity()));
|
||||
if (!SplitPresenter.shouldShowSplit(calculatedSplitAttributes)) {
|
||||
Log.w(TAG, "No space to split, abort pinning top ActivityStack.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Registers a Split
|
||||
final SplitPinContainer splitPinContainer = new SplitPinContainer(primaryContainer,
|
||||
topContainer, splitPinRule, splitPinRule.getDefaultSplitAttributes());
|
||||
topContainer, splitPinRule, calculatedSplitAttributes);
|
||||
task.addSplitContainer(splitPinContainer);
|
||||
|
||||
// Updates the Split
|
||||
@@ -263,7 +274,33 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
|
||||
|
||||
@Override
|
||||
public void unpinTopActivityStack(int taskId){
|
||||
// TODO
|
||||
synchronized (mLock) {
|
||||
final TaskContainer task = getTaskContainer(taskId);
|
||||
if (task == null) {
|
||||
Log.e(TAG, "Cannot find the task to unpin, id: " + taskId);
|
||||
return;
|
||||
}
|
||||
|
||||
final SplitPinContainer splitPinContainer = task.getSplitPinContainer();
|
||||
if (splitPinContainer == null) {
|
||||
Log.e(TAG, "No ActivityStack is pinned.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove the SplitPinContainer from the task.
|
||||
final TaskFragmentContainer containerToUnpin =
|
||||
splitPinContainer.getSecondaryContainer();
|
||||
task.removeSplitPinContainer();
|
||||
|
||||
// Resets the isolated navigation and updates the container.
|
||||
final TransactionRecord transactionRecord = mTransactionManager.startNewTransaction();
|
||||
final WindowContainerTransaction wct = transactionRecord.getTransaction();
|
||||
mPresenter.setTaskFragmentIsolatedNavigation(wct,
|
||||
containerToUnpin.getTaskFragmentToken(), false /* isolated */);
|
||||
updateContainer(wct, containerToUnpin);
|
||||
transactionRecord.apply(false /* shouldApplyIndependently */);
|
||||
updateCallbackIfNecessary();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -265,8 +265,25 @@ class TaskContainer {
|
||||
}
|
||||
|
||||
void removeSplitPinContainer() {
|
||||
if (mSplitPinContainer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final TaskFragmentContainer primaryContainer = mSplitPinContainer.getPrimaryContainer();
|
||||
final TaskFragmentContainer secondaryContainer = mSplitPinContainer.getSecondaryContainer();
|
||||
mSplitContainers.remove(mSplitPinContainer);
|
||||
mSplitPinContainer = null;
|
||||
|
||||
// Remove the other SplitContainers that contains the unpinned container (unless it
|
||||
// is the current top-most split-pair), since the state are no longer valid.
|
||||
final List<SplitContainer> splitsToRemove = new ArrayList<>();
|
||||
for (SplitContainer splitContainer : mSplitContainers) {
|
||||
if (splitContainer.getSecondaryContainer().equals(secondaryContainer)
|
||||
&& !splitContainer.getPrimaryContainer().equals(primaryContainer)) {
|
||||
splitsToRemove.add(splitContainer);
|
||||
}
|
||||
}
|
||||
removeSplitContainers(splitsToRemove);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
Reference in New Issue
Block a user