Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 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.statusbar.car; |
| 18 | |
| 19 | import android.content.Context; |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 20 | import android.util.AttributeSet; |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 21 | import android.view.View; |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 22 | import android.widget.LinearLayout; |
| 23 | |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 24 | import com.android.keyguard.AlphaOptimizedImageButton; |
Brad Stenning | 2d72674 | 2018-04-06 10:28:08 -0700 | [diff] [blame] | 25 | import com.android.systemui.Dependency; |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 26 | import com.android.systemui.R; |
Brad Stenning | 2d72674 | 2018-04-06 10:28:08 -0700 | [diff] [blame] | 27 | import com.android.systemui.statusbar.phone.StatusBarIconController; |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 28 | |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 29 | /** |
| 30 | * A custom navigation bar for the automotive use case. |
| 31 | * <p> |
Victor Chan | 1c6d058 | 2016-01-09 16:26:37 -0800 | [diff] [blame] | 32 | * The navigation bar in the automotive use case is more like a list of shortcuts, rendered |
| 33 | * in a linear layout. |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 34 | */ |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 35 | class CarNavigationBarView extends LinearLayout { |
Brad Stenning | 7e41181 | 2018-04-13 22:52:39 -0700 | [diff] [blame] | 36 | private View mNavButtons; |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 37 | private AlphaOptimizedImageButton mNotificationsButton; |
| 38 | private CarStatusBar mCarStatusBar; |
Brad Stenning | 38b46f8 | 2018-03-27 13:57:29 -0700 | [diff] [blame] | 39 | private Context mContext; |
Brad Stenning | 7e41181 | 2018-04-13 22:52:39 -0700 | [diff] [blame] | 40 | private View mLockScreenButtons; |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 41 | |
| 42 | public CarNavigationBarView(Context context, AttributeSet attrs) { |
| 43 | super(context, attrs); |
Brad Stenning | 38b46f8 | 2018-03-27 13:57:29 -0700 | [diff] [blame] | 44 | mContext = context; |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | @Override |
| 48 | public void onFinishInflate() { |
Alan Viverette | 51efddb | 2017-04-05 10:00:01 -0400 | [diff] [blame] | 49 | mNavButtons = findViewById(R.id.nav_buttons); |
Brad Stenning | 7e41181 | 2018-04-13 22:52:39 -0700 | [diff] [blame] | 50 | mLockScreenButtons = findViewById(R.id.lock_screen_nav_buttons); |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 51 | |
| 52 | mNotificationsButton = findViewById(R.id.notifications); |
Brad Stenning | 38b46f8 | 2018-03-27 13:57:29 -0700 | [diff] [blame] | 53 | if (mNotificationsButton != null) { |
| 54 | mNotificationsButton.setOnClickListener(this::onNotificationsClick); |
| 55 | } |
Brad Stenning | 2d72674 | 2018-04-06 10:28:08 -0700 | [diff] [blame] | 56 | View mStatusIcons = findViewById(R.id.statusIcons); |
| 57 | if (mStatusIcons != null) { |
| 58 | // Attach the controllers for Status icons such as wifi and bluetooth if the standard |
| 59 | // container is in the view. |
| 60 | StatusBarIconController.DarkIconManager mDarkIconManager = |
| 61 | new StatusBarIconController.DarkIconManager( |
| 62 | mStatusIcons.findViewById(R.id.statusIcons)); |
| 63 | mDarkIconManager.setShouldLog(true); |
| 64 | Dependency.get(StatusBarIconController.class).addIconGroup(mDarkIconManager); |
| 65 | } |
| 66 | |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 67 | } |
| 68 | |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 69 | void setStatusBar(CarStatusBar carStatusBar) { |
| 70 | mCarStatusBar = carStatusBar; |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 71 | } |
| 72 | |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 73 | protected void onNotificationsClick(View v) { |
| 74 | mCarStatusBar.togglePanel(); |
Brad Stenning | e8a7568 | 2018-01-17 10:02:21 -0800 | [diff] [blame] | 75 | } |
Brad Stenning | 7e41181 | 2018-04-13 22:52:39 -0700 | [diff] [blame] | 76 | |
| 77 | /** |
| 78 | * If there are buttons declared in the layout they will be shown and the normal |
| 79 | * Nav buttons will be hidden. |
| 80 | */ |
| 81 | public void showKeyguardButtons() { |
| 82 | if (mLockScreenButtons == null) { |
| 83 | return; |
| 84 | } |
| 85 | mLockScreenButtons.setVisibility(View.VISIBLE); |
| 86 | mNavButtons.setVisibility(View.GONE); |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * If there are buttons declared in the layout they will be hidden and the normal |
| 91 | * Nav buttons will be shown. |
| 92 | */ |
| 93 | public void hideKeyguardButtons() { |
| 94 | if (mLockScreenButtons == null) { |
| 95 | return; |
| 96 | } |
| 97 | mNavButtons.setVisibility(View.VISIBLE); |
| 98 | mLockScreenButtons.setVisibility(View.GONE); |
| 99 | } |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 100 | } |