Skip to content

Commit a54c01e

Browse files
cwrenAndroid (Google) Code Review
authored andcommitted
Merge "Invert the sense of the two-figner direction on tablets." into jb-dev
2 parents b44700f + 9b2cd15 commit a54c01e

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

packages/SystemUI/src/com/android/systemui/ExpandHelper.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@
2323
import android.animation.ObjectAnimator;
2424
import android.content.Context;
2525
import android.util.Log;
26+
import android.view.Gravity;
2627
import android.view.MotionEvent;
2728
import android.view.ScaleGestureDetector;
2829
import android.view.View;
2930
import android.view.ViewGroup;
3031
import android.view.View.OnClickListener;
32+
import android.widget.ScrollView;
33+
import android.widget.FrameLayout;
3134

3235
public class ExpandHelper implements Gefingerpoken, OnClickListener {
3336
public interface Callback {
@@ -38,7 +41,7 @@ public interface Callback {
3841
}
3942

4043
private static final String TAG = "ExpandHelper";
41-
protected static final boolean DEBUG = false;
44+
protected static final boolean DEBUG = true;
4245
private static final long EXPAND_DURATION = 250;
4346
private static final long GLOW_DURATION = 150;
4447

@@ -82,8 +85,11 @@ public interface Callback {
8285
private int mLargeSize;
8386
private float mMaximumStretch;
8487

88+
private int mGravity;
89+
8590
private class ViewScaler {
8691
View mView;
92+
8793
public ViewScaler() {}
8894
public void setView(View v) {
8995
mView = v;
@@ -119,14 +125,23 @@ public int getNaturalHeight(int maximum) {
119125
}
120126
}
121127

128+
/**
129+
* Handle expansion gestures to expand and contract children of the callback.
130+
*
131+
* @param context application context
132+
* @param callback the container that holds the items to be manipulated
133+
* @param small the smallest allowable size for the manuipulated items.
134+
* @param large the largest allowable size for the manuipulated items.
135+
* @param scoller if non-null also manipulate the scroll position to obey the gravity.
136+
*/
122137
public ExpandHelper(Context context, Callback callback, int small, int large) {
123138
mSmallSize = small;
124139
mMaximumStretch = mSmallSize * STRETCH_INTERVAL;
125140
mLargeSize = large;
126141
mContext = context;
127142
mCallback = callback;
128143
mScaler = new ViewScaler();
129-
144+
mGravity = Gravity.TOP;
130145
mScaleAnimation = ObjectAnimator.ofFloat(mScaler, "height", 0f);
131146
mScaleAnimation.setDuration(EXPAND_DURATION);
132147

@@ -194,6 +209,7 @@ public boolean onScale(ScaleGestureDetector detector) {
194209
span *= USE_SPAN ? 1f : 0f;
195210
float drag = detector.getFocusY() - mInitialTouchFocusY;
196211
drag *= USE_DRAG ? 1f : 0f;
212+
drag *= mGravity == Gravity.BOTTOM ? -1f : 1f;
197213
float pull = Math.abs(drag) + Math.abs(span) + 1f;
198214
float hand = drag * Math.abs(drag) / pull + span * Math.abs(span) / pull;
199215
if (DEBUG) Log.d(TAG, "current span handle is: " + hand);
@@ -227,6 +243,10 @@ public void setEventSource(View eventSource) {
227243
mEventSource = eventSource;
228244
}
229245

246+
public void setGravity(int gravity) {
247+
mGravity = gravity;
248+
}
249+
230250
public void setGlow(float glow) {
231251
if (!mGlowAnimationSet.isRunning() || glow == 0f) {
232252
if (mGlowAnimationSet.isRunning()) {

packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import android.view.KeyEvent;
2323
import android.view.MotionEvent;
2424
import android.widget.FrameLayout;
25+
import android.widget.ScrollView;
2526
import android.widget.TextSwitcher;
2627

2728
import com.android.systemui.ExpandHelper;
@@ -47,6 +48,7 @@ public StatusBarWindowView(Context context, AttributeSet attrs) {
4748
protected void onAttachedToWindow () {
4849
super.onAttachedToWindow();
4950
latestItems = (NotificationRowLayout) findViewById(R.id.latestItems);
51+
ScrollView scroller = (ScrollView) findViewById(R.id.scroll);
5052
int minHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_min_height);
5153
int maxHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_max_height);
5254
mExpandHelper = new ExpandHelper(mContext, latestItems, minHeight, maxHeight);

packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import android.graphics.Rect;
2525
import android.util.AttributeSet;
2626
import android.util.Slog;
27+
import android.view.Gravity;
2728
import android.view.LayoutInflater;
2829
import android.view.MotionEvent;
2930
import android.view.View;
@@ -33,6 +34,7 @@
3334
import android.view.animation.DecelerateInterpolator;
3435
import android.view.animation.Interpolator;
3536
import android.widget.RelativeLayout;
37+
import android.widget.ScrollView;
3638

3739
import com.android.systemui.ExpandHelper;
3840
import com.android.systemui.R;
@@ -114,6 +116,7 @@ protected void onAttachedToWindow () {
114116
int maxHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_max_height);
115117
mExpandHelper = new ExpandHelper(mContext, latestItems, minHeight, maxHeight);
116118
mExpandHelper.setEventSource(this);
119+
mExpandHelper.setGravity(Gravity.BOTTOM);
117120
}
118121

119122
private View.OnClickListener mClearButtonListener = new View.OnClickListener() {

0 commit comments

Comments
 (0)