diff options
| author | 2017-03-31 15:20:24 +0000 | |
|---|---|---|
| committer | 2017-03-31 15:20:24 +0000 | |
| commit | 270e4953d27ef75177c7061912d478bc392e1fdb (patch) | |
| tree | 26c86dbdc90b05fc2cf440b6d5660d2de724908f | |
| parent | 3d9286e650831758ed12e3749d5074131c1c3c92 (diff) | |
| parent | 8f9a6c3e897eafcc39d64ca5173dc8c50fcba8f5 (diff) | |
Corrects CompactExtractEditLayout to account for systemWindowInsetBottom am: d1a0d19794
am: 8f9a6c3e89
Change-Id: I10087b9982b3eceb200b447d4faecad4eb8d19fe
| -rw-r--r-- | core/java/android/inputmethodservice/CompactExtractEditLayout.java | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/core/java/android/inputmethodservice/CompactExtractEditLayout.java b/core/java/android/inputmethodservice/CompactExtractEditLayout.java index 35c54b284275..4925d25de026 100644 --- a/core/java/android/inputmethodservice/CompactExtractEditLayout.java +++ b/core/java/android/inputmethodservice/CompactExtractEditLayout.java @@ -17,6 +17,7 @@ package android.inputmethodservice; import android.content.Context; +import android.content.res.Configuration; import android.content.res.Resources; import android.annotation.FractionRes; import android.util.AttributeSet; @@ -24,6 +25,7 @@ import android.util.DisplayMetrics; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; +import android.view.WindowInsets; import android.widget.LinearLayout; /** @@ -109,9 +111,25 @@ public class CompactExtractEditLayout extends LinearLayout { super.onAttachedToWindow(); if (mPerformLayoutChanges) { Resources res = getResources(); + Configuration cfg = res.getConfiguration(); DisplayMetrics dm = res.getDisplayMetrics(); - int heightPixels = dm.heightPixels; int widthPixels = dm.widthPixels; + int heightPixels = dm.heightPixels; + + // Percentages must be based on the pixel height of the full (apparent) display height + // which is sometimes different from display metrics. + // + // On a round device, a display height smaller than width indicates a chin (cropped + // edge of the display) for which there is no screen buffer allocated. This is + // typically 25-35px in height. + // + // getRootWindowInsets() does not function for InputMethod windows (always null). + // Instead just set height to match width if less. This is safe because round wear + // devices are by definition 1:1 aspect ratio. + + if (cfg.isScreenRound() && heightPixels < widthPixels) { + heightPixels = widthPixels; + } applyProportionalLayout(widthPixels, heightPixels); } } |