FileDocCategorySizeDatePackage
KeyguardMultiUserSelectorView.javaAPI DocAndroid 5.1 API5780Thu Mar 12 22:22:42 GMT 2015com.android.keyguard

KeyguardMultiUserSelectorView

public class KeyguardMultiUserSelectorView extends android.widget.FrameLayout implements View.OnClickListener

Fields Summary
private static final String
TAG
private android.view.ViewGroup
mUsersGrid
private KeyguardMultiUserAvatar
mActiveUserAvatar
private KeyguardHostView.UserSwitcherCallback
mCallback
private static final int
FADE_OUT_ANIMATION_DURATION
Comparator
mOrderAddedComparator
Constructors Summary
public KeyguardMultiUserSelectorView(android.content.Context context)


       
        this(context, null, 0);
    
public KeyguardMultiUserSelectorView(android.content.Context context, android.util.AttributeSet attrs)

        this(context, attrs, 0);
    
public KeyguardMultiUserSelectorView(android.content.Context context, android.util.AttributeSet attrs, int defStyle)

        super(context, attrs, defStyle);
    
Methods Summary
public voidaddUsers(java.util.Collection userList)

        UserInfo activeUser;
        try {
            activeUser = ActivityManagerNative.getDefault().getCurrentUser();
        } catch (RemoteException re) {
            activeUser = null;
        }

        ArrayList<UserInfo> users = new ArrayList<UserInfo>(userList);
        Collections.sort(users, mOrderAddedComparator);

        for (UserInfo user: users) {
            if (user.supportsSwitchTo()) {
                KeyguardMultiUserAvatar uv = createAndAddUser(user);
                if (user.id == activeUser.id) {
                    mActiveUserAvatar = uv;
                }
                uv.setActive(false, false, null);
            }
        }
        mActiveUserAvatar.lockPressed(true);
    
private KeyguardMultiUserAvatarcreateAndAddUser(android.content.pm.UserInfo user)


        
        KeyguardMultiUserAvatar uv = KeyguardMultiUserAvatar.fromXml(
                R.layout.keyguard_multi_user_avatar, mContext, this, user);
        mUsersGrid.addView(uv);
        return uv;
    
voidfinalizeActiveUserNow(boolean animate)

        mActiveUserAvatar.lockPressed(false);
        mActiveUserAvatar.setActive(true, animate, null);
    
public voidfinalizeActiveUserView(boolean animate)

        if (animate) {
            getHandler().postDelayed(new Runnable() {
                    @Override
                        public void run() {
                        finalizeActiveUserNow(true);
                    }
                }, 500);
        } else {
            finalizeActiveUserNow(animate);
        }
    
public voidonClick(android.view.View v)

        if (!(v instanceof KeyguardMultiUserAvatar)) return;
        final KeyguardMultiUserAvatar avatar = (KeyguardMultiUserAvatar) v;
        if (avatar.isClickable()) { // catch race conditions
            if (mActiveUserAvatar == avatar) {
                // If they click the currently active user, show the unlock hint
                mCallback.showUnlockHint();
                return;
            } else {
                // Reset the previously active user to appear inactive
                mCallback.hideSecurityView(FADE_OUT_ANIMATION_DURATION);
                setAllClickable(false);
                avatar.lockPressed(true);
                mActiveUserAvatar.setActive(false, true, new Runnable() {
                    @Override
                    public void run() {
                        mActiveUserAvatar = avatar;
                        try {
                            ActivityManagerNative.getDefault()
                                    .switchUser(avatar.getUserInfo().id);
                        } catch (RemoteException re) {
                            Log.e(TAG, "Couldn't switch user " + re);
                        }
                    }
                });
            }
        }
    
protected voidonFinishInflate()

        mUsersGrid = (ViewGroup) findViewById(R.id.keyguard_users_grid);
        mUsersGrid.removeAllViews();
        setClipChildren(false);
        setClipToPadding(false);

    
public booleanonInterceptTouchEvent(android.view.MotionEvent event)

        if(event.getActionMasked() != MotionEvent.ACTION_CANCEL && mCallback != null) {
            mCallback.userActivity();
        }
        return false;
    
private voidsetAllClickable(boolean clickable)

        for(int i = 0; i < mUsersGrid.getChildCount(); i++) {
            View v = mUsersGrid.getChildAt(i);
            v.setClickable(clickable);
            v.setPressed(false);
        }
    
public voidsetCallback(KeyguardHostView.UserSwitcherCallback callback)

        mCallback = callback;