Brad Stenning | 034a04937 | 2018-06-15 15:29:19 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 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.systemui; |
| 18 | |
| 19 | import android.content.Context; |
Brad Stenning | 034a04937 | 2018-06-15 15:29:19 -0700 | [diff] [blame] | 20 | |
| 21 | import com.android.internal.widget.LockPatternUtils; |
| 22 | import com.android.keyguard.ViewMediatorCallback; |
Adora Zhang | 0237b9c | 2019-03-08 12:27:09 -0800 | [diff] [blame] | 23 | import com.android.systemui.car.CarNotificationEntryManager; |
Gus Prevas | ec9e1f0 | 2018-12-18 15:28:12 -0500 | [diff] [blame] | 24 | import com.android.systemui.car.CarNotificationInterruptionStateProvider; |
Brad Stenning | 034a04937 | 2018-06-15 15:29:19 -0700 | [diff] [blame] | 25 | import com.android.systemui.statusbar.car.CarFacetButtonController; |
| 26 | import com.android.systemui.statusbar.car.CarStatusBarKeyguardViewManager; |
Adora Zhang | 0237b9c | 2019-03-08 12:27:09 -0800 | [diff] [blame] | 27 | import com.android.systemui.statusbar.notification.NotificationEntryManager; |
Gus Prevas | ec9e1f0 | 2018-12-18 15:28:12 -0500 | [diff] [blame] | 28 | import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider; |
Brad Stenning | 034a04937 | 2018-06-15 15:29:19 -0700 | [diff] [blame] | 29 | import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; |
Brad Stenning | 8d1a51c | 2018-11-20 17:34:16 -0800 | [diff] [blame] | 30 | import com.android.systemui.volume.CarVolumeDialogComponent; |
| 31 | import com.android.systemui.volume.VolumeDialogComponent; |
Brad Stenning | 034a04937 | 2018-06-15 15:29:19 -0700 | [diff] [blame] | 32 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 33 | import javax.inject.Singleton; |
| 34 | |
| 35 | import dagger.Component; |
| 36 | import dagger.Module; |
| 37 | import dagger.Provides; |
| 38 | |
Brad Stenning | 034a04937 | 2018-06-15 15:29:19 -0700 | [diff] [blame] | 39 | /** |
| 40 | * Class factory to provide car specific SystemUI components. |
| 41 | */ |
| 42 | public class CarSystemUIFactory extends SystemUIFactory { |
| 43 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 44 | private CarDependencyComponent mCarDependencyComponent; |
| 45 | |
| 46 | @Override |
| 47 | protected void init(Context context) { |
| 48 | super.init(context); |
| 49 | mCarDependencyComponent = DaggerCarSystemUIFactory_CarDependencyComponent.builder() |
| 50 | .contextHolder(new ContextHolder(context)) |
| 51 | .build(); |
| 52 | } |
| 53 | |
| 54 | public CarDependencyComponent getCarDependencyComponent() { |
| 55 | return mCarDependencyComponent; |
| 56 | } |
| 57 | |
Brad Stenning | 034a04937 | 2018-06-15 15:29:19 -0700 | [diff] [blame] | 58 | public StatusBarKeyguardViewManager createStatusBarKeyguardViewManager(Context context, |
Adora Zhang | 0237b9c | 2019-03-08 12:27:09 -0800 | [diff] [blame] | 59 | ViewMediatorCallback viewMediatorCallback, LockPatternUtils lockPatternUtils) { |
Brad Stenning | 034a04937 | 2018-06-15 15:29:19 -0700 | [diff] [blame] | 60 | return new CarStatusBarKeyguardViewManager(context, viewMediatorCallback, lockPatternUtils); |
| 61 | } |
| 62 | |
Brad Stenning | 8d1a51c | 2018-11-20 17:34:16 -0800 | [diff] [blame] | 63 | public VolumeDialogComponent createVolumeDialogComponent(SystemUI systemUi, Context context) { |
| 64 | return new CarVolumeDialogComponent(systemUi, context); |
| 65 | } |
| 66 | |
Brad Stenning | 034a04937 | 2018-06-15 15:29:19 -0700 | [diff] [blame] | 67 | @Override |
Gus Prevas | ec9e1f0 | 2018-12-18 15:28:12 -0500 | [diff] [blame] | 68 | public NotificationInterruptionStateProvider provideNotificationInterruptionStateProvider( |
| 69 | Context context) { |
| 70 | return new CarNotificationInterruptionStateProvider(context); |
| 71 | } |
| 72 | |
Gus Prevas | 59ec2ff | 2018-12-28 16:20:28 -0500 | [diff] [blame] | 73 | @Override |
| 74 | public boolean provideAllowNotificationLongPress() { |
| 75 | return false; |
| 76 | } |
| 77 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 78 | @Module |
| 79 | protected static class ContextHolder { |
| 80 | private Context mContext; |
| 81 | |
| 82 | public ContextHolder(Context context) { |
| 83 | mContext = context; |
| 84 | } |
| 85 | |
| 86 | @Provides |
| 87 | public Context provideContext() { |
| 88 | return mContext; |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | @Singleton |
| 93 | @Component(modules = ContextHolder.class) |
| 94 | public interface CarDependencyComponent { |
| 95 | CarFacetButtonController getCarFacetButtonController(); |
Brad Stenning | 034a04937 | 2018-06-15 15:29:19 -0700 | [diff] [blame] | 96 | } |
Adora Zhang | 0237b9c | 2019-03-08 12:27:09 -0800 | [diff] [blame] | 97 | |
| 98 | /** |
| 99 | * Use {@link CarNotificationEntryManager}, which does nothing when adding a notification. |
| 100 | */ |
| 101 | @Singleton |
| 102 | public NotificationEntryManager provideNotificationEntryManager(Context context) { |
| 103 | return new CarNotificationEntryManager(context); |
| 104 | } |
Brad Stenning | 034a04937 | 2018-06-15 15:29:19 -0700 | [diff] [blame] | 105 | } |