Introduce Default Ime height.
Assume IME_DEFAULT_HEIGHT_DP = 300. When ime is yet to be shown but the UI is ready, then use IME_DEFAULT_HEIGHT_DP. For the 2nd time onwards save the actual ime height and use it when the keyboard is not shown yet. Bug: 285166099 Test: Manual Change-Id: I33e38cbd5c2910f4a6dc4cc83c8dc4b6d94fbcff
This commit is contained in:
@@ -24,7 +24,10 @@ import android.os.SystemClock;
|
||||
*/
|
||||
public class KeyboardStateManager {
|
||||
private long mUpdatedTime;
|
||||
private int mImeHeight;
|
||||
private int mImeHeightPx;
|
||||
// Height of the keyboard when it's shown.
|
||||
// mImeShownHeightPx>=mImeHeightPx always.
|
||||
private int mImeShownHeightPx;
|
||||
|
||||
public enum KeyboardState {
|
||||
NO_IME_ACTION,
|
||||
@@ -34,8 +37,9 @@ public class KeyboardStateManager {
|
||||
|
||||
private KeyboardState mKeyboardState;
|
||||
|
||||
public KeyboardStateManager() {
|
||||
public KeyboardStateManager(int defaultImeShownHeightPx) {
|
||||
mKeyboardState = NO_IME_ACTION;
|
||||
mImeShownHeightPx = defaultImeShownHeightPx;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,13 +68,25 @@ public class KeyboardStateManager {
|
||||
* Returns keyboard's current height.
|
||||
*/
|
||||
public int getImeHeight() {
|
||||
return mImeHeight;
|
||||
return mImeHeightPx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter method to set keyboard height.
|
||||
* Returns keyboard's height in pixels when shown.
|
||||
*/
|
||||
public void setImeHeight(int imeHeight) {
|
||||
mImeHeight = imeHeight;
|
||||
public int getImeShownHeight() {
|
||||
return mImeShownHeightPx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter method to set keyboard height in pixels.
|
||||
*/
|
||||
public void setImeHeight(int imeHeightPx) {
|
||||
mImeHeightPx = imeHeightPx;
|
||||
if (mImeHeightPx > 0) {
|
||||
// Update the mImeShownHeightPx with the actual ime height when shown and store it
|
||||
// for future sessions.
|
||||
mImeShownHeightPx = mImeHeightPx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user