Merge "Don't allow the status bar to collapse things we're touching." into jb-mr1-dev

This commit is contained in:
Chris Wren
2012-08-03 09:52:08 -07:00
committed by Android (Google) Code Review
5 changed files with 57 additions and 15 deletions

View File

@@ -18,4 +18,5 @@
<resources>
<item type="id" name="expandable_tag" />
<item type="id" name="user_expanded_tag" />
<item type="id" name="user_lock_tag" />
</resources>

View File

@@ -39,7 +39,8 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
View getChildAtRawPosition(float x, float y);
View getChildAtPosition(float x, float y);
boolean canChildBeExpanded(View v);
boolean setUserExpandedChild(View v, boolean userxpanded);
boolean setUserExpandedChild(View v, boolean userExpanded);
boolean setUserLockedChild(View v, boolean userLocked);
}
private static final String TAG = "ExpandHelper";
@@ -433,7 +434,7 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
final int y = (int) ev.getY();
View underPointer = findView(x, y);
if (isFinished && underPointer != null && underPointer != mCurrView) {
setGlow(0f);
finishScale(false);
initScale(underPointer);
mInitialTouchY = ev.getY();
mHasPopped = false;
@@ -458,6 +459,7 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
private boolean initScale(View v) {
if (v != null) {
if (DEBUG) Slog.d(TAG, "scale begins on view: " + v);
mCallback.setUserLockedChild(v, true);
setView(v);
setGlow(GLOW_BASE);
mScaler.setView(v);
@@ -479,21 +481,26 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
}
private void finishScale(boolean force) {
float currentHeight = mScaler.getHeight();
float targetHeight = mSmallSize;
float h = mScaler.getHeight();
final boolean wasClosed = (mOldHeight == mSmallSize);
if (wasClosed) {
h = (force || h > mSmallSize) ? mNaturalHeight : mSmallSize;
targetHeight = (force || currentHeight > mSmallSize) ? mNaturalHeight : mSmallSize;
} else {
h = (force || h < mNaturalHeight) ? mSmallSize : mNaturalHeight;
targetHeight = (force || currentHeight < mNaturalHeight) ? mSmallSize : mNaturalHeight;
}
if (mScaleAnimation.isRunning()) {
mScaleAnimation.cancel();
}
mScaleAnimation.setFloatValues(h);
mScaleAnimation.setupStartValues();
mScaleAnimation.start();
setGlow(0f);
mCallback.setUserExpandedChild(mCurrView, h == mNaturalHeight);
if (targetHeight != currentHeight) {
mScaleAnimation.setFloatValues(targetHeight);
mScaleAnimation.setupStartValues();
mScaleAnimation.start();
}
mCallback.setUserLockedChild(mCurrView, false);
if (DEBUG) Slog.d(TAG, "scale was finished on view: " + mCurrView);
}

View File

@@ -780,16 +780,20 @@ public abstract class BaseStatusBar extends SystemUI implements
int N = mNotificationData.size();
for (int i = 0; i < N; i++) {
NotificationData.Entry entry = mNotificationData.get(i);
if (i == (N-1)) {
if (DEBUG) Slog.d(TAG, "expanding top notification at " + i);
expandView(entry, true);
} else {
if (!entry.userExpanded()) {
if (DEBUG) Slog.d(TAG, "collapsing notification at " + i);
expandView(entry, false);
if (!entry.userLocked()) {
if (i == (N-1)) {
if (DEBUG) Slog.d(TAG, "expanding top notification at " + i);
expandView(entry, true);
} else {
if (DEBUG) Slog.d(TAG, "ignoring user-modified notification at " + i);
if (!entry.userExpanded()) {
if (DEBUG) Slog.d(TAG, "collapsing notification at " + i);
expandView(entry, false);
} else {
if (DEBUG) Slog.d(TAG, "ignoring user-modified notification at " + i);
}
}
} else {
if (DEBUG) Slog.d(TAG, "ignoring notification being held by user at " + i);
}
}
}

View File

@@ -71,6 +71,18 @@ public class NotificationData {
public boolean setUserExpanded(boolean userExpanded) {
return NotificationData.setUserExpanded(row, userExpanded);
}
/**
* Return whether the entry is being touched by the user.
*/
public boolean userLocked() {
return NotificationData.getUserLocked(row);
}
/**
* Set the flag indicating that this is being touched by the user.
*/
public boolean setUserLocked(boolean userLocked) {
return NotificationData.setUserLocked(row, userLocked);
}
}
private final ArrayList<Entry> mEntries = new ArrayList<Entry>();
private final Comparator<Entry> mEntryCmp = new Comparator<Entry>() {
@@ -197,4 +209,18 @@ public class NotificationData {
public static boolean setUserExpanded(View row, boolean userExpanded) {
return writeBooleanTag(row, R.id.user_expanded_tag, userExpanded);
}
/**
* Return whether the entry is being touched by the user.
*/
public static boolean getUserLocked(View row) {
return readBooleanTag(row, R.id.user_lock_tag);
}
/**
* Set whether the entry is being touched by the user.
*/
public static boolean setUserLocked(View row, boolean userLocked) {
return writeBooleanTag(row, R.id.user_lock_tag, userLocked);
}
}

View File

@@ -161,6 +161,10 @@ public class NotificationRowLayout
return NotificationData.setUserExpanded(v, userExpanded);
}
public boolean setUserLockedChild(View v, boolean userLocked) {
return NotificationData.setUserLocked(v, userLocked);
}
public void onChildDismissed(View v) {
final View veto = v.findViewById(R.id.veto);
if (veto != null && veto.getVisibility() != View.GONE && mRemoveViews) {