Bring up IME and focus on input when scroll to top.

Do this behind a feature flag AND only when "Always show keyboard" is selected or in prefix state.

Bug: 218846025
Test: keyboard shown when swiping up for QSB and AA+ (both main and work). Keyboard not shown when either the feature flag or Always show keyboard is disabled.
Change-Id: I3df2e0e44a8313eaf749cd6b91b7f9d0b9b80ec3
This commit is contained in:
Holly Sun
2022-10-03 16:56:26 -07:00
parent 5db9942c61
commit a793fc6e2c
4 changed files with 48 additions and 4 deletions
@@ -16,19 +16,50 @@
package com.android.launcher3.allapps;
import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.WindowInsets;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.android.launcher3.ExtendedEditText;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.Utilities;
import com.android.launcher3.config.FeatureFlags;
/**
* AllAppsContainerView with launcher specific callbacks
*/
public class LauncherAllAppsContainerView extends ActivityAllAppsContainerView<Launcher> {
private final RecyclerView.OnScrollListener mActivityScrollListener =
new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
int scrolledOffset = recyclerView.computeVerticalScrollOffset();
ExtendedEditText input = mSearchUiManager.getEditText();
// Scroll up and scroll to top
if (dy < 0 && scrolledOffset == 0 && input != null) {
boolean isImeEnabledOnSwipeUp = Launcher.getLauncher(mActivityContext)
.getSearchConfig().isImeEnabledOnSwipeUp();
if (isImeEnabledOnSwipeUp || !TextUtils.isEmpty(input.getText())) {
input.showKeyboard();
}
}
}
};
@Override
protected void onInitializeRecyclerView(RecyclerView rv) {
super.onInitializeRecyclerView(rv);
if (FeatureFlags.SCROLL_TOP_TO_RESET.get()) {
rv.addOnScrollListener(mActivityScrollListener);
}
}
public LauncherAllAppsContainerView(Context context) {
this(context, null);
}