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

Commit 7676e403 authored by Deepanshu Gupta's avatar Deepanshu Gupta Committed by Android (Google) Code Review
Browse files

Merge changes I4c215676,Ib476302c,I0aede288,I9241dec7,Ibe7167a6, ... into mnc-dev

* changes:
  Update status bar time.
  Fix imports.
  Add MockView constructor used by LayoutInflater.
  Poor implementation of Path.approximate()
  Include EpicenterTranslateClipReveal in LayoutLib
  Fix theme namespace in tests.
  LayoutLib: fix layout when nav bar is absent.
  LayoutLib: Fix Status/Navigation Bar color.
parents 20a5d331 36e3fa55
Loading
Loading
Loading
Loading
+53 −3
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import com.android.layoutlib.bridge.Bridge;
import com.android.layoutlib.bridge.impl.DelegateManager;
import com.android.tools.layoutlib.annotations.LayoutlibDelegate;

import android.annotation.NonNull;
import android.graphics.Path.Direction;
import android.graphics.Path.FillType;

@@ -30,10 +31,12 @@ import java.awt.geom.Arc2D;
import java.awt.geom.Area;
import java.awt.geom.Ellipse2D;
import java.awt.geom.GeneralPath;
import java.awt.geom.Path2D;
import java.awt.geom.PathIterator;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RoundRectangle2D;
import java.util.ArrayList;

/**
 * Delegate implementing the native methods of android.graphics.Path
@@ -56,7 +59,7 @@ public final class Path_Delegate {

    // ---- delegate data ----
    private FillType mFillType = FillType.WINDING;
    private GeneralPath mPath = new GeneralPath();
    private Path2D mPath = new Path2D.Double();

    private float mLastX = 0;
    private float mLastY = 0;
@@ -486,8 +489,54 @@ public final class Path_Delegate {

    @LayoutlibDelegate
    /*package*/ static float[] native_approximate(long nPath, float error) {
        Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, "Path.approximate() not supported", null);
        Bridge.getLog().warning(LayoutLog.TAG_UNSUPPORTED, "Path.approximate() not fully supported",
                null);
        Path_Delegate pathDelegate = sManager.getDelegate(nPath);
        if (pathDelegate == null) {
            return null;
        }
        PathIterator pathIterator = pathDelegate.mPath.getPathIterator(null);
        float[] tmp = new float[6];
        float[] coords = new float[6];
        boolean isFirstPoint = true;
        while (!pathIterator.isDone()) {
            int type = pathIterator.currentSegment(tmp);
            switch (type) {
                case PathIterator.SEG_MOVETO:
                case PathIterator.SEG_LINETO:
                    store(coords, tmp, 1, isFirstPoint);
                    break;
                case PathIterator.SEG_QUADTO:
                    store(coords, tmp, 2, isFirstPoint);
                    break;
                case PathIterator.SEG_CUBICTO:
                    store(coords, tmp, 3, isFirstPoint);
                    break;
                case PathIterator.SEG_CLOSE:
                    // No points returned.
            }
            isFirstPoint = false;
            pathIterator.next();
        }
        if (isFirstPoint) {
            // No points found
            return new float[0];
        } else {
            return coords;
        }
    }

    private static void store(float[] src, float[] dst, int count, boolean isFirst) {
        if (isFirst) {
            dst[0] = 0;
            dst[1] = src[0];
            dst[2] = src[1];
        }
        if (count > 1 || !isFirst) {
            dst[3] = 1;
            dst[4] = src[2 * count];
            dst[5] = src[2 * count + 1];
        }
    }

    // ---- Private helper methods ----
@@ -522,6 +571,7 @@ public final class Path_Delegate {
        throw new IllegalArgumentException();
    }

    @NonNull
    private static Direction getDirection(int direction) {
        for (Direction d : Direction.values()) {
            if (direction == d.nativeInt) {
+4 −0
Original line number Diff line number Diff line
@@ -30,6 +30,10 @@ import android.widget.TextView;
 */
public class MockView extends TextView {

    public MockView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public MockView(Context context, AttributeSet attrs, int defStyle) {
        this(context, attrs, defStyle, 0);
    }
+2 −7
Original line number Diff line number Diff line
@@ -18,14 +18,12 @@ package com.android.layoutlib.bridge.android.support;

import com.android.ide.common.rendering.api.LayoutLog;
import com.android.layoutlib.bridge.Bridge;
import com.android.layoutlib.bridge.util.ReflectionUtils.ReflectionException;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.view.View;

import java.lang.reflect.Method;

import static com.android.layoutlib.bridge.util.ReflectionUtils.ReflectionException;
import static com.android.layoutlib.bridge.util.ReflectionUtils.getMethod;
import static com.android.layoutlib.bridge.util.ReflectionUtils.invoke;

@@ -53,10 +51,7 @@ public class DesignLibUtil {
            return;
        }
        try {
            Method setTitle = getMethod(view.getClass(), "setTitle", CharSequence.class);
            if (setTitle != null) {
                invoke(setTitle, view, title);
            }
            invoke(getMethod(view.getClass(), "setTitle", CharSequence.class), view, title);
        } catch (ReflectionException e) {
            Bridge.getLog().warning(LayoutLog.TAG_INFO,
                    "Error occurred while trying to set title.", e);
+3 −10
Original line number Diff line number Diff line
@@ -21,16 +21,13 @@ import com.android.ide.common.rendering.api.LayoutlibCallback;
import com.android.layoutlib.bridge.Bridge;
import com.android.layoutlib.bridge.android.BridgeContext;
import com.android.layoutlib.bridge.android.RenderParamsFlags;
import com.android.layoutlib.bridge.util.ReflectionUtils;
import com.android.layoutlib.bridge.util.ReflectionUtils.ReflectionException;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
import android.view.View;

import java.lang.reflect.Method;

import static com.android.layoutlib.bridge.util.ReflectionUtils.ReflectionException;
import static com.android.layoutlib.bridge.util.ReflectionUtils.getCause;
import static com.android.layoutlib.bridge.util.ReflectionUtils.getMethod;
import static com.android.layoutlib.bridge.util.ReflectionUtils.invoke;
@@ -98,8 +95,7 @@ public class RecyclerViewUtil {

    @Nullable
    private static Object getLayoutManager(View recyclerView) throws ReflectionException {
        Method getLayoutManager = getMethod(recyclerView.getClass(), "getLayoutManager");
        return getLayoutManager != null ? invoke(getLayoutManager, recyclerView) : null;
        return invoke(getMethod(recyclerView.getClass(), "getLayoutManager"), recyclerView);
    }

    @Nullable
@@ -127,10 +123,7 @@ public class RecyclerViewUtil {
    private static void setProperty(@NonNull Object object, @NonNull Class<?> propertyClass,
            @Nullable Object propertyValue, @NonNull String propertySetter)
            throws ReflectionException {
        Method setter = getMethod(object.getClass(), propertySetter, propertyClass);
        if (setter != null) {
            invoke(setter, object, propertyValue);
        }
        invoke(getMethod(object.getClass(), propertySetter, propertyClass), object, propertyValue);
    }

    /**
+5 −2
Original line number Diff line number Diff line
@@ -74,8 +74,8 @@ public class Config {
    }

    public static String getTime(int platformVersion) {
        if (isGreaterOrEqual(platformVersion, LOLLIPOP_MR1)) {
            return "5:10";
        if (isGreaterOrEqual(platformVersion, MNC)) {
            return "6:00";
        }
        if (platformVersion < GINGERBREAD) {
            return "2:20";
@@ -95,6 +95,9 @@ public class Config {
        if (platformVersion < LOLLIPOP_MR1) {
            return "5:00";
        }
        if (platformVersion < MNC) {
            return "5:10";
        }
        // Should never happen.
        return "4:04";
    }
Loading