Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

Commit 31aada5

Browse files
authored
revert flow (#491)
1 parent d8867c8 commit 31aada5

File tree

3 files changed

+32
-10
lines changed
  • constraintlayout

3 files changed

+32
-10
lines changed

constraintlayout/constraintlayout/src/main/res/values/attrs.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@
245245
<enum name="none" value="0" />
246246
<enum name="chain" value="1" />
247247
<enum name="aligned" value="2" />
248-
<enum name="deprecatedChain" value="3" />
248+
<enum name="chain2" value="3" />
249249
</attr>
250250

251251
<!-- if defined, wrap after max elements -->

constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/utils/Utils.java

+10
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ public static int rgbaTocColor(float r, float g, float b, float a) {
6464
int color = (ia << 24) | (ir << 16) | (ig << 8) | ib;
6565
return color;
6666
}
67+
public interface DebugHandle {
68+
void message(String str);
69+
}
70+
static DebugHandle ourHandle;
71+
public static void setDebugHandle(DebugHandle handle) {
72+
ourHandle = handle;
73+
}
6774
public static void logStack(String msg, int n) {
6875
StackTraceElement[] st = new Throwable().getStackTrace();
6976
String s = " ";
@@ -83,6 +90,9 @@ public static void log(String str) {
8390
String npad = " ".substring(Integer.toString(s.getLineNumber()).length());
8491
String ss = ".(" + s.getFileName() + ":" + s.getLineNumber() + ")" + npad +methodName;
8592
System.out.println(ss + " " + str);
93+
if (ourHandle != null) {
94+
ourHandle.message(ss + " " + str);
95+
}
8696
}
8797

8898
}

constraintlayout/core/src/main/java/androidx/constraintlayout/core/widgets/Flow.java

+21-9
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class Flow extends VirtualLayout {
4343
public static final int WRAP_NONE = 0;
4444
public static final int WRAP_CHAIN = 1;
4545
public static final int WRAP_ALIGNED = 2;
46-
public static final int WRAP_CHAIN_DEPRECATED = 3;
46+
public static final int WRAP_CHAIN_NEW = 3;
4747

4848
private int mHorizontalStyle = UNKNOWN;
4949
private int mVerticalStyle = UNKNOWN;
@@ -170,6 +170,9 @@ public void setWrapMode(int value) {
170170

171171
public void setMaxElementsWrap(int value) { mMaxElementsWrap = value; }
172172

173+
public float getMaxElementsWrap() {
174+
return mMaxElementsWrap;
175+
}
173176
/////////////////////////////////////////////////////////////////////////////////////////////
174177
// Utility methods
175178
/////////////////////////////////////////////////////////////////////////////////////////////
@@ -293,14 +296,15 @@ public void measure(int widthMode, int widthSize, int heightMode, int heightSize
293296
measureChainWrap(widgets, count, mOrientation, max, measured);
294297
}
295298
break;
296-
case WRAP_CHAIN_DEPRECATED: {
297-
measureChainWrap_broken(widgets, count, mOrientation, max, measured);
298-
}
299-
break;
300299
case WRAP_NONE: {
301300
measureNoWrap(widgets, count, mOrientation, max, measured);
302301
}
303302
break;
303+
case WRAP_CHAIN_NEW: {
304+
measureChainWrap_new(widgets, count, mOrientation, max, measured);
305+
}
306+
break;
307+
304308
}
305309

306310
width = measured[HORIZONTAL] + paddingLeft + paddingRight;
@@ -785,7 +789,7 @@ private void recomputeDimensions() {
785789
* @param max the maximum available space
786790
* @param measured output parameters -- will contain the resulting measure
787791
*/
788-
private void measureChainWrap_broken(ConstraintWidget[] widgets, int count, int orientation, int max, int[] measured) {
792+
private void measureChainWrap(ConstraintWidget[] widgets, int count, int orientation, int max, int[] measured) {
789793
if (count == 0) {
790794
return;
791795
}
@@ -926,18 +930,18 @@ private void measureChainWrap_broken(ConstraintWidget[] widgets, int count, int
926930
measured[VERTICAL] = maxHeight;
927931
}
928932
/////////////////////////////////////////////////////////////////////////////////////////////
929-
// Measure Chain Wrap
933+
// Measure Chain Wrap new
930934
/////////////////////////////////////////////////////////////////////////////////////////////
931935

932936
/**
933-
* Measure the virtual layout using a list of chains for the children
937+
* Measure the virtual layout using a list of chains for the children in new "fixed way"
934938
* @param widgets list of widgets
935939
* @param count
936940
* @param orientation the layout orientation (horizontal or vertical)
937941
* @param max the maximum available space
938942
* @param measured output parameters -- will contain the resulting measure
939943
*/
940-
private void measureChainWrap(ConstraintWidget[] widgets, int count, int orientation, int max, int[] measured) {
944+
private void measureChainWrap_new(ConstraintWidget[] widgets, int count, int orientation, int max, int[] measured) {
941945
if (count == 0) {
942946
return;
943947
}
@@ -1406,6 +1410,14 @@ public void addToSolver(LinearSystem system, boolean optimize) {
14061410
case WRAP_ALIGNED: {
14071411
createAlignedConstraints(isInRtl);
14081412
}
1413+
break;
1414+
case WRAP_CHAIN_NEW: {
1415+
final int count = mChainList.size();
1416+
for (int i = 0; i < count; i++) {
1417+
WidgetsList list = mChainList.get(i);
1418+
list.createConstraints(isInRtl, i, i == count - 1);
1419+
}
1420+
} break;
14091421
}
14101422
needsCallbackFromSolver(false);
14111423
}

0 commit comments

Comments
 (0)