blob: 81f7846b357dba84b543f7cb3423ee998c2fd8d2 [file] [log] [blame]
Rakesh Iyer1186faa2015-12-07 16:48:46 -08001/*
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
17package com.android.systemui.statusbar.car;
18
19import android.content.Context;
Rakesh Iyer1186faa2015-12-07 16:48:46 -080020import android.util.AttributeSet;
Rakesh Iyer1186faa2015-12-07 16:48:46 -080021import android.view.View;
Rakesh Iyer1186faa2015-12-07 16:48:46 -080022import android.widget.LinearLayout;
23
Brad Stenning078235b2017-12-18 08:25:10 -080024import com.android.keyguard.AlphaOptimizedImageButton;
Brad Stenning2d726742018-04-06 10:28:08 -070025import com.android.systemui.Dependency;
Rakesh Iyer1186faa2015-12-07 16:48:46 -080026import com.android.systemui.R;
Brad Stenning2d726742018-04-06 10:28:08 -070027import com.android.systemui.statusbar.phone.StatusBarIconController;
Rakesh Iyer1186faa2015-12-07 16:48:46 -080028
Rakesh Iyer1186faa2015-12-07 16:48:46 -080029/**
30 * A custom navigation bar for the automotive use case.
31 * <p>
Victor Chan1c6d0582016-01-09 16:26:37 -080032 * The navigation bar in the automotive use case is more like a list of shortcuts, rendered
33 * in a linear layout.
Rakesh Iyer1186faa2015-12-07 16:48:46 -080034 */
Brad Stenning078235b2017-12-18 08:25:10 -080035class CarNavigationBarView extends LinearLayout {
Brad Stenning7e411812018-04-13 22:52:39 -070036 private View mNavButtons;
Brad Stenning078235b2017-12-18 08:25:10 -080037 private AlphaOptimizedImageButton mNotificationsButton;
38 private CarStatusBar mCarStatusBar;
Brad Stenning38b46f82018-03-27 13:57:29 -070039 private Context mContext;
Brad Stenning7e411812018-04-13 22:52:39 -070040 private View mLockScreenButtons;
Rakesh Iyer1186faa2015-12-07 16:48:46 -080041
42 public CarNavigationBarView(Context context, AttributeSet attrs) {
43 super(context, attrs);
Brad Stenning38b46f82018-03-27 13:57:29 -070044 mContext = context;
Rakesh Iyer1186faa2015-12-07 16:48:46 -080045 }
46
47 @Override
48 public void onFinishInflate() {
Alan Viverette51efddb2017-04-05 10:00:01 -040049 mNavButtons = findViewById(R.id.nav_buttons);
Brad Stenning7e411812018-04-13 22:52:39 -070050 mLockScreenButtons = findViewById(R.id.lock_screen_nav_buttons);
Brad Stenning078235b2017-12-18 08:25:10 -080051
52 mNotificationsButton = findViewById(R.id.notifications);
Brad Stenning38b46f82018-03-27 13:57:29 -070053 if (mNotificationsButton != null) {
54 mNotificationsButton.setOnClickListener(this::onNotificationsClick);
55 }
Brad Stenning2d726742018-04-06 10:28:08 -070056 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 Iyer1186faa2015-12-07 16:48:46 -080067 }
68
Brad Stenning078235b2017-12-18 08:25:10 -080069 void setStatusBar(CarStatusBar carStatusBar) {
70 mCarStatusBar = carStatusBar;
Rakesh Iyer1186faa2015-12-07 16:48:46 -080071 }
72
Brad Stenning078235b2017-12-18 08:25:10 -080073 protected void onNotificationsClick(View v) {
74 mCarStatusBar.togglePanel();
Brad Stenninge8a75682018-01-17 10:02:21 -080075 }
Brad Stenning7e411812018-04-13 22:52:39 -070076
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 Iyer1186faa2015-12-07 16:48:46 -0800100}