Implement HUN visuals: shadows and translucency
Bug: 15106201 Change-Id: I718e3d36355d0f58abc3daadb8c6a9d554f29bec
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 504 B |
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.2 KiB |
@@ -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>
|
||||
@@ -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"
|
||||
/>
|
||||
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>
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -162,6 +145,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) {
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user