1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.car.notification.headsup;
18 
19 import android.content.Context;
20 import android.content.res.Resources;
21 import android.graphics.PixelFormat;
22 import android.view.Gravity;
23 import android.view.WindowManager;
24 
25 import com.android.car.notification.R;
26 
27 /**
28  * A controller for Notification application's HUN display.
29  *
30  * Used to attach HUNs views to window.
31  */
32 public class CarHeadsUpNotificationAppContainer extends CarHeadsUpNotificationContainer {
33 
CarHeadsUpNotificationAppContainer(Context context)34     public CarHeadsUpNotificationAppContainer(Context context) {
35         super(context, context.getSystemService(WindowManager.class));
36     }
37 
38     @Override
getWindowManagerLayoutParams()39     protected WindowManager.LayoutParams getWindowManagerLayoutParams() {
40         Resources resources = getContext().getResources();
41         WindowManager.LayoutParams wrapperParams = new WindowManager.LayoutParams(
42                 resources.getDimensionPixelSize(R.dimen.headsup_container_width),
43                 resources.getDimensionPixelSize(R.dimen.headsup_container_height),
44                 // This type allows covering status bar and receiving touch input
45                 WindowManager.LayoutParams.TYPE_SYSTEM_ERROR,
46                 WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
47                         | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
48                 PixelFormat.TRANSLUCENT);
49         wrapperParams.gravity = getShowHunOnBottom() ? Gravity.BOTTOM : Gravity.TOP;
50         wrapperParams.y = resources.getDimensionPixelSize(
51                 R.dimen.headsup_notification_window_y_offset);
52         return wrapperParams;
53     }
54 }