diff options
author | Adrian Roos <roosa@google.com> | 2014-07-15 13:44:24 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-07-14 21:09:14 +0000 |
commit | 945654188ef8b5ee1c404bd950a9ef45defa43d1 (patch) | |
tree | faee264d3357d51c5b669ec258ae9abc0bf681a8 /packages | |
parent | a50cd8d4264ca98e19b858596de3a223ba6bf42e (diff) | |
parent | 1ef80fe5905a19cf92f073163c187a96287335e4 (diff) | |
download | frameworks_base-945654188ef8b5ee1c404bd950a9ef45defa43d1.zip frameworks_base-945654188ef8b5ee1c404bd950a9ef45defa43d1.tar.gz frameworks_base-945654188ef8b5ee1c404bd950a9ef45defa43d1.tar.bz2 |
Merge "Make user switcher appear inside the QS panel" into lmp-dev
Diffstat (limited to 'packages')
9 files changed, 173 insertions, 61 deletions
diff --git a/packages/SystemUI/res/layout/qs_user_detail.xml b/packages/SystemUI/res/layout/qs_user_detail.xml new file mode 100644 index 0000000..eedae9f --- /dev/null +++ b/packages/SystemUI/res/layout/qs_user_detail.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> + +<!-- + ~ Copyright (C) 2014 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 + --> + +<com.android.systemui.qs.tiles.UserDetail + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent"> + <include layout="@layout/user_switcher_host" /> +</com.android.systemui.qs.tiles.UserDetail>
\ No newline at end of file diff --git a/packages/SystemUI/res/layout/user_switcher_host.xml b/packages/SystemUI/res/layout/user_switcher_host.xml index 816af57..c1626c6 100644 --- a/packages/SystemUI/res/layout/user_switcher_host.xml +++ b/packages/SystemUI/res/layout/user_switcher_host.xml @@ -21,17 +21,11 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="#dd000000" - android:elevation="12dp"> - <FrameLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="@dimen/volume_panel_top" - android:background="@*android:drawable/dialog_full_holo_dark"> + android:layout_height="match_parent"> + <ListView android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="match_parent" tools:listitem="@layout/user_switcher_item"/> - </FrameLayout> + </com.android.systemui.settings.UserSwitcherHostView>
\ No newline at end of file diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java index 72474b8..5f09cbd 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java @@ -34,6 +34,7 @@ import com.android.systemui.R; import com.android.systemui.qs.QSTile.DetailAdapter; import com.android.systemui.settings.BrightnessController; import com.android.systemui.settings.ToggleSlider; +import com.android.systemui.statusbar.phone.QSTileHost; import java.util.ArrayList; @@ -61,9 +62,10 @@ public class QSPanel extends ViewGroup { private boolean mExpanded; private boolean mListening; - private TileRecord mDetailRecord; + private Record mDetailRecord; private Callback mCallback; private BrightnessController mBrightnessController; + private QSTileHost mHost; public QSPanel(Context context) { this(context, null); @@ -89,12 +91,24 @@ public class QSPanel extends ViewGroup { mBrightnessController = new BrightnessController(getContext(), (ImageView) findViewById(R.id.brightness_icon), (ToggleSlider) findViewById(R.id.brightness_slider)); + + mDetailDoneButton.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + showDetail(false, mDetailRecord); + } + }); } public void setCallback(Callback callback) { mCallback = callback; } + public void setHost(QSTileHost host) { + mHost = host; + } + + public void updateResources() { final Resources res = mContext.getResources(); final int columns = Math.max(1, res.getInteger(R.integer.quick_settings_num_columns)); @@ -143,7 +157,13 @@ public class QSPanel extends ViewGroup { } } - private void showDetail(boolean show, TileRecord r) { + public void showDetailAdapter(boolean show, DetailAdapter adapter) { + Record r = new Record(); + r.detailAdapter = adapter; + showDetail(show, r); + } + + private void showDetail(boolean show, Record r) { mHandler.obtainMessage(H.SHOW_DETAIL, show ? 1 : 0, 0, r).sendToTarget(); } @@ -203,40 +223,52 @@ public class QSPanel extends ViewGroup { addView(r.tileView); } - private void handleShowDetail(TileRecord r, boolean show) { - if (r == null) return; - AnimatorListener listener = null; + private void handleShowDetail(Record r, boolean show) { + if (r instanceof TileRecord) { + handleShowDetailTile((TileRecord) r, show); + } else { + handleShowDetailImpl(r, show, getWidth() /* x */, 0/* y */); + } + } + + private void handleShowDetailTile(TileRecord r, boolean show) { + if ((mDetailRecord != null) == show) return; + if (show) { - if (mDetailRecord != null) return; // already showing something in detail r.detailAdapter = r.tile.getDetailAdapter(); if (r.detailAdapter == null) return; - mDetailRecord = r; - r.detailView = r.detailAdapter.createDetailView(mContext, r.detailView, mDetailContent); + } + int x = r.tileView.getLeft() + r.tileView.getWidth() / 2; + int y = r.tileView.getTop() + r.tileView.getHeight() / 2; + handleShowDetailImpl(r, show, x, y); + } + + private void handleShowDetailImpl(Record r, boolean show, int x, int y) { + if ((mDetailRecord != null) == show) return; // already in right state + DetailAdapter detailAdapter = null; + AnimatorListener listener = null; + if (show) { + detailAdapter = r.detailAdapter; + r.detailView = detailAdapter.createDetailView(mContext, r.detailView, mDetailContent); if (r.detailView == null) throw new IllegalStateException("Must return detail view"); - mDetailDoneButton.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - showDetail(false, mDetailRecord); - } - }); - final Intent settingsIntent = r.detailAdapter.getSettingsIntent(); + + final Intent settingsIntent = detailAdapter.getSettingsIntent(); mDetailSettingsButton.setVisibility(settingsIntent != null ? VISIBLE : GONE); mDetailSettingsButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - mDetailRecord.tile.mHost.startSettingsActivity(settingsIntent); + mHost.startSettingsActivity(settingsIntent); } }); + mDetailContent.removeAllViews(); mDetail.bringToFront(); mDetailContent.addView(r.detailView); + mDetailRecord = r; } else { - if (mDetailRecord == null) return; listener = mTeardownDetailWhenDone; } - fireShowingDetail(show ? r.detailAdapter : null); - int x = r.tileView.getLeft() + r.tileView.getWidth() / 2; - int y = r.tileView.getTop() + r.tileView.getHeight() / 2; + fireShowingDetail(show ? detailAdapter : null); mClipper.animateCircularClip(x, y, show, listener); } @@ -339,18 +371,21 @@ public class QSPanel extends ViewGroup { @Override public void handleMessage(Message msg) { if (msg.what == SHOW_DETAIL) { - handleShowDetail((TileRecord)msg.obj, msg.arg1 != 0); + handleShowDetail((Record)msg.obj, msg.arg1 != 0); } else if (msg.what == SET_TILE_VISIBILITY) { handleSetTileVisibility((View)msg.obj, msg.arg1 != 0); } } } - private static final class TileRecord { - QSTile<?> tile; - QSTileView tileView; + private static class Record { View detailView; DetailAdapter detailAdapter; + } + + private static final class TileRecord extends Record { + QSTile<?> tile; + QSTileView tileView; int row; int col; } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetail.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetail.java new file mode 100644 index 0000000..a9a2724 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetail.java @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2014 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.tiles; + +import com.android.systemui.R; +import com.android.systemui.qs.QSTile; + +import android.content.Context; +import android.content.Intent; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.FrameLayout; + +/** + * Quick settings detail view for user switching. + */ +public class UserDetail extends FrameLayout { + + static final Intent USER_SETTINGS_INTENT = new Intent("android.settings.USER_SETTINGS"); + + public UserDetail(Context context) { + this(context, null); + } + + public UserDetail(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public UserDetail(Context context, AttributeSet attrs, int defStyleAttr) { + this(context, attrs, defStyleAttr, 0); + } + + public UserDetail(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + } + + public static QSTile.DetailAdapter USER_DETAIL_ADAPTER = new QSTile.DetailAdapter() { + @Override + public int getTitle() { + return R.string.quick_settings_user_title; + } + + @Override + public Boolean getToggleState() { + return null; + } + + @Override + public View createDetailView(Context context, View convertView, ViewGroup parent) { + return LayoutInflater.from(context).inflate(R.layout.qs_user_detail, parent, false); + } + + @Override + public Intent getSettingsIntent() { + return USER_SETTINGS_INTENT; + } + + @Override + public void setToggleState(boolean state) { + } + }; +} diff --git a/packages/SystemUI/src/com/android/systemui/settings/UserSwitcherHostView.java b/packages/SystemUI/src/com/android/systemui/settings/UserSwitcherHostView.java index a3b10f2..a5c5862 100644 --- a/packages/SystemUI/src/com/android/systemui/settings/UserSwitcherHostView.java +++ b/packages/SystemUI/src/com/android/systemui/settings/UserSwitcherHostView.java @@ -90,6 +90,7 @@ public class UserSwitcherHostView extends FrameLayout mListView = (ListView) findViewById(android.R.id.list); mListView.setAdapter(mAdapter); mListView.setOnItemClickListener(this); + refreshUsers(); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java index 0f12274..d32ad50 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java @@ -18,29 +18,22 @@ package com.android.systemui.statusbar.phone; import android.content.Context; import android.content.Intent; -import android.graphics.Canvas; -import android.graphics.Path; -import android.graphics.drawable.Drawable; import android.os.UserHandle; import android.os.UserManager; import android.provider.ContactsContract; import android.util.AttributeSet; -import android.view.LayoutInflater; import android.view.View; -import android.view.ViewGroup; import android.widget.FrameLayout; -import android.widget.ImageButton; -import com.android.systemui.R; -import com.android.systemui.settings.UserSwitcherHostView; -import com.android.systemui.statusbar.policy.UserInfoController; +import com.android.systemui.qs.QSPanel; +import com.android.systemui.qs.tiles.UserDetail; /** * Container for image of the multi user switcher (tappable). */ public class MultiUserSwitch extends FrameLayout implements View.OnClickListener { - private ViewGroup mOverlayParent; + private QSPanel mQsPanel; public MultiUserSwitch(Context context, AttributeSet attrs) { super(context, attrs); @@ -52,25 +45,15 @@ public class MultiUserSwitch extends FrameLayout implements View.OnClickListener setOnClickListener(this); } - public void setOverlayParent(ViewGroup parent) { - mOverlayParent = parent; + public void setQsPanel(QSPanel qsPanel) { + mQsPanel = qsPanel; } @Override public void onClick(View v) { final UserManager um = UserManager.get(getContext()); if (um.isUserSwitcherEnabled()) { - final UserSwitcherHostView switcher = - (UserSwitcherHostView) LayoutInflater.from(getContext()).inflate( - R.layout.user_switcher_host, mOverlayParent, false); - switcher.setFinishRunnable(new Runnable() { - @Override - public void run() { - mOverlayParent.removeView(switcher); - } - }); - switcher.refreshUsers(); - mOverlayParent.addView(switcher); + mQsPanel.showDetailAdapter(true, UserDetail.USER_DETAIL_ADAPTER); } else { Intent intent = ContactsContract.QuickContact.composeQuickContactsIntent( getContext(), v, ContactsContract.Profile.CONTENT_URI, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java index 55b3088..fc0f2d5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -150,7 +150,6 @@ public class NotificationPanelView extends PanelView implements super.onFinishInflate(); mHeader = (StatusBarHeaderView) findViewById(R.id.header); mHeader.setOnClickListener(this); - mHeader.setOverlayParent(this); mKeyguardStatusView = findViewById(R.id.keyguard_status_view); mQsContainer = findViewById(R.id.quick_settings_container); mQsPanel = (QSPanel) findViewById(R.id.quick_settings_panel); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 505af44..2c43161 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -699,6 +699,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, mBluetoothController, mLocationController, mRotationLockController, mNetworkController, mZenModeController, null /*tethering*/, mCastController, mVolumeComponent, mFlashlightController); + mQSPanel.setHost(qsh); for (QSTile<?> tile : qsh.getTiles()) { mQSPanel.addTile(tile); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java index 33d1b15..33fc479 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java @@ -475,10 +475,6 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL }); } - public void setOverlayParent(ViewGroup parent) { - mMultiUserSwitch.setOverlayParent(parent); - } - @Override public void onClick(View v) { if (v == mSettingsButton) { @@ -501,6 +497,7 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL if (mQSPanel != null) { mQSPanel.setCallback(mQsPanelCallback); } + mMultiUserSwitch.setQsPanel(qsp); } @Override |