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

* commit '5345c310af8363948cee6a91d11add3ec51e8a9c':
  Don't allow the status bar to collapse things we're touching.
This commit is contained in:
Chris Wren
2012-08-03 09:54:43 -07:00
committed by Android Git Automerger
5 changed files with 57 additions and 15 deletions

View File

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

View File

@@ -39,7 +39,8 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
View getChildAtRawPosition(float x, float y); View getChildAtRawPosition(float x, float y);
View getChildAtPosition(float x, float y); View getChildAtPosition(float x, float y);
boolean canChildBeExpanded(View v); 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"; private static final String TAG = "ExpandHelper";
@@ -433,7 +434,7 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
final int y = (int) ev.getY(); final int y = (int) ev.getY();
View underPointer = findView(x, y); View underPointer = findView(x, y);
if (isFinished && underPointer != null && underPointer != mCurrView) { if (isFinished && underPointer != null && underPointer != mCurrView) {
setGlow(0f); finishScale(false);
initScale(underPointer); initScale(underPointer);
mInitialTouchY = ev.getY(); mInitialTouchY = ev.getY();
mHasPopped = false; mHasPopped = false;
@@ -458,6 +459,7 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
private boolean initScale(View v) { private boolean initScale(View v) {
if (v != null) { if (v != null) {
if (DEBUG) Slog.d(TAG, "scale begins on view: " + v); if (DEBUG) Slog.d(TAG, "scale begins on view: " + v);
mCallback.setUserLockedChild(v, true);
setView(v); setView(v);
setGlow(GLOW_BASE); setGlow(GLOW_BASE);
mScaler.setView(v); mScaler.setView(v);
@@ -479,21 +481,26 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
} }
private void finishScale(boolean force) { private void finishScale(boolean force) {
float currentHeight = mScaler.getHeight();
float targetHeight = mSmallSize;
float h = mScaler.getHeight(); float h = mScaler.getHeight();
final boolean wasClosed = (mOldHeight == mSmallSize); final boolean wasClosed = (mOldHeight == mSmallSize);
if (wasClosed) { if (wasClosed) {
h = (force || h > mSmallSize) ? mNaturalHeight : mSmallSize; targetHeight = (force || currentHeight > mSmallSize) ? mNaturalHeight : mSmallSize;
} else { } else {
h = (force || h < mNaturalHeight) ? mSmallSize : mNaturalHeight; targetHeight = (force || currentHeight < mNaturalHeight) ? mSmallSize : mNaturalHeight;
} }
if (mScaleAnimation.isRunning()) { if (mScaleAnimation.isRunning()) {
mScaleAnimation.cancel(); mScaleAnimation.cancel();
} }
mScaleAnimation.setFloatValues(h);
mScaleAnimation.setupStartValues();
mScaleAnimation.start();
setGlow(0f); setGlow(0f);
mCallback.setUserExpandedChild(mCurrView, h == mNaturalHeight); 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); 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(); int N = mNotificationData.size();
for (int i = 0; i < N; i++) { for (int i = 0; i < N; i++) {
NotificationData.Entry entry = mNotificationData.get(i); NotificationData.Entry entry = mNotificationData.get(i);
if (i == (N-1)) { if (!entry.userLocked()) {
if (DEBUG) Slog.d(TAG, "expanding top notification at " + i); if (i == (N-1)) {
expandView(entry, true); if (DEBUG) Slog.d(TAG, "expanding top notification at " + i);
} else { expandView(entry, true);
if (!entry.userExpanded()) {
if (DEBUG) Slog.d(TAG, "collapsing notification at " + i);
expandView(entry, false);
} else { } 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) { public boolean setUserExpanded(boolean userExpanded) {
return NotificationData.setUserExpanded(row, 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 ArrayList<Entry> mEntries = new ArrayList<Entry>();
private final Comparator<Entry> mEntryCmp = new Comparator<Entry>() { private final Comparator<Entry> mEntryCmp = new Comparator<Entry>() {
@@ -197,4 +209,18 @@ public class NotificationData {
public static boolean setUserExpanded(View row, boolean userExpanded) { public static boolean setUserExpanded(View row, boolean userExpanded) {
return writeBooleanTag(row, R.id.user_expanded_tag, 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); return NotificationData.setUserExpanded(v, userExpanded);
} }
public boolean setUserLockedChild(View v, boolean userLocked) {
return NotificationData.setUserLocked(v, userLocked);
}
public void onChildDismissed(View v) { public void onChildDismissed(View v) {
final View veto = v.findViewById(R.id.veto); final View veto = v.findViewById(R.id.veto);
if (veto != null && veto.getVisibility() != View.GONE && mRemoveViews) { if (veto != null && veto.getVisibility() != View.GONE && mRemoveViews) {