Merge "proper geometry for heads up on tablets."
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
BIN
packages/SystemUI/res/drawable-xhdpi/heads_up_window_bg.9.png
Normal file
BIN
packages/SystemUI/res/drawable-xhdpi/heads_up_window_bg.9.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 965 B |
Binary file not shown.
|
Before Width: | Height: | Size: 500 B |
@@ -24,12 +24,18 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="@*android:dimen/status_bar_height"
|
||||
>
|
||||
<FrameLayout
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/contentHolder"
|
||||
android:background="@drawable/heads_up_window_bg"
|
||||
/>
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="@dimen/notification_panel_width"
|
||||
android:id="@+id/content_slider"
|
||||
android:layout_marginStart="@dimen/notification_panel_margin_left"
|
||||
>
|
||||
<FrameLayout
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/content_holder"
|
||||
android:background="@drawable/heads_up_window_bg"
|
||||
/>
|
||||
</FrameLayout>
|
||||
</com.android.systemui.statusbar.policy.HeadsUpNotificationView>
|
||||
|
||||
@@ -212,4 +212,7 @@
|
||||
<dimen name="qs_tile_margin_below_icon">17dp</dimen>
|
||||
<!-- Quick Settings tile geometry: icon size -->
|
||||
<dimen name="qs_tile_icon_size">32dp</dimen>
|
||||
|
||||
<!-- The width of the notification panel window: match_parent below sw600dp -->
|
||||
<dimen name="notification_panel_width">-1dp</dimen>
|
||||
</resources>
|
||||
|
||||
@@ -362,8 +362,6 @@ public class PhoneStatusBar extends BaseStatusBar {
|
||||
|
||||
addNavigationBar();
|
||||
|
||||
if (ENABLE_HEADS_UP) addHeadsUpView();
|
||||
|
||||
// Lastly, call to the icon policy to install/update all the icons.
|
||||
mIconPolicy = new PhoneStatusBarPolicy(mContext);
|
||||
}
|
||||
@@ -840,9 +838,8 @@ public class PhoneStatusBar extends BaseStatusBar {
|
||||
|
||||
private void addHeadsUpView() {
|
||||
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL, // above the status bar!
|
||||
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT,
|
||||
WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL, // below the status bar!
|
||||
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
|
||||
| WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
|
||||
| WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
|
||||
@@ -851,7 +848,8 @@ public class PhoneStatusBar extends BaseStatusBar {
|
||||
| WindowManager.LayoutParams.FLAG_SPLIT_TOUCH,
|
||||
PixelFormat.TRANSLUCENT);
|
||||
lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
|
||||
lp.gravity = Gravity.TOP | Gravity.FILL_HORIZONTAL;
|
||||
lp.gravity = Gravity.TOP;
|
||||
lp.y = getStatusBarHeight();
|
||||
lp.setTitle("Heads Up");
|
||||
lp.packageName = mContext.getPackageName();
|
||||
lp.windowAnimations = R.style.Animation_StatusBar_HeadsUp;
|
||||
@@ -2293,6 +2291,7 @@ public class PhoneStatusBar extends BaseStatusBar {
|
||||
@Override
|
||||
public void createAndAddWindows() {
|
||||
addStatusBarWindow();
|
||||
if (ENABLE_HEADS_UP) addHeadsUpView();
|
||||
}
|
||||
|
||||
private void addStatusBarWindow() {
|
||||
@@ -2364,6 +2363,10 @@ public class PhoneStatusBar extends BaseStatusBar {
|
||||
mSettingsPanel.setLayoutParams(lp);
|
||||
}
|
||||
|
||||
if (ENABLE_HEADS_UP && mHeadsUpNotificationView != null) {
|
||||
mHeadsUpNotificationView.setMargin(mNotificationPanelMarginPx);
|
||||
}
|
||||
|
||||
updateCarrierLabelVisibility(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.android.systemui.ExpandHelper;
|
||||
@@ -34,7 +35,7 @@ import com.android.systemui.SwipeHelper;
|
||||
import com.android.systemui.statusbar.BaseStatusBar;
|
||||
import com.android.systemui.statusbar.NotificationData;
|
||||
|
||||
public class HeadsUpNotificationView extends LinearLayout implements SwipeHelper.Callback, ExpandHelper.Callback {
|
||||
public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.Callback, ExpandHelper.Callback {
|
||||
private static final String TAG = "HeadsUpNotificationView";
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
@@ -47,11 +48,8 @@ public class HeadsUpNotificationView extends LinearLayout implements SwipeHelper
|
||||
private ExpandHelper mExpandHelper;
|
||||
private long mStartTouchTime;
|
||||
|
||||
public ViewGroup getHolder() {
|
||||
return mContentHolder;
|
||||
}
|
||||
|
||||
private ViewGroup mContentHolder;
|
||||
private ViewGroup mContentSlider;
|
||||
|
||||
private NotificationData.Entry mHeadsUp;
|
||||
|
||||
@@ -61,101 +59,18 @@ public class HeadsUpNotificationView extends LinearLayout implements SwipeHelper
|
||||
|
||||
public HeadsUpNotificationView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
setOrientation(LinearLayout.VERTICAL);
|
||||
mTouchSensitivityDelay = getResources().getInteger(R.integer.heads_up_sensitivity_delay);
|
||||
if (DEBUG) Log.v(TAG, "create() " + mTouchSensitivityDelay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToWindow() {
|
||||
float densityScale = getResources().getDisplayMetrics().density;
|
||||
float pagingTouchSlop = ViewConfiguration.get(getContext()).getScaledPagingTouchSlop();
|
||||
mSwipeHelper = new SwipeHelper(SwipeHelper.X, this, densityScale, pagingTouchSlop);
|
||||
|
||||
int minHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_min_height);
|
||||
int maxHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_max_height);
|
||||
mExpandHelper = new ExpandHelper(mContext, this, minHeight, maxHeight);
|
||||
|
||||
mContentHolder = (ViewGroup) findViewById(R.id.contentHolder);
|
||||
if (mHeadsUp != null) {
|
||||
// whoops, we're on already!
|
||||
setNotification(mHeadsUp);
|
||||
}
|
||||
}
|
||||
|
||||
public void setBar(BaseStatusBar bar) {
|
||||
mBar = bar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
if (DEBUG) Log.v(TAG, "onInterceptTouchEvent()");
|
||||
if (System.currentTimeMillis() < mStartTouchTime) {
|
||||
return true;
|
||||
}
|
||||
return mSwipeHelper.onInterceptTouchEvent(ev)
|
||||
|| mExpandHelper.onInterceptTouchEvent(ev)
|
||||
|| super.onInterceptTouchEvent(ev);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent ev) {
|
||||
if (System.currentTimeMillis() < mStartTouchTime) {
|
||||
return false;
|
||||
}
|
||||
mBar.resetHeadsUpDecayTimer();
|
||||
return mSwipeHelper.onTouchEvent(ev)
|
||||
|| mExpandHelper.onTouchEvent(ev)
|
||||
|| super.onTouchEvent(ev);
|
||||
}
|
||||
|
||||
public boolean canChildBeDismissed(View v) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onChildDismissed(View v) {
|
||||
Log.v(TAG, "User swiped heads up to dismiss");
|
||||
mBar.onHeadsUpDismissed();
|
||||
}
|
||||
|
||||
public void onBeginDrag(View v) {
|
||||
}
|
||||
|
||||
public void onDragCancelled(View v) {
|
||||
mContentHolder.setAlpha(1f); // sometimes this isn't quite reset
|
||||
}
|
||||
|
||||
public View getChildAtPosition(MotionEvent ev) {
|
||||
public ViewGroup getHolder() {
|
||||
return mContentHolder;
|
||||
}
|
||||
|
||||
public View getChildContentView(View v) {
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
float densityScale = getResources().getDisplayMetrics().density;
|
||||
mSwipeHelper.setDensityScale(densityScale);
|
||||
float pagingTouchSlop = ViewConfiguration.get(getContext()).getScaledPagingTouchSlop();
|
||||
mSwipeHelper.setPagingTouchSlop(pagingTouchSlop);
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean setNotification(NotificationData.Entry headsUp) {
|
||||
mHeadsUp = headsUp;
|
||||
mHeadsUp.row.setExpanded(false);
|
||||
@@ -172,6 +87,92 @@ public class HeadsUpNotificationView extends LinearLayout implements SwipeHelper
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isInsistent() {
|
||||
return mHeadsUp != null
|
||||
&& (mHeadsUp.notification.getNotification().flags & Notification.FLAG_INSISTENT) != 0;
|
||||
}
|
||||
|
||||
public void setMargin(int notificationPanelMarginPx) {
|
||||
if (DEBUG) Log.v(TAG, "setMargin() " + notificationPanelMarginPx);
|
||||
if (mContentSlider != null) {
|
||||
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mContentSlider.getLayoutParams();
|
||||
lp.setMarginStart(notificationPanelMarginPx);
|
||||
mContentSlider.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
|
||||
public void onAttachedToWindow() {
|
||||
float densityScale = getResources().getDisplayMetrics().density;
|
||||
float pagingTouchSlop = ViewConfiguration.get(getContext()).getScaledPagingTouchSlop();
|
||||
mSwipeHelper = new SwipeHelper(SwipeHelper.X, this, densityScale, pagingTouchSlop);
|
||||
|
||||
int minHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_min_height);
|
||||
int maxHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_max_height);
|
||||
mExpandHelper = new ExpandHelper(mContext, this, minHeight, maxHeight);
|
||||
|
||||
mContentHolder = (ViewGroup) findViewById(R.id.content_holder);
|
||||
mContentSlider = (ViewGroup) findViewById(R.id.content_slider);
|
||||
|
||||
if (mHeadsUp != null) {
|
||||
// whoops, we're on already!
|
||||
setNotification(mHeadsUp);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
if (DEBUG) Log.v(TAG, "onInterceptTouchEvent()");
|
||||
if (System.currentTimeMillis() < mStartTouchTime) {
|
||||
return true;
|
||||
}
|
||||
return mSwipeHelper.onInterceptTouchEvent(ev)
|
||||
|| mExpandHelper.onInterceptTouchEvent(ev)
|
||||
|| super.onInterceptTouchEvent(ev);
|
||||
}
|
||||
|
||||
// View methods
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent ev) {
|
||||
if (System.currentTimeMillis() < mStartTouchTime) {
|
||||
return false;
|
||||
}
|
||||
mBar.resetHeadsUpDecayTimer();
|
||||
return mSwipeHelper.onTouchEvent(ev)
|
||||
|| mExpandHelper.onTouchEvent(ev)
|
||||
|| super.onTouchEvent(ev);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
float densityScale = getResources().getDisplayMetrics().density;
|
||||
mSwipeHelper.setDensityScale(densityScale);
|
||||
float pagingTouchSlop = ViewConfiguration.get(getContext()).getScaledPagingTouchSlop();
|
||||
mSwipeHelper.setPagingTouchSlop(pagingTouchSlop);
|
||||
}
|
||||
|
||||
// ExpandHelper.Callback methods
|
||||
|
||||
@Override
|
||||
public View getChildAtRawPosition(float x, float y) {
|
||||
return getChildAtPosition(x, y);
|
||||
@@ -201,8 +202,35 @@ public class HeadsUpNotificationView extends LinearLayout implements SwipeHelper
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInsistent() {
|
||||
return mHeadsUp != null
|
||||
&& (mHeadsUp.notification.getNotification().flags & Notification.FLAG_INSISTENT) != 0;
|
||||
// SwipeHelper.Callback methods
|
||||
|
||||
@Override
|
||||
public boolean canChildBeDismissed(View v) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChildDismissed(View v) {
|
||||
Log.v(TAG, "User swiped heads up to dismiss");
|
||||
mBar.onHeadsUpDismissed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeginDrag(View v) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDragCancelled(View v) {
|
||||
mContentHolder.setAlpha(1f); // sometimes this isn't quite reset
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getChildAtPosition(MotionEvent ev) {
|
||||
return mContentSlider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getChildContentView(View v) {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user