OSDN Git Service

Zoom notifications on lockscreen after tapping.
[android-x86/frameworks-base.git] / packages / SystemUI / src / com / android / systemui / statusbar / ExpandableNotificationRow.java
index 2daf619..fdf4dbf 100644 (file)
@@ -25,7 +25,8 @@ import android.widget.FrameLayout;
 import com.android.internal.widget.SizeAdaptiveLayout;
 import com.android.systemui.R;
 
-public class ExpandableNotificationRow extends FrameLayout {
+public class ExpandableNotificationRow extends FrameLayout
+        implements LatestItemView.OnActivatedListener {
     private int mRowMinHeight;
     private int mRowMaxHeight;
 
@@ -40,6 +41,8 @@ public class ExpandableNotificationRow extends FrameLayout {
     /** Are we showing the "public" version */
     private boolean mShowingPublic;
 
+    private LatestItemView mLatestItemView;
+
     /**
      * Is this notification expanded by the system. The expansion state can be overridden by the
      * user expansion.
@@ -49,6 +52,8 @@ public class ExpandableNotificationRow extends FrameLayout {
     private SizeAdaptiveLayout mPrivateLayout;
     private int mMaxExpandHeight;
     private boolean mMaxHeightNeedsUpdate;
+    private NotificationActivator mActivator;
+    private LatestItemView.OnActivatedListener mOnActivatedListener;
 
     public ExpandableNotificationRow(Context context, AttributeSet attrs) {
         super(context, attrs);
@@ -59,6 +64,10 @@ public class ExpandableNotificationRow extends FrameLayout {
         super.onFinishInflate();
         mPublicLayout = (SizeAdaptiveLayout) findViewById(R.id.expandedPublic);
         mPrivateLayout = (SizeAdaptiveLayout) findViewById(R.id.expanded);
+        mLatestItemView = (LatestItemView) findViewById(R.id.container);
+
+        mActivator = new NotificationActivator(this);
+        mLatestItemView.setOnActivatedListener(this);
     }
 
     public void setHeightRange(int rowMinHeight, int rowMaxHeight) {
@@ -152,8 +161,6 @@ public class ExpandableNotificationRow extends FrameLayout {
         return mShowingPublic ? mRowMinHeight : getMaxExpandHeight();
     }
 
-
-
     private void updateMaxExpandHeight() {
         ViewGroup.LayoutParams lp = getLayoutParams();
         int oldHeight = lp.height;
@@ -195,6 +202,14 @@ public class ExpandableNotificationRow extends FrameLayout {
         mPrivateLayout.setVisibility(show ? View.GONE : View.VISIBLE);
     }
 
+    /**
+     * Sets the notification as dimmed, meaning that it will appear in a more gray variant.
+     */
+    public void setDimmed(boolean dimmed) {
+        mLatestItemView.setDimmed(dimmed);
+        mActivator.setDimmed(dimmed);
+    }
+
     public int getMaxExpandHeight() {
         if (mMaxHeightNeedsUpdate) {
             updateMaxExpandHeight();
@@ -202,4 +217,44 @@ public class ExpandableNotificationRow extends FrameLayout {
         }
         return mMaxExpandHeight;
     }
+
+    /**
+     * Sets the notification as locked. In the locked state, the first tap will produce a quantum
+     * ripple to make the notification brighter and only the second tap will cause a click.
+     */
+    public void setLocked(boolean locked) {
+        mLatestItemView.setLocked(locked);
+    }
+
+    public void setOnActivatedListener(LatestItemView.OnActivatedListener listener) {
+        mOnActivatedListener = listener;
+    }
+
+    public NotificationActivator getActivator() {
+        return mActivator;
+    }
+
+    @Override
+    public void onActivated(View view) {
+        if (mOnActivatedListener != null) {
+            mOnActivatedListener.onActivated(this);
+        }
+    }
+
+    @Override
+    public void onReset(View view) {
+        if (mOnActivatedListener != null) {
+            mOnActivatedListener.onReset(this);
+        }
+    }
+
+    /**
+     * Sets the resource id for the background of this notification.
+     *
+     * @param bgResId The background resource to use in normal state.
+     * @param dimmedBgResId The background resource to use in dimmed state.
+     */
+    public void setBackgroundResourceIds(int bgResId, int dimmedBgResId) {
+        mLatestItemView.setBackgroundResourceIds(bgResId, dimmedBgResId);
+    }
 }