Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d947cf64 authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Android (Google) Code Review
Browse files

Merge "Wrapping remote app animations"

parents 1f2acb9a 2776b068
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.util.ArraySet;
import android.util.IntProperty;
import android.util.Property;
import android.util.TypedValue;
import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
@@ -290,6 +291,20 @@ public class Utilities {
        return context.getApplicationContext().getResources().getConfiguration();
    }

    /**
     * @return The next frame name for the specified surface.
     */
    public static long getNextFrameNumber(Surface s) {
        return s.getNextFrameNumber();
    }

    /**
     * @return The surface for the specified view.
     */
    public static Surface getSurface(View v) {
        return v.getViewRootImpl().mSurface;
    }

    /**
     * Returns a lightweight dump of a rect.
     */
+34 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package com.android.systemui.shared.system;

import android.app.Activity;

public class ActivityCompat {
    private final Activity mWrapped;

    public ActivityCompat(Activity activity) {
        mWrapped = activity;
    }

    /**
     * @see Activity#registerRemoteAnimations
     */
    public void registerRemoteAnimations(RemoteAnimationDefinitionCompat definition) {
        mWrapped.registerRemoteAnimations(definition.getWrapped());
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -38,4 +38,9 @@ public abstract class ActivityOptionsCompat {
                : SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT);
        return options;
    }

    public static ActivityOptions makeRemoteAnimation(
            RemoteAnimationAdapterCompat remoteAnimationAdapter) {
        return ActivityOptions.makeRemoteAnimation(remoteAnimationAdapter.getWrapped());
    }
}
+71 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package com.android.systemui.shared.system;

import android.os.RemoteException;
import android.util.Log;
import android.view.IRemoteAnimationFinishedCallback;
import android.view.IRemoteAnimationRunner;
import android.view.RemoteAnimationAdapter;
import android.view.RemoteAnimationTarget;

/**
 * @see RemoteAnimationAdapter
 */
public class RemoteAnimationAdapterCompat {

    private final RemoteAnimationAdapter mWrapped;

    public RemoteAnimationAdapterCompat(RemoteAnimationRunnerCompat runner, long duration,
            long statusBarTransitionDelay) {
        mWrapped = new RemoteAnimationAdapter(wrapRemoteAnimationRunner(runner), duration,
                statusBarTransitionDelay);
    }

    RemoteAnimationAdapter getWrapped() {
        return mWrapped;
    }

    private static IRemoteAnimationRunner.Stub wrapRemoteAnimationRunner(
            RemoteAnimationRunnerCompat remoteAnimationAdapter) {
        return new IRemoteAnimationRunner.Stub() {
            @Override
            public void onAnimationStart(RemoteAnimationTarget[] apps,
                    IRemoteAnimationFinishedCallback finishedCallback) throws RemoteException {
                final RemoteAnimationTargetCompat[] appsCompat =
                        RemoteAnimationTargetCompat.wrap(apps);
                final Runnable animationFinishedCallback = new Runnable() {
                    @Override
                    public void run() {
                        try {
                            finishedCallback.onAnimationFinished();
                        } catch (RemoteException e) {
                            Log.e("ActivityOptionsCompat", "Failed to call app controlled animation"
                                    + " finished callback", e);
                        }
                    }
                };
                remoteAnimationAdapter.onAnimationStart(appsCompat, animationFinishedCallback);
            }

            @Override
            public void onAnimationCancelled() throws RemoteException {
                remoteAnimationAdapter.onAnimationCancelled();
            }
        };
    }
}
+35 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package com.android.systemui.shared.system;

import android.view.RemoteAnimationDefinition;

/**
 * @see RemoteAnimationDefinition
 */
public class RemoteAnimationDefinitionCompat {

    private final RemoteAnimationDefinition mWrapped = new RemoteAnimationDefinition();

    public void addRemoteAnimation(int transition, RemoteAnimationAdapterCompat adapter) {
        mWrapped.addRemoteAnimation(transition, adapter.getWrapped());
    }

    RemoteAnimationDefinition getWrapped() {
        return mWrapped;
    }
}
Loading