From 31aada50f7968f93f55875bd68a7fb0022b81dea Mon Sep 17 00:00:00 2001 From: John Hoford Date: Thu, 13 Jan 2022 11:14:33 -0800 Subject: [PATCH] revert flow (#491) --- .../src/main/res/values/attrs.xml | 2 +- .../core/motion/utils/Utils.java | 10 +++++++ .../constraintlayout/core/widgets/Flow.java | 30 +++++++++++++------ 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/constraintlayout/constraintlayout/src/main/res/values/attrs.xml b/constraintlayout/constraintlayout/src/main/res/values/attrs.xml index ad235ce1d..2b7111ddc 100644 --- a/constraintlayout/constraintlayout/src/main/res/values/attrs.xml +++ b/constraintlayout/constraintlayout/src/main/res/values/attrs.xml @@ -245,7 +245,7 @@ - + diff --git a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/utils/Utils.java b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/utils/Utils.java index 825b83fc0..eb156ac88 100644 --- a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/utils/Utils.java +++ b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/utils/Utils.java @@ -64,6 +64,13 @@ public static int rgbaTocColor(float r, float g, float b, float a) { int color = (ia << 24) | (ir << 16) | (ig << 8) | ib; return color; } + public interface DebugHandle { + void message(String str); + } + static DebugHandle ourHandle; + public static void setDebugHandle(DebugHandle handle) { + ourHandle = handle; + } public static void logStack(String msg, int n) { StackTraceElement[] st = new Throwable().getStackTrace(); String s = " "; @@ -83,6 +90,9 @@ public static void log(String str) { String npad = " ".substring(Integer.toString(s.getLineNumber()).length()); String ss = ".(" + s.getFileName() + ":" + s.getLineNumber() + ")" + npad +methodName; System.out.println(ss + " " + str); + if (ourHandle != null) { + ourHandle.message(ss + " " + str); + } } } diff --git a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/widgets/Flow.java b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/widgets/Flow.java index ec03bf05b..0b4ff323f 100644 --- a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/widgets/Flow.java +++ b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/widgets/Flow.java @@ -43,7 +43,7 @@ public class Flow extends VirtualLayout { public static final int WRAP_NONE = 0; public static final int WRAP_CHAIN = 1; public static final int WRAP_ALIGNED = 2; - public static final int WRAP_CHAIN_DEPRECATED = 3; + public static final int WRAP_CHAIN_NEW = 3; private int mHorizontalStyle = UNKNOWN; private int mVerticalStyle = UNKNOWN; @@ -170,6 +170,9 @@ public void setWrapMode(int value) { public void setMaxElementsWrap(int value) { mMaxElementsWrap = value; } + public float getMaxElementsWrap() { + return mMaxElementsWrap; + } ///////////////////////////////////////////////////////////////////////////////////////////// // Utility methods ///////////////////////////////////////////////////////////////////////////////////////////// @@ -293,14 +296,15 @@ public void measure(int widthMode, int widthSize, int heightMode, int heightSize measureChainWrap(widgets, count, mOrientation, max, measured); } break; - case WRAP_CHAIN_DEPRECATED: { - measureChainWrap_broken(widgets, count, mOrientation, max, measured); - } - break; case WRAP_NONE: { measureNoWrap(widgets, count, mOrientation, max, measured); } break; + case WRAP_CHAIN_NEW: { + measureChainWrap_new(widgets, count, mOrientation, max, measured); + } + break; + } width = measured[HORIZONTAL] + paddingLeft + paddingRight; @@ -785,7 +789,7 @@ private void recomputeDimensions() { * @param max the maximum available space * @param measured output parameters -- will contain the resulting measure */ - private void measureChainWrap_broken(ConstraintWidget[] widgets, int count, int orientation, int max, int[] measured) { + private void measureChainWrap(ConstraintWidget[] widgets, int count, int orientation, int max, int[] measured) { if (count == 0) { return; } @@ -926,18 +930,18 @@ private void measureChainWrap_broken(ConstraintWidget[] widgets, int count, int measured[VERTICAL] = maxHeight; } ///////////////////////////////////////////////////////////////////////////////////////////// - // Measure Chain Wrap + // Measure Chain Wrap new ///////////////////////////////////////////////////////////////////////////////////////////// /** - * Measure the virtual layout using a list of chains for the children + * Measure the virtual layout using a list of chains for the children in new "fixed way" * @param widgets list of widgets * @param count * @param orientation the layout orientation (horizontal or vertical) * @param max the maximum available space * @param measured output parameters -- will contain the resulting measure */ - private void measureChainWrap(ConstraintWidget[] widgets, int count, int orientation, int max, int[] measured) { + private void measureChainWrap_new(ConstraintWidget[] widgets, int count, int orientation, int max, int[] measured) { if (count == 0) { return; } @@ -1406,6 +1410,14 @@ public void addToSolver(LinearSystem system, boolean optimize) { case WRAP_ALIGNED: { createAlignedConstraints(isInRtl); } + break; + case WRAP_CHAIN_NEW: { + final int count = mChainList.size(); + for (int i = 0; i < count; i++) { + WidgetsList list = mChainList.get(i); + list.createConstraints(isInRtl, i, i == count - 1); + } + } break; } needsCallbackFromSolver(false); }