Merge "Use proper margins for NPV plugin and set the offset"

This commit is contained in:
TreeHugger Robot
2019-09-27 07:25:41 +00:00
committed by Android (Google) Code Review
3 changed files with 17 additions and 7 deletions

View File

@@ -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"/>
android:background="@drawable/qs_background_primary"/>

View File

@@ -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)
}
}

View File

@@ -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(