mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-28 15:56:49 +00:00
Merge "Add IDs to buttons in 3 button nav for Taskbar" into sc-v2-dev am: 3fcc02b8dc
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/15027506 Change-Id: I0a9ba369f2a852ec1afd4e39663f339db1316d9b
This commit is contained in:
@@ -30,6 +30,7 @@ import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_I
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.annotation.DrawableRes;
|
||||
import android.annotation.IdRes;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Region;
|
||||
import android.graphics.Region.Op;
|
||||
@@ -123,7 +124,8 @@ public class NavbarButtonsViewController {
|
||||
flags -> (flags & FLAG_KEYGUARD_VISIBLE) == 0, MultiValueAlpha.VALUE, 1, 0));
|
||||
|
||||
// Rotation button
|
||||
RotationButton rotationButton = new RotationButtonImpl(addButton(mEndContainer));
|
||||
RotationButton rotationButton = new RotationButtonImpl(
|
||||
addButton(mEndContainer, R.id.rotate_suggestion));
|
||||
rotationButton.hide();
|
||||
mControllers.rotationButtonController.setRotationButton(rotationButton);
|
||||
} else {
|
||||
@@ -138,7 +140,7 @@ public class NavbarButtonsViewController {
|
||||
TaskbarNavButtonController navButtonController) {
|
||||
|
||||
View backButton = addButton(R.drawable.ic_sysbar_back, BUTTON_BACK,
|
||||
startContainer, navButtonController);
|
||||
startContainer, navButtonController, R.id.back);
|
||||
// Rotate when Ime visible
|
||||
mPropertyHolders.add(new StatePropertyHolder(backButton,
|
||||
flags -> (flags & FLAG_IME_VISIBLE) == 0, View.ROTATION, 0,
|
||||
@@ -149,19 +151,19 @@ public class NavbarButtonsViewController {
|
||||
|
||||
// home and recents buttons
|
||||
View homeButton = addButton(R.drawable.ic_sysbar_home, BUTTON_HOME, startContainer,
|
||||
navButtonController);
|
||||
navButtonController, R.id.home);
|
||||
mPropertyHolders.add(new StatePropertyHolder(homeButton,
|
||||
flags -> (flags & FLAG_IME_VISIBLE) == 0 &&
|
||||
(flags & FLAG_KEYGUARD_VISIBLE) == 0));
|
||||
View recentsButton = addButton(R.drawable.ic_sysbar_recent, BUTTON_RECENTS,
|
||||
startContainer, navButtonController);
|
||||
startContainer, navButtonController, R.id.recent_apps);
|
||||
mPropertyHolders.add(new StatePropertyHolder(recentsButton,
|
||||
flags -> (flags & FLAG_IME_VISIBLE) == 0 &&
|
||||
(flags & FLAG_KEYGUARD_VISIBLE) == 0));
|
||||
|
||||
// IME switcher
|
||||
View imeSwitcherButton = addButton(R.drawable.ic_ime_switcher, BUTTON_IME_SWITCH,
|
||||
endContainer, navButtonController);
|
||||
endContainer, navButtonController, R.id.ime_switcher);
|
||||
mPropertyHolders.add(new StatePropertyHolder(imeSwitcherButton,
|
||||
flags -> ((flags & MASK_IME_SWITCHER_VISIBLE) == MASK_IME_SWITCHER_VISIBLE)
|
||||
&& ((flags & FLAG_ROTATION_BUTTON_VISIBLE) == 0)
|
||||
@@ -169,7 +171,7 @@ public class NavbarButtonsViewController {
|
||||
|
||||
// A11y button
|
||||
mA11yButton = addButton(R.drawable.ic_sysbar_accessibility_button, BUTTON_A11Y,
|
||||
endContainer, navButtonController);
|
||||
endContainer, navButtonController, R.id.accessibility_button);
|
||||
mPropertyHolders.add(new StatePropertyHolder(mA11yButton,
|
||||
flags -> (flags & FLAG_A11Y_VISIBLE) != 0
|
||||
&& (flags & FLAG_ROTATION_BUTTON_VISIBLE) == 0));
|
||||
@@ -251,16 +253,17 @@ public class NavbarButtonsViewController {
|
||||
}
|
||||
|
||||
private ImageView addButton(@DrawableRes int drawableId, @TaskbarButton int buttonType,
|
||||
ViewGroup parent, TaskbarNavButtonController navButtonController) {
|
||||
ImageView buttonView = addButton(parent);
|
||||
ViewGroup parent, TaskbarNavButtonController navButtonController, @IdRes int id) {
|
||||
ImageView buttonView = addButton(parent, id);
|
||||
buttonView.setImageResource(drawableId);
|
||||
buttonView.setOnClickListener(view -> navButtonController.onButtonClick(buttonType));
|
||||
return buttonView;
|
||||
}
|
||||
|
||||
private ImageView addButton(ViewGroup parent) {
|
||||
private ImageView addButton(ViewGroup parent, int id) {
|
||||
ImageView buttonView = (ImageView) mContext.getLayoutInflater()
|
||||
.inflate(R.layout.taskbar_nav_button, parent, false);
|
||||
buttonView.setId(id);
|
||||
parent.addView(buttonView);
|
||||
mAllButtons.add(buttonView);
|
||||
return buttonView;
|
||||
|
||||
@@ -23,6 +23,8 @@ import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
|
||||
import com.android.launcher3.testing.TestLogging;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
import com.android.quickstep.OverviewCommandHelper;
|
||||
import com.android.quickstep.SystemUiProxy;
|
||||
import com.android.quickstep.TouchInteractionService;
|
||||
@@ -94,6 +96,7 @@ public class TaskbarNavButtonController {
|
||||
}
|
||||
|
||||
private void navigateToOverview() {
|
||||
TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "onOverviewToggle");
|
||||
mService.getOverviewCommandHelper().addCommand(OverviewCommandHelper.TYPE_TOGGLE);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,4 +19,13 @@
|
||||
<item type="id" name="view_type_widgets_list" />
|
||||
<item type="id" name="view_type_widgets_header" />
|
||||
<item type="id" name="view_type_widgets_search_header" />
|
||||
|
||||
<!-- Do not change, must be kept in sync with sysui navbar button IDs for tests! -->
|
||||
<item type="id" name="home" />
|
||||
<item type="id" name="recent_apps" />
|
||||
<item type="id" name="back" />
|
||||
<item type="id" name="ime_switcher" />
|
||||
<item type="id" name="accessibility_button" />
|
||||
<item type="id" name="rotate_suggestion" />
|
||||
<!-- /Do not change, must be kept in sync with sysui navbar button IDs for tests! -->
|
||||
</resources>
|
||||
|
||||
@@ -117,6 +117,10 @@ public class TestInformationHandler implements ResourceBasedOverride {
|
||||
TestProtocol.sDisableSensorRotation = true;
|
||||
return response;
|
||||
|
||||
case TestProtocol.REQUEST_IS_TABLET:
|
||||
response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, mDeviceProfile.isTablet);
|
||||
return response;
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -94,6 +94,7 @@ public final class TestProtocol {
|
||||
public static final String REQUEST_GET_TEST_EVENTS = "get-test-events";
|
||||
public static final String REQUEST_STOP_EVENT_LOGGING = "stop-event-logging";
|
||||
public static final String REQUEST_CLEAR_DATA = "clear-data";
|
||||
public static final String REQUEST_IS_TABLET = "is-tablet";
|
||||
|
||||
public static boolean sDebugTracing = false;
|
||||
public static final String REQUEST_ENABLE_DEBUG_TRACING = "enable-debug-tracing";
|
||||
|
||||
@@ -136,7 +136,7 @@ public class Background extends LauncherInstrumentation.VisibleContainer {
|
||||
case THREE_BUTTON:
|
||||
mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, SQUARE_BUTTON_EVENT);
|
||||
mLauncher.runToState(
|
||||
() -> mLauncher.waitForSystemUiObject("recent_apps").click(),
|
||||
() -> mLauncher.waitForNavigationUiObject("recent_apps").click(),
|
||||
OVERVIEW_STATE_ORDINAL);
|
||||
break;
|
||||
}
|
||||
@@ -224,7 +224,7 @@ public class Background extends LauncherInstrumentation.VisibleContainer {
|
||||
|
||||
case THREE_BUTTON:
|
||||
// Double press the recents button.
|
||||
UiObject2 recentsButton = mLauncher.waitForSystemUiObject("recent_apps");
|
||||
UiObject2 recentsButton = mLauncher.waitForNavigationUiObject("recent_apps");
|
||||
mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, SQUARE_BUTTON_EVENT);
|
||||
mLauncher.runToState(() -> recentsButton.click(), OVERVIEW_STATE_ORDINAL);
|
||||
mLauncher.getOverview();
|
||||
|
||||
@@ -283,6 +283,11 @@ public final class LauncherInstrumentation {
|
||||
.getParcelable(TestProtocol.TEST_INFO_RESPONSE_FIELD);
|
||||
}
|
||||
|
||||
public boolean isTablet() {
|
||||
return getTestInfo(TestProtocol.REQUEST_IS_TABLET)
|
||||
.getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD);
|
||||
}
|
||||
|
||||
void setActiveContainer(VisibleContainer container) {
|
||||
sActiveContainer = new WeakReference<>(container);
|
||||
}
|
||||
@@ -554,29 +559,35 @@ public final class LauncherInstrumentation {
|
||||
public String getNavigationModeMismatchError(boolean waitForCorrectState) {
|
||||
final int waitTime = waitForCorrectState ? WAIT_TIME_MS : 0;
|
||||
final NavigationModel navigationModel = getNavigationModel();
|
||||
|
||||
String resPackage = getNavigationButtonResPackage();
|
||||
if (navigationModel == NavigationModel.THREE_BUTTON) {
|
||||
if (!mDevice.wait(Until.hasObject(By.res(SYSTEMUI_PACKAGE, "recent_apps")), waitTime)) {
|
||||
if (!mDevice.wait(Until.hasObject(By.res(resPackage, "recent_apps")), waitTime)) {
|
||||
return "Recents button not present in 3-button mode";
|
||||
}
|
||||
} else {
|
||||
if (!mDevice.wait(Until.gone(By.res(SYSTEMUI_PACKAGE, "recent_apps")), waitTime)) {
|
||||
if (!mDevice.wait(Until.gone(By.res(resPackage, "recent_apps")), waitTime)) {
|
||||
return "Recents button is present in non-3-button mode";
|
||||
}
|
||||
}
|
||||
|
||||
if (navigationModel == NavigationModel.ZERO_BUTTON) {
|
||||
if (!mDevice.wait(Until.gone(By.res(SYSTEMUI_PACKAGE, "home")), waitTime)) {
|
||||
if (!mDevice.wait(Until.gone(By.res(resPackage, "home")), waitTime)) {
|
||||
return "Home button is present in gestural mode";
|
||||
}
|
||||
} else {
|
||||
if (!mDevice.wait(Until.hasObject(By.res(SYSTEMUI_PACKAGE, "home")), waitTime)) {
|
||||
if (!mDevice.wait(Until.hasObject(By.res(resPackage, "home")), waitTime)) {
|
||||
return "Home button not present in non-gestural mode";
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getNavigationButtonResPackage() {
|
||||
return isTablet() && getNavigationModel() == NavigationModel.THREE_BUTTON ?
|
||||
getLauncherPackageName() :
|
||||
SYSTEMUI_PACKAGE;
|
||||
}
|
||||
|
||||
private UiObject2 verifyContainerType(ContainerType containerType) {
|
||||
waitForLauncherInitialized();
|
||||
|
||||
@@ -741,7 +752,7 @@ public final class LauncherInstrumentation {
|
||||
}
|
||||
|
||||
runToState(
|
||||
waitForSystemUiObject("home")::click,
|
||||
waitForNavigationUiObject("home")::click,
|
||||
NORMAL_STATE_ORDINAL,
|
||||
!hasLauncherObject(WORKSPACE_RES_ID)
|
||||
&& (hasLauncherObject(APPS_RES_ID)
|
||||
@@ -891,6 +902,15 @@ public final class LauncherInstrumentation {
|
||||
return object;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
UiObject2 waitForNavigationUiObject(String resId) {
|
||||
String resPackage = getNavigationButtonResPackage();
|
||||
final UiObject2 object = mDevice.wait(
|
||||
Until.findObject(By.res(resPackage, resId)), WAIT_TIME_MS);
|
||||
assertNotNull("Can't find a navigation UI object with id: " + resId, object);
|
||||
return object;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
UiObject2 findObjectInContainer(UiObject2 container, BySelector selector) {
|
||||
try {
|
||||
|
||||
@@ -63,7 +63,7 @@ public final class Workspace extends Home {
|
||||
/**
|
||||
* Swipes up to All Apps.
|
||||
*
|
||||
* @return the App Apps object.
|
||||
* @return the All Apps object.
|
||||
*/
|
||||
@NonNull
|
||||
public AllApps switchToAllApps() {
|
||||
|
||||
Reference in New Issue
Block a user