| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package androidx.window.extensions.embedding; |
| 18 |
|
| 19 |
import static android.view.WindowManager.TRANSIT_OLD_ACTIVITY_CLOSE; |
| 20 |
import static android.view.WindowManager.TRANSIT_OLD_ACTIVITY_OPEN; |
| 21 |
import static android.view.WindowManager.TRANSIT_OLD_TASK_FRAGMENT_CHANGE; |
| 22 |
import static android.view.WindowManager.TRANSIT_OLD_TASK_FRAGMENT_CLOSE; |
| 23 |
import static android.view.WindowManager.TRANSIT_OLD_TASK_FRAGMENT_OPEN; |
| 24 |
|
| 25 |
import android.util.Log; |
| 26 |
import android.view.RemoteAnimationAdapter; |
| 27 |
import android.view.RemoteAnimationDefinition; |
| 28 |
import android.window.TaskFragmentOrganizer; |
| 29 |
|
| 30 |
import androidx.annotation.NonNull; |
| 31 |
|
| 32 |
import com.android.internal.annotations.VisibleForTesting; |
| 33 |
|
| 34 |
|
| 35 |
class TaskFragmentAnimationController { |
| 36 |
|
| 37 |
private static final String TAG = "TaskFragAnimationCtrl"; |
| 38 |
static final boolean DEBUG = false; |
| 39 |
|
| 40 |
private final TaskFragmentOrganizer mOrganizer; |
| 41 |
private final TaskFragmentAnimationRunner mRemoteRunner = new TaskFragmentAnimationRunner(); |
| 42 |
@VisibleForTesting |
| 43 |
final RemoteAnimationDefinition mDefinition; |
| 44 |
private boolean mIsRegistered; |
| 45 |
|
| 46 |
TaskFragmentAnimationController(@NonNull TaskFragmentOrganizer organizer) { |
| 47 |
mOrganizer = organizer; |
| 48 |
mDefinition = new RemoteAnimationDefinition(); |
| 49 |
final RemoteAnimationAdapter animationAdapter = |
| 50 |
new RemoteAnimationAdapter(mRemoteRunner, 0, 0, true ); |
| 51 |
mDefinition.addRemoteAnimation(TRANSIT_OLD_ACTIVITY_OPEN, animationAdapter); |
| 52 |
mDefinition.addRemoteAnimation(TRANSIT_OLD_TASK_FRAGMENT_OPEN, animationAdapter); |
| 53 |
mDefinition.addRemoteAnimation(TRANSIT_OLD_ACTIVITY_CLOSE, animationAdapter); |
| 54 |
mDefinition.addRemoteAnimation(TRANSIT_OLD_TASK_FRAGMENT_CLOSE, animationAdapter); |
| 55 |
mDefinition.addRemoteAnimation(TRANSIT_OLD_TASK_FRAGMENT_CHANGE, animationAdapter); |
| 56 |
} |
| 57 |
|
| 58 |
void registerRemoteAnimations() { |
| 59 |
if (DEBUG) { |
| 60 |
Log.v(TAG, "registerRemoteAnimations"); |
| 61 |
} |
| 62 |
if (mIsRegistered) { |
| 63 |
return; |
| 64 |
} |
| 65 |
mOrganizer.registerRemoteAnimations(mDefinition); |
| 66 |
mIsRegistered = true; |
| 67 |
} |
| 68 |
|
| 69 |
void unregisterRemoteAnimations() { |
| 70 |
if (DEBUG) { |
| 71 |
Log.v(TAG, "unregisterRemoteAnimations"); |
| 72 |
} |
| 73 |
if (!mIsRegistered) { |
| 74 |
return; |
| 75 |
} |
| 76 |
mOrganizer.unregisterRemoteAnimations(); |
| 77 |
mIsRegistered = false; |
| 78 |
} |
| 79 |
} |