Merge "Allow pinch gestures to spill over into the shade header." into jb-dev
This commit is contained in:
@@ -31,7 +31,7 @@ import com.android.internal.widget.SizeAdaptiveLayout;
|
||||
|
||||
public class ExpandHelper implements Gefingerpoken, OnClickListener {
|
||||
public interface Callback {
|
||||
View getChildAtPosition(MotionEvent ev);
|
||||
View getChildAtRawPosition(float x, float y);
|
||||
View getChildAtPosition(float x, float y);
|
||||
boolean canChildBeExpanded(View v);
|
||||
boolean setUserExpandedChild(View v, boolean userxpanded);
|
||||
@@ -62,6 +62,7 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
|
||||
private Context mContext;
|
||||
|
||||
private boolean mStretching;
|
||||
private View mEventSource;
|
||||
private View mCurrView;
|
||||
private View mCurrViewTopGlow;
|
||||
private View mCurrViewBottomGlow;
|
||||
@@ -141,7 +142,19 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
|
||||
@Override
|
||||
public boolean onScaleBegin(ScaleGestureDetector detector) {
|
||||
if (DEBUG) Log.v(TAG, "onscalebegin()");
|
||||
View v = mCallback.getChildAtPosition(detector.getFocusX(), detector.getFocusY());
|
||||
float x = detector.getFocusX();
|
||||
float y = detector.getFocusY();
|
||||
|
||||
View v = null;
|
||||
if (mEventSource != null) {
|
||||
int[] location = new int[2];
|
||||
mEventSource.getLocationOnScreen(location);
|
||||
x += (float) location[0];
|
||||
y += (float) location[1];
|
||||
v = mCallback.getChildAtRawPosition(x, y);
|
||||
} else {
|
||||
v = mCallback.getChildAtPosition(x, y);
|
||||
}
|
||||
|
||||
// your fingers have to be somewhat close to the bounds of the view in question
|
||||
mInitialTouchFocusY = detector.getFocusY();
|
||||
@@ -189,6 +202,11 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setEventSource(View eventSource) {
|
||||
mEventSource = eventSource;
|
||||
}
|
||||
|
||||
public void setGlow(float glow) {
|
||||
if (!mGlowAnimationSet.isRunning() || glow == 0f) {
|
||||
if (mGlowAnimationSet.isRunning()) {
|
||||
@@ -211,7 +229,6 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
if (DEBUG) Log.d(TAG, "interceptTouch: act=" + (ev.getAction()) +
|
||||
" stretching=" + mStretching);
|
||||
@@ -223,11 +240,13 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
|
||||
final int action = ev.getAction();
|
||||
if (DEBUG) Log.d(TAG, "touch: act=" + (action) + " stretching=" + mStretching);
|
||||
if (mStretching) {
|
||||
if (DEBUG) Log.d(TAG, "detector ontouch");
|
||||
mDetector.onTouchEvent(ev);
|
||||
}
|
||||
switch (action) {
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
if (DEBUG) Log.d(TAG, "cancel");
|
||||
mStretching = false;
|
||||
clearView();
|
||||
break;
|
||||
|
||||
@@ -289,7 +289,7 @@ public class PhoneStatusBar extends BaseStatusBar {
|
||||
animateCollapse();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return mStatusBarWindow.onTouchEvent(event);
|
||||
}});
|
||||
|
||||
mStatusBarView = (PhoneStatusBarView) mStatusBarWindow.findViewById(R.id.status_bar);
|
||||
|
||||
@@ -18,17 +18,39 @@ package com.android.systemui.statusbar.phone;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextSwitcher;
|
||||
|
||||
import com.android.systemui.ExpandHelper;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.statusbar.policy.NotificationRowLayout;
|
||||
|
||||
|
||||
public class StatusBarWindowView extends FrameLayout
|
||||
{
|
||||
private static final String TAG = "StatusBarWindowView";
|
||||
|
||||
private ExpandHelper mExpandHelper;
|
||||
private NotificationRowLayout latestItems;
|
||||
|
||||
PhoneStatusBar mService;
|
||||
|
||||
public StatusBarWindowView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setMotionEventSplittingEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow () {
|
||||
super.onAttachedToWindow();
|
||||
latestItems = (NotificationRowLayout) findViewById(R.id.latestItems);
|
||||
int minHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_min_height);
|
||||
int maxHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_max_height);
|
||||
mExpandHelper = new ExpandHelper(mContext, latestItems, minHeight, maxHeight);
|
||||
mExpandHelper.setEventSource(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,5 +65,25 @@ public class StatusBarWindowView extends FrameLayout
|
||||
}
|
||||
return super.dispatchKeyEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
MotionEvent cancellation = MotionEvent.obtain(ev);
|
||||
cancellation.setAction(MotionEvent.ACTION_CANCEL);
|
||||
|
||||
boolean intercept = mExpandHelper.onInterceptTouchEvent(ev) ||
|
||||
super.onInterceptTouchEvent(ev);
|
||||
if (intercept) {
|
||||
latestItems.onInterceptTouchEvent(cancellation);
|
||||
}
|
||||
return intercept;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent ev) {
|
||||
boolean handled = mExpandHelper.onTouchEvent(ev) ||
|
||||
super.onTouchEvent(ev);
|
||||
return handled;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.android.systemui.ExpandHelper;
|
||||
import com.android.systemui.Gefingerpoken;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.SwipeHelper;
|
||||
import com.android.systemui.statusbar.NotificationData;
|
||||
@@ -62,9 +61,6 @@ public class NotificationRowLayout
|
||||
HashMap<View, ValueAnimator> mDisappearingViews = new HashMap<View, ValueAnimator>();
|
||||
|
||||
private SwipeHelper mSwipeHelper;
|
||||
private ExpandHelper mExpandHelper;
|
||||
|
||||
private Gefingerpoken mCurrentHelper;
|
||||
|
||||
// Flag set during notification removal animation to avoid causing too much work until
|
||||
// animation is done
|
||||
@@ -81,8 +77,6 @@ public class NotificationRowLayout
|
||||
|
||||
setOrientation(LinearLayout.VERTICAL);
|
||||
|
||||
setMotionEventSplittingEnabled(false);
|
||||
|
||||
if (DEBUG) {
|
||||
setOnHierarchyChangeListener(new ViewGroup.OnHierarchyChangeListener() {
|
||||
@Override
|
||||
@@ -101,9 +95,6 @@ public class NotificationRowLayout
|
||||
float densityScale = getResources().getDisplayMetrics().density;
|
||||
float pagingTouchSlop = ViewConfiguration.get(mContext).getScaledPagingTouchSlop();
|
||||
mSwipeHelper = new SwipeHelper(SwipeHelper.X, this, densityScale, pagingTouchSlop);
|
||||
int minHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_min_height);
|
||||
int maxHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_max_height);
|
||||
mExpandHelper = new ExpandHelper(mContext, this, minHeight, maxHeight);
|
||||
}
|
||||
|
||||
public void setLongPressListener(View.OnLongClickListener listener) {
|
||||
@@ -135,39 +126,17 @@ public class NotificationRowLayout
|
||||
if (DEBUG) Log.v(TAG, "onInterceptTouchEvent()");
|
||||
if (DEBUG) logLayoutTransition();
|
||||
|
||||
MotionEvent cancellation = MotionEvent.obtain(ev);
|
||||
cancellation.setAction(MotionEvent.ACTION_CANCEL);
|
||||
|
||||
if (mSwipeHelper.onInterceptTouchEvent(ev)) {
|
||||
if (DEBUG) Log.v(TAG, "will swipe");
|
||||
mCurrentHelper = mSwipeHelper;
|
||||
mExpandHelper.onInterceptTouchEvent(cancellation);
|
||||
return true;
|
||||
} else if (mExpandHelper.onInterceptTouchEvent(ev)) {
|
||||
if (DEBUG) Log.v(TAG, "will stretch");
|
||||
mCurrentHelper = mExpandHelper;
|
||||
mSwipeHelper.onInterceptTouchEvent(cancellation);
|
||||
return true;
|
||||
} else {
|
||||
mCurrentHelper = null;
|
||||
if (super.onInterceptTouchEvent(ev)) {
|
||||
if (DEBUG) Log.v(TAG, "intercepting ourselves");
|
||||
mSwipeHelper.onInterceptTouchEvent(cancellation);
|
||||
mExpandHelper.onInterceptTouchEvent(cancellation);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return mSwipeHelper.onInterceptTouchEvent(ev) ||
|
||||
super.onInterceptTouchEvent(ev);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent ev) {
|
||||
if (DEBUG) Log.v(TAG, "onTouchEvent()");
|
||||
if (DEBUG) logLayoutTransition();
|
||||
if (mCurrentHelper != null) {
|
||||
return mCurrentHelper.onTouchEvent(ev);
|
||||
}
|
||||
return super.onTouchEvent(ev);
|
||||
|
||||
return mSwipeHelper.onTouchEvent(ev) ||
|
||||
super.onTouchEvent(ev);
|
||||
}
|
||||
|
||||
public boolean canChildBeDismissed(View v) {
|
||||
@@ -202,6 +171,13 @@ public class NotificationRowLayout
|
||||
public View getChildAtPosition(MotionEvent ev) {
|
||||
return getChildAtPosition(ev.getX(), ev.getY());
|
||||
}
|
||||
|
||||
public View getChildAtRawPosition(float touchX, float touchY) {
|
||||
int[] location = new int[2];
|
||||
getLocationOnScreen(location);
|
||||
return getChildAtPosition((float) (touchX - location[0]), (float) (touchY - location[1]));
|
||||
}
|
||||
|
||||
public View getChildAtPosition(float touchX, float touchY) {
|
||||
// find the view under the pointer, accounting for GONE views
|
||||
final int count = getChildCount();
|
||||
|
||||
Reference in New Issue
Block a user