Loading src/com/android/launcher3/views/ActivityContext.java +20 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.view.WindowInsetsCompat; import com.android.launcher3.BubbleTextView; import com.android.launcher3.DeviceProfile; Loading Loading @@ -314,6 +315,25 @@ public interface ActivityContext { == ((Context) this).getResources().getConfiguration().keyboard; } /** * Returns if the software keyboard is hidden. Hardware keyboards do not display on screen by * default. */ default boolean isSoftwareKeyboardHidden() { if (isHardwareKeyboard()) { return true; } else { View dragLayer = getDragLayer(); WindowInsets insets = dragLayer.getRootWindowInsets(); if (insets == null) { return false; } WindowInsetsCompat insetsCompat = WindowInsetsCompat.toWindowInsetsCompat(insets, dragLayer); return !insetsCompat.isVisible(WindowInsetsCompat.Type.ime()); } } /** * Sends a pending intent animating from a view. * Loading tests/src/com/android/launcher3/allapps/TaplKeyboardFocusTest.java +3 −7 Original line number Diff line number Diff line Loading @@ -23,8 +23,6 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import android.view.KeyEvent; import android.view.View; import android.view.WindowInsets; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; Loading @@ -33,6 +31,7 @@ import com.android.launcher3.LauncherState; import com.android.launcher3.tapl.HomeAllApps; import com.android.launcher3.ui.AbstractLauncherUiTest; import com.android.launcher3.util.rule.TestStabilityRule; import com.android.launcher3.views.ActivityContext; import org.junit.Before; import org.junit.Test; Loading Loading @@ -102,11 +101,8 @@ public class TaplKeyboardFocusTest extends AbstractLauncherUiTest { executeOnLauncher(launcher -> launcher.getAppsView().getSearchUiManager().getEditText() .hideKeyboard(/* clearFocus= */ false)); waitForLauncherCondition("Keyboard still visible.", launcher -> { View root = launcher.getDragLayer(); WindowInsets insets = root.getRootWindowInsets(); return insets != null && !insets.isVisible(WindowInsets.Type.ime()); }); waitForLauncherCondition("Keyboard still visible.", ActivityContext::isSoftwareKeyboardHidden); mLauncher.pressAndHoldKeyCode(KeyEvent.KEYCODE_DPAD_DOWN, 0); mLauncher.unpressKeyCode(KeyEvent.KEYCODE_DPAD_DOWN, 0); Loading Loading
src/com/android/launcher3/views/ActivityContext.java +20 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.view.WindowInsetsCompat; import com.android.launcher3.BubbleTextView; import com.android.launcher3.DeviceProfile; Loading Loading @@ -314,6 +315,25 @@ public interface ActivityContext { == ((Context) this).getResources().getConfiguration().keyboard; } /** * Returns if the software keyboard is hidden. Hardware keyboards do not display on screen by * default. */ default boolean isSoftwareKeyboardHidden() { if (isHardwareKeyboard()) { return true; } else { View dragLayer = getDragLayer(); WindowInsets insets = dragLayer.getRootWindowInsets(); if (insets == null) { return false; } WindowInsetsCompat insetsCompat = WindowInsetsCompat.toWindowInsetsCompat(insets, dragLayer); return !insetsCompat.isVisible(WindowInsetsCompat.Type.ime()); } } /** * Sends a pending intent animating from a view. * Loading
tests/src/com/android/launcher3/allapps/TaplKeyboardFocusTest.java +3 −7 Original line number Diff line number Diff line Loading @@ -23,8 +23,6 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import android.view.KeyEvent; import android.view.View; import android.view.WindowInsets; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; Loading @@ -33,6 +31,7 @@ import com.android.launcher3.LauncherState; import com.android.launcher3.tapl.HomeAllApps; import com.android.launcher3.ui.AbstractLauncherUiTest; import com.android.launcher3.util.rule.TestStabilityRule; import com.android.launcher3.views.ActivityContext; import org.junit.Before; import org.junit.Test; Loading Loading @@ -102,11 +101,8 @@ public class TaplKeyboardFocusTest extends AbstractLauncherUiTest { executeOnLauncher(launcher -> launcher.getAppsView().getSearchUiManager().getEditText() .hideKeyboard(/* clearFocus= */ false)); waitForLauncherCondition("Keyboard still visible.", launcher -> { View root = launcher.getDragLayer(); WindowInsets insets = root.getRootWindowInsets(); return insets != null && !insets.isVisible(WindowInsets.Type.ime()); }); waitForLauncherCondition("Keyboard still visible.", ActivityContext::isSoftwareKeyboardHidden); mLauncher.pressAndHoldKeyCode(KeyEvent.KEYCODE_DPAD_DOWN, 0); mLauncher.unpressKeyCode(KeyEvent.KEYCODE_DPAD_DOWN, 0); Loading