diff options
| author | 2020-03-18 17:07:41 +0000 | |
|---|---|---|
| committer | 2020-03-18 17:07:41 +0000 | |
| commit | 962b460f1c1d8bb93926fa86b215cffb4265715e (patch) | |
| tree | 784f045ed7bac9be26cc90f07f23eda8cd0c4b8c | |
| parent | 96d70f138e4eba0a51ee1186da1df0eb64bcdd26 (diff) | |
| parent | 96cf38e427fdc59240c52c372f8db9ce54683661 (diff) | |
Merge "Added boolean flag to allow showing notification on the bottom of the screen rather than on the top." into rvc-dev
4 files changed, 88 insertions, 3 deletions
diff --git a/packages/CarSystemUI/res/drawable/headsup_scrim_bottom.xml b/packages/CarSystemUI/res/drawable/headsup_scrim_bottom.xml new file mode 100644 index 000000000000..1724ef008269 --- /dev/null +++ b/packages/CarSystemUI/res/drawable/headsup_scrim_bottom.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2020 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. + --> +<shape + xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle"> + <gradient + android:startColor="@android:color/black" + android:endColor="@android:color/transparent" + android:angle="90" /> +</shape> diff --git a/packages/CarSystemUI/res/layout/headsup_container_bottom.xml b/packages/CarSystemUI/res/layout/headsup_container_bottom.xml new file mode 100644 index 000000000000..caf1677234d0 --- /dev/null +++ b/packages/CarSystemUI/res/layout/headsup_container_bottom.xml @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2020 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. + --> + +<androidx.constraintlayout.widget.ConstraintLayout + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:id="@+id/notification_headsup" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <androidx.constraintlayout.widget.Guideline + android:id="@+id/gradient_edge" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="horizontal" + app:layout_constraintGuide_begin="@dimen/headsup_scrim_height"/> + + <View + android:id="@+id/scrim" + android:layout_width="match_parent" + android:layout_height="0dp" + android:background="@drawable/headsup_scrim_bottom" + app:layout_constraintBottom_toBottomOf="@+id/gradient_edge" + app:layout_constraintTop_toTopOf="parent"/> + + <FrameLayout + android:id="@+id/headsup_content" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/headsup_notification_top_margin" + app:layout_constraintEnd_toStartOf="parent" + app:layout_constraintStart_toEndOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + /> + +</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file diff --git a/packages/CarSystemUI/res/values/config.xml b/packages/CarSystemUI/res/values/config.xml index aaa65de2fa1d..2077e7707f59 100644 --- a/packages/CarSystemUI/res/values/config.xml +++ b/packages/CarSystemUI/res/values/config.xml @@ -34,6 +34,13 @@ <!-- Whether heads-up notifications should be shown when shade is open. --> <bool name="config_enableHeadsUpNotificationWhenNotificationShadeOpen">true</bool> + <!-- Whether heads-up notifications should be shown on the bottom. If false, heads-up + notifications will be shown pushed to the top of their parent container. If true, they will + be shown pushed to the bottom of their parent container. If true, then should override + config_headsUpNotificationAnimationHelper to use a different AnimationHelper, such as + com.android.car.notification.headsup.animationhelper. + CarHeadsUpNotificationBottomAnimationHelper. --> + <bool name="config_showHeadsUpNotificationOnBottom">false</bool> <bool name="config_hideNavWhenKeyguardBouncerShown">true</bool> <bool name="config_enablePersistentDockedActivity">false</bool> diff --git a/packages/CarSystemUI/src/com/android/systemui/car/notification/CarHeadsUpNotificationSystemContainer.java b/packages/CarSystemUI/src/com/android/systemui/car/notification/CarHeadsUpNotificationSystemContainer.java index 689d2d537bd6..53e5d9fe91ec 100644 --- a/packages/CarSystemUI/src/com/android/systemui/car/notification/CarHeadsUpNotificationSystemContainer.java +++ b/packages/CarSystemUI/src/com/android/systemui/car/notification/CarHeadsUpNotificationSystemContainer.java @@ -60,6 +60,8 @@ public class CarHeadsUpNotificationSystemContainer implements CarHeadsUpNotifica mCarDeviceProvisionedController = deviceProvisionedController; mCarStatusBarLazy = carStatusBarLazy; + boolean showOnBottom = resources.getBoolean(R.bool.config_showHeadsUpNotificationOnBottom); + WindowManager.LayoutParams lp = new WindowManager.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT, @@ -68,11 +70,13 @@ public class CarHeadsUpNotificationSystemContainer implements CarHeadsUpNotifica | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN, PixelFormat.TRANSLUCENT); - lp.gravity = Gravity.TOP; + lp.gravity = showOnBottom ? Gravity.BOTTOM : Gravity.TOP; lp.setTitle("HeadsUpNotification"); - mWindow = (ViewGroup) LayoutInflater.from(context) - .inflate(R.layout.headsup_container, null, false); + int layoutId = showOnBottom + ? R.layout.headsup_container_bottom + : R.layout.headsup_container; + mWindow = (ViewGroup) LayoutInflater.from(context).inflate(layoutId, null, false); windowManager.addView(mWindow, lp); mWindow.setVisibility(View.INVISIBLE); mHeadsUpContentFrame = mWindow.findViewById(R.id.headsup_content); |