Skip to content

Commit 5345c31

Browse files
cwrenAndroid (Google) Code Review
authored andcommitted
Merge "Don't allow the status bar to collapse things we're touching." into jb-mr1-dev
2 parents 3185b37 + 3ddab0d commit 5345c31

File tree

5 files changed

+57
-15
lines changed

5 files changed

+57
-15
lines changed

packages/SystemUI/res/values/ids.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@
1818
<resources>
1919
<item type="id" name="expandable_tag" />
2020
<item type="id" name="user_expanded_tag" />
21+
<item type="id" name="user_lock_tag" />
2122
</resources>

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ public interface Callback {
3939
View getChildAtRawPosition(float x, float y);
4040
View getChildAtPosition(float x, float y);
4141
boolean canChildBeExpanded(View v);
42-
boolean setUserExpandedChild(View v, boolean userxpanded);
42+
boolean setUserExpandedChild(View v, boolean userExpanded);
43+
boolean setUserLockedChild(View v, boolean userLocked);
4344
}
4445

4546
private static final String TAG = "ExpandHelper";
@@ -433,7 +434,7 @@ public boolean onTouchEvent(MotionEvent ev) {
433434
final int y = (int) ev.getY();
434435
View underPointer = findView(x, y);
435436
if (isFinished && underPointer != null && underPointer != mCurrView) {
436-
setGlow(0f);
437+
finishScale(false);
437438
initScale(underPointer);
438439
mInitialTouchY = ev.getY();
439440
mHasPopped = false;
@@ -458,6 +459,7 @@ public boolean onTouchEvent(MotionEvent ev) {
458459
private boolean initScale(View v) {
459460
if (v != null) {
460461
if (DEBUG) Slog.d(TAG, "scale begins on view: " + v);
462+
mCallback.setUserLockedChild(v, true);
461463
setView(v);
462464
setGlow(GLOW_BASE);
463465
mScaler.setView(v);
@@ -479,21 +481,26 @@ private boolean initScale(View v) {
479481
}
480482

481483
private void finishScale(boolean force) {
484+
float currentHeight = mScaler.getHeight();
485+
float targetHeight = mSmallSize;
482486
float h = mScaler.getHeight();
483487
final boolean wasClosed = (mOldHeight == mSmallSize);
484488
if (wasClosed) {
485-
h = (force || h > mSmallSize) ? mNaturalHeight : mSmallSize;
489+
targetHeight = (force || currentHeight > mSmallSize) ? mNaturalHeight : mSmallSize;
486490
} else {
487-
h = (force || h < mNaturalHeight) ? mSmallSize : mNaturalHeight;
491+
targetHeight = (force || currentHeight < mNaturalHeight) ? mSmallSize : mNaturalHeight;
488492
}
489493
if (mScaleAnimation.isRunning()) {
490494
mScaleAnimation.cancel();
491495
}
492-
mScaleAnimation.setFloatValues(h);
493-
mScaleAnimation.setupStartValues();
494-
mScaleAnimation.start();
495496
setGlow(0f);
496497
mCallback.setUserExpandedChild(mCurrView, h == mNaturalHeight);
498+
if (targetHeight != currentHeight) {
499+
mScaleAnimation.setFloatValues(targetHeight);
500+
mScaleAnimation.setupStartValues();
501+
mScaleAnimation.start();
502+
}
503+
mCallback.setUserLockedChild(mCurrView, false);
497504
if (DEBUG) Slog.d(TAG, "scale was finished on view: " + mCurrView);
498505
}
499506

packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -780,16 +780,20 @@ protected void updateExpansionStates() {
780780
int N = mNotificationData.size();
781781
for (int i = 0; i < N; i++) {
782782
NotificationData.Entry entry = mNotificationData.get(i);
783-
if (i == (N-1)) {
784-
if (DEBUG) Slog.d(TAG, "expanding top notification at " + i);
785-
expandView(entry, true);
786-
} else {
787-
if (!entry.userExpanded()) {
788-
if (DEBUG) Slog.d(TAG, "collapsing notification at " + i);
789-
expandView(entry, false);
783+
if (!entry.userLocked()) {
784+
if (i == (N-1)) {
785+
if (DEBUG) Slog.d(TAG, "expanding top notification at " + i);
786+
expandView(entry, true);
790787
} else {
791-
if (DEBUG) Slog.d(TAG, "ignoring user-modified notification at " + i);
788+
if (!entry.userExpanded()) {
789+
if (DEBUG) Slog.d(TAG, "collapsing notification at " + i);
790+
expandView(entry, false);
791+
} else {
792+
if (DEBUG) Slog.d(TAG, "ignoring user-modified notification at " + i);
793+
}
792794
}
795+
} else {
796+
if (DEBUG) Slog.d(TAG, "ignoring notification being held by user at " + i);
793797
}
794798
}
795799
}

packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,18 @@ public boolean userExpanded() {
7171
public boolean setUserExpanded(boolean userExpanded) {
7272
return NotificationData.setUserExpanded(row, userExpanded);
7373
}
74+
/**
75+
* Return whether the entry is being touched by the user.
76+
*/
77+
public boolean userLocked() {
78+
return NotificationData.getUserLocked(row);
79+
}
80+
/**
81+
* Set the flag indicating that this is being touched by the user.
82+
*/
83+
public boolean setUserLocked(boolean userLocked) {
84+
return NotificationData.setUserLocked(row, userLocked);
85+
}
7486
}
7587
private final ArrayList<Entry> mEntries = new ArrayList<Entry>();
7688
private final Comparator<Entry> mEntryCmp = new Comparator<Entry>() {
@@ -197,4 +209,18 @@ public static boolean getUserExpanded(View row) {
197209
public static boolean setUserExpanded(View row, boolean userExpanded) {
198210
return writeBooleanTag(row, R.id.user_expanded_tag, userExpanded);
199211
}
212+
213+
/**
214+
* Return whether the entry is being touched by the user.
215+
*/
216+
public static boolean getUserLocked(View row) {
217+
return readBooleanTag(row, R.id.user_lock_tag);
218+
}
219+
220+
/**
221+
* Set whether the entry is being touched by the user.
222+
*/
223+
public static boolean setUserLocked(View row, boolean userLocked) {
224+
return writeBooleanTag(row, R.id.user_lock_tag, userLocked);
225+
}
200226
}

packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ public boolean setUserExpandedChild(View v, boolean userExpanded) {
161161
return NotificationData.setUserExpanded(v, userExpanded);
162162
}
163163

164+
public boolean setUserLockedChild(View v, boolean userLocked) {
165+
return NotificationData.setUserLocked(v, userLocked);
166+
}
167+
164168
public void onChildDismissed(View v) {
165169
final View veto = v.findViewById(R.id.veto);
166170
if (veto != null && veto.getVisibility() != View.GONE && mRemoveViews) {

0 commit comments

Comments
 (0)