summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClara Bayarri <clarabayarri@google.com>2015-05-13 15:46:57 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-05-13 15:46:59 +0000
commit99bd704f1c6bb4b818e6521ca41a70a2ec2245f4 (patch)
tree135c24e3f04180dcedf607717cf56841c7ccd280
parent05fe90c10b54111a742187935f2890029b348bf5 (diff)
parent0d7d4ef56083543d58ef5835ec594865a547347c (diff)
downloadframeworks_base-99bd704f1c6bb4b818e6521ca41a70a2ec2245f4.zip
frameworks_base-99bd704f1c6bb4b818e6521ca41a70a2ec2245f4.tar.gz
frameworks_base-99bd704f1c6bb4b818e6521ca41a70a2ec2245f4.tar.bz2
Merge "Fix Floating Toolbar appearing after ActionMode was cancelled" into mnc-dev
-rw-r--r--core/java/com/android/internal/policy/PhoneWindow.java7
-rw-r--r--core/java/com/android/internal/view/FloatingActionMode.java24
2 files changed, 19 insertions, 12 deletions
diff --git a/core/java/com/android/internal/policy/PhoneWindow.java b/core/java/com/android/internal/policy/PhoneWindow.java
index a578a6e..bc64373 100644
--- a/core/java/com/android/internal/policy/PhoneWindow.java
+++ b/core/java/com/android/internal/policy/PhoneWindow.java
@@ -3376,9 +3376,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
mFloatingActionMode.finish();
}
cleanupFloatingActionModeViews();
- mFloatingToolbar = new FloatingToolbar(mContext, PhoneWindow.this);
- final FloatingActionMode mode = new FloatingActionMode(
- mContext, callback, originatingView, mFloatingToolbar);
+ final FloatingActionMode mode =
+ new FloatingActionMode(mContext, callback, originatingView);
mFloatingActionModeOriginatingView = originatingView;
mFloatingToolbarPreDrawListener =
new OnPreDrawListener() {
@@ -3393,6 +3392,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
private void setHandledFloatingActionMode(ActionMode mode) {
mFloatingActionMode = mode;
+ mFloatingToolbar = new FloatingToolbar(mContext, PhoneWindow.this);
+ ((FloatingActionMode) mFloatingActionMode).setFloatingToolbar(mFloatingToolbar);
mFloatingActionMode.invalidate();
mFloatingToolbar.show();
mFloatingActionModeOriginatingView.getViewTreeObserver()
diff --git a/core/java/com/android/internal/view/FloatingActionMode.java b/core/java/com/android/internal/view/FloatingActionMode.java
index aacdb34..c3f4da7 100644
--- a/core/java/com/android/internal/view/FloatingActionMode.java
+++ b/core/java/com/android/internal/view/FloatingActionMode.java
@@ -24,6 +24,7 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
+import com.android.internal.util.Preconditions;
import com.android.internal.view.menu.MenuBuilder;
import com.android.internal.widget.FloatingToolbar;
@@ -32,20 +33,28 @@ public class FloatingActionMode extends ActionMode {
private final Context mContext;
private final ActionMode.Callback2 mCallback;
private final MenuBuilder mMenu;
- private final FloatingToolbar mFloatingToolbar;
private final Rect mContentRect;
private final Rect mContentRectOnWindow;
private final Rect mPreviousContentRectOnWindow;
private final int[] mViewPosition;
private final View mOriginatingView;
+ private FloatingToolbar mFloatingToolbar;
public FloatingActionMode(
- Context context, ActionMode.Callback2 callback, View originatingView,
- FloatingToolbar floatingToolbar) {
+ Context context, ActionMode.Callback2 callback, View originatingView) {
mContext = context;
mCallback = callback;
mMenu = new MenuBuilder(context).setDefaultShowAsAction(
MenuItem.SHOW_AS_ACTION_IF_ROOM);
+ setType(ActionMode.TYPE_FLOATING);
+ mContentRect = new Rect();
+ mContentRectOnWindow = new Rect();
+ mPreviousContentRectOnWindow = new Rect();
+ mViewPosition = new int[2];
+ mOriginatingView = originatingView;
+ }
+
+ public void setFloatingToolbar(FloatingToolbar floatingToolbar) {
mFloatingToolbar = floatingToolbar
.setMenu(mMenu)
.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@@ -54,12 +63,6 @@ public class FloatingActionMode extends ActionMode {
return mCallback.onActionItemClicked(FloatingActionMode.this, item);
}
});
- setType(ActionMode.TYPE_FLOATING);
- mContentRect = new Rect();
- mContentRectOnWindow = new Rect();
- mPreviousContentRectOnWindow = new Rect();
- mViewPosition = new int[2];
- mOriginatingView = originatingView;
}
@Override
@@ -79,6 +82,7 @@ public class FloatingActionMode extends ActionMode {
@Override
public void invalidate() {
+ Preconditions.checkNotNull(mFloatingToolbar);
mCallback.onPrepareActionMode(this, mMenu);
mFloatingToolbar.updateLayout();
invalidateContentRect();
@@ -86,11 +90,13 @@ public class FloatingActionMode extends ActionMode {
@Override
public void invalidateContentRect() {
+ Preconditions.checkNotNull(mFloatingToolbar);
mCallback.onGetContentRect(this, mOriginatingView, mContentRect);
repositionToolbar();
}
public void updateViewLocationInWindow() {
+ Preconditions.checkNotNull(mFloatingToolbar);
mOriginatingView.getLocationInWindow(mViewPosition);
repositionToolbar();
}