am 592f6343: am f0fd172a: lock out clicks while switching.

* commit '592f6343726b61ad199236ccf6077941ad23aa74':
  lock out clicks while switching.
This commit is contained in:
Chris Wren
2012-10-29 13:36:59 -07:00
committed by Android Git Automerger
2 changed files with 43 additions and 27 deletions

View File

@@ -207,9 +207,11 @@ class KeyguardMultiUserAvatar extends FrameLayout {
@Override
public void setPressed(boolean pressed) {
super.setPressed(pressed);
mFramed.setPressed(pressed);
mUserImage.invalidate();
if (!pressed || isClickable()) {
super.setPressed(pressed);
mFramed.setPressed(pressed);
mUserImage.invalidate();
}
}
public UserInfo getUserInfo() {

View File

@@ -110,36 +110,50 @@ public class KeyguardMultiUserSelectorView extends FrameLayout implements View.O
return false;
}
private void setAllClickable(boolean clickable)
{
for(int i = 0; i < mUsersGrid.getChildCount(); i++) {
View v = mUsersGrid.getChildAt(i);
v.setClickable(clickable);
v.setPressed(false);
}
}
@Override
public void onClick(View v) {
if (!(v instanceof KeyguardMultiUserAvatar)) return;
final KeyguardMultiUserAvatar avatar = (KeyguardMultiUserAvatar) v;
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);
mActiveUserAvatar.setActive(false, true, new Runnable() {
@Override
public void run() {
mActiveUserAvatar = avatar;
mActiveUserAvatar.setActive(true, true, new Runnable() {
@Override
public void run() {
if (this.getClass().getName().contains("internal")) {
try {
ActivityManagerNative.getDefault()
.switchUser(avatar.getUserInfo().id);
} catch (RemoteException re) {
Log.e(TAG, "Couldn't switch user " + re);
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);
mActiveUserAvatar.setActive(false, true, new Runnable() {
@Override
public void run() {
mActiveUserAvatar = avatar;
mActiveUserAvatar.setActive(true, true, new Runnable() {
@Override
public void run() {
if (this.getClass().getName().contains("internal")) {
try {
ActivityManagerNative.getDefault()
.switchUser(avatar.getUserInfo().id);
} catch (RemoteException re) {
Log.e(TAG, "Couldn't switch user " + re);
}
} else {
setAllClickable(true);
}
}
}
});
}
});
});
}
});
}
}
}
}