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;
20 import android.util.AttributeSet;
21 import android.view.View;
22 import android.widget.LinearLayout;
23 
24 import com.android.systemui.R;
25 import com.android.systemui.statusbar.phone.NavigationBarView;
26 
27 /**
28  * A custom navigation bar for the automotive use case.
29  * <p>
30  * The navigation bar in the automotive use case is more like a list of shortcuts, rendered
31  * in a linear layout.
32  */
33 class CarNavigationBarView extends NavigationBarView {
34     private LinearLayout mNavButtons;
35     private LinearLayout mLightsOutButtons;
36 
CarNavigationBarView(Context context, AttributeSet attrs)37     public CarNavigationBarView(Context context, AttributeSet attrs) {
38         super(context, attrs);
39     }
40 
41     @Override
onFinishInflate()42     public void onFinishInflate() {
43         mNavButtons = (LinearLayout) findViewById(R.id.nav_buttons);
44         mLightsOutButtons = (LinearLayout) findViewById(R.id.lights_out);
45     }
46 
addButton(CarNavigationButton button, CarNavigationButton lightsOutButton)47     public void addButton(CarNavigationButton button, CarNavigationButton lightsOutButton){
48         mNavButtons.addView(button);
49         mLightsOutButtons.addView(lightsOutButton);
50     }
51 
52     @Override
setDisabledFlags(int disabledFlags, boolean force)53     public void setDisabledFlags(int disabledFlags, boolean force) {
54         // TODO: Populate.
55     }
56 
57     @Override
reorient()58     public void reorient() {
59         // We expect the car head unit to always have a fixed rotation so we ignore this. The super
60         // class implentation expects mRotatedViews to be populated, so if you call into it, there
61         // is a possibility of a NullPointerException.
62     }
63 
64     @Override
getCurrentView()65     public View getCurrentView() {
66         return this;
67     }
68 
69     @Override
setNavigationIconHints(int hints, boolean force)70     public void setNavigationIconHints(int hints, boolean force) {
71         // We do not need to set the navigation icon hints for a vehicle
72         // Calling setNavigationIconHints in the base class will result in a NPE as the car
73         // navigation bar does not have a back button.
74     }
75 }
76