Merge "Fixed several bugs where the dismissview was not reachable." into lmp-dev
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index abd706b..800734a 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -2622,6 +2622,33 @@
contentView.setTextViewTextSize(R.id.text, TypedValue.COMPLEX_UNIT_PX, subTextSize);
}
+ private void unshrinkLine3Text(RemoteViews contentView) {
+ float regularTextSize = mContext.getResources().getDimensionPixelSize(
+ com.android.internal.R.dimen.notification_text_size);
+ contentView.setTextViewTextSize(R.id.text, TypedValue.COMPLEX_UNIT_PX, regularTextSize);
+ }
+
+ private void resetStandardTemplate(RemoteViews contentView) {
+ removeLargeIconBackground(contentView);
+ contentView.setViewPadding(R.id.icon, 0, 0, 0, 0);
+ contentView.setImageViewResource(R.id.icon, 0);
+ contentView.setInt(R.id.icon, "setBackgroundResource", 0);
+ contentView.setViewVisibility(R.id.right_icon, View.GONE);
+ contentView.setInt(R.id.right_icon, "setBackgroundResource", 0);
+ contentView.setImageViewResource(R.id.right_icon, 0);
+ contentView.setImageViewResource(R.id.icon, 0);
+ contentView.setTextViewText(R.id.title, null);
+ contentView.setTextViewText(R.id.text, null);
+ unshrinkLine3Text(contentView);
+ contentView.setTextViewText(R.id.text2, null);
+ contentView.setViewVisibility(R.id.text2, View.GONE);
+ contentView.setViewVisibility(R.id.info, View.GONE);
+ contentView.setViewVisibility(R.id.time, View.GONE);
+ contentView.setViewVisibility(R.id.line3, View.GONE);
+ contentView.setViewVisibility(R.id.overflow_divider, View.GONE);
+ contentView.setViewVisibility(R.id.progress, View.GONE);
+ }
+
private RemoteViews applyStandardTemplate(int resId) {
return applyStandardTemplate(resId, true /* hasProgress */);
}
@@ -2633,6 +2660,8 @@
RemoteViews contentView = new BuilderRemoteViews(mContext.getPackageName(),
mOriginatingUserId, resId);
+ resetStandardTemplate(contentView);
+
boolean showLine3 = false;
boolean showLine2 = false;
boolean contentTextInLine2 = false;
@@ -2784,15 +2813,22 @@
return Math.round((1 - largeFactor) * padding + largeFactor * largePadding);
}
+ private void resetStandardTemplateWithActions(RemoteViews big) {
+ big.setViewVisibility(R.id.actions, View.GONE);
+ big.setViewVisibility(R.id.action_divider, View.GONE);
+ big.removeAllViews(R.id.actions);
+ }
+
private RemoteViews applyStandardTemplateWithActions(int layoutId) {
RemoteViews big = applyStandardTemplate(layoutId);
+ resetStandardTemplateWithActions(big);
+
int N = mActions.size();
if (N > 0) {
big.setViewVisibility(R.id.actions, View.VISIBLE);
big.setViewVisibility(R.id.action_divider, View.VISIBLE);
if (N>MAX_ACTION_BUTTONS) N=MAX_ACTION_BUTTONS;
- big.removeAllViews(R.id.actions);
for (int i=0; i<N; i++) {
final RemoteViews button = generateActionButton(mActions.get(i));
big.addView(R.id.actions, button);
diff --git a/packages/SystemUI/res/drawable/notification_guts_bg.xml b/packages/SystemUI/res/drawable/notification_guts_bg.xml
index 07932d1..1730dce 100644
--- a/packages/SystemUI/res/drawable/notification_guts_bg.xml
+++ b/packages/SystemUI/res/drawable/notification_guts_bg.xml
@@ -17,5 +17,6 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/notification_guts_bg_color" />
- <corners android:radius="@dimen/notification_material_rounded_rect_radius" />
+ <!--The radius is 1dp smaller than the notification one, to avoid aliasing bugs on the corners -->
+ <corners android:radius="1dp" />
</shape>
diff --git a/packages/SystemUI/res/layout/notification_guts.xml b/packages/SystemUI/res/layout/notification_guts.xml
index 566c304..ac8af1b 100644
--- a/packages/SystemUI/res/layout/notification_guts.xml
+++ b/packages/SystemUI/res/layout/notification_guts.xml
@@ -15,11 +15,10 @@
limitations under the License.
-->
-<FrameLayout
+<com.android.systemui.statusbar.NotificationGuts
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="@drawable/notification_guts_bg"
android:id="@+id/notification_guts"
android:visibility="gone"
android:clickable="true"
@@ -87,4 +86,4 @@
android:src="@drawable/ic_settings"
/>
</LinearLayout>
-</FrameLayout>
+</com.android.systemui.statusbar.NotificationGuts>
diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml
index 103d8b9..f3a62b8 100644
--- a/packages/SystemUI/res/values/colors.xml
+++ b/packages/SystemUI/res/values/colors.xml
@@ -101,9 +101,9 @@
<color name="segmented_button_text_inactive">#99afbdc4</color><!-- 60% -->
<!-- The "inside" of a notification, reached via longpress -->
- <color name="notification_guts_bg_color">#ff424242</color><!-- grey 800 -->
+ <color name="notification_guts_bg_color">@color/system_secondary_color</color>
<color name="notification_guts_title_color">#FFFFFFFF</color>
- <color name="notification_guts_text_color">#99FFFFFF</color>
+ <color name="notification_guts_text_color">#b2FFFFFF</color>
<color name="notification_guts_btn_color">#FFFFFFFF</color>
<color name="search_panel_card_color">#ffffff</color>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index d1eb83b..3f631f7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -203,7 +203,7 @@
protected int mZenMode;
// which notification is currently being longpress-examined by the user
- private View mNotificationGutsExposed;
+ private NotificationGuts mNotificationGutsExposed;
private TimeInterpolator mLinearOutSlowIn, mFastOutLinearIn;
@@ -739,15 +739,16 @@
if (v.getWindowToken() == null) return false;
// Assume we are a status_bar_notification_row
- final View guts = v.findViewById(R.id.notification_guts);
+ final NotificationGuts guts = (NotificationGuts) v.findViewById(
+ R.id.notification_guts);
if (guts == null) return false;
// Already showing?
if (guts.getVisibility() == View.VISIBLE) return false;
guts.setVisibility(View.VISIBLE);
- final double horz = Math.max(v.getWidth() - x, x);
- final double vert = Math.max(v.getHeight() - y, y);
+ final double horz = Math.max(guts.getWidth() - x, x);
+ final double vert = Math.max(guts.getActualHeight() - y, y);
final float r = (float) Math.hypot(horz, vert);
final Animator a
= ViewAnimationUtils.createCircularReveal(guts, x, y, 0, r);
@@ -764,11 +765,11 @@
public void dismissPopups() {
if (mNotificationGutsExposed != null) {
- final View v = mNotificationGutsExposed;
+ final NotificationGuts v = mNotificationGutsExposed;
mNotificationGutsExposed = null;
final int x = (v.getLeft() + v.getRight()) / 2;
- final int y = (v.getTop() + v.getBottom()) / 2;
+ final int y = (v.getTop() + v.getActualHeight() / 2);
final Animator a = ViewAnimationUtils.createCircularReveal(v,
x, y, x, 0);
a.setDuration(200);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index fe754a9..dfcc408 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -60,6 +60,7 @@
private ExpansionLogger mLogger;
private String mLoggingKey;
private boolean mWasReset;
+ private NotificationGuts mGuts;
public interface ExpansionLogger {
public void logNotificationExpansion(String key, boolean userAction, boolean expanded);
@@ -103,6 +104,7 @@
super.onFinishInflate();
mPublicLayout = (NotificationContentView) findViewById(R.id.expandedPublic);
mPrivateLayout = (NotificationContentView) findViewById(R.id.expanded);
+ mGuts = (NotificationGuts) findViewById(R.id.notification_guts);
mVetoButton = findViewById(R.id.veto);
}
@@ -368,6 +370,7 @@
public void setActualHeight(int height, boolean notifyListeners) {
mPrivateLayout.setActualHeight(height);
mPublicLayout.setActualHeight(height);
+ mGuts.setActualHeight(height);
invalidate();
super.setActualHeight(height, notifyListeners);
}
@@ -389,6 +392,7 @@
super.setClipTopAmount(clipTopAmount);
mPrivateLayout.setClipTopAmount(clipTopAmount);
mPublicLayout.setClipTopAmount(clipTopAmount);
+ mGuts.setClipTopAmount(clipTopAmount);
}
public void notifyContentUpdated() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java
new file mode 100644
index 0000000..46e0bf8
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.systemui.statusbar;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.drawable.Drawable;
+import android.util.AttributeSet;
+import android.widget.FrameLayout;
+import com.android.systemui.R;
+
+/**
+ * The guts of a notification revealed when performing a long press.
+ */
+public class NotificationGuts extends FrameLayout {
+
+ private Drawable mBackground;
+ private int mClipTopAmount;
+ private int mActualHeight;
+
+ public NotificationGuts(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ setWillNotDraw(false);
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ draw(canvas, mBackground);
+ }
+
+ private void draw(Canvas canvas, Drawable drawable) {
+ if (drawable != null) {
+ drawable.setBounds(0, mClipTopAmount, getWidth(), mActualHeight);
+ drawable.draw(canvas);
+ }
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ mBackground = mContext.getDrawable(R.drawable.notification_guts_bg);
+ if (mBackground != null) {
+ mBackground.setCallback(this);
+ }
+ }
+
+ @Override
+ protected boolean verifyDrawable(Drawable who) {
+ return super.verifyDrawable(who) || who == mBackground;
+ }
+
+ @Override
+ protected void drawableStateChanged() {
+ drawableStateChanged(mBackground);
+ }
+
+ private void drawableStateChanged(Drawable d) {
+ if (d != null && d.isStateful()) {
+ d.setState(getDrawableState());
+ }
+ }
+
+ @Override
+ public void drawableHotspotChanged(float x, float y) {
+ if (mBackground != null) {
+ mBackground.setHotspot(x, y);
+ }
+ }
+
+ public void setActualHeight(int actualHeight) {
+ mActualHeight = actualHeight;
+ invalidate();
+ }
+
+ public int getActualHeight() {
+ return mActualHeight;
+ }
+
+ public void setClipTopAmount(int clipTopAmount) {
+ mClipTopAmount = clipTopAmount;
+ invalidate();
+ }
+
+ @Override
+ public boolean hasOverlappingRendering() {
+
+ // Prevents this view from creating a layer when alpha is animating.
+ return false;
+ }
+}