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

Commit

Permalink
Merge branch 'main' into fix-errorprone
Browse files Browse the repository at this point in the history
  • Loading branch information
jswong65 authored Jun 17, 2022
2 parents b3eef9e + 64b78e4 commit afd155a
Show file tree
Hide file tree
Showing 34 changed files with 538 additions and 234 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ public static class CustomSet extends ViewTimeCycle {
SparseArray<ConstraintAttribute> mConstraintAttributeList;
SparseArray<float[]> mWaveProperties = new SparseArray<>();
float[] mTempValues;
float[] mCache;

@SuppressWarnings("StringSplitter")
public CustomSet(String attribute, SparseArray<ConstraintAttribute> attrList) {
mAttributeName = attribute.split(",")[1];
mConstraintAttributeList = attrList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ public Key copy(Key src) {
mTranslationY = k.mTranslationY;
mTranslationZ = k.mTranslationZ;
mProgress = k.mProgress;
mTransitionEasing = k.mTransitionEasing;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ public Key copy(Key src) {
mTranslationX = k.mTranslationX;
mTranslationY = k.mTranslationY;
mTranslationZ = k.mTranslationZ;
mCustomWaveShape = k.mCustomWaveShape;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -809,19 +809,6 @@ public boolean isEnabled() {
return !mDisable;
}

/**
* Enable or disable the Transition. If a Transition is disabled it is not eligible
* for automatically switching to.
*
* @param enable
* deprecated This method should be called {@code setEnabled}, so that {@code isEnabled}
* can be accessed as a <a href="https://developer.android.com/kotlin/interop#property_prefixes">property from Kotlin</a>.
* Use {@link #setEnabled(boolean)} instead.
*/
private void setEnable(boolean enable) {
setEnabled(enable);
}

/**
* enable or disable the Transition. If a Transition is disabled it is not eligible
* for automatically switching to.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ private void warmth(float warmth) {
float colorR, colorG, colorB;
if (centiKelvin > 66) {
float tmp = centiKelvin - 60.f;
colorR = (329.698727446f * (float) Math.pow(tmp, -0.1332047592f));
// colorR = (329.698727446f * (float) Math.pow(tmp, -0.1332047592f))
// colorG = (288.1221695283f * (float) Math.pow(tmp, 0.0755148492f))
colorR = (329.69873f * (float) Math.pow(tmp, -0.1332047592f));
colorG = (288.1221695283f * (float) Math.pow(tmp, 0.0755148492f));

} else {
Expand All @@ -153,8 +155,9 @@ private void warmth(float warmth) {
}
if (centiKelvin < 66) {
if (centiKelvin > 19) {
colorB = (138.5177312231f
* (float) Math.log(centiKelvin - 10) - 305.0447927307f);
// 138.5177312231f * (float) Math.log(centiKelvin - 10) - 305.0447927307f);
colorB = (138.51773f
* (float) Math.log(centiKelvin - 10) - 305.0448f);
} else {
colorB = 0;
}
Expand All @@ -175,17 +178,20 @@ private void warmth(float warmth) {
float colorR, colorG, colorB;
if (centiKelvin > 66) {
float tmp = centiKelvin - 60.f;
colorR = (329.698727446f * (float) Math.pow(tmp, -0.1332047592f));
colorG = (288.1221695283f * (float) Math.pow(tmp, 0.0755148492f));
// colorR = (329.698727446f * (float) Math.pow(tmp, -0.1332047592f));
// colorG = (288.1221695283f * (float) Math.pow(tmp, 0.0755148492f));
colorR = (329.69873f * (float) Math.pow(tmp, -0.13320476f));
colorG = (288.12216f * (float) Math.pow(tmp, 0.075514849f));

} else {
colorG = (99.4708025861f * (float) Math.log(centiKelvin) - 161.1195681661f);
//float of (99.4708025861f * (float) Math.log(centiKelvin) - 161.1195681661f);
colorG = (99.4708f * (float) Math.log(centiKelvin) - 161.11957f);
colorR = 255;
}
if (centiKelvin < 66) {
if (centiKelvin > 19) {
colorB = (138.5177312231f
* (float) Math.log(centiKelvin - 10) - 305.0447927307f);
//float of (138.5177312231 * Math.log(centiKelvin - 10) - 305.0447927307);
colorB = (138.51773f * (float) Math.log(centiKelvin - 10) - 305.0448f);
} else {
colorB = 0;
}
Expand Down Expand Up @@ -482,10 +488,10 @@ private void setMatrix() {
) {
return;
}
float panX = (Float.isNaN(mPanX)) ? 0 : mPanX;
float panY = (Float.isNaN(mPanY)) ? 0 : mPanY;
float zoom = (Float.isNaN(mZoom)) ? 1 : mZoom;
float rota = (Float.isNaN(mRotate)) ? 0 : mRotate;
float panX = Float.isNaN(mPanX) ? 0 : mPanX;
float panY = Float.isNaN(mPanY) ? 0 : mPanY;
float zoom = Float.isNaN(mZoom) ? 1 : mZoom;
float rota = Float.isNaN(mRotate) ? 0 : mRotate;
Matrix imageMatrix = new Matrix();
imageMatrix.reset();
float iw = getDrawable().getIntrinsicWidth();
Expand Down Expand Up @@ -660,7 +666,7 @@ public void setCrossfade(float crossfade) {
if (!mOverlay) {
mLayer.getDrawable(0).setAlpha((int) (255 * (1 - mCrossfade)));
}
mLayer.getDrawable(1).setAlpha((int) (255 * (mCrossfade)));
mLayer.getDrawable(1).setAlpha((int) (255 * mCrossfade));
super.setImageDrawable(mLayer);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,14 @@ private void setupTexture() {
if (iw <= 0) {
int w = getWidth();
if (w == 0) {
w = ((Float.isNaN(mTextureWidth)) ? 128 : (int) mTextureWidth);
w = (Float.isNaN(mTextureWidth) ? 128 : (int) mTextureWidth);
}
iw = w;
}
if (ih <= 0) {
int h = getHeight();
if (h == 0) {
h = ((Float.isNaN(mTextureHeight)) ? 128 : (int) mTextureHeight);
h = (Float.isNaN(mTextureHeight) ? 128 : (int) mTextureHeight);
}
ih = h;
}
Expand Down Expand Up @@ -326,7 +326,7 @@ private float getHorizontalOffset() {
float scale = Float.isNaN(mBaseTextSize) ? 1.0f : mTextSize / mBaseTextSize;

float textWidth = scale * mPaint.measureText(mText, 0, mText.length());
float boxWidth = ((Float.isNaN(mFloatWidth)) ? getMeasuredWidth() : mFloatWidth)
float boxWidth = (Float.isNaN(mFloatWidth) ? getMeasuredWidth() : mFloatWidth)
- getPaddingLeft()
- getPaddingRight();
return (boxWidth - textWidth) * (1 + mTextPanX) / 2.f;
Expand All @@ -337,7 +337,7 @@ private float getVerticalOffset() {

Paint.FontMetrics fm = mPaint.getFontMetrics();

float boxHeight = ((Float.isNaN(mFloatHeight)) ? getMeasuredHeight() : mFloatHeight)
float boxHeight = (Float.isNaN(mFloatHeight) ? getMeasuredHeight() : mFloatHeight)
- getPaddingTop()
- getPaddingBottom();

Expand Down Expand Up @@ -429,9 +429,9 @@ public void layout(int l, int t, int r, int b) {
float vh = mFloatHeight - mPaddingBottom - mPaddingTop;
if (normalScale) {
if (tw * vh > th * vw) { // width limited tw/vw > th/vh
mPaint.setTextSize((mPaintTextSize * vw) / (tw));
mPaint.setTextSize(mPaintTextSize * vw / (tw));
} else { // height limited
mPaint.setTextSize((mPaintTextSize * vh) / (th));
mPaint.setTextSize(mPaintTextSize * vh / (th));
}
} else {
scaleText = (tw * vh > th * vw) ? vw / (float) tw : vh / (float) th;
Expand Down Expand Up @@ -475,9 +475,9 @@ public void layout(float l, float t, float r, float b) {
float vw = r - l - mPaddingRight - mPaddingLeft;
float vh = b - t - mPaddingBottom - mPaddingTop;
if (tw * vh > th * vw) { // width limited tw/vw > th/vh
mPaint.setTextSize((mPaintTextSize * vw) / (tw));
mPaint.setTextSize(mPaintTextSize * vw / (tw));
} else { // height limited
mPaint.setTextSize((mPaintTextSize * vh) / (th));
mPaint.setTextSize(mPaintTextSize * vh / (th));
}
if (mUseOutline || !Float.isNaN(mBaseTextSize)) {
buildShape(Float.isNaN(mBaseTextSize) ? 1.0f : mTextSize / mBaseTextSize);
Expand Down Expand Up @@ -646,7 +646,7 @@ public Typeface getTypeface() {
return mPaint.getTypeface();
}

// @Override
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthMode = View.MeasureSpec.getMode(widthMeasureSpec);
int heightMode = View.MeasureSpec.getMode(heightMeasureSpec);
Expand Down Expand Up @@ -946,16 +946,16 @@ public void setTextBackgroundRotate(float rotation) {
}

private void updateShaderMatrix() {
float panX = (Float.isNaN(mBackgroundPanX)) ? 0 : mBackgroundPanX;
float panY = (Float.isNaN(mBackgroundPanY)) ? 0 : mBackgroundPanY;
float zoom = (Float.isNaN(mZoom)) ? 1 : mZoom;
float rota = (Float.isNaN(mRotate)) ? 0 : mRotate;
float panX = Float.isNaN(mBackgroundPanX) ? 0 : mBackgroundPanX;
float panY = Float.isNaN(mBackgroundPanY) ? 0 : mBackgroundPanY;
float zoom = Float.isNaN(mZoom) ? 1 : mZoom;
float rota = Float.isNaN(mRotate) ? 0 : mRotate;

mTextShaderMatrix.reset();
float iw = mTextBackgroundBitmap.getWidth();
float ih = mTextBackgroundBitmap.getHeight();
float sw = (Float.isNaN(mTextureWidth)) ? mFloatWidth : mTextureWidth;
float sh = (Float.isNaN(mTextureHeight)) ? mFloatHeight : mTextureHeight;
float sw = Float.isNaN(mTextureWidth) ? mFloatWidth : mTextureWidth;
float sh = Float.isNaN(mTextureHeight) ? mFloatHeight : mTextureHeight;

float scale = zoom * ((iw * sh < ih * sw) ? sw / iw : sh / ih);
mTextShaderMatrix.postScale(scale, scale);
Expand All @@ -967,8 +967,8 @@ private void updateShaderMatrix() {
if (!Float.isNaN(mTextureWidth)) {
gapx = mTextureWidth / 2;
}
float tx = 0.5f * (panX * (gapx) + sw - (scale * iw));
float ty = 0.5f * (panY * (gapy) + sh - (scale * ih));
float tx = 0.5f * (panX * gapx + sw - (scale * iw));
float ty = 0.5f * (panY * gapy + sh - (scale * ih));

mTextShaderMatrix.postTranslate(tx, ty);
mTextShaderMatrix.postRotate(rota, sw / 2, sh / 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ public abstract class ConstraintHelper extends View {
*/
private View[] mViews = null;

/**
* @DoNotShow
*/
protected final static String CHILD_TAG = "CONSTRAINT_LAYOUT_HELPER_CHILD";

protected HashMap<Integer, String> mMap = new HashMap<>();

public ConstraintHelper(Context context) {
Expand Down Expand Up @@ -702,4 +707,15 @@ public int indexFromId(final int id) {
}
return index;
}

/**
* hook for helpers to apply parameters in MotionLayout
*/
public void applyHelperParams() {

}

public static boolean isChildOfHelper(View v) {
return CHILD_TAG == v.getTag();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;

import static androidx.constraintlayout.widget.ConstraintLayout.LayoutParams.MATCH_CONSTRAINT_SPREAD;
import static androidx.constraintlayout.widget.ConstraintLayout.LayoutParams.MATCH_CONSTRAINT_WRAP;
import static androidx.constraintlayout.widget.ConstraintLayout.LayoutParams.PARENT_ID;
Expand Down Expand Up @@ -605,7 +604,7 @@ public class ConstraintLayout extends ViewGroup {
* @DoNotShow
*/
public static final int DESIGN_INFO_ID = 0;
private ConstraintsChangedListener mConstraintsChangedListener;
// private ConstraintsChangedListener mConstraintsChangedListener;
private Metrics mMetrics;

private static SharedValues sSharedValues = null;
Expand Down Expand Up @@ -851,7 +850,7 @@ public final void measure(ConstraintWidget widget,
|| !shouldDoWrap
|| (shouldDoWrap && otherDimensionStable)
|| (child instanceof Placeholder)
|| (widget.isResolvedVertically());
|| widget.isResolvedVertically();
if (useCurrent) {
verticalSpec = MeasureSpec.makeMeasureSpec(widget.getHeight(),
MeasureSpec.EXACTLY);
Expand Down Expand Up @@ -2195,6 +2194,7 @@ protected void dispatchDraw(Canvas canvas) {
Object tag = child.getTag();
if (tag != null && tag instanceof String) {
String coordinates = (String) tag;
@SuppressWarnings("StringSplitter")
String[] split = coordinates.split(",");
if (split.length == 4) {
int x = Integer.parseInt(split[0]);
Expand Down Expand Up @@ -2267,7 +2267,7 @@ protected void dispatchDraw(Canvas canvas) {
* @param constraintsChangedListener
*/
public void setOnConstraintsChanged(ConstraintsChangedListener constraintsChangedListener) {
this.mConstraintsChangedListener = constraintsChangedListener;
// this.mConstraintsChangedListener = constraintsChangedListener;
if (mConstraintLayoutSpec != null) {
mConstraintLayoutSpec.setOnConstraintsChanged(constraintsChangedListener);
}
Expand Down Expand Up @@ -2872,11 +2872,15 @@ public void reset() {
/**
* Create a LayoutParams base on an existing layout Params
*
* @param source the Layout Params to be copied
* @param params the Layout Params to be copied
*/
public LayoutParams(LayoutParams source) {
super(source);
public LayoutParams(ViewGroup.LayoutParams params) {
super(params);

if (!(params instanceof LayoutParams)) {
return;
}
LayoutParams source = (LayoutParams) params;
///////////////////////////////////////////////////////////////////////////////////////
// Layout margins handling TODO: re-activate in 3.0
///////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -3753,10 +3757,6 @@ public LayoutParams(int width, int height) {
super(width, height);
}

public LayoutParams(ViewGroup.LayoutParams source) {
super(source);
}

/**
* {@inheritDoc}
*/
Expand Down
Loading

0 comments on commit afd155a

Please sign in to comment.