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

Fixes apr20 #212

Merged
merged 3 commits into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
}
}

Expand All @@ -1758,22 +1755,27 @@ 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/" +
Debug.getName(mMotionLayout.getContext(), derivedFromId));
return;
}
cs.readFallback(derivedFrom);
mDeriveMap.put(key, -1);
} else {
cs.readFallback(motionLayout);
}
cs.applyDeltaFrom(cs);
}

public static String stripID(String id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutDescription="@xml/verification_scene_098"
app:layout_optimizationLevel="none"
app:motionDebug="SHOW_PROGRESS"
tools:context=".VerificationActivity">

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginLeft="24dp"
android:layout_marginTop="24dp"
android:text="state A"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:layout_marginEnd="24dp"
android:layout_marginRight="24dp"
android:text="state B"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginLeft="24dp"
android:layout_marginBottom="24dp"
android:text="state C"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />

<TextView
android:id="@+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:layout_marginRight="24dp"
android:layout_marginBottom="24dp"
android:text="state D"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />

<TextView
android:id="@+id/textView14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test of Includes"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" />


</androidx.constraintlayout.motion.widget.MotionLayout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<MotionScene
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto">

<Include motion:constraintSet="@xml/verification_scene_098l"/>
<!-- <ConstraintSet android:id="@+id/left" >-->


<!-- </ConstraintSet>-->
<Include motion:constraintSet="@xml/verification_scene_098r"/>

<Transition
motion:constraintSetEnd="@+id/b"
motion:constraintSetStart="@id/a"
motion:duration="1000">
<OnClick motion:clickAction="transitionToEnd"/>
</Transition>
<Transition
motion:constraintSetEnd="@+id/c"
motion:constraintSetStart="@id/b"
motion:duration="1000">
<OnClick motion:clickAction="transitionToEnd"/>
</Transition>

<Transition
motion:constraintSetEnd="@+id/d"
motion:constraintSetStart="@id/c"
motion:duration="1000">
<OnClick motion:clickAction="transitionToEnd"/>
</Transition>

<Transition
motion:constraintSetEnd="@+id/a"
motion:constraintSetStart="@id/d"
motion:duration="1000">
<OnClick motion:clickAction="transitionToEnd"/>
</Transition>

<ConstraintSet android:id="@+id/start"></ConstraintSet>

<ConstraintSet android:id="@+id/end">
</ConstraintSet>

<ConstraintSet android:id="@+id/a" motion:deriveConstraintsFrom="@+id/left">
<ConstraintOverride android:id="@+id/button" motion:layout_constraintVertical_bias="0.1" />

</ConstraintSet>

<ConstraintSet android:id="@+id/b" motion:deriveConstraintsFrom="@+id/right">
<ConstraintOverride android:id="@+id/button" motion:layout_constraintHorizontal_bias="0.8" motion:layout_constraintVertical_bias="0.0" />
</ConstraintSet>

<ConstraintSet android:id="@+id/c" motion:deriveConstraintsFrom="@+id/left">
<ConstraintOverride android:id="@+id/button" motion:layout_constraintVertical_bias="0.9" />

</ConstraintSet>
<ConstraintSet android:id="@+id/d" motion:deriveConstraintsFrom="@+id/right">
<ConstraintOverride android:id="@+id/button" motion:layout_constraintVertical_bias="0.8" />

</ConstraintSet>
</MotionScene>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<ConstraintSet android:id="@+id/left"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto">

<!-- <Constraint android:id="@+id/button"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- motion:layout_constraintHorizontal_bias="0.2"-->
<!-- motion:layout_constraintBottom_toBottomOf="parent"-->
<!-- motion:layout_constraintEnd_toEndOf="parent"-->

<!-- motion:layout_constraintStart_toStartOf="parent"-->
<!-- motion:layout_constraintTop_toTopOf="parent" />-->
<ConstraintOverride android:id="@+id/button" motion:layout_constraintHorizontal_bias="0.1" />


</ConstraintSet>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<ConstraintSet android:id="@+id/right"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto">

<!-- <Constraint android:id="@+id/button"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- motion:layout_constraintHorizontal_bias="1.0"-->
<!-- motion:layout_constraintBottom_toBottomOf="parent"-->
<!-- motion:layout_constraintEnd_toEndOf="parent"-->

<!-- motion:layout_constraintStart_toStartOf="parent"-->
<!-- motion:layout_constraintTop_toTopOf="parent" />-->
<ConstraintOverride android:id="@+id/button" motion:layout_constraintHorizontal_bias="1.0" />


</ConstraintSet>