diff options
| author | 2022-10-03 14:24:13 -0700 | |
|---|---|---|
| committer | 2022-10-05 00:55:27 +0000 | |
| commit | d544909970e984e42547d67b405e4c19dd6d74e3 (patch) | |
| tree | 646216461b299712a3a770e7ddd96b74e3cd8d93 | |
| parent | 37f4b300c66fe893f039a38b56b5deb1b6e0c6a3 (diff) | |
Fixes bug in user switcher bouncer dropdown
The bug was caused by the blind readding of header and footer views to
the ListView that backs the dropdown popup menu. The bug pre-existed the
refactoring work but was hidden because there were fewer updates being
sent to the UI.
The bug means that, if the bouncer dropdown is opened quickly after a
user switch event, the dropdown will visually have larger gaps above and
below its items.
The fix is simply to check whether we've already added a header and
footer to the list view before adding them again.
Bug: 246631653
Test: the bug no longer occurs after the fix
Change-Id: I58d307d79a0c7804636f145df22fe3e8f8e134fe
| -rw-r--r-- | packages/SystemUI/res-keyguard/values/ids.xml | 20 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/keyguard/KeyguardUserSwitcherPopupMenu.java | 11 |
2 files changed, 27 insertions, 4 deletions
diff --git a/packages/SystemUI/res-keyguard/values/ids.xml b/packages/SystemUI/res-keyguard/values/ids.xml new file mode 100644 index 000000000000..0dff4ffa3866 --- /dev/null +++ b/packages/SystemUI/res-keyguard/values/ids.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?><!-- + ~ Copyright (C) 2022 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. + ~ + --> + +<resources> + <item type="id" name="header_footer_views_added_tag_key" /> +</resources> diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUserSwitcherPopupMenu.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUserSwitcherPopupMenu.java index efa5558f5088..b793fd22aed1 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUserSwitcherPopupMenu.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUserSwitcherPopupMenu.java @@ -66,10 +66,13 @@ public class KeyguardUserSwitcherPopupMenu extends ListPopupWindow { listView.setDividerHeight(mContext.getResources().getDimensionPixelSize( R.dimen.bouncer_user_switcher_popup_divider_height)); - int height = mContext.getResources().getDimensionPixelSize( - R.dimen.bouncer_user_switcher_popup_header_height); - listView.addHeaderView(createSpacer(height), null, false); - listView.addFooterView(createSpacer(height), null, false); + if (listView.getTag(R.id.header_footer_views_added_tag_key) == null) { + int height = mContext.getResources().getDimensionPixelSize( + R.dimen.bouncer_user_switcher_popup_header_height); + listView.addHeaderView(createSpacer(height), null, false); + listView.addFooterView(createSpacer(height), null, false); + listView.setTag(R.id.header_footer_views_added_tag_key, new Object()); + } listView.setOnTouchListener((v, ev) -> { if (ev.getActionMasked() == MotionEvent.ACTION_DOWN) { |