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

Commit d0aba607 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Introduce KeyboardStateManager to maintain keyboardstate as show or hide." into tm-qpr-dev

parents 0b448547 a461660f
Loading
Loading
Loading
Loading
+8 −16
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package com.android.launcher3;

import static com.android.launcher3.logging.KeyboardStateManager.KeyboardState.SHOW;
import static com.android.launcher3.util.UiThreadHelper.hideKeyboardAsync;

import android.content.Context;
@@ -33,8 +34,6 @@ import com.android.launcher3.views.ActivityContext;
 * Note: AppCompatEditText doesn't fully support #displayCompletions and #onCommitCompletion
 */
public class ExtendedEditText extends EditText {

    private boolean mShowImeAfterFirstLayout;
    private boolean mForceDisableSuggestions = false;

    /**
@@ -85,21 +84,9 @@ public class ExtendedEditText extends EditText {
        return false;
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
        if (mShowImeAfterFirstLayout) {
            // soft input only shows one frame after the layout of the EditText happens,
            post(() -> {
                showSoftInput();
                mShowImeAfterFirstLayout = false;
            });
        }
    }


    public void showKeyboard() {
        mShowImeAfterFirstLayout = !showSoftInput();
        onKeyboardShown();
        showSoftInput();
    }

    public void hideKeyboard() {
@@ -107,6 +94,11 @@ public class ExtendedEditText extends EditText {
        clearFocus();
    }

    protected void onKeyboardShown() {
        ActivityContext.lookupContext(getContext()).getStatsLogManager()
                .keyboardStateManager().setKeyboardState(SHOW);
    }

    private boolean showSoftInput() {
        return requestFocus() &&
                getContext().getSystemService(InputMethodManager.class)
+5 −0
Original line number Diff line number Diff line
@@ -288,6 +288,11 @@ public final class FeatureFlags {
    public static final BooleanFlag SHOW_SEARCH_EDUCARD_QSB = new DeviceFlag(
            "SHOW_SEARCH_EDUCARD_QSB", false, "Shows Search Educard for QSB entry in OneSearch.");

    public static final BooleanFlag ENABLE_IME_LATENCY_LOGGER = getDebugFlag(
            "ENABLE_IME_LATENCY_LOGGER", false,
            "Enable option to log the keyboard latency for both atomic and controlled keyboard "
                    + "animations on an EditText");

    public static void initialize(Context context) {
        synchronized (sDebugFlags) {
            for (DebugFlag flag : sDebugFlags) {
+61 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.launcher3.logging;

import static com.android.launcher3.logging.KeyboardStateManager.KeyboardState.NO_IME_ACTION;

import android.os.SystemClock;

/**
 * Class to maintain keyboard states.
 */
public class KeyboardStateManager {
    private long mUpdatedTime;

    public enum KeyboardState {
        NO_IME_ACTION,
        SHOW,
        HIDE,
    }

    private KeyboardState mKeyboardState;

    public KeyboardStateManager() {
        mKeyboardState = NO_IME_ACTION;
    }

    /**
     * Returns time when keyboard state was updated.
     */
    public long getLastUpdatedTime() {
        return mUpdatedTime;
    }

    /**
     * Returns current keyboard state.
     */
    public KeyboardState getKeyboardState() {
        return mKeyboardState;
    }

    /**
     * Setter method to set keyboard state.
     */
    public void setKeyboardState(KeyboardState keyboardState) {
        mUpdatedTime = SystemClock.elapsedRealtime();
        mKeyboardState = keyboardState;
    }
}
+11 −0
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ public class StatsLogManager implements ResourceBasedOverride {
    private InstanceId mInstanceId;

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

    /**
     * Returns event enum based on the two state transition information when swipe
@@ -816,6 +817,16 @@ public class StatsLogManager implements ResourceBasedOverride {
        return logger;
    }

    /**
     * Returns a singleton KeyboardStateManager.
     */
    public KeyboardStateManager keyboardStateManager() {
        if (mKeyboardStateManager == null) {
            mKeyboardStateManager = new KeyboardStateManager();
        }
        return mKeyboardStateManager;
    }

    protected StatsLogger createLogger() {
        return new StatsLogger() {
        };
+5 −0
Original line number Diff line number Diff line
@@ -40,4 +40,9 @@ public class LogConfig {
     * When turned on, we enable suggest related logging.
     */
    public static final String SEARCH_LOGGING = "SearchLogging";

    /**
     * When turned on, we enable IME related latency related logging.
     */
    public static final String IME_LATENCY_LOGGING = "ImeLatencyLogging";
}
Loading