diff options
3 files changed, 98 insertions, 28 deletions
diff --git a/packages/SystemUI/res/layout/car_qs_panel.xml b/packages/SystemUI/res/layout/car_qs_panel.xml index c8589864419d..7844cac43f9a 100644 --- a/packages/SystemUI/res/layout/car_qs_panel.xml +++ b/packages/SystemUI/res/layout/car_qs_panel.xml @@ -16,6 +16,7 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/quick_settings_container" + android:clipChildren="false" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/car_qs_background_primary" @@ -49,6 +50,7 @@ android:layout_width="match_parent" android:layout_height="@dimen/car_page_indicator_dot_diameter" android:layout_marginBottom="@dimen/car_page_indicator_margin_bottom" + android:alpha="0" android:layout_alignParentBottom="true" /> </RelativeLayout> diff --git a/packages/SystemUI/src/com/android/systemui/qs/car/CarQSFragment.java b/packages/SystemUI/src/com/android/systemui/qs/car/CarQSFragment.java index d1bd2f635ce8..0109d6a347bd 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/car/CarQSFragment.java +++ b/packages/SystemUI/src/com/android/systemui/qs/car/CarQSFragment.java @@ -54,6 +54,7 @@ public class CarQSFragment extends Fragment implements QS { private UserGridView mUserGridView; private PageIndicator mPageIndicator; private AnimatorSet mAnimatorSet; + private UserSwitchCallback mUserSwitchCallback; @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @@ -80,7 +81,9 @@ public class CarQSFragment extends Fragment implements QS { mPageIndicator = view.findViewById(R.id.user_switcher_page_indicator); mPageIndicator.setupWithViewPager(mUserGridView); - mFooter.setUserSwitchCallback(new UserSwitchCallback()); + mUserSwitchCallback = new UserSwitchCallback(); + mFooter.setUserSwitchCallback(mUserSwitchCallback); + mUserGridView.setUserSwitchCallback(mUserSwitchCallback); } @Override @@ -107,11 +110,13 @@ public class CarQSFragment extends Fragment implements QS { @Override public void setHeaderListening(boolean listening) { mFooter.setListening(listening); + mUserGridView.setListening(listening); } @Override public void setListening(boolean listening) { mFooter.setListening(listening); + mUserGridView.setListening(listening); } @Override @@ -213,6 +218,19 @@ public class CarQSFragment extends Fragment implements QS { mShowing = false; animateHeightChange(false /* opening */); } + + public void resetShowing() { + if (mShowing) { + for (int i = 0; i < mUserGridView.getChildCount(); i++) { + ViewGroup podContainer = (ViewGroup) mUserGridView.getChildAt(i); + // Need to bring the last child to the front to maintain the order in the pod + // container. Why? ¯\_(ツ)_/¯ + if (podContainer.getChildCount() > 0) { + podContainer.getChildAt(podContainer.getChildCount() - 1).bringToFront(); + } + } + } + } } private void updateUserSwitcherHeight(int height) { @@ -288,9 +306,6 @@ public class CarQSFragment extends Fragment implements QS { // to have all values start at the beginning. setupInitialValues(mAnimatorSet); - // The animation comes from above areas normally occupied by the rest of the QS panel. - mPanel.setClipChildren(false); - mAnimatorSet.start(); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridView.java b/packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridView.java index e2411771051e..cfe950faa3fc 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridView.java @@ -33,19 +33,31 @@ import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; +import com.android.systemui.Dependency; import com.android.systemui.R; +import com.android.systemui.qs.car.CarQSFragment; import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.policy.UserInfoController; import com.android.systemui.statusbar.policy.UserSwitcherController; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Vector; + /** * Displays a ViewPager with icons for the users in the system to allow switching between users. * One of the uses of this is for the lock screen in auto. */ -public class UserGridView extends ViewPager { +public class UserGridView extends ViewPager implements + UserInfoController.OnUserInfoChangedListener { private StatusBar mStatusBar; private UserSwitcherController mUserSwitcherController; private Adapter mAdapter; private UserSelectionListener mUserSelectionListener; + private UserInfoController mUserInfoController; + private Vector mUserContainers; + private CarQSFragment.UserSwitchCallback mUserSwitchCallback; public UserGridView(Context context, AttributeSet attrs) { super(context, attrs); @@ -55,10 +67,53 @@ public class UserGridView extends ViewPager { mStatusBar = statusBar; mUserSwitcherController = userSwitcherController; mAdapter = new Adapter(mUserSwitcherController); + mUserInfoController = Dependency.get(UserInfoController.class); + refreshContainers(); + } + + private void refreshContainers() { + mUserContainers = new Vector(); + + Context context = getContext(); + LayoutInflater inflater = LayoutInflater.from(context); + + for (int i = 0; i < mAdapter.getCount(); i++) { + ViewGroup pods = (ViewGroup) inflater.inflate( + R.layout.car_fullscreen_user_pod_container, null); + + int iconsPerPage = mAdapter.getIconsPerPage(); + int limit = Math.min(mUserSwitcherController.getUsers().size(), (i + 1) * iconsPerPage); + for (int j = i * iconsPerPage; j < limit; j++) { + View v = mAdapter.makeUserPod(inflater, context, j, pods); + pods.addView(v); + // This is hacky, but the dividers on the pod container LinearLayout don't seem + // to work for whatever reason. Instead, set a right margin on the pod if it's not + // the right-most pod and there is more than one pod in the container. + if (i < limit - 1 && limit > 1) { + ViewGroup.MarginLayoutParams params = + (ViewGroup.MarginLayoutParams) v.getLayoutParams(); + params.setMargins(0, 0, getResources().getDimensionPixelSize( + R.dimen.car_fullscreen_user_pod_margin_between), 0); + v.setLayoutParams(params); + } + } + mUserContainers.add(pods); + } + + mAdapter = new Adapter(mUserSwitcherController); addOnLayoutChangeListener(mAdapter); setAdapter(mAdapter); } + @Override + public void onUserInfoChanged(String name, Drawable picture, String userAccount) { + refreshContainers(); + } + + public void setUserSwitchCallback(CarQSFragment.UserSwitchCallback callback) { + mUserSwitchCallback = callback; + } + public void onUserSwitched(int newUserId) { // Bring up security view after user switch is completed. post(this::showOfflineAuthUi); @@ -68,6 +123,14 @@ public class UserGridView extends ViewPager { mUserSelectionListener = userSelectionListener; } + public void setListening(boolean listening) { + if (listening) { + mUserInfoController.addCallback(this); + } else { + mUserInfoController.removeCallback(this); + } + } + void showOfflineAuthUi() { // TODO: Show keyguard UI in-place. mStatusBar.executeRunnableDismissingKeyguard(null, null, true, true, true); @@ -142,30 +205,20 @@ public class UserGridView extends ViewPager { } @Override - public Object instantiateItem(ViewGroup container, int position) { - Context context = getContext(); - LayoutInflater inflater = LayoutInflater.from(context); - - ViewGroup pods = (ViewGroup) inflater.inflate( - R.layout.car_fullscreen_user_pod_container, null); + public void finishUpdate(ViewGroup container) { + if (mUserSwitchCallback != null) { + mUserSwitchCallback.resetShowing(); + } + } - int iconsPerPage = getIconsPerPage(); - int limit = Math.min(mUserAdapter.getCount(), (position + 1) * iconsPerPage); - for (int i = position * iconsPerPage; i < limit; i++) { - View v = makeUserPod(inflater, context, i, pods); - pods.addView(v); - // This is hacky, but the dividers on the pod container LinearLayout don't seem - // to work for whatever reason. Instead, set a right margin on the pod if it's not - // the right-most pod and there is more than one pod in the container. - if (i < limit - 1 && limit > 1) { - ViewGroup.MarginLayoutParams params = - (ViewGroup.MarginLayoutParams) v.getLayoutParams(); - params.setMargins(0, 0, mPodMarginBetween, 0); - v.setLayoutParams(params); - } + @Override + public Object instantiateItem(ViewGroup container, int position) { + if (position < mUserContainers.size()) { + container.addView((View) mUserContainers.get(position)); + return mUserContainers.get(position); + } else { + return null; } - container.addView(pods); - return pods; } /** @@ -276,7 +329,7 @@ public class UserGridView extends ViewPager { } private final class WrappedBaseUserAdapter extends UserSwitcherController.BaseUserAdapter { - private Adapter mContainer; + private final Adapter mContainer; public WrappedBaseUserAdapter(UserSwitcherController controller, Adapter container) { super(controller); |