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

Commit 139349b7 authored by Chris Craik's avatar Chris Craik Committed by Android (Google) Code Review
Browse files

Merge "Add elevation, Z properties to View"

parents 967c4354 cc39e16c
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -491,6 +491,7 @@ package android {
    field public static final int editTextStyle = 16842862; // 0x101006e
    field public static final deprecated int editable = 16843115; // 0x101016b
    field public static final int editorExtras = 16843300; // 0x1010224
    field public static final int elevation = 16843851; // 0x101044b
    field public static final int ellipsize = 16842923; // 0x10100ab
    field public static final int ems = 16843096; // 0x1010158
    field public static final int enabled = 16842766; // 0x101000e
@@ -30121,6 +30122,7 @@ package android.view {
    method public int getDrawingCacheQuality();
    method public void getDrawingRect(android.graphics.Rect);
    method public long getDrawingTime();
    method public float getElevation();
    method public boolean getFilterTouchesWhenObscured();
    method public boolean getFitsSystemWindows();
    method public java.util.ArrayList<android.view.View> getFocusables(int);
@@ -30219,6 +30221,7 @@ package android.view {
    method public void getWindowVisibleDisplayFrame(android.graphics.Rect);
    method public float getX();
    method public float getY();
    method public float getZ();
    method public boolean hasFocus();
    method public boolean hasFocusable();
    method public boolean hasNestedScrollingParent();
@@ -30385,6 +30388,7 @@ package android.view {
    method public void setDrawingCacheEnabled(boolean);
    method public void setDrawingCacheQuality(int);
    method public void setDuplicateParentStateEnabled(boolean);
    method public void setElevation(float);
    method public void setEnabled(boolean);
    method public void setFadingEdgeLength(int);
    method public void setFilterTouchesWhenObscured(boolean);
@@ -30470,6 +30474,7 @@ package android.view {
    method public void setWillNotDraw(boolean);
    method public void setX(float);
    method public void setY(float);
    method public void setZ(float);
    method public boolean showContextMenu();
    method public android.view.ActionMode startActionMode(android.view.ActionMode.Callback);
    method public void startAnimation(android.view.animation.Animation);
@@ -31049,6 +31054,8 @@ package android.view {
    method public android.view.ViewPropertyAnimator xBy(float);
    method public android.view.ViewPropertyAnimator y(float);
    method public android.view.ViewPropertyAnimator yBy(float);
    method public android.view.ViewPropertyAnimator z(float);
    method public android.view.ViewPropertyAnimator zBy(float);
  }
  public final class ViewStub extends android.view.View {
+10 −0
Original line number Diff line number Diff line
@@ -443,6 +443,14 @@ public class RenderNode {
        return nHasOverlappingRendering(mNativeRenderNode);
    }

    public void setElevation(float lift) {
        nSetElevation(mNativeRenderNode, lift);
    }

    public float getElevation() {
        return nGetElevation(mNativeRenderNode);
    }

    /**
     * Sets the translation value for the display list on the X axis.
     *
@@ -854,6 +862,7 @@ public class RenderNode {
    private static native void nSetAlpha(long renderNode, float alpha);
    private static native void nSetHasOverlappingRendering(long renderNode,
            boolean hasOverlappingRendering);
    private static native void nSetElevation(long renderNode, float lift);
    private static native void nSetTranslationX(long renderNode, float translationX);
    private static native void nSetTranslationY(long renderNode, float translationY);
    private static native void nSetTranslationZ(long renderNode, float translationZ);
@@ -874,6 +883,7 @@ public class RenderNode {
    private static native float nGetCameraDistance(long renderNode);
    private static native float nGetScaleX(long renderNode);
    private static native float nGetScaleY(long renderNode);
    private static native float nGetElevation(long renderNode);
    private static native float nGetTranslationX(long renderNode);
    private static native float nGetTranslationY(long renderNode);
    private static native float nGetTranslationZ(long renderNode);
+53 −5
Original line number Diff line number Diff line
@@ -3649,6 +3649,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        float tx = 0;
        float ty = 0;
        float tz = 0;
        float elevation = 0;
        float rotation = 0;
        float rotationX = 0;
        float rotationY = 0;
@@ -3732,6 +3733,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                    tz = a.getDimensionPixelOffset(attr, 0);
                    transformSet = true;
                    break;
                case com.android.internal.R.styleable.View_elevation:
                    elevation = a.getDimensionPixelOffset(attr, 0);
                    transformSet = true;
                    break;
                case com.android.internal.R.styleable.View_rotation:
                    rotation = a.getFloat(attr, 0);
                    transformSet = true;
@@ -4080,6 +4085,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            setTranslationX(tx);
            setTranslationY(ty);
            setTranslationZ(tz);
            setElevation(elevation);
            setRotation(rotation);
            setRotationX(rotationX);
            setRotationY(rotationY);
@@ -10435,6 +10441,48 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        setTranslationY(y - mTop);
    }
    /**
     * The visual z position of this view, in pixels. This is equivalent to the
     * {@link #setTranslationZ(float) translationZ} property plus the current
     * {@link #getElevation() elevation} property.
     *
     * @return The visual z position of this view, in pixels.
     */
    @ViewDebug.ExportedProperty(category = "drawing")
    public float getZ() {
        return getElevation() + getTranslationZ();
    }
    /**
     * Sets the visual z position of this view, in pixels. This is equivalent to setting the
     * {@link #setTranslationZ(float) translationZ} property to be the difference between
     * the x value passed in and the current {@link #getElevation() elevation} property.
     *
     * @param z The visual z position of this view, in pixels.
     */
    public void setZ(float z) {
        setTranslationZ(z - getElevation());
    }
    @ViewDebug.ExportedProperty(category = "drawing")
    public float getElevation() {
        return mRenderNode.getElevation();
    }
    /**
     * Sets the base depth location of this view.
     *
     * @attr ref android.R.styleable#View_elevation
     */
    public void setElevation(float elevation) {
        if (elevation != getElevation()) {
            invalidateViewProperty(true, false);
            mRenderNode.setElevation(elevation);
            invalidateViewProperty(false, true);
            invalidateParentIfNeededAndWasQuickRejected();
        }
    }
    /**
     * The horizontal location of this view relative to its {@link #getLeft() left} position.
@@ -10502,9 +10550,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    }
    /**
     * The depth location of this view relative to its parent.
     * The depth location of this view relative to its {@link #getElevation() elevation}.
     *
     * @return The depth of this view relative to its parent.
     * @return The depth of this view relative to its elevation.
     */
    @ViewDebug.ExportedProperty(category = "drawing")
    public float getTranslationZ() {
@@ -10512,7 +10560,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    }
    /**
     * Sets the depth location of this view relative to its parent.
     * Sets the depth location of this view relative to its {@link #getElevation() elevation}.
     *
     * @attr ref android.R.styleable#View_translationZ
     */
@@ -11184,7 +11232,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            }
            // Damage the entire IsolatedZVolume recieving this view's shadow.
            if (isHardwareAccelerated() && getTranslationZ() != 0) {
            if (isHardwareAccelerated() && getZ() != 0) {
                damageShadowReceiver();
            }
        }
@@ -11260,7 +11308,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        } else {
            damageInParent();
        }
        if (isHardwareAccelerated() && invalidateParent && getTranslationZ() != 0) {
        if (isHardwareAccelerated() && invalidateParent && getZ() != 0) {
            damageShadowReceiver();
        }
    }
+34 −2
Original line number Diff line number Diff line
@@ -144,10 +144,11 @@ public class ViewPropertyAnimator {
    private static final int ROTATION_Y     = 0x0080;
    private static final int X              = 0x0100;
    private static final int Y              = 0x0200;
    private static final int ALPHA          = 0x0400;
    private static final int Z              = 0x0400;
    private static final int ALPHA          = 0x0800;

    private static final int TRANSFORM_MASK = TRANSLATION_X | TRANSLATION_Y | TRANSLATION_Z |
            SCALE_X | SCALE_Y | ROTATION | ROTATION_X | ROTATION_Y | X | Y;
            SCALE_X | SCALE_Y | ROTATION | ROTATION_X | ROTATION_Y | X | Y | Z;

    /**
     * The mechanism by which the user can request several properties that are then animated
@@ -469,6 +470,32 @@ public class ViewPropertyAnimator {
        return this;
    }

    /**
     * This method will cause the View's <code>z</code> property to be animated to the
     * specified value. Animations already running on the property will be canceled.
     *
     * @param value The value to be animated to.
     * @see View#setZ(float)
     * @return This object, allowing calls to methods in this class to be chained.
     */
    public ViewPropertyAnimator z(float value) {
        animateProperty(Z, value);
        return this;
    }

    /**
     * This method will cause the View's <code>z</code> property to be animated by the
     * specified value. Animations already running on the property will be canceled.
     *
     * @param value The amount to be animated by, as an offset from the current value.
     * @see View#setZ(float)
     * @return This object, allowing calls to methods in this class to be chained.
     */
    public ViewPropertyAnimator zBy(float value) {
        animatePropertyBy(Z, value);
        return this;
    }

    /**
     * This method will cause the View's <code>rotation</code> property to be animated to the
     * specified value. Animations already running on the property will be canceled.
@@ -957,6 +984,9 @@ public class ViewPropertyAnimator {
            case Y:
                renderNode.setTranslationY(value - mView.mTop);
                break;
            case Z:
                renderNode.setTranslationZ(value - renderNode.getElevation());
                break;
            case ALPHA:
                info.mAlpha = value;
                renderNode.setAlpha(value);
@@ -993,6 +1023,8 @@ public class ViewPropertyAnimator {
                return mView.mLeft + node.getTranslationX();
            case Y:
                return mView.mTop + node.getTranslationY();
            case Z:
                return node.getElevation() + node.getTranslationZ();
            case ALPHA:
                return mView.mTransformationInfo.mAlpha;
        }
+14 −0
Original line number Diff line number Diff line
@@ -164,6 +164,12 @@ static void android_view_RenderNode_setHasOverlappingRendering(JNIEnv* env,
    renderNode->mutateStagingProperties().setHasOverlappingRendering(hasOverlappingRendering);
}

static void android_view_RenderNode_setElevation(JNIEnv* env,
        jobject clazz, jlong renderNodePtr, float elevation) {
    RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr);
    renderNode->mutateStagingProperties().setElevation(elevation);
}

static void android_view_RenderNode_setTranslationX(JNIEnv* env,
        jobject clazz, jlong renderNodePtr, float tx) {
    RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr);
@@ -331,6 +337,12 @@ static jfloat android_view_RenderNode_getScaleY(JNIEnv* env,
    return renderNode->stagingProperties().getScaleY();
}

static jfloat android_view_RenderNode_getElevation(JNIEnv* env,
        jobject clazz, jlong renderNodePtr) {
    RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr);
    return renderNode->stagingProperties().getElevation();
}

static jfloat android_view_RenderNode_getTranslationX(JNIEnv* env,
        jobject clazz, jlong renderNodePtr) {
    RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr);
@@ -457,6 +469,7 @@ static JNINativeMethod gMethods[] = {
    { "nSetAlpha",             "(JF)V",  (void*) android_view_RenderNode_setAlpha },
    { "nSetHasOverlappingRendering", "(JZ)V",
            (void*) android_view_RenderNode_setHasOverlappingRendering },
    { "nSetElevation",         "(JF)V",  (void*) android_view_RenderNode_setElevation },
    { "nSetTranslationX",      "(JF)V",  (void*) android_view_RenderNode_setTranslationX },
    { "nSetTranslationY",      "(JF)V",  (void*) android_view_RenderNode_setTranslationY },
    { "nSetTranslationZ",      "(JF)V",  (void*) android_view_RenderNode_setTranslationZ },
@@ -485,6 +498,7 @@ static JNINativeMethod gMethods[] = {
    { "nGetCameraDistance",       "(J)F",  (void*) android_view_RenderNode_getCameraDistance },
    { "nGetScaleX",               "(J)F",  (void*) android_view_RenderNode_getScaleX },
    { "nGetScaleY",               "(J)F",  (void*) android_view_RenderNode_getScaleY },
    { "nGetElevation",            "(J)F",  (void*) android_view_RenderNode_getElevation },
    { "nGetTranslationX",         "(J)F",  (void*) android_view_RenderNode_getTranslationX },
    { "nGetTranslationY",         "(J)F",  (void*) android_view_RenderNode_getTranslationY },
    { "nGetTranslationZ",         "(J)F",  (void*) android_view_RenderNode_getTranslationZ },
Loading