blob: 13298d378845430f6af6f6bcccaebad172a9ff3f [file] [log] [blame]
Anthony Chen54daefe2017-04-07 17:19:54 -07001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 * except in compliance with the License. You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the
10 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11 * KIND, either express or implied. See the License for the specific language governing
12 * permissions and limitations under the License.
13 */
14package com.android.systemui.qs.car;
15
16import android.app.Fragment;
17import android.os.Bundle;
18import android.support.annotation.Nullable;
19import android.support.annotation.VisibleForTesting;
20import android.view.LayoutInflater;
21import android.view.View;
22import android.view.View.OnClickListener;
23import android.view.ViewGroup;
24
Bryan Eyler2ff95842017-08-08 16:53:33 -070025import com.android.systemui.Dependency;
Anthony Chen54daefe2017-04-07 17:19:54 -070026import com.android.systemui.R;
27import com.android.systemui.plugins.qs.QS;
28import com.android.systemui.qs.QSFooter;
Bryan Eyler2ff95842017-08-08 16:53:33 -070029import com.android.systemui.statusbar.car.UserGridView;
30import com.android.systemui.statusbar.policy.UserSwitcherController;
Anthony Chen54daefe2017-04-07 17:19:54 -070031
32/**
33 * A quick settings fragment for the car. For auto, there is no row for quick settings or ability
34 * to expand the quick settings panel. Instead, the only thing is that displayed is the
35 * status bar, and a static row with access to the user switcher and settings.
36 */
37public class CarQSFragment extends Fragment implements QS {
38 private View mHeader;
Bryan Eyler2ff95842017-08-08 16:53:33 -070039 private CarQSFooter mFooter;
40 private UserGridView mUserGridView;
Anthony Chen54daefe2017-04-07 17:19:54 -070041
42 @Override
43 public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
44 Bundle savedInstanceState) {
45 return inflater.inflate(R.layout.car_qs_panel, container, false);
46 }
47
48 @Override
49 public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
50 super.onViewCreated(view, savedInstanceState);
51 mHeader = view.findViewById(R.id.header);
52 mFooter = view.findViewById(R.id.qs_footer);
Bryan Eyler2ff95842017-08-08 16:53:33 -070053
54 mUserGridView = view.findViewById(R.id.user_grid);
55 mUserGridView.init(null, Dependency.get(UserSwitcherController.class),
56 false /* showInitially */);
57
58 mFooter.setUserGridView(mUserGridView);
Anthony Chen54daefe2017-04-07 17:19:54 -070059 }
60
61 @Override
62 public void hideImmediately() {
63 getView().setVisibility(View.INVISIBLE);
64 }
65
66 @Override
67 public void setQsExpansion(float qsExpansionFraction, float headerTranslation) {
68 // If the header is to be completed translated down, then set it to be visible.
69 getView().setVisibility(headerTranslation == 0 ? View.VISIBLE : View.INVISIBLE);
70 }
71
72 @Override
73 public View getHeader() {
74 return mHeader;
75 }
76
77 @VisibleForTesting
78 QSFooter getFooter() {
79 return mFooter;
80 }
81
82 @Override
83 public void setHeaderListening(boolean listening) {
84 mFooter.setListening(listening);
85 }
86
87 @Override
88 public void setListening(boolean listening) {
89 mFooter.setListening(listening);
90 }
91
92 @Override
93 public int getQsMinExpansionHeight() {
94 return getView().getHeight();
95 }
96
97 @Override
98 public int getDesiredHeight() {
99 return getView().getHeight();
100 }
101
102 @Override
103 public void setPanelView(HeightListener notificationPanelView) {
104 // No quick settings panel.
105 }
106
107 @Override
108 public void setHeightOverride(int desiredHeight) {
109 // No ability to expand quick settings.
110 }
111
112 @Override
113 public void setHeaderClickable(boolean qsExpansionEnabled) {
114 // Usually this sets the expand button to be clickable, but there is no quick settings to
115 // expand.
116 }
117
118 @Override
119 public boolean isCustomizing() {
120 // No ability to customize the quick settings.
121 return false;
122 }
123
124 @Override
125 public void setOverscrolling(boolean overscrolling) {
126 // No overscrolling to reveal quick settings.
127 }
128
129 @Override
130 public void setExpanded(boolean qsExpanded) {
131 // No quick settings to expand
132 }
133
134 @Override
135 public boolean isShowingDetail() {
136 // No detail panel to close.
137 return false;
138 }
139
140 @Override
141 public void closeDetail() {
142 // No detail panel to close.
143 }
144
145 @Override
146 public void setKeyguardShowing(boolean keyguardShowing) {
147 // No keyguard to show.
148 }
149
150 @Override
151 public void animateHeaderSlidingIn(long delay) {
152 // No header to animate.
153 }
154
155 @Override
156 public void animateHeaderSlidingOut() {
157 // No header to animate.
158 }
159
160 @Override
161 public void notifyCustomizeChanged() {
162 // There is no ability to customize quick settings.
163 }
164
165 @Override
166 public void setContainer(ViewGroup container) {
167 // No quick settings, so no container to set.
168 }
169
170 @Override
171 public void setExpandClickListener(OnClickListener onClickListener) {
172 // No ability to expand the quick settings.
173 }
174}