Skip to content

Commit 58bbc5f

Browse files
adampAndroid Git Automerger
authored andcommitted
am 5da6430: Optimize keyguard/IME interactions
* commit '5da6430fff7812e58ee7e9a05c62d72c36f366c8': Optimize keyguard/IME interactions
2 parents cc2a14a + 5da6430 commit 58bbc5f

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ private boolean shouldEnableScreenRotation() {
122122
class ViewManagerHost extends FrameLayout {
123123
public ViewManagerHost(Context context) {
124124
super(context);
125+
setFitsSystemWindows(true);
125126
}
126127

127128
@Override
@@ -164,7 +165,8 @@ private void maybeCreateKeyguardLocked(boolean enableScreenRotation, boolean for
164165

165166
mKeyguardHost = new ViewManagerHost(mContext);
166167

167-
int flags = WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN
168+
int flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
169+
| WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
168170
| WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
169171

170172
if (!mNeedsInput) {

policy/src/com/android/internal/policy/impl/keyguard/SlidingChallengeLayout.java

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import android.graphics.Rect;
3030
import android.graphics.drawable.Drawable;
3131
import android.util.AttributeSet;
32+
import android.util.DisplayMetrics;
3233
import android.util.FloatProperty;
3334
import android.util.Log;
3435
import android.util.Property;
@@ -64,6 +65,8 @@ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout
6465
private Drawable mFrameDrawable;
6566
private boolean mEdgeCaptured;
6667

68+
private DisplayMetrics mDisplayMetrics;
69+
6770
// Initialized during measurement from child layoutparams
6871
private View mExpandChallengeView;
6972
private KeyguardSecurityContainer mChallengeView;
@@ -264,7 +267,8 @@ public SlidingChallengeLayout(Context context, AttributeSet attrs, int defStyle)
264267
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
265268
mTouchSlopSquare = mTouchSlop * mTouchSlop;
266269

267-
final float density = res.getDisplayMetrics().density;
270+
mDisplayMetrics = res.getDisplayMetrics();
271+
final float density = mDisplayMetrics.density;
268272

269273
// top half of the lock icon, plus another 25% to be sure
270274
mDragHandleClosedAbove = (int) (DRAG_HANDLE_CLOSED_ABOVE * density + 0.5f);
@@ -887,9 +891,27 @@ protected void onMeasure(int widthSpec, int heightSpec) {
887891
continue;
888892
}
889893
// 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+
}
892913
}
914+
measureChildWithMargins(child, parentWidthSpec, 0, parentHeightSpec, 0);
893915
}
894916
}
895917

0 commit comments

Comments
 (0)