MultiUserSwitch.java revision 1ef80fe5905a19cf92f073163c187a96287335e4
1/* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License 15 */ 16 17package com.android.systemui.statusbar.phone; 18 19import android.content.Context; 20import android.content.Intent; 21import android.os.UserHandle; 22import android.os.UserManager; 23import android.provider.ContactsContract; 24import android.util.AttributeSet; 25import android.view.View; 26import android.widget.FrameLayout; 27 28import com.android.systemui.qs.QSPanel; 29import com.android.systemui.qs.tiles.UserDetail; 30 31/** 32 * Container for image of the multi user switcher (tappable). 33 */ 34public class MultiUserSwitch extends FrameLayout implements View.OnClickListener { 35 36 private QSPanel mQsPanel; 37 38 public MultiUserSwitch(Context context, AttributeSet attrs) { 39 super(context, attrs); 40 } 41 42 @Override 43 protected void onFinishInflate() { 44 super.onFinishInflate(); 45 setOnClickListener(this); 46 } 47 48 public void setQsPanel(QSPanel qsPanel) { 49 mQsPanel = qsPanel; 50 } 51 52 @Override 53 public void onClick(View v) { 54 final UserManager um = UserManager.get(getContext()); 55 if (um.isUserSwitcherEnabled()) { 56 mQsPanel.showDetailAdapter(true, UserDetail.USER_DETAIL_ADAPTER); 57 } else { 58 Intent intent = ContactsContract.QuickContact.composeQuickContactsIntent( 59 getContext(), v, ContactsContract.Profile.CONTENT_URI, 60 ContactsContract.QuickContact.MODE_LARGE, null); 61 getContext().startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT)); 62 } 63 } 64} 65