Loading core/java/android/view/ActionMode.java +12 −0 Original line number Diff line number Diff line Loading @@ -152,6 +152,18 @@ public abstract class ActionMode { */ public abstract MenuInflater getMenuInflater(); /** * Returns whether the UI presenting this action mode can take focus or not. * This is used by internal components within the framework that would otherwise * present an action mode UI that requires focus, such as an EditText as a custom view. * * @return true if the UI used to show this action mode can take focus * @hide Internal use only */ public boolean isUiFocusable() { return true; } /** * Callback interface for action modes. Supplied to * {@link View#startActionMode(Callback)}, a Callback Loading core/java/android/webkit/FindActionModeCallback.java +8 −0 Original line number Diff line number Diff line Loading @@ -180,6 +180,14 @@ class FindActionModeCallback implements ActionMode.Callback, TextWatcher, @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { if (!mode.isUiFocusable()) { // If the action mode we're running in is not focusable the user // will not be able to type into the find on page field. This // should only come up when we're running in a dialog which is // already less than ideal; disable the option for now. return false; } mode.setCustomView(mCustomView); mode.getMenuInflater().inflate(com.android.internal.R.menu.webview_find, menu); Loading core/java/android/webkit/SelectActionModeCallback.java +20 −5 Original line number Diff line number Diff line Loading @@ -17,13 +17,12 @@ package android.webkit; import android.app.SearchManager; import android.content.Context; import android.content.Intent; import android.provider.Browser; import android.webkit.WebView; import android.view.ActionMode; import android.view.Menu; import android.view.MenuItem; import android.view.View; class SelectActionModeCallback implements ActionMode.Callback { private WebView mWebView; Loading @@ -45,9 +44,25 @@ class SelectActionModeCallback implements ActionMode.Callback { @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { mode.getMenuInflater().inflate(com.android.internal.R.menu.webview_copy, menu); mode.setTitle(com.android.internal.R.string.textSelectionCABTitle); mode.getMenuInflater().inflate(com.android.internal.R.menu.webview_copy, menu); final Context context = mWebView.getContext(); boolean allowText = context.getResources().getBoolean( com.android.internal.R.bool.config_allowActionMenuItemTextWithIcon); mode.setTitle(allowText ? context.getString(com.android.internal.R.string.textSelectionCABTitle) : null); if (!mode.isUiFocusable()) { // If the action mode UI we're running in isn't capable of taking window focus // the user won't be able to type into the find on page UI. Disable this functionality. // (Note that this should only happen in floating dialog windows.) // This can be removed once we can handle multiple focusable windows at a time // in a better way. final MenuItem findOnPageItem = menu.findItem(com.android.internal.R.id.find); if (findOnPageItem != null) { findOnPageItem.setVisible(false); } } mActionMode = mode; return true; } Loading core/java/com/android/internal/view/StandaloneActionMode.java +7 −1 Original line number Diff line number Diff line Loading @@ -36,17 +36,19 @@ public class StandaloneActionMode extends ActionMode implements MenuBuilder.Call private ActionMode.Callback mCallback; private WeakReference<View> mCustomView; private boolean mFinished; private boolean mFocusable; private MenuBuilder mMenu; public StandaloneActionMode(Context context, ActionBarContextView view, ActionMode.Callback callback) { ActionMode.Callback callback, boolean isFocusable) { mContext = context; mContextView = view; mCallback = callback; mMenu = new MenuBuilder(context).setDefaultShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mMenu.setCallback(this); mFocusable = isFocusable; } @Override Loading Loading @@ -139,4 +141,8 @@ public class StandaloneActionMode extends ActionMode implements MenuBuilder.Call invalidate(); mContextView.showOverflowMenu(); } public boolean isUiFocusable() { return mFocusable; } } core/res/res/layout/screen_simple_overlay_action_mode.xml 0 → 100644 +37 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- /* ** Copyright 2011, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ This is an optimized layout for a screen, with the minimum set of features enabled. --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:fitsSystemWindows="true"> <FrameLayout android:id="@android:id/content" android:layout_width="match_parent" android:layout_height="match_parent" android:foregroundInsidePadding="false" android:foregroundGravity="fill_horizontal|top" android:foreground="?android:attr/windowContentOverlay" /> <ViewStub android:id="@+id/action_mode_bar_stub" android:inflatedId="@+id/action_mode_bar" android:layout="@layout/action_mode_bar" android:layout_width="match_parent" android:layout_height="wrap_content" /> </FrameLayout> Loading
core/java/android/view/ActionMode.java +12 −0 Original line number Diff line number Diff line Loading @@ -152,6 +152,18 @@ public abstract class ActionMode { */ public abstract MenuInflater getMenuInflater(); /** * Returns whether the UI presenting this action mode can take focus or not. * This is used by internal components within the framework that would otherwise * present an action mode UI that requires focus, such as an EditText as a custom view. * * @return true if the UI used to show this action mode can take focus * @hide Internal use only */ public boolean isUiFocusable() { return true; } /** * Callback interface for action modes. Supplied to * {@link View#startActionMode(Callback)}, a Callback Loading
core/java/android/webkit/FindActionModeCallback.java +8 −0 Original line number Diff line number Diff line Loading @@ -180,6 +180,14 @@ class FindActionModeCallback implements ActionMode.Callback, TextWatcher, @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { if (!mode.isUiFocusable()) { // If the action mode we're running in is not focusable the user // will not be able to type into the find on page field. This // should only come up when we're running in a dialog which is // already less than ideal; disable the option for now. return false; } mode.setCustomView(mCustomView); mode.getMenuInflater().inflate(com.android.internal.R.menu.webview_find, menu); Loading
core/java/android/webkit/SelectActionModeCallback.java +20 −5 Original line number Diff line number Diff line Loading @@ -17,13 +17,12 @@ package android.webkit; import android.app.SearchManager; import android.content.Context; import android.content.Intent; import android.provider.Browser; import android.webkit.WebView; import android.view.ActionMode; import android.view.Menu; import android.view.MenuItem; import android.view.View; class SelectActionModeCallback implements ActionMode.Callback { private WebView mWebView; Loading @@ -45,9 +44,25 @@ class SelectActionModeCallback implements ActionMode.Callback { @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { mode.getMenuInflater().inflate(com.android.internal.R.menu.webview_copy, menu); mode.setTitle(com.android.internal.R.string.textSelectionCABTitle); mode.getMenuInflater().inflate(com.android.internal.R.menu.webview_copy, menu); final Context context = mWebView.getContext(); boolean allowText = context.getResources().getBoolean( com.android.internal.R.bool.config_allowActionMenuItemTextWithIcon); mode.setTitle(allowText ? context.getString(com.android.internal.R.string.textSelectionCABTitle) : null); if (!mode.isUiFocusable()) { // If the action mode UI we're running in isn't capable of taking window focus // the user won't be able to type into the find on page UI. Disable this functionality. // (Note that this should only happen in floating dialog windows.) // This can be removed once we can handle multiple focusable windows at a time // in a better way. final MenuItem findOnPageItem = menu.findItem(com.android.internal.R.id.find); if (findOnPageItem != null) { findOnPageItem.setVisible(false); } } mActionMode = mode; return true; } Loading
core/java/com/android/internal/view/StandaloneActionMode.java +7 −1 Original line number Diff line number Diff line Loading @@ -36,17 +36,19 @@ public class StandaloneActionMode extends ActionMode implements MenuBuilder.Call private ActionMode.Callback mCallback; private WeakReference<View> mCustomView; private boolean mFinished; private boolean mFocusable; private MenuBuilder mMenu; public StandaloneActionMode(Context context, ActionBarContextView view, ActionMode.Callback callback) { ActionMode.Callback callback, boolean isFocusable) { mContext = context; mContextView = view; mCallback = callback; mMenu = new MenuBuilder(context).setDefaultShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mMenu.setCallback(this); mFocusable = isFocusable; } @Override Loading Loading @@ -139,4 +141,8 @@ public class StandaloneActionMode extends ActionMode implements MenuBuilder.Call invalidate(); mContextView.showOverflowMenu(); } public boolean isUiFocusable() { return mFocusable; } }
core/res/res/layout/screen_simple_overlay_action_mode.xml 0 → 100644 +37 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- /* ** Copyright 2011, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ This is an optimized layout for a screen, with the minimum set of features enabled. --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:fitsSystemWindows="true"> <FrameLayout android:id="@android:id/content" android:layout_width="match_parent" android:layout_height="match_parent" android:foregroundInsidePadding="false" android:foregroundGravity="fill_horizontal|top" android:foreground="?android:attr/windowContentOverlay" /> <ViewStub android:id="@+id/action_mode_bar_stub" android:inflatedId="@+id/action_mode_bar" android:layout="@layout/action_mode_bar" android:layout_width="match_parent" android:layout_height="wrap_content" /> </FrameLayout>