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

Commit a793fc6e authored by Holly Sun's avatar Holly Sun
Browse files

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
parent 5db9942c
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -107,8 +107,7 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
            new RecyclerView.OnScrollListener() {
                @Override
                public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
                    updateHeaderScroll(
                            ((AllAppsRecyclerView) recyclerView).computeVerticalScrollOffset());
                    updateHeaderScroll(recyclerView.computeVerticalScrollOffset());
                }
            };

@@ -192,7 +191,6 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
                reset(true);
            }
        }

    }

    @Override
@@ -815,6 +813,10 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
        }
    }

    protected void onInitializeRecyclerView(RecyclerView rv) {
        rv.addOnScrollListener(mScrollListener);
    }

    /** Holds a {@link BaseAllAppsAdapter} and related fields. */
    public class AdapterHolder {
        public static final int MAIN = 0;
@@ -851,7 +853,7 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
            mRecyclerView.setHasFixedSize(true);
            // No animations will occur when changes occur to the items in this RecyclerView.
            mRecyclerView.setItemAnimator(null);
            mRecyclerView.addOnScrollListener(mScrollListener);
            onInitializeRecyclerView(mRecyclerView);
            FocusedItemDecorator focusedItemDecorator = new FocusedItemDecorator(mRecyclerView);
            mRecyclerView.addItemDecoration(focusedItemDecorator);
            mAdapter.setIconFocusListener(focusedItemDecorator.getFocusListener());
+7 −0
Original line number Diff line number Diff line
@@ -25,4 +25,11 @@ public class BaseSearchConfig {
    public boolean isKeyboardSyncEnabled() {
        return false;
    }

    /**
     * Returns whether IME is enabled on swipe up.
     */
    public boolean isImeEnabledOnSwipeUp() {
        return false;
    }
}
+31 −0
Original line number Diff line number Diff line
@@ -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);
    }
+4 −0
Original line number Diff line number Diff line
@@ -290,6 +290,10 @@ public final class FeatureFlags {
    public static final BooleanFlag ENABLE_WIDGET_PICKER_DEPTH = new DeviceFlag(
            "ENABLE_WIDGET_PICKER_DEPTH", true, "Enable changing depth in widget picker.");

    public static final BooleanFlag SCROLL_TOP_TO_RESET = new DeviceFlag(
            "SCROLL_TOP_TO_RESET", false, "Bring up IME and focus on "
            + "input when scroll to top if 'Always show keyboard' is enabled or in prefix state");

    public static final BooleanFlag SHOW_DELIGHTFUL_PAGINATION = getDebugFlag(
            "SHOW_DELIGHTFUL_PAGINATION", false,
            "Enable showing the new 'delightful pagination' which is a brand"