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

Commit dc988e6

Browse files
authored
2.1 release (#179)
* Update build.gradle Bump version numbers to 2.1.0-beta01, 1.0.0-beta01 for -core and 1.0.0-alpha04 for compose. * bump compose version to beta 2 * Rename MotionEffect attributes
1 parent c7fa124 commit dc988e6

File tree

4 files changed

+60
-58
lines changed

4 files changed

+60
-58
lines changed

constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/helper/widget/MotionEffect.java

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ public class MotionEffect extends MotionHelper {
5757
public static final int EAST = 2;
5858
public static final int WEST = 3;
5959

60-
private float fadeAlpha = 0.1f;
61-
private int fadeStart = 49;
62-
private int fadeEnd = 50;
63-
private int fadeTranslationX = 0;
64-
private int fadeTranslationY = 0;
65-
private boolean fadeMoveStrict = true;
60+
private float motionEffectAlpha = 0.1f;
61+
private int motionEffectStart = 49;
62+
private int motionEffectEnd = 50;
63+
private int motionEffectTranslationX = 0;
64+
private int motionEffectTranslationY = 0;
65+
private boolean motionEffectStrictMove = true;
6666
private static final int UNSET = -1;
6767
private int viewTransitionId = UNSET;
6868

@@ -88,31 +88,31 @@ private void init(Context context, AttributeSet attrs) {
8888
final int N = a.getIndexCount();
8989
for (int i = 0; i < N; i++) {
9090
int attr = a.getIndex(i);
91-
if (attr == R.styleable.MotionEffect_fadeMove_start) {
92-
fadeStart = a.getInt(attr, fadeStart);
93-
fadeStart = Math.max(Math.min(fadeStart, 99), 0);
94-
} else if (attr == R.styleable.MotionEffect_fadeMove_end) {
95-
fadeEnd = a.getInt(attr, fadeEnd);
96-
fadeEnd = Math.max(Math.min(fadeEnd, 99), 0);
97-
} else if (attr == R.styleable.MotionEffect_fadeMove_translationX) {
98-
fadeTranslationX = a.getDimensionPixelOffset(attr, fadeTranslationX);
99-
} else if (attr == R.styleable.MotionEffect_fadeMove_translationY) {
100-
fadeTranslationY = a.getDimensionPixelOffset(attr, fadeTranslationY);
101-
} else if (attr == R.styleable.MotionEffect_fadeMove_alpha) {
102-
fadeAlpha = a.getFloat(attr, fadeAlpha);
103-
} else if (attr == R.styleable.MotionEffect_fadeMove_move) {
91+
if (attr == R.styleable.MotionEffect_motionEffect_start) {
92+
motionEffectStart = a.getInt(attr, motionEffectStart);
93+
motionEffectStart = Math.max(Math.min(motionEffectStart, 99), 0);
94+
} else if (attr == R.styleable.MotionEffect_motionEffect_end) {
95+
motionEffectEnd = a.getInt(attr, motionEffectEnd);
96+
motionEffectEnd = Math.max(Math.min(motionEffectEnd, 99), 0);
97+
} else if (attr == R.styleable.MotionEffect_motionEffect_translationX) {
98+
motionEffectTranslationX = a.getDimensionPixelOffset(attr, motionEffectTranslationX);
99+
} else if (attr == R.styleable.MotionEffect_motionEffect_translationY) {
100+
motionEffectTranslationY = a.getDimensionPixelOffset(attr, motionEffectTranslationY);
101+
} else if (attr == R.styleable.MotionEffect_motionEffect_alpha) {
102+
motionEffectAlpha = a.getFloat(attr, motionEffectAlpha);
103+
} else if (attr == R.styleable.MotionEffect_motionEffect_move) {
104104
fadeMove = a.getInt(attr, fadeMove);
105-
} else if (attr == R.styleable.MotionEffect_fadeMove_strict) {
106-
fadeMoveStrict = a.getBoolean(attr, fadeMoveStrict);
107-
} else if (attr == R.styleable.MotionEffect_fadeMove_viewTransition) {
105+
} else if (attr == R.styleable.MotionEffect_motionEffect_strict) {
106+
motionEffectStrictMove = a.getBoolean(attr, motionEffectStrictMove);
107+
} else if (attr == R.styleable.MotionEffect_motionEffect_viewTransition) {
108108
viewTransitionId = a.getResourceId(attr, viewTransitionId);
109109
}
110110
}
111-
if (fadeStart == fadeEnd) {
112-
if (fadeStart > 0) {
113-
fadeStart --;
111+
if (motionEffectStart == motionEffectEnd) {
112+
if (motionEffectStart > 0) {
113+
motionEffectStart--;
114114
} else {
115-
fadeEnd ++;
115+
motionEffectEnd++;
116116
}
117117
}
118118
a.recycle();
@@ -137,41 +137,41 @@ public void onPreSetup(MotionLayout motionLayout, HashMap<View, MotionController
137137

138138
KeyAttributes alpha1 = new KeyAttributes();
139139
KeyAttributes alpha2 = new KeyAttributes();
140-
alpha1.setValue(Key.ALPHA, fadeAlpha);
141-
alpha2.setValue(Key.ALPHA, fadeAlpha);
142-
alpha1.setFramePosition(fadeStart);
143-
alpha2.setFramePosition(fadeEnd);
140+
alpha1.setValue(Key.ALPHA, motionEffectAlpha);
141+
alpha2.setValue(Key.ALPHA, motionEffectAlpha);
142+
alpha1.setFramePosition(motionEffectStart);
143+
alpha2.setFramePosition(motionEffectEnd);
144144
KeyPosition stick1 = new KeyPosition();
145-
stick1.setFramePosition(fadeStart);
145+
stick1.setFramePosition(motionEffectStart);
146146
stick1.setType(KeyPosition.TYPE_CARTESIAN);
147147
stick1.setValue(KeyPosition.PERCENT_X, 0);
148148
stick1.setValue(KeyPosition.PERCENT_Y, 0);
149149
KeyPosition stick2 = new KeyPosition();
150-
stick2.setFramePosition(fadeEnd);
150+
stick2.setFramePosition(motionEffectEnd);
151151
stick2.setType(KeyPosition.TYPE_CARTESIAN);
152152
stick2.setValue(KeyPosition.PERCENT_X, 1);
153153
stick2.setValue(KeyPosition.PERCENT_Y, 1);
154154

155155
KeyAttributes translationX1 = null;
156156
KeyAttributes translationX2 = null;
157-
if (fadeTranslationX > 0) {
157+
if (motionEffectTranslationX > 0) {
158158
translationX1 = new KeyAttributes();
159159
translationX2 = new KeyAttributes();
160-
translationX1.setValue(Key.TRANSLATION_X, fadeTranslationX);
161-
translationX1.setFramePosition(fadeEnd);
160+
translationX1.setValue(Key.TRANSLATION_X, motionEffectTranslationX);
161+
translationX1.setFramePosition(motionEffectEnd);
162162
translationX2.setValue(Key.TRANSLATION_X, 0);
163-
translationX2.setFramePosition(fadeEnd - 1);
163+
translationX2.setFramePosition(motionEffectEnd - 1);
164164
}
165165

166166
KeyAttributes translationY1 = null;
167167
KeyAttributes translationY2 = null;
168-
if (fadeTranslationY > 0) {
168+
if (motionEffectTranslationY > 0) {
169169
translationY1 = new KeyAttributes();
170170
translationY2 = new KeyAttributes();
171-
translationY1.setValue(Key.TRANSLATION_Y, fadeTranslationY);
172-
translationY1.setFramePosition(fadeEnd);
171+
translationY1.setValue(Key.TRANSLATION_Y, motionEffectTranslationY);
172+
translationY1.setFramePosition(motionEffectEnd);
173173
translationY2.setValue(Key.TRANSLATION_Y, 0);
174-
translationY2.setFramePosition(fadeEnd - 1);
174+
translationY2.setFramePosition(motionEffectEnd - 1);
175175
}
176176

177177
int moveDirection = fadeMove;
@@ -215,19 +215,19 @@ public void onPreSetup(MotionLayout motionLayout, HashMap<View, MotionController
215215
// if move strict is true, also include views that are moving in diagonal, even
216216
// if they aren't moving in the opposite direction.
217217
if (moveDirection == NORTH) {
218-
if (y > 0 && (!fadeMoveStrict || x == 0)) {
218+
if (y > 0 && (!motionEffectStrictMove || x == 0)) {
219219
apply = false;
220220
}
221221
} else if (moveDirection == SOUTH) {
222-
if (y < 0 && (!fadeMoveStrict || x == 0)) {
222+
if (y < 0 && (!motionEffectStrictMove || x == 0)) {
223223
apply = false;
224224
}
225225
} else if (moveDirection == EAST) {
226-
if (x < 0 && (!fadeMoveStrict || y == 0)) {
226+
if (x < 0 && (!motionEffectStrictMove || y == 0)) {
227227
apply = false;
228228
}
229229
} else if (moveDirection == WEST) {
230-
if (x > 0 && (!fadeMoveStrict || y == 0)) {
230+
if (x > 0 && (!motionEffectStrictMove || y == 0)) {
231231
apply = false;
232232
}
233233
}
@@ -238,11 +238,11 @@ public void onPreSetup(MotionLayout motionLayout, HashMap<View, MotionController
238238
mc.addKey(alpha2);
239239
mc.addKey(stick1);
240240
mc.addKey(stick2);
241-
if (fadeTranslationX > 0) {
241+
if (motionEffectTranslationX > 0) {
242242
mc.addKey(translationX1);
243243
mc.addKey(translationX2);
244244
}
245-
if (fadeTranslationY > 0) {
245+
if (motionEffectTranslationY > 0) {
246246
mc.addKey(translationY1);
247247
mc.addKey(translationY2);
248248
}

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -302,20 +302,20 @@
302302
<!-- =============================== Start FadeMove =============================== -->
303303

304304
<declare-styleable name="MotionEffect">
305-
<attr name="fadeMove_start" format="integer" />
306-
<attr name="fadeMove_end" format="integer" />
307-
<attr name="fadeMove_translationX" format="dimension" />
308-
<attr name="fadeMove_translationY" format="dimension" />
309-
<attr name="fadeMove_alpha" format="float" />
310-
<attr name="fadeMove_viewTransition" format="reference" />
311-
<attr name="fadeMove_move" format="enum">
305+
<attr name="motionEffect_start" format="integer" />
306+
<attr name="motionEffect_end" format="integer" />
307+
<attr name="motionEffect_translationX" format="dimension" />
308+
<attr name="motionEffect_translationY" format="dimension" />
309+
<attr name="motionEffect_alpha" format="float" />
310+
<attr name="motionEffect_viewTransition" format="reference" />
311+
<attr name="motionEffect_move" format="enum">
312312
<enum name="auto" value="-1" />
313313
<enum name="north" value="0" />
314314
<enum name="south" value="1" />
315315
<enum name="east" value="2" />
316316
<enum name="west" value="3" />
317317
</attr>
318-
<attr name="fadeMove_strict" format="boolean" />
318+
<attr name="motionEffect_strict" format="boolean" />
319319
</declare-styleable> <!-- =============================== End FadeMove =============================== -->
320320

321321
<!-- Used at design time to define to position the view -->

projects/MotionLayoutExperiments/app/src/main/res/layout/demo_100_keypad.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,11 @@
104104

105105
<androidx.constraintlayout.helper.widget.MotionEffect
106106
android:id="@+id/fade"
107-
app:fadeMove_start="40"
108-
app:fadeMove_alpha="0"
109-
app:fadeMove_end="60"
107+
app:motionEffect_start="40"
108+
app:motionEffect_alpha="0"
109+
app:motionEffect_end="60"
110+
app:motionEffect_move="west"
111+
app:motionEffect_strict="false"
110112
android:layout_width="wrap_content"
111113
android:layout_height="wrap_content"
112114
app:constraint_referenced_ids="t1,t2,t3,t4,t5,t6,t7,t8,t9"

projects/MotionLayoutExperiments/app/src/main/res/layout/demo_110_menu.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
android:id="@+id/fade"
104104
android:layout_width="wrap_content"
105105
android:layout_height="wrap_content"
106-
app:fadeMove_translationY="-40dp"
106+
app:motionEffect_translationY="-40dp"
107107
app:constraint_referenced_ids="t1,tf1,t2,tf2,t3,tf3,t4,tf4,t5,tf5"
108108
/>
109109

0 commit comments

Comments
 (0)