Merge "Added boolean flag to allow showing notification on the bottom of the screen rather than on the top." into rvc-dev

This commit is contained in:
Jian-Yang Liu
2020-03-18 17:07:41 +00:00
committed by Android (Google) Code Review
4 changed files with 88 additions and 3 deletions

View File

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

View File

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

View File

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

View File

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