Loading packages/SystemUI/res/layout/car_qs_detail.xml 0 → 100644 +26 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2017 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- Extends FrameLayout --> <com.android.systemui.qs.car.CarQSDetail xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/qs_detail_background" android:paddingBottom="8dp" android:visibility="gone"> </com.android.systemui.qs.car.CarQSDetail> packages/SystemUI/res/layout/car_qs_panel.xml +7 −0 Original line number Diff line number Diff line Loading @@ -24,4 +24,11 @@ <include layout="@layout/car_status_bar_header" /> <include layout="@layout/car_qs_footer" /> <include android:id="@+id/qs_detail" layout="@layout/car_qs_detail" /> <com.android.systemui.qs.QSPanel android:id="@+id/quick_settings_panel" android:layout_width="match_parent" android:layout_height="0dp"/> </LinearLayout> packages/SystemUI/src/com/android/systemui/qs/car/CarQSDetail.java 0 → 100644 +110 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.android.systemui.qs.car; import android.annotation.Nullable; import android.content.Context; import android.content.res.Configuration; import android.util.AttributeSet; import android.util.SparseArray; import android.view.View; import android.widget.FrameLayout; import com.android.internal.logging.MetricsLogger; import com.android.systemui.Dependency; import com.android.systemui.plugins.qs.DetailAdapter; import com.android.systemui.qs.QSDetail; import com.android.systemui.qs.QSPanel; /** * The detail view that displays below the status bar header in the auto use-case. This view * additional details of quick settings options, such as for showing the users when user switcher * has been selected. */ public class CarQSDetail extends FrameLayout { private final SparseArray<View> mDetailViews = new SparseArray<>(); private DetailAdapter mDetailAdapter; public CarQSDetail(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); for (int i = 0; i < mDetailViews.size(); i++) { mDetailViews.valueAt(i).dispatchConfigurationChanged(newConfig); } } public void setQsPanel(QSPanel panel) { panel.setCallback(mQsPanelCallback); } public boolean isShowingDetail() { return mDetailAdapter != null; } public void handleShowingDetail(@Nullable DetailAdapter adapter) { boolean showingDetail = adapter != null; setClickable(showingDetail); // If it's already in the right state (not showing or already showing the right adapter), // then no need to change. if ((mDetailAdapter == null && adapter == null) || mDetailAdapter == adapter) { return; } if (showingDetail) { int viewCacheIndex = adapter.getMetricsCategory(); View detailView = adapter.createDetailView(mContext, mDetailViews.get(viewCacheIndex), this); if (detailView == null) { throw new IllegalStateException("Must return detail view"); } removeAllViews(); addView(detailView); mDetailViews.put(viewCacheIndex, detailView); Dependency.get(MetricsLogger.class).visible(adapter.getMetricsCategory()); mDetailAdapter = adapter; setVisibility(View.VISIBLE); } else { if (mDetailAdapter != null) { Dependency.get(MetricsLogger.class).hidden(mDetailAdapter.getMetricsCategory()); } mDetailAdapter = null; setVisibility(View.GONE); } } private QSDetail.Callback mQsPanelCallback = new QSDetail.Callback() { @Override public void onToggleStateChanged(final boolean state) { } @Override public void onShowingDetail(final DetailAdapter detail, final int x, final int y) { post(() -> handleShowingDetail(detail)); } @Override public void onScanStateChanged(final boolean state) { } }; } packages/SystemUI/src/com/android/systemui/qs/car/CarQSFooter.java +32 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ import android.content.Intent; import android.graphics.drawable.Drawable; import android.support.annotation.Nullable; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.widget.ImageView; import android.widget.RelativeLayout; Loading @@ -37,11 +38,16 @@ import com.android.systemui.statusbar.policy.UserInfoController; */ public class CarQSFooter extends RelativeLayout implements QSFooter, UserInfoController.OnUserInfoChangedListener { private static final String TAG = "CarQSFooter"; private UserInfoController mUserInfoController; private MultiUserSwitch mMultiUserSwitch; private ImageView mMultiUserAvatar; private CarQSDetail mQsDetail; private QSPanel mQsPanel; public CarQSFooter(Context context, AttributeSet attrs) { super(context, attrs); } Loading @@ -54,6 +60,21 @@ public class CarQSFooter extends RelativeLayout implements QSFooter, mUserInfoController = Dependency.get(UserInfoController.class); mMultiUserSwitch.setOnClickListener(v -> { if (mQsDetail == null || mQsPanel == null) { Log.e(TAG, "CarQSFooter not properly set up; cannot display user switcher."); return; } // MultiUserSwitch.onClick() shows the detail, but does not close the detail, so need // to use the detail's showing state to determine the correct action. if (mQsDetail.isShowingDetail()) { mQsPanel.closeDetail(); } else { mMultiUserSwitch.onClick(v); } }); findViewById(R.id.settings_button).setOnClickListener(v -> { ActivityStarter activityStarter = Dependency.get(ActivityStarter.class); Loading @@ -73,11 +94,22 @@ public class CarQSFooter extends RelativeLayout implements QSFooter, mMultiUserAvatar.setImageDrawable(picture); } /** * Needed for setup in order to allow the multi user switch to show the users. * * @param panel the QSPanel that listens to the user switch controller. This cannot be null * during normal operation. */ @Override public void setQSPanel(@Nullable QSPanel panel) { if (panel != null) { mMultiUserSwitch.setQsPanel(panel); } mQsPanel = panel; } public void setQSDetail(CarQSDetail detail) { mQsDetail = detail; } @Override Loading packages/SystemUI/src/com/android/systemui/qs/car/CarQSFragment.java +14 −4 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.view.ViewGroup; import com.android.systemui.R; import com.android.systemui.plugins.qs.QS; import com.android.systemui.qs.QSFooter; import com.android.systemui.qs.QSPanel; /** * A quick settings fragment for the car. For auto, there is no row for quick settings or ability Loading @@ -33,7 +34,9 @@ import com.android.systemui.qs.QSFooter; */ public class CarQSFragment extends Fragment implements QS { private View mHeader; private QSFooter mFooter; private CarQSFooter mFooter; private QSPanel mQsPanel; private CarQSDetail mQsDetail; @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Loading @@ -46,6 +49,13 @@ public class CarQSFragment extends Fragment implements QS { super.onViewCreated(view, savedInstanceState); mHeader = view.findViewById(R.id.header); mFooter = view.findViewById(R.id.qs_footer); mQsPanel = view.findViewById(R.id.quick_settings_panel); mQsDetail = view.findViewById(R.id.qs_detail); // Inform each other about their existence. mQsDetail.setQsPanel(mQsPanel); mFooter.setQSDetail(mQsDetail); mFooter.setQSPanel(mQsPanel); } @Override Loading Loading @@ -123,13 +133,13 @@ public class CarQSFragment extends Fragment implements QS { @Override public boolean isShowingDetail() { // No detail panel to close. return false; return mQsDetail.isShowingDetail(); } @Override public void closeDetail() { // No detail panel to close. mQsDetail.setVisibility(View.GONE); mQsPanel.closeDetail(); } @Override Loading Loading
packages/SystemUI/res/layout/car_qs_detail.xml 0 → 100644 +26 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2017 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- Extends FrameLayout --> <com.android.systemui.qs.car.CarQSDetail xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/qs_detail_background" android:paddingBottom="8dp" android:visibility="gone"> </com.android.systemui.qs.car.CarQSDetail>
packages/SystemUI/res/layout/car_qs_panel.xml +7 −0 Original line number Diff line number Diff line Loading @@ -24,4 +24,11 @@ <include layout="@layout/car_status_bar_header" /> <include layout="@layout/car_qs_footer" /> <include android:id="@+id/qs_detail" layout="@layout/car_qs_detail" /> <com.android.systemui.qs.QSPanel android:id="@+id/quick_settings_panel" android:layout_width="match_parent" android:layout_height="0dp"/> </LinearLayout>
packages/SystemUI/src/com/android/systemui/qs/car/CarQSDetail.java 0 → 100644 +110 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.android.systemui.qs.car; import android.annotation.Nullable; import android.content.Context; import android.content.res.Configuration; import android.util.AttributeSet; import android.util.SparseArray; import android.view.View; import android.widget.FrameLayout; import com.android.internal.logging.MetricsLogger; import com.android.systemui.Dependency; import com.android.systemui.plugins.qs.DetailAdapter; import com.android.systemui.qs.QSDetail; import com.android.systemui.qs.QSPanel; /** * The detail view that displays below the status bar header in the auto use-case. This view * additional details of quick settings options, such as for showing the users when user switcher * has been selected. */ public class CarQSDetail extends FrameLayout { private final SparseArray<View> mDetailViews = new SparseArray<>(); private DetailAdapter mDetailAdapter; public CarQSDetail(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); for (int i = 0; i < mDetailViews.size(); i++) { mDetailViews.valueAt(i).dispatchConfigurationChanged(newConfig); } } public void setQsPanel(QSPanel panel) { panel.setCallback(mQsPanelCallback); } public boolean isShowingDetail() { return mDetailAdapter != null; } public void handleShowingDetail(@Nullable DetailAdapter adapter) { boolean showingDetail = adapter != null; setClickable(showingDetail); // If it's already in the right state (not showing or already showing the right adapter), // then no need to change. if ((mDetailAdapter == null && adapter == null) || mDetailAdapter == adapter) { return; } if (showingDetail) { int viewCacheIndex = adapter.getMetricsCategory(); View detailView = adapter.createDetailView(mContext, mDetailViews.get(viewCacheIndex), this); if (detailView == null) { throw new IllegalStateException("Must return detail view"); } removeAllViews(); addView(detailView); mDetailViews.put(viewCacheIndex, detailView); Dependency.get(MetricsLogger.class).visible(adapter.getMetricsCategory()); mDetailAdapter = adapter; setVisibility(View.VISIBLE); } else { if (mDetailAdapter != null) { Dependency.get(MetricsLogger.class).hidden(mDetailAdapter.getMetricsCategory()); } mDetailAdapter = null; setVisibility(View.GONE); } } private QSDetail.Callback mQsPanelCallback = new QSDetail.Callback() { @Override public void onToggleStateChanged(final boolean state) { } @Override public void onShowingDetail(final DetailAdapter detail, final int x, final int y) { post(() -> handleShowingDetail(detail)); } @Override public void onScanStateChanged(final boolean state) { } }; }
packages/SystemUI/src/com/android/systemui/qs/car/CarQSFooter.java +32 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ import android.content.Intent; import android.graphics.drawable.Drawable; import android.support.annotation.Nullable; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.widget.ImageView; import android.widget.RelativeLayout; Loading @@ -37,11 +38,16 @@ import com.android.systemui.statusbar.policy.UserInfoController; */ public class CarQSFooter extends RelativeLayout implements QSFooter, UserInfoController.OnUserInfoChangedListener { private static final String TAG = "CarQSFooter"; private UserInfoController mUserInfoController; private MultiUserSwitch mMultiUserSwitch; private ImageView mMultiUserAvatar; private CarQSDetail mQsDetail; private QSPanel mQsPanel; public CarQSFooter(Context context, AttributeSet attrs) { super(context, attrs); } Loading @@ -54,6 +60,21 @@ public class CarQSFooter extends RelativeLayout implements QSFooter, mUserInfoController = Dependency.get(UserInfoController.class); mMultiUserSwitch.setOnClickListener(v -> { if (mQsDetail == null || mQsPanel == null) { Log.e(TAG, "CarQSFooter not properly set up; cannot display user switcher."); return; } // MultiUserSwitch.onClick() shows the detail, but does not close the detail, so need // to use the detail's showing state to determine the correct action. if (mQsDetail.isShowingDetail()) { mQsPanel.closeDetail(); } else { mMultiUserSwitch.onClick(v); } }); findViewById(R.id.settings_button).setOnClickListener(v -> { ActivityStarter activityStarter = Dependency.get(ActivityStarter.class); Loading @@ -73,11 +94,22 @@ public class CarQSFooter extends RelativeLayout implements QSFooter, mMultiUserAvatar.setImageDrawable(picture); } /** * Needed for setup in order to allow the multi user switch to show the users. * * @param panel the QSPanel that listens to the user switch controller. This cannot be null * during normal operation. */ @Override public void setQSPanel(@Nullable QSPanel panel) { if (panel != null) { mMultiUserSwitch.setQsPanel(panel); } mQsPanel = panel; } public void setQSDetail(CarQSDetail detail) { mQsDetail = detail; } @Override Loading
packages/SystemUI/src/com/android/systemui/qs/car/CarQSFragment.java +14 −4 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.view.ViewGroup; import com.android.systemui.R; import com.android.systemui.plugins.qs.QS; import com.android.systemui.qs.QSFooter; import com.android.systemui.qs.QSPanel; /** * A quick settings fragment for the car. For auto, there is no row for quick settings or ability Loading @@ -33,7 +34,9 @@ import com.android.systemui.qs.QSFooter; */ public class CarQSFragment extends Fragment implements QS { private View mHeader; private QSFooter mFooter; private CarQSFooter mFooter; private QSPanel mQsPanel; private CarQSDetail mQsDetail; @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Loading @@ -46,6 +49,13 @@ public class CarQSFragment extends Fragment implements QS { super.onViewCreated(view, savedInstanceState); mHeader = view.findViewById(R.id.header); mFooter = view.findViewById(R.id.qs_footer); mQsPanel = view.findViewById(R.id.quick_settings_panel); mQsDetail = view.findViewById(R.id.qs_detail); // Inform each other about their existence. mQsDetail.setQsPanel(mQsPanel); mFooter.setQSDetail(mQsDetail); mFooter.setQSPanel(mQsPanel); } @Override Loading Loading @@ -123,13 +133,13 @@ public class CarQSFragment extends Fragment implements QS { @Override public boolean isShowingDetail() { // No detail panel to close. return false; return mQsDetail.isShowingDetail(); } @Override public void closeDetail() { // No detail panel to close. mQsDetail.setVisibility(View.GONE); mQsPanel.closeDetail(); } @Override Loading