Commit 6d7e365c authored by Becky Zhou's avatar Becky Zhou Committed by Commit Bot

[TabModal] Improve accessibility and keyboard for javascript dialog

+ Fix keyboard not showing when interacting between url bar and prompt
javascript dialog
+ Fix keyboard not being hidden when entering tab switcher
+ Add accessibility description when opening tab modal dialogs

Bug: 798893, 812443
Change-Id: I162b4dface23c5af142ffc2054aaf489dcc53647
Reviewed-on: https://chromium-review.googlesource.com/897989
Commit-Queue: Becky Zhou <huayinz@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541640}
parent 9b321c9e
......@@ -192,4 +192,11 @@ public class ModalDialogView implements View.OnClickListener {
public Controller getController() {
return mController;
}
/**
* @return The content description of the dialog view.
*/
public String getContentDescription() {
return mParams.title;
}
}
......@@ -22,6 +22,7 @@ import org.chromium.chrome.browser.widget.bottomsheet.BottomSheet;
import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetObserver;
import org.chromium.chrome.browser.widget.bottomsheet.EmptyBottomSheetObserver;
import org.chromium.content_public.browser.ContentViewCore;
import org.chromium.ui.UiUtils;
/**
* The presenter that displays a single tab modal dialog.
......@@ -94,11 +95,14 @@ public class TabModalPresenter extends ModalDialogManager.Presenter {
MarginLayoutParams.MATCH_PARENT, MarginLayoutParams.WRAP_CONTENT, Gravity.CENTER);
mDialogContainer.addView(dialogView, params);
mChromeActivity.addViewObscuringAllTabs(mDialogContainer);
updateContainerHierarchy(true);
}
@Override
protected void removeDialogView(View dialogView) {
setBrowserControlsAccess(false);
// Clear focus so that keyboard can hide accordingly while entering tab switcher.
dialogView.clearFocus();
mDialogContainer.removeView(dialogView);
mDialogContainer.setVisibility(View.GONE);
mChromeActivity.removeViewObscuringAllTabs(mDialogContainer);
......@@ -110,14 +114,24 @@ public class TabModalPresenter extends ModalDialogManager.Presenter {
* @param toFront Whether the dialog container should be brought to the front.
*/
void updateContainerHierarchy(boolean toFront) {
View dialogView = getModalDialog().getView();
if (toFront) {
dialogView.announceForAccessibility(getModalDialog().getContentDescription());
dialogView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
dialogView.requestFocus();
} else {
dialogView.clearFocus();
dialogView.setImportantForAccessibility(
View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
}
if (toFront == mContainerIsAtFront) return;
mContainerIsAtFront = toFront;
if (toFront) {
mDialogContainer.bringToFront();
} else {
mContainerParent.removeView(mDialogContainer);
mContainerParent.addView(
mDialogContainer, mContainerParent.indexOfChild(mDefaultNextSiblingView));
UiUtils.removeViewFromParent(mDialogContainer);
UiUtils.insertBefore(mContainerParent, mDialogContainer, mDefaultNextSiblingView);
}
}
......@@ -206,7 +220,6 @@ public class TabModalPresenter extends ModalDialogManager.Presenter {
mChromeActivity.getToolbarManager().setUrlBarFocus(false);
}
menuButton.setEnabled(false);
updateContainerHierarchy(true);
} else {
// Show the action bar back if it was dismissed when the dialogs were showing.
ContentViewCore contentViewCore = mActiveTab.getContentViewCore();
......
......@@ -1063,6 +1063,14 @@ public class LocationBarLayout extends FrameLayout
setUrlBarText("", null);
}
mUrlBar.deEmphasizeUrl();
// Explicitly tell InputMethodManager that the url bar is focused before any callbacks
// so that it updates the active view accordingly. Otherwise, it may fail to update
// the correct active view if ViewGroup.addView() or ViewGroup.removeView() is called
// to update a view that accepts text input.
InputMethodManager imm = (InputMethodManager) mUrlBar.getContext().getSystemService(
Context.INPUT_METHOD_SERVICE);
imm.viewClicked(mUrlBar);
} else {
mUrlFocusedFromFakebox = false;
mUrlFocusedWithoutAnimations = false;
......@@ -2073,6 +2081,7 @@ public class LocationBarLayout extends FrameLayout
@Override
public void backKeyPressed() {
setUrlBarFocus(false);
hideSuggestions();
UiUtils.hideKeyboard(mUrlBar);
// Revert the URL to match the current page.
......
......@@ -15,7 +15,6 @@ import android.os.Environment;
import android.os.Handler;
import android.os.StrictMode;
import android.text.TextUtils;
import android.util.Log;
import android.view.SurfaceView;
import android.view.View;
import android.view.View.MeasureSpec;
......@@ -27,6 +26,7 @@ import android.widget.AbsListView;
import android.widget.ListAdapter;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.Log;
import java.io.File;
import java.io.IOException;
......
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