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

Commit ee3e1603 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Fix animations, padding in RTL mode.

Show directory animations coming in from left-side when in RTL
language.  Also fix NinePatchDrawable to correctly mirror its padding
when auto-mirrored, and fix InsetDrawable to propagate the layout
direction to the wrapped Drawable.

Bug: 10987190, 11030793
Change-Id: I1213802a07d0c4ced93438df1e6ddf5aed3df677
parent 7aa7601c
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -203,6 +203,12 @@ public class InsetDrawable extends Drawable implements Drawable.Callback
        mInsetState.mDrawable.setColorFilter(cf);
    }

    /** {@hide} */
    @Override
    public void setLayoutDirection(int layoutDirection) {
        mInsetState.mDrawable.setLayoutDirection(layoutDirection);
    }

    @Override
    public int getOpacity() {
        return mInsetState.mDrawable.getOpacity();
+18 −6
Original line number Diff line number Diff line
@@ -219,16 +219,15 @@ public class NinePatchDrawable extends Drawable {
    @Override
    public void draw(Canvas canvas) {
        final Rect bounds = getBounds();
        final boolean needMirroring = isAutoMirrored() &&
                getLayoutDirection() == LayoutDirection.RTL;
        if (needMirroring) {
        final boolean needsMirroring = needsMirroring();
        if (needsMirroring) {
            canvas.save();
            // Mirror the 9patch
            canvas.translate(bounds.right - bounds.left, 0);
            canvas.scale(-1.0f, 1.0f);
        }
        mNinePatch.draw(canvas, bounds, mPaint);
        if (needMirroring) {
        if (needsMirroring) {
            canvas.restore();
        }
    }
@@ -240,7 +239,11 @@ public class NinePatchDrawable extends Drawable {

    @Override
    public boolean getPadding(Rect padding) {
        if (needsMirroring()) {
            padding.set(mPadding.right, mPadding.top, mPadding.left, mPadding.bottom);
        } else {
            padding.set(mPadding);
        }
        return true;
    }

@@ -249,8 +252,13 @@ public class NinePatchDrawable extends Drawable {
     */
    @Override
    public Insets getOpticalInsets() {
        if (needsMirroring()) {
            return Insets.of(mOpticalInsets.right, mOpticalInsets.top, mOpticalInsets.right,
                    mOpticalInsets.bottom);
        } else {
            return mOpticalInsets;
        }
    }

    @Override
    public void setAlpha(int alpha) {
@@ -297,6 +305,10 @@ public class NinePatchDrawable extends Drawable {
        mNinePatchState.mAutoMirrored = mirrored;
    }

    private boolean needsMirroring() {
        return isAutoMirrored() && getLayoutDirection() == LayoutDirection.RTL;
    }

    @Override
    public boolean isAutoMirrored() {
        return mNinePatchState.mAutoMirrored;
+22 −0
Original line number Diff line number Diff line
<!-- Copyright (C) 2013 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.
-->

<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
    android:valueFrom="-1"
    android:valueTo="0"
    android:propertyName="position"
    android:valueType="floatType"
    android:duration="@android:integer/config_mediumAnimTime"
    android:interpolator="@android:interpolator/decelerate_quad" />
+22 −0
Original line number Diff line number Diff line
<!-- Copyright (C) 2013 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.
-->

<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
    android:valueFrom="0"
    android:valueTo="-1"
    android:propertyName="position"
    android:valueType="floatType"
    android:duration="@android:integer/config_mediumAnimTime"
    android:interpolator="@android:interpolator/accelerate_quad" />
Loading