Commit e03ff3d4 authored by Stephane Zermatten's avatar Stephane Zermatten Committed by Commit Bot

[Autofill Assistant] Allow talkback access to the website again.

Before this change, both the bottom sheet and the overlay would call
mActivity.addViewObscuringAllTabs(), which means that talkback always
thought something was obscuring the browser and didn't give access to
the browser.

With this change, responsibility for deciding whether the browser page
is accessible to talkback is moved to the bottom sheet coordinator and
controlled based on the state of the controller.

This allows access to the website using talkback whenever interactive
access to the website is expected.

Bug: b/133436371
Change-Id: I3e49d26985c44f534eb5d11a85b6a2c692e60424
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1634886
Commit-Queue: Stephane Zermatten <szermatt@chromium.org>
Reviewed-by: default avatarJordan Demeulenaere <jdemeulenaere@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664304}
parent fa4a217a
......@@ -4,7 +4,6 @@
package org.chromium.chrome.browser.autofill_assistant;
import android.app.Activity;
import android.content.Context;
import android.support.annotation.Nullable;
import android.transition.ChangeBounds;
......@@ -21,6 +20,7 @@ import org.chromium.base.Callback;
import org.chromium.base.ObserverList;
import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.autofill_assistant.R;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.autofill_assistant.carousel.AssistantActionsCarouselCoordinator;
import org.chromium.chrome.browser.autofill_assistant.carousel.AssistantCarouselCoordinator;
import org.chromium.chrome.browser.autofill_assistant.carousel.AssistantChip;
......@@ -76,7 +76,7 @@ class AssistantBottomBarCoordinator
private boolean mResizeViewport;
AssistantBottomBarCoordinator(
Activity activity, AssistantModel model, BottomSheetController controller) {
ChromeActivity activity, AssistantModel model, BottomSheetController controller) {
mModel = model;
mBottomSheetController = controller;
mContent = new AssistantBottomSheetContent(activity);
......@@ -184,6 +184,13 @@ class AssistantBottomBarCoordinator
} else {
hide();
}
} else if (AssistantModel.ALLOW_TALKBACK_ON_WEBSITE == propertyKey) {
boolean allow = model.get(AssistantModel.ALLOW_TALKBACK_ON_WEBSITE);
if (allow) {
activity.removeViewObscuringAllTabs(bottomSheet);
} else {
activity.addViewObscuringAllTabs(bottomSheet);
}
}
});
......
......@@ -21,6 +21,8 @@ import org.chromium.ui.modelutil.PropertyModel;
@JNINamespace("autofill_assistant")
class AssistantModel extends PropertyModel {
static final WritableBooleanPropertyKey ALLOW_SOFT_KEYBOARD = new WritableBooleanPropertyKey();
static final WritableBooleanPropertyKey ALLOW_TALKBACK_ON_WEBSITE =
new WritableBooleanPropertyKey();
static final WritableBooleanPropertyKey VISIBLE = new WritableBooleanPropertyKey();
private final AssistantOverlayModel mOverlayModel = new AssistantOverlayModel();
......@@ -34,7 +36,7 @@ class AssistantModel extends PropertyModel {
private final AssistantCarouselModel mActionsModel = new AssistantCarouselModel();
AssistantModel() {
super(ALLOW_SOFT_KEYBOARD, VISIBLE);
super(ALLOW_SOFT_KEYBOARD, VISIBLE, ALLOW_TALKBACK_ON_WEBSITE);
}
@CalledByNative
......@@ -80,6 +82,11 @@ class AssistantModel extends PropertyModel {
set(ALLOW_SOFT_KEYBOARD, allowed);
}
@CalledByNative
private void setAllowTalkbackOnWebsite(boolean allowed) {
set(ALLOW_TALKBACK_ON_WEBSITE, allowed);
}
@CalledByNative
void setVisible(boolean visible) {
set(VISIBLE, visible);
......
......@@ -62,8 +62,6 @@ public class AssistantOverlayCoordinator {
* Destroy this coordinator.
*/
public void destroy() {
if (mActivity.isViewObscuringAllTabs()) mActivity.removeViewObscuringAllTabs(mScrim);
setScrimEnabled(false);
mEventFilter.destroy();
mDrawable.destroy();
......@@ -91,14 +89,6 @@ public class AssistantOverlayCoordinator {
mDrawable.setPartial(state == AssistantOverlayState.PARTIAL);
mEventFilter.setPartial(state == AssistantOverlayState.PARTIAL);
}
if (state == AssistantOverlayState.FULL && !mActivity.isViewObscuringAllTabs()) {
mActivity.addViewObscuringAllTabs(mScrim);
}
if (state != AssistantOverlayState.FULL && mActivity.isViewObscuringAllTabs()) {
mActivity.removeViewObscuringAllTabs(mScrim);
}
}
private void setScrimEnabled(boolean enabled) {
......
......@@ -524,6 +524,8 @@ UiControllerAndroid::GetOverlayModel() {
void UiControllerAndroid::SetOverlayState(OverlayState state) {
Java_AssistantOverlayModel_setState(AttachCurrentThread(), GetOverlayModel(),
state);
Java_AssistantModel_setAllowTalkbackOnWebsite(
AttachCurrentThread(), GetModel(), state != OverlayState::FULL);
}
void UiControllerAndroid::OnTouchableAreaChanged(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment