From d43e133a08f1fcbb375dd96128cb9387d237082a Mon Sep 17 00:00:00 2001 From: Matt Pietal Date: Wed, 25 Sep 2019 15:48:05 -0400 Subject: [PATCH] Use proper margins for NPV plugin and set the offset Set the offset to the size of the QS area and add margin after that to visually separate the QS and NPVPlugin areas Test: visual Change-Id: I9dc676eef0a49f1648723cdd91043b839c880ee5 --- .../layout/status_bar_expanded_plugin_frame.xml | 6 +++--- .../systemui/statusbar/phone/NPVPluginManager.kt | 14 ++++++++++++-- .../statusbar/phone/NotificationPanelView.java | 4 ++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/packages/SystemUI/res/layout/status_bar_expanded_plugin_frame.xml b/packages/SystemUI/res/layout/status_bar_expanded_plugin_frame.xml index 4849dfb777edc..7d6ff3b16db6b 100644 --- a/packages/SystemUI/res/layout/status_bar_expanded_plugin_frame.xml +++ b/packages/SystemUI/res/layout/status_bar_expanded_plugin_frame.xml @@ -20,10 +20,10 @@ android:id="@+id/plugin_frame" android:theme="@style/qs_theme" android:layout_width="@dimen/qs_panel_width" - android:layout_height="96dp" + android:layout_height="105dp" android:layout_gravity="center_horizontal" - android:layout_marginTop="@*android:dimen/quick_qs_total_height" + android:layout_marginTop="@dimen/notification_side_paddings" android:layout_marginLeft="@dimen/notification_side_paddings" android:layout_marginRight="@dimen/notification_side_paddings" android:visibility="gone" - android:background="@drawable/qs_background_primary"/> \ No newline at end of file + android:background="@drawable/qs_background_primary"/> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NPVPluginManager.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NPVPluginManager.kt index 7dcc2fcfe2b2d..53601babfd56c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NPVPluginManager.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NPVPluginManager.kt @@ -18,6 +18,7 @@ package com.android.systemui.statusbar.phone import android.content.Context import android.view.View +import android.view.ViewGroup.MarginLayoutParams import android.widget.FrameLayout import com.android.systemui.plugins.NPVPlugin import com.android.systemui.plugins.PluginListener @@ -36,6 +37,7 @@ class NPVPluginManager( private var plugin: NPVPlugin? = null private var animator = createAnimator() + private var yOffset = 0f private fun createAnimator() = TouchAnimator.Builder() .addFloat(parent, "alpha", 1f, 0f) @@ -76,7 +78,7 @@ class NPVPluginManager( } fun setExpansion(expansion: Float, headerTranslation: Float, heightDiff: Float) { - parent.setTranslationY(expansion * heightDiff + headerTranslation) + parent.setTranslationY(expansion * heightDiff + headerTranslation + yOffset) if (!expansion.isNaN()) animator.setPosition(expansion) } @@ -88,5 +90,13 @@ class NPVPluginManager( animator = createAnimator() } - fun getHeight() = if (plugin != null) parent.height else 0 + fun getHeight() = + if (plugin != null) { + parent.height + (parent.getLayoutParams() as MarginLayoutParams).topMargin + } else 0 + + fun setYOffset(y: Float) { + yOffset = y + parent.setTranslationY(yOffset) + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java index 86da10a4b970e..353a5381aa148 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -652,8 +652,7 @@ public class NotificationPanelView extends PanelView implements mNotificationStackScroller.setLayoutParams(lp); } int sideMargin = res.getDimensionPixelOffset(R.dimen.notification_side_paddings); - int topMargin = - res.getDimensionPixelOffset(com.android.internal.R.dimen.quick_qs_total_height); + int topMargin = sideMargin; lp = (FrameLayout.LayoutParams) mPluginFrame.getLayoutParams(); if (lp.width != qsWidth || lp.gravity != panelGravity || lp.leftMargin != sideMargin || lp.rightMargin != sideMargin || lp.topMargin != topMargin) { @@ -796,6 +795,7 @@ public class NotificationPanelView extends PanelView implements int oldMaxHeight = mQsMaxExpansionHeight; if (mQs != null) { mQsMinExpansionHeight = mKeyguardShowing ? 0 : mQs.getQsMinExpansionHeight(); + mNPVPluginManager.setYOffset(mQsMinExpansionHeight); mQsMinExpansionHeight += mNPVPluginManager.getHeight(); mQsMaxExpansionHeight = mQs.getDesiredHeight(); mNotificationStackScroller.setMaxTopPadding(