Commit bf03673f authored by Jordan Demeulenaere's avatar Jordan Demeulenaere Committed by Commit Bot

[Autofill Assistant] Move keyboard state in AssistantModel.

Change-Id: Ief1b7bdb79394818d5511c7e11945d5293be1814
Reviewed-on: https://chromium-review.googlesource.com/c/1442235Reviewed-by: default avatarStephane Zermatten <szermatt@chromium.org>
Commit-Queue: Jordan Demeulenaere <jdemeulenaere@chromium.org>
Cr-Commit-Position: refs/heads/master@{#626985}
parent 983968a6
......@@ -69,6 +69,14 @@ class AssistantCoordinator {
mOverlayCoordinator =
new AssistantOverlayCoordinator(activity, mAssistantView, mModel.getOverlayModel());
// Notify AssistantKeyboardCoordinator when we should (dis)allow the soft keyboard.
mModel.addObserver((source, propertyKey) -> {
if (AssistantModel.ALLOW_SOFT_KEYBOARD == propertyKey) {
mKeyboardCoordinator.allowShowingSoftKeyboard(
mModel.get(AssistantModel.ALLOW_SOFT_KEYBOARD));
}
});
showAssistantView();
}
......@@ -164,14 +172,6 @@ class AssistantCoordinator {
return mBottomBarCoordinator;
}
public AssistantKeyboardCoordinator getKeyboardCoordinator() {
return mKeyboardCoordinator;
}
public AssistantOverlayCoordinator getOverlayCoordinator() {
return mOverlayCoordinator;
}
/**
* Dismiss the assistant view and show a cancellable snackbar alerting the user that the
* Autofill assistant is shutting down.
......
......@@ -10,17 +10,24 @@ import org.chromium.chrome.browser.autofill_assistant.carousel.AssistantCarousel
import org.chromium.chrome.browser.autofill_assistant.details.AssistantDetailsModel;
import org.chromium.chrome.browser.autofill_assistant.header.AssistantHeaderModel;
import org.chromium.chrome.browser.autofill_assistant.overlay.AssistantOverlayModel;
import org.chromium.ui.modelutil.PropertyModel;
/**
* State for the Autofill Assistant UI.
*/
@JNINamespace("autofill_assistant")
class AssistantModel {
class AssistantModel extends PropertyModel {
static final WritableBooleanPropertyKey ALLOW_SOFT_KEYBOARD = new WritableBooleanPropertyKey();
private final AssistantOverlayModel mOverlayModel = new AssistantOverlayModel();
private final AssistantHeaderModel mHeaderModel = new AssistantHeaderModel();
private final AssistantDetailsModel mDetailsModel = new AssistantDetailsModel();
private final AssistantCarouselModel mCarouselModel = new AssistantCarouselModel();
AssistantModel() {
super(ALLOW_SOFT_KEYBOARD);
}
@CalledByNative
public AssistantOverlayModel getOverlayModel() {
return mOverlayModel;
......@@ -40,4 +47,9 @@ class AssistantModel {
public AssistantCarouselModel getCarouselModel() {
return mCarouselModel;
}
@CalledByNative
private void setAllowSoftKeyboard(boolean allowed) {
set(ALLOW_SOFT_KEYBOARD, allowed);
}
}
......@@ -111,11 +111,6 @@ class AutofillAssistantUiController implements AssistantCoordinator.Delegate {
mNativeUiController = 0;
}
@CalledByNative
private void onAllowShowingSoftKeyboard(boolean allowed) {
mCoordinator.getKeyboardCoordinator().allowShowingSoftKeyboard(allowed);
}
@CalledByNative
private void onShutdown(@DropOutReason int reason) {
mCoordinator.shutdownImmediately(reason);
......
......@@ -165,8 +165,8 @@ void UiControllerAndroid::HideProgressBar() {
}
void UiControllerAndroid::AllowShowingSoftKeyboard(bool enabled) {
Java_AutofillAssistantUiController_onAllowShowingSoftKeyboard(
AttachCurrentThread(), java_autofill_assistant_ui_controller_, enabled);
Java_AssistantModel_setAllowSoftKeyboard(AttachCurrentThread(), GetModel(),
enabled);
}
void UiControllerAndroid::ExpandBottomSheet() {
......
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