Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e1a4eb4a authored by Anushree Ganjam's avatar Anushree Ganjam Committed by Android (Google) Code Review
Browse files

Merge "Introduce Default Ime height." into udc-qpr-dev

parents 666c3b23 5730f03c
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -110,8 +110,6 @@ public class StatsLogCompatManager extends StatsLogManager {
    public static final CopyOnWriteArrayList<StatsLogConsumer> LOGS_CONSUMER =
            new CopyOnWriteArrayList<>();

    private final Context mContext;

    public StatsLogCompatManager(Context context) {
        mContext = context;
    }
+4 −0
Original line number Diff line number Diff line
@@ -438,4 +438,8 @@
    <!--  Folder spaces  -->
    <dimen name="folder_top_padding_default">24dp</dimen>
    <dimen name="folder_footer_horiz_padding">20dp</dimen>

    <!-- Default Ime height. Used only for logging purposes.
    Assume this is default keyboard height in EN locale in case the keyboard height is not known when queried.-->
    <dimen name="default_ime_height">300dp</dimen>
</resources>
+22 −6
Original line number Diff line number Diff line
@@ -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;
        }
    }
}
+5 −1
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ public class StatsLogManager implements ResourceBasedOverride {
    private InstanceId mInstanceId;

    protected @Nullable ActivityContext mActivityContext = null;
    protected @Nullable Context mContext = null;
    private KeyboardStateManager mKeyboardStateManager;

    /**
@@ -1035,7 +1036,9 @@ public class StatsLogManager implements ResourceBasedOverride {
     */
    public KeyboardStateManager keyboardStateManager() {
        if (mKeyboardStateManager == null) {
            mKeyboardStateManager = new KeyboardStateManager();
            mKeyboardStateManager = new KeyboardStateManager(
                    mContext != null ? mContext.getResources().getDimensionPixelSize(
                            R.dimen.default_ime_height) : 0);
        }
        return mKeyboardStateManager;
    }
@@ -1071,6 +1074,7 @@ public class StatsLogManager implements ResourceBasedOverride {
        StatsLogManager manager = Overrides.getObject(StatsLogManager.class,
                context.getApplicationContext(), R.string.stats_log_manager_class);
        manager.mActivityContext = ActivityContext.lookupContextNoThrow(context);
        manager.mContext = context;
        return manager;
    }
}