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

Commit 2b95c241 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Added more @RemotableViewMethod methods, mutate ImageView.

Catch some View methods missed during the first pass of
marking with @RemotableViewMethod annotation.  Also adds new
ImageView.setColorFilter(int) to match the android:tint XML
attribute.

When ImageView touches ColorFilter or alpha, mutate the
underlying Drawable. Fix NPE in StateListDrawable.mutate().
parent 6a70d7d1
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -201490,6 +201490,19 @@
<parameter name="mode" type="android.graphics.PorterDuff.Mode">
</parameter>
</method>
<method name="setColorFilter"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="color" type="int">
</parameter>
</method>
<method name="setColorFilter"
 return="void"
 abstract="false"
+1 −0
Original line number Diff line number Diff line
@@ -3050,6 +3050,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
     *
     * @param enabled True if this view is enabled, false otherwise.
     */
    @RemotableViewMethod
    public void setEnabled(boolean enabled) {
        if (enabled == isEnabled()) return;

+23 −2
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.util.AttributeSet;
import android.util.Log;
import android.view.RemotableViewMethod;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
@@ -69,6 +70,7 @@ public class ImageView extends View {
    private ColorFilter mColorFilter;
    private int mAlpha = 255;
    private int mViewAlphaScale = 256;
    private boolean mColorMod = false;

    private Drawable mDrawable = null;
    private int[] mState = null;
@@ -138,7 +140,7 @@ public class ImageView extends View {

        int tint = a.getInt(com.android.internal.R.styleable.ImageView_tint, 0);
        if (tint != 0) {
            setColorFilter(tint, PorterDuff.Mode.SRC_ATOP);
            setColorFilter(tint);
        }
        
        mCropToPadding = a.getBoolean(
@@ -877,6 +879,18 @@ public class ImageView extends View {
        setColorFilter(new PorterDuffColorFilter(color, mode));
    }

    /**
     * Set a tinting option for the image. Assumes
     * {@link PorterDuff.Mode#SRC_ATOP} blending mode.
     *
     * @param color Color tint to apply.
     * @attr ref android.R.styleable#ImageView_tint
     */
    @RemotableViewMethod
    public final void setColorFilter(int color) {
        setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
    }

    public final void clearColorFilter() {
        setColorFilter(null);
    }
@@ -889,22 +903,29 @@ public class ImageView extends View {
    public void setColorFilter(ColorFilter cf) {
        if (mColorFilter != cf) {
            mColorFilter = cf;
            mColorMod = true;
            applyColorMod();
            invalidate();
        }
    }

    @RemotableViewMethod
    public void setAlpha(int alpha) {
        alpha &= 0xFF;          // keep it legal
        if (mAlpha != alpha) {
            mAlpha = alpha;
            mColorMod = true;
            applyColorMod();
            invalidate();
        }
    }

    private void applyColorMod() {
        if (mDrawable != null) {
        // Only mutate and apply when modifications have occurred. This should
        // not reset the mColorMod flag, since these filters need to be
        // re-applied if the Drawable is changed.
        if (mDrawable != null && mColorMod) {
            mDrawable = mDrawable.mutate();
            mDrawable.setColorFilter(mColorFilter);
            mDrawable.setAlpha(mAlpha * mViewAlphaScale >> 8);
        }
+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ import android.widget.RemoteViews.RemoteView;
@RemoteView
public class ViewFlipper extends ViewAnimator {
    private static final String TAG = "ViewFlipper";
    private static final boolean LOGD = true;
    private static final boolean LOGD = false;

    private static final int DEFAULT_INTERVAL = 3000;

+4 −1
Original line number Diff line number Diff line
@@ -238,7 +238,10 @@ public class StateListDrawable extends DrawableContainer {
            final int count = sets.length;
            mStateListState.mStateSets = new int[count][];
            for (int i = 0; i < count; i++) {
                mStateListState.mStateSets[i] = sets[i].clone();
                final int[] set = sets[i];
                if (set != null) {
                    mStateListState.mStateSets[i] = set.clone();
                }
            }
            mMutated = true;
        }