Merge "Improved expansion logic of NotificationStackScroller"
This commit is contained in:
@@ -108,7 +108,7 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
|
||||
|
||||
private int mGravity;
|
||||
|
||||
private View mScrollView;
|
||||
private ScrollAdapter mScrollAdapter;
|
||||
|
||||
private OnScaleGestureListener mScaleGestureListener
|
||||
= new ScaleGestureDetector.SimpleOnScaleGestureListener() {
|
||||
@@ -301,8 +301,8 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
|
||||
mGravity = gravity;
|
||||
}
|
||||
|
||||
public void setScrollView(View scrollView) {
|
||||
mScrollView = scrollView;
|
||||
public void setScrollAdapter(ScrollAdapter adapter) {
|
||||
mScrollAdapter = adapter;
|
||||
}
|
||||
|
||||
private float calculateGlow(float target, float actual) {
|
||||
@@ -384,7 +384,7 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (mScrollView != null && mScrollView.getScrollY() > 0) {
|
||||
if (mScrollAdapter != null && !mScrollAdapter.isScrolledToTop()) {
|
||||
return false;
|
||||
}
|
||||
// Now look for other gestures
|
||||
@@ -407,7 +407,7 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
|
||||
}
|
||||
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
mWatchingForPull = isInside(mScrollView, x, y);
|
||||
mWatchingForPull = isInside(mScrollAdapter.getHostView(), x, y);
|
||||
mLastMotionY = y;
|
||||
break;
|
||||
|
||||
@@ -608,5 +608,19 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
|
||||
}
|
||||
mVibrator.vibrate(duration, AudioManager.STREAM_SYSTEM);
|
||||
}
|
||||
|
||||
public interface ScrollAdapter {
|
||||
|
||||
/**
|
||||
* @return Whether the view returned by {@link #getHostView()} is scrolled to the top
|
||||
* and can therefore be expanded by a single finger drag
|
||||
*/
|
||||
public boolean isScrolledToTop();
|
||||
|
||||
/**
|
||||
* @return The view in which the scrolling is performed
|
||||
*/
|
||||
public View getHostView();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1483,7 +1483,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode {
|
||||
}
|
||||
|
||||
mExpandedVisible = true;
|
||||
if(!ENABLE_NOTIFICATION_STACK) {
|
||||
if (!ENABLE_NOTIFICATION_STACK) {
|
||||
((NotificationRowLayout) mPile).setLayoutTransitionsEnabled(true);
|
||||
}
|
||||
if (mNavigationBarView != null)
|
||||
@@ -1777,7 +1777,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode {
|
||||
}
|
||||
|
||||
mExpandedVisible = false;
|
||||
if(!ENABLE_NOTIFICATION_STACK) {
|
||||
if (!ENABLE_NOTIFICATION_STACK) {
|
||||
((NotificationRowLayout) mPile).setLayoutTransitionsEnabled(false);
|
||||
}
|
||||
if (mNavigationBarView != null)
|
||||
@@ -2477,7 +2477,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode {
|
||||
int totalDelay = 0;
|
||||
|
||||
|
||||
if(!ENABLE_NOTIFICATION_STACK) {
|
||||
if (!ENABLE_NOTIFICATION_STACK) {
|
||||
// Set the shade-animating state to avoid doing other work during
|
||||
// all of these animations. In particular, avoid layout and
|
||||
// redrawing when collapsing the shade.
|
||||
|
||||
@@ -27,11 +27,11 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewRootImpl;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ScrollView;
|
||||
|
||||
import com.android.systemui.ExpandHelper;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.statusbar.BaseStatusBar;
|
||||
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
|
||||
|
||||
|
||||
public class StatusBarWindowView extends FrameLayout
|
||||
@@ -42,7 +42,7 @@ public class StatusBarWindowView extends FrameLayout
|
||||
private ExpandHelper mExpandHelper;
|
||||
private ViewGroup latestItems;
|
||||
private NotificationPanelView mNotificationPanel;
|
||||
private ScrollView mScrollView;
|
||||
private View mNotificationScroller;
|
||||
|
||||
PhoneStatusBar mService;
|
||||
|
||||
@@ -56,19 +56,37 @@ public class StatusBarWindowView extends FrameLayout
|
||||
protected void onAttachedToWindow () {
|
||||
super.onAttachedToWindow();
|
||||
|
||||
ExpandHelper.ScrollAdapter scrollAdapter;
|
||||
if (BaseStatusBar.ENABLE_NOTIFICATION_STACK) {
|
||||
latestItems = (ViewGroup) findViewById(R.id.notification_stack_scroller);
|
||||
NotificationStackScrollLayout stackScrollLayout =
|
||||
(NotificationStackScrollLayout) findViewById(R.id.notification_stack_scroller);
|
||||
|
||||
// ScrollView and notification container are unified in a single view now.
|
||||
latestItems = stackScrollLayout;
|
||||
scrollAdapter = stackScrollLayout;
|
||||
mNotificationScroller = stackScrollLayout;
|
||||
} else {
|
||||
latestItems = (ViewGroup) findViewById(R.id.latestItems);
|
||||
mNotificationScroller = findViewById(R.id.scroll);
|
||||
scrollAdapter = new ExpandHelper.ScrollAdapter() {
|
||||
@Override
|
||||
public boolean isScrolledToTop() {
|
||||
return mNotificationScroller.getScrollY() == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getHostView() {
|
||||
return mNotificationScroller;
|
||||
}
|
||||
};
|
||||
}
|
||||
mScrollView = (ScrollView) findViewById(R.id.scroll);
|
||||
mNotificationPanel = (NotificationPanelView) findViewById(R.id.notification_panel);
|
||||
int minHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_min_height);
|
||||
int maxHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_max_height);
|
||||
mExpandHelper = new ExpandHelper(getContext(), (ExpandHelper.Callback) latestItems,
|
||||
minHeight, maxHeight);
|
||||
mExpandHelper.setEventSource(this);
|
||||
mExpandHelper.setScrollView(mScrollView);
|
||||
mExpandHelper.setScrollAdapter(scrollAdapter);
|
||||
|
||||
// We really need to be able to animate while window animations are going on
|
||||
// so that activities may be started asynchronously from panel animations
|
||||
@@ -94,7 +112,8 @@ public class StatusBarWindowView extends FrameLayout
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
boolean intercept = false;
|
||||
if (mNotificationPanel.isFullyExpanded() && mScrollView.getVisibility() == View.VISIBLE) {
|
||||
if (mNotificationPanel.isFullyExpanded()
|
||||
&& mNotificationScroller.getVisibility() == View.VISIBLE) {
|
||||
intercept = mExpandHelper.onInterceptTouchEvent(ev);
|
||||
}
|
||||
if (!intercept) {
|
||||
|
||||
@@ -42,7 +42,7 @@ import com.android.systemui.statusbar.ExpandableNotificationRow;
|
||||
* A layout which handles a dynamic amount of notifications and presents them in a scrollable stack.
|
||||
*/
|
||||
public class NotificationStackScrollLayout extends ViewGroup
|
||||
implements SwipeHelper.Callback, ExpandHelper.Callback {
|
||||
implements SwipeHelper.Callback, ExpandHelper.Callback, ExpandHelper.ScrollAdapter {
|
||||
|
||||
private static final String TAG = "NotificationStackScrollLayout";
|
||||
private static final boolean DEBUG = false;
|
||||
@@ -813,4 +813,14 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
mSwipeHelper.removeLongPressCallback();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isScrolledToTop() {
|
||||
return mOwnScrollY == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getHostView() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user