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;
/** 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.
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);
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) {
return mShowingPublic ? mRowMinHeight : getMaxExpandHeight();
}
-
-
private void updateMaxExpandHeight() {
ViewGroup.LayoutParams lp = getLayoutParams();
int oldHeight = lp.height;
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();
}
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);
+ }
}