Allow FloatingToolbar to be outside of the attached window.
Currently PopupWindow used for the floating toolbar specifies neither FLAG_LAYOUT_NO_LIMITS nor FLAG_LAYOUT_IN_SCREEN. As a result, the floating toolbar can overlap the selected text when the attached window does not have enough height. Here is the repro code. final TextView textView = new TextView(this); textView.setLayoutParams( new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); textView.setText("A test sentence."); textView.setTextIsSelectable(true); final AlertDialog dialog = new AlertDialog.Builder(this) .setView(textView) .create(); dialog.getWindow().setGravity(Gravity.BOTTOM) dialog.show(); If you tap a word in the dialog, the floating toolbar unintentionally overlaps the selected text due to the limited height of the AlertDialog. It also turns out that just calling PopupWindow.setClippingEnabled(false) to specify FLAG_LAYOUT_NO_LIMITS is not sufficient and ends up showing the toolbar on the NavBar because we have mistakenly compared bounds in window-local coordinates (e.g. FloatingActionModemContentRectOnWindow) with bounds in screen coordinates (e.g. FloatingActionMode#mScreenRect). Hence the confusion of window-local coordinates and screen coordinates in FloatingToolbar and FloatingToolbar also needs to be addresses. To summarize here are the notable changes in this CL: - Specify FLAG_LAYOUT_NO_LIMITS so that the floating toolbar can be placed outside of the attached window. (We do this with PopupWindow#setClippingEnabled) - Switch to use screen coordinates from window-local coordiantes in FloatingToolbar and FloatingActionMode because some system components such as WindowManager prefer screen coordinates. - Put -OnScreen suffix for Rect and Point variables as long as they are in screen coordinates. Bug: 22335001 Change-Id: I71a8d356e868dc7715b030ca1078da4ec39368c3
Loading
Please register or sign in to comment