diff --git a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/MotionScene.java b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/MotionScene.java index b7782ffa7..487ad831e 100644 --- a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/MotionScene.java +++ b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/MotionScene.java @@ -93,6 +93,7 @@ public class MotionScene { private static final String ONSWIPE_TAG = "OnSwipe"; private static final String ONCLICK_TAG = "OnClick"; private static final String STATESET_TAG = "StateSet"; + private static final String INCLUDE_TAG_UC = "Include"; private static final String INCLUDE_TAG = "include"; private static final String KEYFRAMESET_TAG = "KeyFrameSet"; private static final String CONSTRAINTSET_TAG = "ConstraintSet"; @@ -1089,6 +1090,7 @@ private void load(Context context, int resourceId) { parseConstraintSet(context, parser); break; case INCLUDE_TAG: + case INCLUDE_TAG_UC: parseInclude(context, parser); break; case KEYFRAMESET_TAG: @@ -1717,7 +1719,6 @@ boolean getMoveWhenScrollAtTop() { * read the constraints from the inflation of the ConstraintLayout * If the constraintset does not contain information about a view this information is used * as a "fallback" position. - * * @param motionLayout */ void readFallback(MotionLayout motionLayout) { @@ -1728,11 +1729,7 @@ void readFallback(MotionLayout motionLayout) { Log.e(TAG, "Cannot be derived from yourself"); return; } - readConstraintChain(key); - } - for (int i = 0; i < mConstraintSetMap.size(); i++) { - ConstraintSet cs = mConstraintSetMap.valueAt(i); - cs.readFallback(motionLayout); + readConstraintChain(key,motionLayout); } } @@ -1758,13 +1755,16 @@ private boolean hasCycleDependency(int key) { } /** + * Recursive decent of the deriveConstraintsFrom tree reading the motionLayout if + * needed. + * * @param key */ - private void readConstraintChain(int key) { + private void readConstraintChain(int key, MotionLayout motionLayout) { + ConstraintSet cs = mConstraintSetMap.get(key); int derivedFromId = mDeriveMap.get(key); if (derivedFromId > 0) { - readConstraintChain(mDeriveMap.get(key)); - ConstraintSet cs = mConstraintSetMap.get(key); + readConstraintChain(derivedFromId, motionLayout); ConstraintSet derivedFrom = mConstraintSetMap.get(derivedFromId); if (derivedFrom == null) { Log.e(TAG, "ERROR! invalid deriveConstraintsFrom: @id/" + @@ -1772,8 +1772,10 @@ private void readConstraintChain(int key) { return; } cs.readFallback(derivedFrom); - mDeriveMap.put(key, -1); + } else { + cs.readFallback(motionLayout); } + cs.applyDeltaFrom(cs); } public static String stripID(String id) { diff --git a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/widget/ConstraintSet.java b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/widget/ConstraintSet.java index 61676a179..a94b857c0 100644 --- a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/widget/ConstraintSet.java +++ b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/widget/ConstraintSet.java @@ -577,7 +577,6 @@ public void readFallback(ConstraintSet set) { if (constraint == null) { continue; } - constraint.mDelta = parent.mDelta; if (!constraint.layout.mApply) { constraint.layout.copyFrom(parent.layout); } @@ -668,14 +667,17 @@ public void readFallback(ConstraintLayout constraintLayout) { } } - for (Constraint constraint : mConstraints.values()) { - if (constraint.mDelta != null) { - constraint.mDelta.applyDelta(constraint); + } + + public void applyDeltaFrom(ConstraintSet cs) { + for (Constraint from : cs.mConstraints.values()) { + if (from.mDelta != null) { + Constraint constraint = getConstraint(from.mViewId); + from.mDelta.applyDelta(constraint); } } } - /** * Parse the constraint dimension attribute * diff --git a/projects/MotionLayoutVerification/app/src/main/java/android/support/constraint/app/VerificationActivity.java b/projects/MotionLayoutVerification/app/src/main/java/android/support/constraint/app/VerificationActivity.java index 6e5d3c23c..fa3f353d8 100644 --- a/projects/MotionLayoutVerification/app/src/main/java/android/support/constraint/app/VerificationActivity.java +++ b/projects/MotionLayoutVerification/app/src/main/java/android/support/constraint/app/VerificationActivity.java @@ -97,7 +97,7 @@ public class VerificationActivity extends AppCompatActivity implements View.OnCl private static boolean REVERSE = false; - private final String RUN_FIRST = "verification_501"; + private final String RUN_FIRST = "verification_098"; private final String LAYOUTS_MATCHES = "v.*_.*"; private static String SHOW_FIRST = ""; diff --git a/projects/MotionLayoutVerification/app/src/main/res/layout/verification_098.xml b/projects/MotionLayoutVerification/app/src/main/res/layout/verification_098.xml new file mode 100644 index 000000000..5425704fd --- /dev/null +++ b/projects/MotionLayoutVerification/app/src/main/res/layout/verification_098.xml @@ -0,0 +1,78 @@ + + + +