Anthony Chen | 54daefe | 2017-04-07 17:19:54 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 14 | package com.android.systemui.qs.car; |
| 15 | |
| 16 | import android.app.Fragment; |
| 17 | import android.os.Bundle; |
| 18 | import android.support.annotation.Nullable; |
| 19 | import android.support.annotation.VisibleForTesting; |
| 20 | import android.view.LayoutInflater; |
| 21 | import android.view.View; |
| 22 | import android.view.View.OnClickListener; |
| 23 | import android.view.ViewGroup; |
| 24 | |
Bryan Eyler | 2ff9584 | 2017-08-08 16:53:33 -0700 | [diff] [blame] | 25 | import com.android.systemui.Dependency; |
Anthony Chen | 54daefe | 2017-04-07 17:19:54 -0700 | [diff] [blame] | 26 | import com.android.systemui.R; |
| 27 | import com.android.systemui.plugins.qs.QS; |
| 28 | import com.android.systemui.qs.QSFooter; |
Bryan Eyler | 2ff9584 | 2017-08-08 16:53:33 -0700 | [diff] [blame] | 29 | import com.android.systemui.statusbar.car.UserGridView; |
| 30 | import com.android.systemui.statusbar.policy.UserSwitcherController; |
Anthony Chen | 54daefe | 2017-04-07 17:19:54 -0700 | [diff] [blame] | 31 | |
| 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 | */ |
| 37 | public class CarQSFragment extends Fragment implements QS { |
| 38 | private View mHeader; |
Bryan Eyler | 2ff9584 | 2017-08-08 16:53:33 -0700 | [diff] [blame] | 39 | private CarQSFooter mFooter; |
| 40 | private UserGridView mUserGridView; |
Anthony Chen | 54daefe | 2017-04-07 17:19:54 -0700 | [diff] [blame] | 41 | |
| 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 Eyler | 2ff9584 | 2017-08-08 16:53:33 -0700 | [diff] [blame] | 53 | |
| 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 Chen | 54daefe | 2017-04-07 17:19:54 -0700 | [diff] [blame] | 59 | } |
| 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 | } |