blob: e5a311d099d57ba7921a39e90dad487dc878dd54 [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;
Brad Stenninge8a75682018-01-17 10:02:21 -080020import android.graphics.Canvas;
Rakesh Iyer1186faa2015-12-07 16:48:46 -080021import android.util.AttributeSet;
Brad Stenninge8a75682018-01-17 10:02:21 -080022import android.view.MotionEvent;
Rakesh Iyer1186faa2015-12-07 16:48:46 -080023import android.view.View;
Rakesh Iyer1186faa2015-12-07 16:48:46 -080024import android.widget.LinearLayout;
25
26import com.android.systemui.R;
Brad Stenninge8a75682018-01-17 10:02:21 -080027import com.android.systemui.plugins.statusbar.phone.NavGesture;
28import com.android.systemui.statusbar.phone.NavigationBarGestureHelper;
Rakesh Iyer1186faa2015-12-07 16:48:46 -080029import com.android.systemui.statusbar.phone.NavigationBarView;
Rakesh Iyer1186faa2015-12-07 16:48:46 -080030
Rakesh Iyer1186faa2015-12-07 16:48:46 -080031/**
32 * A custom navigation bar for the automotive use case.
33 * <p>
Victor Chan1c6d0582016-01-09 16:26:37 -080034 * The navigation bar in the automotive use case is more like a list of shortcuts, rendered
35 * in a linear layout.
Rakesh Iyer1186faa2015-12-07 16:48:46 -080036 */
37class CarNavigationBarView extends NavigationBarView {
Victor Chan1c6d0582016-01-09 16:26:37 -080038 private LinearLayout mNavButtons;
39 private LinearLayout mLightsOutButtons;
Rakesh Iyer1186faa2015-12-07 16:48:46 -080040
41 public CarNavigationBarView(Context context, AttributeSet attrs) {
42 super(context, attrs);
43 }
44
45 @Override
46 public void onFinishInflate() {
Alan Viverette51efddb2017-04-05 10:00:01 -040047 mNavButtons = findViewById(R.id.nav_buttons);
48 mLightsOutButtons = findViewById(R.id.lights_out);
Rakesh Iyer1186faa2015-12-07 16:48:46 -080049 }
50
Victor Chan1c6d0582016-01-09 16:26:37 -080051 public void addButton(CarNavigationButton button, CarNavigationButton lightsOutButton){
52 mNavButtons.addView(button);
53 mLightsOutButtons.addView(lightsOutButton);
Rakesh Iyer1186faa2015-12-07 16:48:46 -080054 }
55
56 @Override
57 public void setDisabledFlags(int disabledFlags, boolean force) {
58 // TODO: Populate.
59 }
60
61 @Override
62 public void reorient() {
63 // We expect the car head unit to always have a fixed rotation so we ignore this. The super
64 // class implentation expects mRotatedViews to be populated, so if you call into it, there
65 // is a possibility of a NullPointerException.
66 }
67
68 @Override
69 public View getCurrentView() {
70 return this;
71 }
Victor Chanecdb8b02016-01-07 18:32:43 -080072
73 @Override
74 public void setNavigationIconHints(int hints, boolean force) {
75 // We do not need to set the navigation icon hints for a vehicle
76 // Calling setNavigationIconHints in the base class will result in a NPE as the car
77 // navigation bar does not have a back button.
78 }
Brad Stenninge8a75682018-01-17 10:02:21 -080079
80 @Override
81 public void onPluginConnected(NavGesture plugin, Context context) {
82 // set to null version of the plugin ignoring incoming arg.
83 super.onPluginConnected(new NullNavGesture(), context);
84 }
85
86 @Override
87 public void onPluginDisconnected(NavGesture plugin) {
88 // reinstall the null nav gesture plugin
89 super.onPluginConnected(new NullNavGesture(), getContext());
90 }
91
92 /**
93 * Null object pattern to work around expectations of the base class.
94 * This is a temporary solution to have the car system ui working.
95 * Already underway is a refactor of they car sys ui as to not use this class
96 * hierarchy.
97 */
98 private static class NullNavGesture implements NavGesture {
99 @Override
100 public GestureHelper getGestureHelper() {
101 return new GestureHelper() {
102 @Override
103 public boolean onTouchEvent(MotionEvent event) {
104 return false;
105 }
106
107 @Override
108 public boolean onInterceptTouchEvent(MotionEvent event) {
109 return false;
110 }
111
112 @Override
113 public void setBarState(boolean vertical, boolean isRtl) {
114 }
115
116 @Override
117 public void onDraw(Canvas canvas) {
118 }
119
120 @Override
121 public void onDarkIntensityChange(float intensity) {
122 }
123
124 @Override
125 public void onLayout(boolean changed, int left, int top, int right, int bottom) {
126 }
127 };
128 }
129
130 @Override
131 public int getVersion() {
132 return 0;
133 }
134
135 @Override
136 public void onCreate(Context sysuiContext, Context pluginContext) {
137 }
138
139 @Override
140 public void onDestroy() {
141 }
142 }
Rakesh Iyer1186faa2015-12-07 16:48:46 -0800143}