diff options
9 files changed, 94 insertions, 42 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 6d3aa98..9a8d802 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -1637,15 +1637,21 @@ public class Notification implements Parcelable if (mBuilder.mSubText == null) { contentView.setViewVisibility(R.id.line3, View.GONE); + } else { + contentView.setViewVisibility(R.id.line3, View.VISIBLE); } if (mBigContentTitle != null && mBigContentTitle.equals("")) { contentView.setViewVisibility(R.id.line1, View.GONE); + } else { + contentView.setViewVisibility(R.id.line1, View.VISIBLE); } if (mSummaryText != null && !mSummaryText.equals("")) { contentView.setViewVisibility(R.id.overflow_title, View.VISIBLE); contentView.setTextViewText(R.id.overflow_title, mSummaryText); + } else { + contentView.setViewVisibility(R.id.overflow_title, View.GONE); } return contentView; @@ -1852,6 +1858,8 @@ public class Notification implements Parcelable if (str != null && !str.equals("")) { contentView.setViewVisibility(rowIds[i], View.VISIBLE); contentView.setTextViewText(rowIds[i], str); + } else { + contentView.setViewVisibility(rowIds[i], View.GONE); } i++; } diff --git a/docs/html/guide/practices/design/performance.jd b/docs/html/guide/practices/design/performance.jd index c41f971..dd9b554 100644 --- a/docs/html/guide/practices/design/performance.jd +++ b/docs/html/guide/practices/design/performance.jd @@ -180,6 +180,9 @@ accessing a local), direct field access is about 7x faster than invoking a trivial getter. This is true in Froyo, but will improve in the future when the JIT inlines getter methods.</p> +<p>Note that if you're using ProGuard, you can have the best +of both worlds because ProGuard can inline accessors for you.</p> + <a name="use_final" id="use_final"></a> <h2>Use Static Final For Constants</h2> diff --git a/packages/SystemUI/src/com/android/systemui/ExpandHelper.java b/packages/SystemUI/src/com/android/systemui/ExpandHelper.java index 7a7afa7..ba3336b 100644 --- a/packages/SystemUI/src/com/android/systemui/ExpandHelper.java +++ b/packages/SystemUI/src/com/android/systemui/ExpandHelper.java @@ -31,7 +31,7 @@ import com.android.internal.widget.SizeAdaptiveLayout; public class ExpandHelper implements Gefingerpoken, OnClickListener { public interface Callback { - View getChildAtPosition(MotionEvent ev); + View getChildAtRawPosition(float x, float y); View getChildAtPosition(float x, float y); boolean canChildBeExpanded(View v); boolean setUserExpandedChild(View v, boolean userxpanded); @@ -62,6 +62,7 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener { private Context mContext; private boolean mStretching; + private View mEventSource; private View mCurrView; private View mCurrViewTopGlow; private View mCurrViewBottomGlow; @@ -141,7 +142,19 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener { @Override public boolean onScaleBegin(ScaleGestureDetector detector) { if (DEBUG) Log.v(TAG, "onscalebegin()"); - View v = mCallback.getChildAtPosition(detector.getFocusX(), detector.getFocusY()); + float x = detector.getFocusX(); + float y = detector.getFocusY(); + + View v = null; + if (mEventSource != null) { + int[] location = new int[2]; + mEventSource.getLocationOnScreen(location); + x += (float) location[0]; + y += (float) location[1]; + v = mCallback.getChildAtRawPosition(x, y); + } else { + v = mCallback.getChildAtPosition(x, y); + } // your fingers have to be somewhat close to the bounds of the view in question mInitialTouchFocusY = detector.getFocusY(); @@ -189,6 +202,11 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener { } }); } + + public void setEventSource(View eventSource) { + mEventSource = eventSource; + } + public void setGlow(float glow) { if (!mGlowAnimationSet.isRunning() || glow == 0f) { if (mGlowAnimationSet.isRunning()) { @@ -211,7 +229,6 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener { } } } - public boolean onInterceptTouchEvent(MotionEvent ev) { if (DEBUG) Log.d(TAG, "interceptTouch: act=" + (ev.getAction()) + " stretching=" + mStretching); @@ -223,11 +240,13 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener { final int action = ev.getAction(); if (DEBUG) Log.d(TAG, "touch: act=" + (action) + " stretching=" + mStretching); if (mStretching) { + if (DEBUG) Log.d(TAG, "detector ontouch"); mDetector.onTouchEvent(ev); } switch (action) { case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: + if (DEBUG) Log.d(TAG, "cancel"); mStretching = false; clearView(); break; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 2ea1827..4e6857e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -289,7 +289,7 @@ public class PhoneStatusBar extends BaseStatusBar { animateCollapse(); } } - return true; + return mStatusBarWindow.onTouchEvent(event); }}); mStatusBarView = (PhoneStatusBarView) mStatusBarWindow.findViewById(R.id.status_bar); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java index 0fc5b4d..ed1b2f5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java @@ -18,17 +18,39 @@ package com.android.systemui.statusbar.phone; import android.content.Context; import android.util.AttributeSet; +import android.util.Log; import android.view.KeyEvent; +import android.view.MotionEvent; import android.widget.FrameLayout; import android.widget.TextSwitcher; +import com.android.systemui.ExpandHelper; +import com.android.systemui.R; +import com.android.systemui.statusbar.policy.NotificationRowLayout; + public class StatusBarWindowView extends FrameLayout { + private static final String TAG = "StatusBarWindowView"; + + private ExpandHelper mExpandHelper; + private NotificationRowLayout latestItems; + PhoneStatusBar mService; public StatusBarWindowView(Context context, AttributeSet attrs) { super(context, attrs); + setMotionEventSplittingEnabled(false); + } + + @Override + protected void onAttachedToWindow () { + super.onAttachedToWindow(); + latestItems = (NotificationRowLayout) findViewById(R.id.latestItems); + int minHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_min_height); + int maxHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_max_height); + mExpandHelper = new ExpandHelper(mContext, latestItems, minHeight, maxHeight); + mExpandHelper.setEventSource(this); } @Override @@ -43,5 +65,25 @@ public class StatusBarWindowView extends FrameLayout } return super.dispatchKeyEvent(event); } + + @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + MotionEvent cancellation = MotionEvent.obtain(ev); + cancellation.setAction(MotionEvent.ACTION_CANCEL); + + boolean intercept = mExpandHelper.onInterceptTouchEvent(ev) || + super.onInterceptTouchEvent(ev); + if (intercept) { + latestItems.onInterceptTouchEvent(cancellation); + } + return intercept; + } + + @Override + public boolean onTouchEvent(MotionEvent ev) { + boolean handled = mExpandHelper.onTouchEvent(ev) || + super.onTouchEvent(ev); + return handled; + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java index f41d99c..0284644 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java @@ -36,7 +36,6 @@ import android.view.inputmethod.InputMethodManager; import android.widget.LinearLayout; import com.android.systemui.ExpandHelper; -import com.android.systemui.Gefingerpoken; import com.android.systemui.R; import com.android.systemui.SwipeHelper; import com.android.systemui.statusbar.NotificationData; @@ -62,9 +61,6 @@ public class NotificationRowLayout HashMap<View, ValueAnimator> mDisappearingViews = new HashMap<View, ValueAnimator>(); private SwipeHelper mSwipeHelper; - private ExpandHelper mExpandHelper; - - private Gefingerpoken mCurrentHelper; // Flag set during notification removal animation to avoid causing too much work until // animation is done @@ -81,8 +77,6 @@ public class NotificationRowLayout setOrientation(LinearLayout.VERTICAL); - setMotionEventSplittingEnabled(false); - if (DEBUG) { setOnHierarchyChangeListener(new ViewGroup.OnHierarchyChangeListener() { @Override @@ -101,9 +95,6 @@ public class NotificationRowLayout float densityScale = getResources().getDisplayMetrics().density; float pagingTouchSlop = ViewConfiguration.get(mContext).getScaledPagingTouchSlop(); mSwipeHelper = new SwipeHelper(SwipeHelper.X, this, densityScale, pagingTouchSlop); - int minHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_min_height); - int maxHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_max_height); - mExpandHelper = new ExpandHelper(mContext, this, minHeight, maxHeight); } public void setLongPressListener(View.OnLongClickListener listener) { @@ -135,39 +126,17 @@ public class NotificationRowLayout if (DEBUG) Log.v(TAG, "onInterceptTouchEvent()"); if (DEBUG) logLayoutTransition(); - MotionEvent cancellation = MotionEvent.obtain(ev); - cancellation.setAction(MotionEvent.ACTION_CANCEL); - - if (mSwipeHelper.onInterceptTouchEvent(ev)) { - if (DEBUG) Log.v(TAG, "will swipe"); - mCurrentHelper = mSwipeHelper; - mExpandHelper.onInterceptTouchEvent(cancellation); - return true; - } else if (mExpandHelper.onInterceptTouchEvent(ev)) { - if (DEBUG) Log.v(TAG, "will stretch"); - mCurrentHelper = mExpandHelper; - mSwipeHelper.onInterceptTouchEvent(cancellation); - return true; - } else { - mCurrentHelper = null; - if (super.onInterceptTouchEvent(ev)) { - if (DEBUG) Log.v(TAG, "intercepting ourselves"); - mSwipeHelper.onInterceptTouchEvent(cancellation); - mExpandHelper.onInterceptTouchEvent(cancellation); - return true; - } - } - return false; + return mSwipeHelper.onInterceptTouchEvent(ev) || + super.onInterceptTouchEvent(ev); } @Override public boolean onTouchEvent(MotionEvent ev) { if (DEBUG) Log.v(TAG, "onTouchEvent()"); if (DEBUG) logLayoutTransition(); - if (mCurrentHelper != null) { - return mCurrentHelper.onTouchEvent(ev); - } - return super.onTouchEvent(ev); + + return mSwipeHelper.onTouchEvent(ev) || + super.onTouchEvent(ev); } public boolean canChildBeDismissed(View v) { @@ -202,6 +171,13 @@ public class NotificationRowLayout public View getChildAtPosition(MotionEvent ev) { return getChildAtPosition(ev.getX(), ev.getY()); } + + public View getChildAtRawPosition(float touchX, float touchY) { + int[] location = new int[2]; + getLocationOnScreen(location); + return getChildAtPosition((float) (touchX - location[0]), (float) (touchY - location[1])); + } + public View getChildAtPosition(float touchX, float touchY) { // find the view under the pointer, accounting for GONE views final int count = getChildCount(); diff --git a/services/java/com/android/server/NativeDaemonConnector.java b/services/java/com/android/server/NativeDaemonConnector.java index 6a6c585..a15d3bb 100644 --- a/services/java/com/android/server/NativeDaemonConnector.java +++ b/services/java/com/android/server/NativeDaemonConnector.java @@ -148,6 +148,7 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo mCallbackHandler.sendMessage(mCallbackHandler.obtainMessage( event.getCode(), event.getRawEvent())); } else { + log("POST<- {" + rawEvent + "}"); mResponseQueue.add(event.getCmdNumber(), event); } } catch (IllegalArgumentException e) { @@ -327,6 +328,7 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo loge("timed-out waiting for response to " + logCmd); throw new NativeDaemonFailureException(logCmd, event); } + log("RMV <- {" + event + "}"); events.add(event); } while (event.isClassContinue()); @@ -337,6 +339,7 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo throw new NativeDaemonFailureException(logCmd, event); } + log("RTN <- {" + logCmd + "}"); return events.toArray(new NativeDaemonEvent[events.size()]); } diff --git a/services/java/com/android/server/NetworkManagementService.java b/services/java/com/android/server/NetworkManagementService.java index 4536a6d..e2852b5 100644 --- a/services/java/com/android/server/NetworkManagementService.java +++ b/services/java/com/android/server/NetworkManagementService.java @@ -166,7 +166,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub } mConnector = new NativeDaemonConnector( - new NetdCallbackReceiver(), "netd", 10, NETD_TAG, 50); + new NetdCallbackReceiver(), "netd", 10, NETD_TAG, 80); mThread = new Thread(mConnector, NETD_TAG); // Add ourself to the Watchdog monitors. diff --git a/services/java/com/android/server/StatusBarManagerService.java b/services/java/com/android/server/StatusBarManagerService.java index 8429086..78c0c12 100644 --- a/services/java/com/android/server/StatusBarManagerService.java +++ b/services/java/com/android/server/StatusBarManagerService.java @@ -489,7 +489,8 @@ public class StatusBarManagerService extends IStatusBarService.Stub synchronized (mNotifications) { final StatusBarNotification n = mNotifications.remove(key); if (n == null) { - throw new IllegalArgumentException("removeNotification key not found: " + key); + Slog.e(TAG, "removeNotification key not found: " + key); + return; } if (mBar != null) { try { |
