diff --git a/constraintlayout/.idea/codeStyles/Project.xml b/constraintlayout/.idea/codeStyles/Project.xml
new file mode 100644
index 000000000..681f41ae2
--- /dev/null
+++ b/constraintlayout/.idea/codeStyles/Project.xml
@@ -0,0 +1,116 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ xmlns:android
+
+ ^$
+
+
+
+
+
+
+
+
+ xmlns:.*
+
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*:id
+
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ .*:name
+
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ name
+
+ ^$
+
+
+
+
+
+
+
+
+ style
+
+ ^$
+
+
+
+
+
+
+
+
+ .*
+
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*
+
+ http://schemas.android.com/apk/res/android
+
+
+ ANDROID_ATTRIBUTE_ORDER
+
+
+
+
+
+
+ .*
+
+ .*
+
+
+ BY_NAME
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/projects/MotionLayoutVerification/app/src/main/AndroidManifest.xml b/projects/MotionLayoutVerification/app/src/main/AndroidManifest.xml
index c071e1c82..366d1e1d8 100644
--- a/projects/MotionLayoutVerification/app/src/main/AndroidManifest.xml
+++ b/projects/MotionLayoutVerification/app/src/main/AndroidManifest.xml
@@ -24,7 +24,18 @@
android:configChanges="orientation|screenSize"/>
-
+
+
+
+
+
+
diff --git a/projects/MotionLayoutVerification/app/src/main/java/android/support/constraint/app/CheckCallbackActivity.java b/projects/MotionLayoutVerification/app/src/main/java/android/support/constraint/app/CheckCallbackActivity.java
new file mode 100644
index 000000000..566032651
--- /dev/null
+++ b/projects/MotionLayoutVerification/app/src/main/java/android/support/constraint/app/CheckCallbackActivity.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.constraint.app;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.constraintlayout.motion.widget.Debug;
+import androidx.constraintlayout.motion.widget.MotionLayout;
+import androidx.constraintlayout.motion.widget.TransitionAdapter;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
+// used with verification_042.xml
+public class CheckCallbackActivity extends AppCompatActivity {
+ private static final String TAG = "CustomSwipeClick";
+ String layout_name;
+ MotionLayout mMotionLayout;
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ Bundle extra = getIntent().getExtras();
+ String prelayout = extra.getString(Utils.KEY);
+ setTitle(layout_name = prelayout);
+ Context ctx = getApplicationContext();
+ int id = ctx.getResources().getIdentifier(prelayout, "layout", ctx.getPackageName());
+ setContentView(id);
+ mMotionLayout = Utils.findMotionLayout(this);
+
+ populateRecyclerView();
+
+ TextView text = findViewById(R.id.text);
+ if (text != null) {
+ mMotionLayout.setTransitionListener(new TransitionAdapter() {
+ @Override
+ public void onTransitionCompleted(MotionLayout motionLayout, int currentId) {
+ text.setText((currentId == R.id.expanded) ? "cb down" : "cb up");
+ Log.v(TAG, Debug.getLoc() + " "+Debug.getName(getApplicationContext(),currentId));
+ }
+
+ });
+ }
+ }
+ // ================================= Recycler support ====================================
+ private void populateRecyclerView() {
+ RecyclerView rview = Utils.findView(this, RecyclerView.class);
+ if (rview == null) {
+ return;
+ }
+
+ rview.setLayoutManager(new LinearLayoutManager(this));
+ rview.setAdapter(new MyAdapter());
+ }
+
+ static class MyAdapter extends RecyclerView.Adapter {
+ private String[] mDataset = new String[300];
+ {
+ for (int i = 0; i < mDataset.length; i++) {
+ mDataset[i] = "hello world 1234567890 ".substring(0,12+(i%10));
+ }
+ }
+
+ @Override
+ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ TextView tv = new TextView(parent.getContext());
+ tv.setPadding(10, 10, 10, 5);
+ tv.setTextSize(30);
+ RecyclerView.ViewHolder vh = new RecyclerView.ViewHolder(tv){};
+ return vh;
+ }
+
+ @Override
+ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
+ ((TextView)holder.itemView).setText(mDataset[position]);
+ }
+
+ @Override
+ public int getItemCount() {
+ return mDataset.length;
+ }
+ }
+
+
+
+}
diff --git a/projects/MotionLayoutVerification/app/src/main/java/android/support/constraint/app/ConstraintSetVerify.java b/projects/MotionLayoutVerification/app/src/main/java/android/support/constraint/app/ConstraintSetVerify.java
new file mode 100644
index 000000000..91af9f845
--- /dev/null
+++ b/projects/MotionLayoutVerification/app/src/main/java/android/support/constraint/app/ConstraintSetVerify.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.constraint.app;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.view.View;
+
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.ActionBar;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.constraintlayout.widget.ConstraintLayout;
+import androidx.constraintlayout.widget.ConstraintSet;
+
+public class ConstraintSetVerify extends AppCompatActivity {
+ private static final String TAG = "ConstraintSetVerify";
+ String layout_name;
+ ConstraintLayout mConstraintLayout;
+
+ @Override
+ protected void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ Bundle extra = getIntent().getExtras();
+ String prelayout = extra.getString(Utils.KEY);
+ layout_name = prelayout;
+ Context ctx = getApplicationContext();
+ int id = ctx.getResources().getIdentifier(prelayout, "layout", ctx.getPackageName());
+ ActionBar bar = getSupportActionBar();
+ if (bar != null) {
+ bar.hide();
+ }
+ setContentView(id);
+ mConstraintLayout = Utils.findConstraintLayout(this);
+ findViewById(R.id.showContent).setOnClickListener( (v)->showContent(v));
+ findViewById(R.id.showSplash).setOnClickListener( (v)->showSplash(v));
+ }
+ public void showSplash(View v) {
+ ConstraintSet set = new ConstraintSet();
+ set.clone(mConstraintLayout);
+ set.setVerticalBias(R.id.logo, 0.5f);
+ set.setVisibility(R.id.splashScreen, View.VISIBLE);
+ set.setVisibility(R.id.contentGroup, View.GONE);
+ set.applyTo(mConstraintLayout);
+ }
+ public void showContent(View v) {
+
+ ConstraintSet set = new ConstraintSet();
+ set.clone(mConstraintLayout);
+ set.setVerticalBias(R.id.logo, 0.3f);
+ set.setVisibility(R.id.splashScreen, View.GONE);
+ set.setVisibility(R.id.contentGroup, View.VISIBLE);
+ set.applyTo(mConstraintLayout);
+
+ }
+
+}
diff --git a/projects/MotionLayoutVerification/app/src/main/java/android/support/constraint/app/RotationRotateToToolbar.java b/projects/MotionLayoutVerification/app/src/main/java/android/support/constraint/app/RotationRotateToToolbar.java
new file mode 100644
index 000000000..cd5f8b32a
--- /dev/null
+++ b/projects/MotionLayoutVerification/app/src/main/java/android/support/constraint/app/RotationRotateToToolbar.java
@@ -0,0 +1,164 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.constraint.app;
+
+import android.content.Context;
+import android.content.res.Configuration;
+import android.graphics.Rect;
+import android.os.Build;
+import android.os.Bundle;
+import android.util.DisplayMetrics;
+import android.util.Log;
+import android.view.Surface;
+import android.view.View;
+import android.view.ViewTreeObserver;
+import android.view.Window;
+import android.view.WindowManager;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.annotation.RequiresApi;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.constraintlayout.motion.widget.Debug;
+import androidx.constraintlayout.motion.widget.MotionLayout;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Arrays;
+
+/**
+ * This demonstrates using the api motionLayout.rotateTo
+ * It allows you to control the transition between landscape and portrait
+ * rotateTo performs an animation between the current state and the
+ */
+public class RotationRotateToToolbar extends AppCompatActivity {
+ private static final String TAG = "CheckSharedValues";
+ String layout_name;
+ MotionLayout mMotionLayout;
+ private int mDuration = 4000;
+
+ @Override
+ protected void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ Bundle extra = getIntent().getExtras();
+ String prelayout = extra.getString(Utils.KEY);
+ layout_name = prelayout;
+ Context ctx = getApplicationContext();
+ int id = ctx.getResources().getIdentifier(prelayout, "layout", ctx.getPackageName());
+
+ setContentView(id);
+ mMotionLayout = Utils.findMotionLayout(this);
+
+ int rotation = getWindowManager().getDefaultDisplay().getRotation();
+ }
+
+ @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
+ @Override
+ public void onAttachedToWindow() {
+ super.onAttachedToWindow();
+ int rotationAnimation = WindowManager.LayoutParams.ROTATION_ANIMATION_JUMPCUT;
+ Window win = getWindow();
+ WindowManager.LayoutParams winParams = win.getAttributes();
+ winParams.rotationAnimation = rotationAnimation;
+ win.setAttributes(winParams);
+ mMotionLayout.transitionToState(getLayoutForOrientation());
+ mMotionLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
+ @Override
+ public void onGlobalLayout() {
+ globalLayout();
+ }
+ });
+
+ }
+ void globalLayout() {
+ final int[] location = new int[2];
+ mMotionLayout.getLocationInWindow(location); // Includes offset from status bar, *dumb*
+ Rect anchorRect = new Rect(location[0], location[1],
+ location[0] + mMotionLayout.getWidth(), location[1] + mMotionLayout.getHeight());
+
+ mMotionLayout.getRootView().findViewById(android.R.id.content).getLocationInWindow(location);
+ int windowTopOffset = location[1];
+ anchorRect.offset(0, -windowTopOffset);
+ Log.v(TAG , Debug.getLoc()+" anchorRect = "+anchorRect);
+
+//
+
+ DisplayMetrics dm = new DisplayMetrics();
+ this.getWindowManager().getDefaultDisplay().getMetrics(dm);
+ int topOffset = dm.heightPixels - mMotionLayout.getMeasuredHeight();
+
+ View tempView = mMotionLayout; // the view you'd like to locate
+ int[] loc = new int[2];
+ tempView.getLocationOnScreen(loc);
+
+ final int y = loc[1] - topOffset;
+ Log.v(TAG , Debug.getLoc()+" loc = "+ Arrays.toString(loc));
+ Log.v(TAG , Debug.getLoc()+" y = "+y);
+
+ }
+
+
+ @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
+ @Override
+ public void setRequestedOrientation(int requestedOrientation) {
+ super.setRequestedOrientation(requestedOrientation);
+ int rotationAnimation = WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS;
+ Window win = getWindow();
+ WindowManager.LayoutParams winParams = win.getAttributes();
+ winParams.rotationAnimation = rotationAnimation;
+ win.setAttributes(winParams);
+ }
+
+ int previous_rotation;
+
+ @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
+ @Override
+ public void onConfigurationChanged(@NonNull @NotNull Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ int layout = getLayoutForOrientation();
+ int rotation = getWindowManager().getDefaultDisplay().getRotation();
+ mMotionLayout.rotateTo(layout, mDuration); // special api to rotate
+ previous_rotation = rotation;
+ Log.v(TAG , Debug.getLoc()+" ");
+ }
+
+ /**
+ * Compute the constraint set to transition to.
+ *
+ * @return
+ */
+ private int getLayoutForOrientation() {
+ switch (getWindowManager().getDefaultDisplay().getRotation()) {
+ default:
+ case Surface.ROTATION_0:
+ return R.id.portrait;
+ case Surface.ROTATION_90:
+ return R.id.landscape;
+ case Surface.ROTATION_180:
+ return R.id.portrait;
+ case Surface.ROTATION_270:
+ if (null != mMotionLayout.getConstraintSet(R.id.landscape_right)) {
+ return R.id.landscape_right;
+ }
+ return R.id.landscape;
+ }
+ }
+
+ public void duration(View view) {
+ mDuration = Integer.parseInt((String) view.getTag());
+ }
+}
diff --git a/projects/MotionLayoutVerification/app/src/main/java/android/support/constraint/app/RotationToolbar.java b/projects/MotionLayoutVerification/app/src/main/java/android/support/constraint/app/RotationToolbar.java
new file mode 100644
index 000000000..bddfe1191
--- /dev/null
+++ b/projects/MotionLayoutVerification/app/src/main/java/android/support/constraint/app/RotationToolbar.java
@@ -0,0 +1,248 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.constraint.app;
+
+import android.content.Context;
+import android.content.res.Configuration;
+import android.graphics.Color;
+import android.hardware.Sensor;
+import android.hardware.SensorEvent;
+import android.hardware.SensorEventListener;
+import android.hardware.SensorManager;
+import android.os.Build;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.Surface;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.SeekBar;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.annotation.RequiresApi;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.constraintlayout.motion.widget.Debug;
+import androidx.constraintlayout.motion.widget.MotionLayout;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Arrays;
+
+public class RotationToolbar extends AppCompatActivity {
+ private static final String TAG = "CheckSharedValues";
+ String layout_name;
+ MotionLayout mMotionLayout;
+ private SensorManager sensorManager;
+ float mAngle;
+ final float D_FACTOR = 10;
+ int mCurrentTransitionType = -1;
+ final int TRANSITION_LEFT_FROM_TOP = 0;
+ final int TRANSITION_RIGHT_FROM_TOP = 1;
+ final int TRANSITION_RIGHT_FROM_LEFT = 2;
+ final int TRANSITION_LEFT_FROM_RIGHT = 3;
+ int[][] mTransition = {
+ {R.id.portrait, R.id.landscape_R90}, //TRANSITION_LEFT_FROM_TOP
+ {R.id.portrait, R.id.landscape_right_RN90}, //TRANSITION_RIGHT_FROM_TOP
+ {R.id.landscape, R.id.portrait_R90}, //TRANSITION_RIGHT_FROM_LEFT
+ {R.id.landscape_right, R.id.portrait_RN90},//TRANSITION_LEFT_FROM_RIGHT
+ };
+ int count = 0;
+ float[] mAccValues;
+ int mLastProcessOrientation;
+
+ @Override
+ protected void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ Bundle extra = getIntent().getExtras();
+ String prelayout = extra.getString(Utils.KEY);
+ layout_name = prelayout;
+ Context ctx = getApplicationContext();
+ int id = ctx.getResources().getIdentifier(prelayout, "layout", ctx.getPackageName());
+
+ setContentView(id);
+
+ mMotionLayout = Utils.findMotionLayout(this);
+ boolean landscape = (getWindowManager().getDefaultDisplay().getRotation() & 1) == 1;
+ sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
+ Sensor sensor = sensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY);
+
+ mMotionLayout.setState(landscape ? R.id.landscape : R.id.portrait, -1, -1);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
+ sensorManager.registerListener(gravity_listener, sensor, 10000);
+ }
+ }
+
+ @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
+ @Override
+ public void onAttachedToWindow() {
+ super.onAttachedToWindow();
+ int rotationAnimation = WindowManager.LayoutParams.ROTATION_ANIMATION_JUMPCUT;
+ Window win = getWindow();
+ WindowManager.LayoutParams winParams = win.getAttributes();
+ winParams.rotationAnimation = rotationAnimation;
+ win.setAttributes(winParams);
+ boolean landscape = (getWindowManager().getDefaultDisplay().getRotation() & 1) == 1;
+ mMotionLayout.setState(getLayoutForOrientation(), -1, -1);
+ }
+
+ @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
+ @Override
+ public void setRequestedOrientation(int requestedOrientation) {
+ super.setRequestedOrientation(requestedOrientation);
+ int rotationAnimation = WindowManager.LayoutParams.ROTATION_ANIMATION_JUMPCUT;
+ Window win = getWindow();
+ WindowManager.LayoutParams winParams = win.getAttributes();
+ winParams.rotationAnimation = rotationAnimation;
+ win.setAttributes(winParams);
+ }
+
+ @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
+ @Override
+ public void onConfigurationChanged(@NonNull @NotNull Configuration newConfig) {
+ mCurrentTransitionType = -1;
+ orientation();
+ super.onConfigurationChanged(newConfig);
+ }
+
+ long waitTill = System.currentTimeMillis();
+
+ /**
+ * Compute the constraint set to transition to.
+ *
+ * @return
+ */
+ private int getLayoutForOrientation() {
+ switch (getWindowManager().getDefaultDisplay().getRotation()) {
+ default:
+ case Surface.ROTATION_0:
+ return R.id.portrait;
+ case Surface.ROTATION_90:
+ return R.id.landscape;
+ case Surface.ROTATION_180:
+ return R.id.portrait;
+ case Surface.ROTATION_270:
+ if (null != mMotionLayout.getConstraintSet(R.id.landscape_right)) {
+ return R.id.landscape_right;
+ }
+ return R.id.landscape;
+ }
+ }
+
+ float curve(float accX, float accY) {
+ float ang = (float) Math.atan2(accX, accY);
+ ang /= (Math.PI / 2);
+ return ang;
+ }
+ int[]color = {Color.RED,Color.GREEN,Color.BLACK,Color.BLUE};
+ int []scrLoc = new int[2];
+ public void orientation() {
+ int id = mMotionLayout.getEndState();
+ int rotation = getWindowManager().getDefaultDisplay().getRotation();
+ mMotionLayout.setBackgroundColor(color[rotation]);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ if (mMotionLayout != null && mMotionLayout.getRootWindowInsets() != null) {
+ Log.v(TAG, Debug.getLoc() + " " + mMotionLayout.getRootWindowInsets().toString());
+ }
+ mMotionLayout.getLocationOnScreen(scrLoc);
+ Log.v(TAG,Debug.getLoc()+ " "+ Arrays.toString(scrLoc) );
+
+ }
+ boolean set_transition = false;
+ if (mLastProcessOrientation != rotation) {
+ set_transition = true;
+ }
+ mLastProcessOrientation = rotation;
+ if (mCurrentTransitionType == -1) {
+ set_transition = true;
+ }
+ float p = mAngle;
+
+ int type;
+ float progress = 0;
+ switch (rotation) {
+ case Surface.ROTATION_90:
+ type = TRANSITION_RIGHT_FROM_LEFT;
+ progress = pmap(Math.max(1 - p, 0));
+ break;
+ case Surface.ROTATION_270:
+ type = TRANSITION_LEFT_FROM_RIGHT;
+ progress = pmap(Math.max(1 + p, 0));
+ break;
+ case Surface.ROTATION_0:
+ default:
+ if (p > 0) {
+ type = TRANSITION_LEFT_FROM_TOP;
+ } else {
+ type = TRANSITION_RIGHT_FROM_TOP;
+ }
+ progress = pmap(Math.abs(p));
+ }
+
+ if (type != mCurrentTransitionType || set_transition) {
+ mMotionLayout.setTransition(mTransition[type][0], mTransition[type][1]);
+ mCurrentTransitionType = type;
+ }
+ mMotionLayout.setProgress(progress);
+ }
+
+ SensorEventListener gravity_listener = new SensorEventListener() {
+ float dampX, dampY;
+ float prevX, prevY;
+
+ @Override
+ public void onSensorChanged(SensorEvent sensorEvent) {
+ mAccValues = sensorEvent.values;
+ float x = mAccValues[0];
+ float y = mAccValues[1];
+ if (Math.hypot(x, y) < 2) {
+ return;
+ }
+ dampX = x + dampX * D_FACTOR;
+ dampY = y + dampY * D_FACTOR;
+ dampX /= (1 + D_FACTOR);
+ dampY /= (1 + D_FACTOR);
+
+ if ((Math.abs(dampX - prevX) < 0.01 && Math.abs(dampY - prevY) < 0.01)) {
+ return;
+ }
+ prevX = dampX;
+ prevY = dampY;
+ mAngle = curve(dampX, dampY);
+ orientation();
+ }
+
+ @Override
+ public void onAccuracyChanged(Sensor sensor, int i) {
+ }
+ };
+ int mHold = 0;
+
+ float pmap(float p) {
+ float t = p - 0.5f;
+ t *= 1 + mHold / 20f;
+ return Math.max(0, Math.min(1, t + 0.5f));
+ }
+
+ public void hold(View v) {
+ SeekBar bar = findViewById(R.id.seek);
+ int prog = bar.getProgress();
+ Log.v(TAG, Debug.getLoc() + " (@) " + prog);
+ mHold = prog;
+ }
+
+}
diff --git a/projects/MotionLayoutVerification/app/src/main/java/android/support/constraint/app/Utils.java b/projects/MotionLayoutVerification/app/src/main/java/android/support/constraint/app/Utils.java
index 48978e090..d1706fbf4 100644
--- a/projects/MotionLayoutVerification/app/src/main/java/android/support/constraint/app/Utils.java
+++ b/projects/MotionLayoutVerification/app/src/main/java/android/support/constraint/app/Utils.java
@@ -21,6 +21,7 @@
import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.motion.widget.MotionLayout;
+import androidx.constraintlayout.widget.ConstraintLayout;
import java.lang.reflect.Field;
import java.util.ArrayList;
@@ -48,7 +49,45 @@ static MotionLayout findMotionLayout(AppCompatActivity activity) {
}
return null;
}
+ static T findView(AppCompatActivity activity, Class c) {
+ ViewGroup group = ((ViewGroup) activity.findViewById(android.R.id.content).getRootView());
+ ArrayList groups = new ArrayList<>();
+ groups.add(group);
+ while (!groups.isEmpty()) {
+ ViewGroup vg = groups.remove(0);
+ int n = vg.getChildCount();
+ for (int i = 0; i < n; i++) {
+ View view = vg.getChildAt(i);
+ if (c.isAssignableFrom(view.getClass())) {
+ return (T) view;
+ }
+ if (view instanceof ViewGroup) {
+ groups.add((ViewGroup) view);
+ }
+ }
+ }
+ return (T) null;
+ }
+ static ConstraintLayout findConstraintLayout(AppCompatActivity activity) {
+ ViewGroup group = ((ViewGroup) activity.findViewById(android.R.id.content).getRootView());
+ ArrayList groups = new ArrayList<>();
+ groups.add(group);
+ while (!groups.isEmpty()) {
+ ViewGroup vg = groups.remove(0);
+ int n = vg.getChildCount();
+ for (int i = 0; i < n; i++) {
+ View view = vg.getChildAt(i);
+ if (view instanceof ConstraintLayout) {
+ return (ConstraintLayout) view;
+ }
+ if (view instanceof ViewGroup) {
+ groups.add((ViewGroup) view);
+ }
+ }
+ }
+ return null;
+ }
static String[] getLayouts(String match) {
ArrayList list = new ArrayList<>();
Field[] f = R.layout.class.getDeclaredFields();
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 21a016dce..3534cd0ec 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
@@ -76,7 +76,7 @@
public class VerificationActivity extends AppCompatActivity implements View.OnClickListener {
private static final String TAG = "Verification00";
private String KEY = "layout";
- private static final boolean DEBUG = false;
+ private static final boolean DEBUG = true;
String layout_name;
HashMap activity_map = new HashMap<>();
@@ -87,14 +87,18 @@ public class VerificationActivity extends AppCompatActivity implements View.OnCl
activity_map.put("verification_038", RotationUsingRotateTo.class);
activity_map.put("verification_039", RotationAngular.class);
activity_map.put("verification_350", CustomSwipeClick.class);
+ activity_map.put("constraint_set_01", ConstraintSetVerify.class);
+ activity_map.put("verification_042", CheckCallbackActivity.class);
+ // activity_map.put("verification_037", RotationToolbar.class);
+ // activity_map.put("verification_038", RotationRotateToToolbar.class);
}
String s = AppCompatActivity.class.getName();
private static boolean REVERSE = false;
- private final String RUN_FIRST = "verification_350";
- private final String LAYOUTS_MATCHES = "verification_\\d+";
+ private final String RUN_FIRST = "verification_042";
+ private final String LAYOUTS_MATCHES = ".*_\\d+";
private static String SHOW_FIRST = "";
MotionLayout mMotionLayout;
@@ -157,12 +161,15 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
}
if (mMotionLayout != null) {
ArrayList transition = mMotionLayout.getDefinedTransitions();
- int[] tids = new int[transition.size()];
+ int[] tids = new int[0];
int count = 0;
- for (MotionScene.Transition t : transition) {
- int tid = t.getId();
- if (tid != -1) {
- tids[count++] = tid;
+ if (transition != null) {
+ tids = new int[transition.size()];
+ for (MotionScene.Transition t : transition) {
+ int tid = t.getId();
+ if (tid != -1) {
+ tids[count++] = tid;
+ }
}
}
diff --git a/projects/MotionLayoutVerification/app/src/main/res/layout/constraint_set_01.xml b/projects/MotionLayoutVerification/app/src/main/res/layout/constraint_set_01.xml
new file mode 100644
index 000000000..d30d62366
--- /dev/null
+++ b/projects/MotionLayoutVerification/app/src/main/res/layout/constraint_set_01.xml
@@ -0,0 +1,125 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/projects/MotionLayoutVerification/app/src/main/res/layout/verification_037.xml b/projects/MotionLayoutVerification/app/src/main/res/layout/verification_037.xml
new file mode 100644
index 000000000..f8fd0e75a
--- /dev/null
+++ b/projects/MotionLayoutVerification/app/src/main/res/layout/verification_037.xml
@@ -0,0 +1,106 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/projects/MotionLayoutVerification/app/src/main/res/layout/verification_042.xml b/projects/MotionLayoutVerification/app/src/main/res/layout/verification_042.xml
new file mode 100644
index 000000000..9a19782b8
--- /dev/null
+++ b/projects/MotionLayoutVerification/app/src/main/res/layout/verification_042.xml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/projects/MotionLayoutVerification/app/src/main/res/layout/verification_052.xml b/projects/MotionLayoutVerification/app/src/main/res/layout/verification_052.xml
new file mode 100644
index 000000000..0f5349e9a
--- /dev/null
+++ b/projects/MotionLayoutVerification/app/src/main/res/layout/verification_052.xml
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/projects/MotionLayoutVerification/app/src/main/res/layout/verification_450.xml b/projects/MotionLayoutVerification/app/src/main/res/layout/verification_450.xml
new file mode 100644
index 000000000..efb31f546
--- /dev/null
+++ b/projects/MotionLayoutVerification/app/src/main/res/layout/verification_450.xml
@@ -0,0 +1,214 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/projects/MotionLayoutVerification/app/src/main/res/layout/verification_450a.xml b/projects/MotionLayoutVerification/app/src/main/res/layout/verification_450a.xml
new file mode 100644
index 000000000..4e6c30235
--- /dev/null
+++ b/projects/MotionLayoutVerification/app/src/main/res/layout/verification_450a.xml
@@ -0,0 +1,197 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/projects/MotionLayoutVerification/app/src/main/res/xml/verification_scene_037.xml b/projects/MotionLayoutVerification/app/src/main/res/xml/verification_scene_037.xml
new file mode 100644
index 000000000..ec0b45533
--- /dev/null
+++ b/projects/MotionLayoutVerification/app/src/main/res/xml/verification_scene_037.xml
@@ -0,0 +1,110 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/projects/MotionLayoutVerification/app/src/main/res/xml/verification_scene_042.xml b/projects/MotionLayoutVerification/app/src/main/res/xml/verification_scene_042.xml
new file mode 100644
index 000000000..32d54d94a
--- /dev/null
+++ b/projects/MotionLayoutVerification/app/src/main/res/xml/verification_scene_042.xml
@@ -0,0 +1,86 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ /
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/projects/MotionLayoutVerification/app/src/main/res/xml/verification_scene_052.xml b/projects/MotionLayoutVerification/app/src/main/res/xml/verification_scene_052.xml
new file mode 100644
index 000000000..0b8260f05
--- /dev/null
+++ b/projects/MotionLayoutVerification/app/src/main/res/xml/verification_scene_052.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/projects/MotionLayoutVerification/app/src/main/res/xml/verification_scene_450.xml b/projects/MotionLayoutVerification/app/src/main/res/xml/verification_scene_450.xml
new file mode 100644
index 000000000..70ba7029a
--- /dev/null
+++ b/projects/MotionLayoutVerification/app/src/main/res/xml/verification_scene_450.xml
@@ -0,0 +1,85 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/projects/MotionLayoutVerification/app/src/main/res/xml/verification_scene_450a.xml b/projects/MotionLayoutVerification/app/src/main/res/xml/verification_scene_450a.xml
new file mode 100644
index 000000000..4aa9b0960
--- /dev/null
+++ b/projects/MotionLayoutVerification/app/src/main/res/xml/verification_scene_450a.xml
@@ -0,0 +1,80 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file