Set gravity to end if we begin clipping subviews.
In the pin view, after a certain number of pin inputs, the pin dots begin to get cut off. This is because the gravity is centered. During the layout pass, we calculate what to set the gravity to. We use the local visible rect to determine if the first child (the leftmost dot) is clipped or not visible. This will help us indicate whether we are overflowing. In this case we want to justify all of the dots to the end. Otherwise, we want to remain centered. Fixes: 285576678 Test: Tested non hinting pin view with overflow. Tested deletion and full deletion as well. Change-Id: I037f265ec80b1a105f0658217adc4383a3181987
This commit is contained in:
@@ -30,6 +30,7 @@ import android.transition.TransitionManager;
|
||||
import android.transition.TransitionValues;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
@@ -51,11 +52,29 @@ public class PinShapeNonHintingView extends LinearLayout implements PinShapeInpu
|
||||
private int mPosition = 0;
|
||||
private final PinShapeAdapter mPinShapeAdapter;
|
||||
private ValueAnimator mValueAnimator = ValueAnimator.ofFloat(1f, 0f);
|
||||
private Rect mFirstChildVisibleRect = new Rect();
|
||||
public PinShapeNonHintingView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mPinShapeAdapter = new PinShapeAdapter(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
super.onLayout(changed, l, t, r, b);
|
||||
if (getChildCount() > 0) {
|
||||
View firstChild = getChildAt(0);
|
||||
boolean isVisible = firstChild.getLocalVisibleRect(mFirstChildVisibleRect);
|
||||
boolean clipped = mFirstChildVisibleRect.left > 0
|
||||
|| mFirstChildVisibleRect.right < firstChild.getWidth();
|
||||
if (!isVisible || clipped) {
|
||||
setGravity(Gravity.END | Gravity.CENTER_VERTICAL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
setGravity(Gravity.CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void append() {
|
||||
int size = getResources().getDimensionPixelSize(R.dimen.password_shape_size);
|
||||
|
||||
Reference in New Issue
Block a user