|
29 | 29 | import android.graphics.Rect; |
30 | 30 | import android.graphics.drawable.Drawable; |
31 | 31 | import android.util.AttributeSet; |
| 32 | +import android.util.DisplayMetrics; |
32 | 33 | import android.util.FloatProperty; |
33 | 34 | import android.util.Log; |
34 | 35 | import android.util.Property; |
@@ -64,6 +65,8 @@ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout |
64 | 65 | private Drawable mFrameDrawable; |
65 | 66 | private boolean mEdgeCaptured; |
66 | 67 |
|
| 68 | + private DisplayMetrics mDisplayMetrics; |
| 69 | + |
67 | 70 | // Initialized during measurement from child layoutparams |
68 | 71 | private View mExpandChallengeView; |
69 | 72 | private KeyguardSecurityContainer mChallengeView; |
@@ -264,7 +267,8 @@ public SlidingChallengeLayout(Context context, AttributeSet attrs, int defStyle) |
264 | 267 | mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); |
265 | 268 | mTouchSlopSquare = mTouchSlop * mTouchSlop; |
266 | 269 |
|
267 | | - final float density = res.getDisplayMetrics().density; |
| 270 | + mDisplayMetrics = res.getDisplayMetrics(); |
| 271 | + final float density = mDisplayMetrics.density; |
268 | 272 |
|
269 | 273 | // top half of the lock icon, plus another 25% to be sure |
270 | 274 | mDragHandleClosedAbove = (int) (DRAG_HANDLE_CLOSED_ABOVE * density + 0.5f); |
@@ -887,9 +891,27 @@ protected void onMeasure(int widthSpec, int heightSpec) { |
887 | 891 | continue; |
888 | 892 | } |
889 | 893 | // Don't measure the challenge view twice! |
890 | | - if (child != mChallengeView) { |
891 | | - measureChildWithMargins(child, widthSpec, 0, heightSpec, 0); |
| 894 | + if (child == mChallengeView) continue; |
| 895 | + |
| 896 | + // Measure children. Widget frame measures special, so that we can ignore |
| 897 | + // insets for the IME. |
| 898 | + int parentWidthSpec = widthSpec, parentHeightSpec = heightSpec; |
| 899 | + final LayoutParams lp = (LayoutParams) child.getLayoutParams(); |
| 900 | + if (lp.childType == LayoutParams.CHILD_TYPE_WIDGETS) { |
| 901 | + final View root = getRootView(); |
| 902 | + if (root != null) { |
| 903 | + // This calculation is super dodgy and relies on several assumptions. |
| 904 | + // Specifically that the root of the window will be padded in for insets |
| 905 | + // and that the window is LAYOUT_IN_SCREEN. |
| 906 | + final int windowWidth = mDisplayMetrics.widthPixels; |
| 907 | + final int windowHeight = mDisplayMetrics.heightPixels - root.getPaddingTop(); |
| 908 | + parentWidthSpec = MeasureSpec.makeMeasureSpec( |
| 909 | + windowWidth, MeasureSpec.EXACTLY); |
| 910 | + parentHeightSpec = MeasureSpec.makeMeasureSpec( |
| 911 | + windowHeight, MeasureSpec.EXACTLY); |
| 912 | + } |
892 | 913 | } |
| 914 | + measureChildWithMargins(child, parentWidthSpec, 0, parentHeightSpec, 0); |
893 | 915 | } |
894 | 916 | } |
895 | 917 |
|
|
0 commit comments