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

Commit c9b8f95c authored by Deepanshu Gupta's avatar Deepanshu Gupta
Browse files

Fix Switch colors

The conversion of the PorterDuff mode from int to enum was incorrect
resulting in the wrong PorterDuff Mode being used.

Change-Id: I7607d505b6e4382e6101869971154f6a77db279c
parent c5b905f5
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import com.android.layoutlib.bridge.Bridge;

import android.graphics.BlendComposite;
import android.graphics.BlendComposite.BlendingMode;
import android.graphics.PorterDuff;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffColorFilter_Delegate;
import android.graphics.PorterDuffXfermode_Delegate;
@@ -34,6 +35,8 @@ import java.awt.Composite;
 */
public final class PorterDuffUtility {

    private static final int MODES_COUNT = Mode.values().length;

    // Make the class non-instantiable.
    private PorterDuffUtility() {
    }
@@ -43,12 +46,11 @@ public final class PorterDuffUtility {
     * {@link Mode#SRC_OVER} for invalid modes.
     */
    public static Mode getPorterDuffMode(int porterDuffMode) {
        Mode[] values = Mode.values();
        if (porterDuffMode >= 0 && porterDuffMode < values.length) {
            return values[porterDuffMode];
        if (porterDuffMode >= 0 && porterDuffMode < MODES_COUNT) {
            return PorterDuff.intToMode(porterDuffMode);
        }
        Bridge.getLog().error(LayoutLog.TAG_BROKEN,
                String.format("Unknown PorterDuff.Mode: %1$d", porterDuffMode), null /*data*/);
                String.format("Unknown PorterDuff.Mode: %1$d", porterDuffMode), null);
        assert false;
        return Mode.SRC_OVER;
    }