summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Roos <roosa@google.com>2014-05-26 14:59:15 +0200
committerAdrian Roos <roosa@google.com>2014-05-26 19:03:00 +0200
commitde61fd7822ea15fb691405c1aae472caa58e83ba (patch)
tree9ac3b5dfcee8c749f5048d1d2217de0cf83a08e2
parentb13d754898eee54876799b3a306ff6fa453acfda (diff)
downloadandroid_frameworks_base-de61fd7822ea15fb691405c1aae472caa58e83ba.tar.gz
android_frameworks_base-de61fd7822ea15fb691405c1aae472caa58e83ba.tar.bz2
android_frameworks_base-de61fd7822ea15fb691405c1aae472caa58e83ba.zip
Implement HUN visuals: shadows and translucency
Bug: 15106201 Change-Id: I718e3d36355d0f58abc3daadb8c6a9d554f29bec
-rw-r--r--packages/SystemUI/res/drawable-sw600dp-hdpi/heads_up_window_bg.9.pngbin504 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-sw600dp-xhdpi/heads_up_window_bg.9.pngbin1391 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-sw600dp-xxhdpi/heads_up_window_bg.9.pngbin1207 -> 0 bytes
-rw-r--r--packages/SystemUI/res/layout-sw600dp/heads_up.xml30
-rw-r--r--packages/SystemUI/res/layout/heads_up.xml46
-rw-r--r--packages/SystemUI/src/com/android/systemui/SwipeHelper.java7
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java73
8 files changed, 76 insertions, 82 deletions
diff --git a/packages/SystemUI/res/drawable-sw600dp-hdpi/heads_up_window_bg.9.png b/packages/SystemUI/res/drawable-sw600dp-hdpi/heads_up_window_bg.9.png
deleted file mode 100644
index b30cf15b28b..00000000000
--- a/packages/SystemUI/res/drawable-sw600dp-hdpi/heads_up_window_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-sw600dp-xhdpi/heads_up_window_bg.9.png b/packages/SystemUI/res/drawable-sw600dp-xhdpi/heads_up_window_bg.9.png
deleted file mode 100644
index 31eb8f72010..00000000000
--- a/packages/SystemUI/res/drawable-sw600dp-xhdpi/heads_up_window_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-sw600dp-xxhdpi/heads_up_window_bg.9.png b/packages/SystemUI/res/drawable-sw600dp-xxhdpi/heads_up_window_bg.9.png
deleted file mode 100644
index c76d0e1788d..00000000000
--- a/packages/SystemUI/res/drawable-sw600dp-xxhdpi/heads_up_window_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/layout-sw600dp/heads_up.xml b/packages/SystemUI/res/layout-sw600dp/heads_up.xml
deleted file mode 100644
index f7035fe0319..00000000000
--- a/packages/SystemUI/res/layout-sw600dp/heads_up.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-** Copyright 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.
-*/
--->
-<com.android.systemui.statusbar.policy.HeadsUpNotificationView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_height="wrap_content"
- android:layout_width="match_parent"
- >
- <FrameLayout
- android:id="@+id/content_holder"
- android:layout_height="wrap_content"
- android:layout_width="@dimen/notification_panel_width"
- android:background="@drawable/heads_up_window_bg"
- />
-</com.android.systemui.statusbar.policy.HeadsUpNotificationView>
diff --git a/packages/SystemUI/res/layout/heads_up.xml b/packages/SystemUI/res/layout/heads_up.xml
index 7d9cfa1c49f..236fdc33593 100644
--- a/packages/SystemUI/res/layout/heads_up.xml
+++ b/packages/SystemUI/res/layout/heads_up.xml
@@ -1,26 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
-/* apps/common/assets/default/default/skins/StatusBar.xml
-**
-** Copyright 2006, 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.
-*/
+ 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.
-->
<com.android.systemui.statusbar.policy.HeadsUpNotificationView
xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_height="wrap_content"
- android:layout_width="match_parent"
- android:id="@+id/content_holder"
- android:background="@drawable/notification_panel_bg"
- /> \ No newline at end of file
+ android:layout_height="match_parent"
+ android:layout_width="match_parent">
+
+ <FrameLayout
+ android:layout_height="wrap_content"
+ android:layout_marginStart="@dimen/notification_side_padding"
+ android:layout_marginEnd="@dimen/notification_side_padding"
+ android:elevation="16dp"
+ android:id="@+id/content_holder"
+ style="@style/NotificationsQuickSettings" />
+
+</com.android.systemui.statusbar.policy.HeadsUpNotificationView> \ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
index 6387a924f0f..1b12cb07cb8 100644
--- a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
@@ -56,6 +56,7 @@ public class SwipeHelper implements Gefingerpoken {
static final float ALPHA_FADE_END = 0.5f; // fraction of thumbnail width
// beyond which alpha->0
private float mMinAlpha = 0f;
+ private float mMaxAlpha = 1f;
private float mPagingTouchSlop;
private Callback mCallback;
@@ -140,6 +141,10 @@ public class SwipeHelper implements Gefingerpoken {
mMinAlpha = minAlpha;
}
+ public void setMaxAlpha(float maxAlpha) {
+ mMaxAlpha = maxAlpha;
+ }
+
private float getAlphaForOffset(View view) {
float viewSize = getSize(view);
final float fadeSize = ALPHA_FADE_END * viewSize;
@@ -150,7 +155,7 @@ public class SwipeHelper implements Gefingerpoken {
} else if (pos < viewSize * (1.0f - ALPHA_FADE_START)) {
result = 1.0f + (viewSize * ALPHA_FADE_START + pos) / fadeSize;
}
- return Math.max(mMinAlpha, result);
+ return Math.min(Math.max(mMinAlpha, result), mMaxAlpha);
}
private void updateAlphaFromOffset(View animView, boolean dismissable) {
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 0922abd77db..40985001b54 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -966,7 +966,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
private void addHeadsUpView() {
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
- LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT,
+ LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, // above the status bar!
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
| WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java
index 81e2cb38196..9271e717c41 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.policy;
import android.content.Context;
import android.content.res.Configuration;
+import android.graphics.Outline;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.Log;
@@ -25,6 +26,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
+import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
import com.android.systemui.ExpandHelper;
@@ -35,14 +37,17 @@ import com.android.systemui.statusbar.BaseStatusBar;
import com.android.systemui.statusbar.ExpandableView;
import com.android.systemui.statusbar.NotificationData;
-public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.Callback, ExpandHelper.Callback {
+public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.Callback, ExpandHelper.Callback,
+ ViewTreeObserver.OnComputeInternalInsetsListener {
private static final String TAG = "HeadsUpNotificationView";
private static final boolean DEBUG = false;
private static final boolean SPEW = DEBUG;
Rect mTmpRect = new Rect();
+ int[] mTmpTwoArray = new int[2];
private final int mTouchSensitivityDelay;
+ private final float mMaxAlpha = 0.95f;
private SwipeHelper mSwipeHelper;
private EdgeSwipeHelper mEdgeSwipeHelper;
@@ -87,8 +92,9 @@ public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.
}
mContentHolder.setX(0);
mContentHolder.setVisibility(View.VISIBLE);
- mContentHolder.setAlpha(1f);
+ mContentHolder.setAlpha(mMaxAlpha);
mContentHolder.addView(mHeadsUp.row);
+
mSwipeHelper.snapChild(mContentHolder, 1f);
mStartTouchTime = System.currentTimeMillis() + mTouchSensitivityDelay;
}
@@ -99,32 +105,6 @@ public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.
return mHeadsUp == null || mHeadsUp.notification.isClearable();
}
- public void setMargin(int notificationPanelMarginPx) {
- if (SPEW) Log.v(TAG, "setMargin() " + notificationPanelMarginPx);
- if (mContentHolder != null &&
- mContentHolder.getLayoutParams() instanceof FrameLayout.LayoutParams) {
- FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mContentHolder.getLayoutParams();
- lp.setMarginStart(notificationPanelMarginPx);
- mContentHolder.setLayoutParams(lp);
- }
- }
-
- // LinearLayout methods
-
- @Override
- public void onDraw(android.graphics.Canvas c) {
- super.onDraw(c);
- if (DEBUG) {
- //Log.d(TAG, "onDraw: canvas height: " + c.getHeight() + "px; measured height: "
- // + getMeasuredHeight() + "px");
- c.save();
- c.clipRect(6, 6, c.getWidth() - 6, getMeasuredHeight() - 6,
- android.graphics.Region.Op.DIFFERENCE);
- c.drawColor(0xFFcc00cc);
- c.restore();
- }
- }
-
// ViewGroup methods
@Override
@@ -134,6 +114,7 @@ public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.
float pagingTouchSlop = viewConfiguration.getScaledPagingTouchSlop();
float touchSlop = viewConfiguration.getScaledTouchSlop();
mSwipeHelper = new SwipeHelper(SwipeHelper.X, this, densityScale, pagingTouchSlop);
+ mSwipeHelper.setMaxAlpha(mMaxAlpha);
mEdgeSwipeHelper = new EdgeSwipeHelper(touchSlop);
int minHeight = getResources().getDimensionPixelSize(R.dimen.notification_min_height);
@@ -146,6 +127,8 @@ public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.
// whoops, we're on already!
setNotification(mHeadsUp);
}
+
+ getViewTreeObserver().addOnComputeInternalInsetsListener(this);
}
@Override
@@ -163,6 +146,20 @@ public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.
// View methods
@Override
+ public void onDraw(android.graphics.Canvas c) {
+ super.onDraw(c);
+ if (DEBUG) {
+ //Log.d(TAG, "onDraw: canvas height: " + c.getHeight() + "px; measured height: "
+ // + getMeasuredHeight() + "px");
+ c.save();
+ c.clipRect(6, 6, c.getWidth() - 6, getMeasuredHeight() - 6,
+ android.graphics.Region.Op.DIFFERENCE);
+ c.drawColor(0xFFcc00cc);
+ c.restore();
+ }
+ }
+
+ @Override
public boolean onTouchEvent(MotionEvent ev) {
if (System.currentTimeMillis() < mStartTouchTime) {
return false;
@@ -183,6 +180,14 @@ public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.
mSwipeHelper.setPagingTouchSlop(pagingTouchSlop);
}
+ @Override
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ super.onLayout(changed, left, top, right, bottom);
+ Outline o = new Outline();
+ o.setRect(0, 0, mContentHolder.getWidth(), mContentHolder.getHeight());
+ mContentHolder.setOutline(o);
+ }
+
// ExpandHelper.Callback methods
@Override
@@ -233,7 +238,7 @@ public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.
@Override
public void onDragCancelled(View v) {
- mContentHolder.setAlpha(1f); // sometimes this isn't quite reset
+ mContentHolder.setAlpha(mMaxAlpha); // sometimes this isn't quite reset
}
@Override
@@ -250,6 +255,16 @@ public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.
return mContentHolder;
}
+ @Override
+ public void onComputeInternalInsets(ViewTreeObserver.InternalInsetsInfo info) {
+ mContentHolder.getLocationOnScreen(mTmpTwoArray);
+
+ info.setTouchableInsets(ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION);
+ info.touchableRegion.set(mTmpTwoArray[0], mTmpTwoArray[1],
+ mTmpTwoArray[0] + mContentHolder.getWidth(),
+ mTmpTwoArray[1] + mContentHolder.getHeight());
+ }
+
private class EdgeSwipeHelper implements Gefingerpoken {
private static final boolean DEBUG_EDGE_SWIPE = false;
private final float mTouchSlop;