am 94548476: Merge "Add content description to keyguard user avatar" into mnc-dev
* commit '9454847618c3b799a0acfa0a2495cf8a120c4f26': Add content description to keyguard user avatar
This commit is contained in:
@@ -801,6 +801,9 @@
|
||||
<!-- Accessibility label for the button that opens the user switcher and announces the current user. -->
|
||||
<string name="accessibility_multi_user_switch_switcher_with_current">Switch user, current user <xliff:g id="current_user_name" example="John Doe">%s</xliff:g></string>
|
||||
|
||||
<!-- Accessibility label for the user icon on the lock screen. -->
|
||||
<string name="accessibility_multi_user_switch_inactive">Current user <xliff:g id="current_user_name" example="John Doe">%s</xliff:g></string>
|
||||
|
||||
<!-- Accessibility label for the button that opens the quick contact of the user. -->
|
||||
<string name="accessibility_multi_user_switch_quick_contact">Show profile</string>
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.android.systemui.R;
|
||||
import com.android.systemui.statusbar.policy.BatteryController;
|
||||
import com.android.systemui.statusbar.policy.KeyguardUserSwitcher;
|
||||
import com.android.systemui.statusbar.policy.UserInfoController;
|
||||
import com.android.systemui.statusbar.policy.UserSwitcherController;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
|
||||
@@ -140,6 +141,10 @@ public class KeyguardStatusBarView extends RelativeLayout
|
||||
((BatteryMeterView) findViewById(R.id.battery)).setBatteryController(batteryController);
|
||||
}
|
||||
|
||||
public void setUserSwitcherController(UserSwitcherController controller) {
|
||||
mMultiUserSwitch.setUserSwitcherController(controller);
|
||||
}
|
||||
|
||||
public void setUserInfoController(UserInfoController userInfoController) {
|
||||
userInfoController.addListener(new UserInfoController.OnUserInfoChangedListener() {
|
||||
@Override
|
||||
|
||||
@@ -24,7 +24,7 @@ import android.provider.ContactsContract;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.android.systemui.R;
|
||||
@@ -40,10 +40,14 @@ public class MultiUserSwitch extends FrameLayout implements View.OnClickListener
|
||||
private QSPanel mQsPanel;
|
||||
private KeyguardUserSwitcher mKeyguardUserSwitcher;
|
||||
private boolean mKeyguardMode;
|
||||
private UserSwitcherController.BaseUserAdapter mUserListener;
|
||||
|
||||
final UserManager mUserManager;
|
||||
|
||||
private final int[] mTmpInt2 = new int[2];
|
||||
|
||||
private UserSwitcherController mUserSwitcherController;
|
||||
|
||||
public MultiUserSwitch(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mUserManager = UserManager.get(getContext());
|
||||
@@ -53,10 +57,18 @@ public class MultiUserSwitch extends FrameLayout implements View.OnClickListener
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
setOnClickListener(this);
|
||||
refreshContentDescription();
|
||||
}
|
||||
|
||||
public void setQsPanel(QSPanel qsPanel) {
|
||||
mQsPanel = qsPanel;
|
||||
setUserSwitcherController(qsPanel.getHost().getUserSwitcherController());
|
||||
}
|
||||
|
||||
public void setUserSwitcherController(UserSwitcherController userSwitcherController) {
|
||||
mUserSwitcherController = userSwitcherController;
|
||||
registerListener();
|
||||
refreshContentDescription();
|
||||
}
|
||||
|
||||
public void setKeyguardUserSwitcher(KeyguardUserSwitcher keyguardUserSwitcher) {
|
||||
@@ -65,6 +77,28 @@ public class MultiUserSwitch extends FrameLayout implements View.OnClickListener
|
||||
|
||||
public void setKeyguardMode(boolean keyguardShowing) {
|
||||
mKeyguardMode = keyguardShowing;
|
||||
registerListener();
|
||||
}
|
||||
|
||||
private void registerListener() {
|
||||
if (UserSwitcherController.isUserSwitcherAvailable(mUserManager) && mUserListener == null) {
|
||||
|
||||
final UserSwitcherController controller = mUserSwitcherController;
|
||||
if (controller != null) {
|
||||
mUserListener = new UserSwitcherController.BaseUserAdapter(controller) {
|
||||
@Override
|
||||
public void notifyDataSetChanged() {
|
||||
refreshContentDescription();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
refreshContentDescription();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,22 +108,16 @@ public class MultiUserSwitch extends FrameLayout implements View.OnClickListener
|
||||
if (mKeyguardUserSwitcher != null) {
|
||||
mKeyguardUserSwitcher.show(true /* animate */);
|
||||
}
|
||||
} else {
|
||||
if (mQsPanel != null) {
|
||||
UserSwitcherController userSwitcherController =
|
||||
mQsPanel.getHost().getUserSwitcherController();
|
||||
if (userSwitcherController != null) {
|
||||
View center = getChildCount() > 0 ? getChildAt(0) : this;
|
||||
} else if (mQsPanel != null && mUserSwitcherController != null) {
|
||||
View center = getChildCount() > 0 ? getChildAt(0) : this;
|
||||
|
||||
center.getLocationInWindow(mTmpInt2);
|
||||
mTmpInt2[0] += center.getWidth() / 2;
|
||||
mTmpInt2[1] += center.getHeight() / 2;
|
||||
center.getLocationInWindow(mTmpInt2);
|
||||
mTmpInt2[0] += center.getWidth() / 2;
|
||||
mTmpInt2[1] += center.getHeight() / 2;
|
||||
|
||||
mQsPanel.showDetailAdapter(true,
|
||||
userSwitcherController.userDetailAdapter,
|
||||
mTmpInt2);
|
||||
}
|
||||
}
|
||||
mQsPanel.showDetailAdapter(true,
|
||||
mUserSwitcherController.userDetailAdapter,
|
||||
mTmpInt2);
|
||||
}
|
||||
} else {
|
||||
Intent intent = ContactsContract.QuickContact.composeQuickContactsIntent(
|
||||
@@ -100,20 +128,21 @@ public class MultiUserSwitch extends FrameLayout implements View.OnClickListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
|
||||
super.onPopulateAccessibilityEvent(event);
|
||||
public void setClickable(boolean clickable) {
|
||||
super.setClickable(clickable);
|
||||
refreshContentDescription();
|
||||
}
|
||||
|
||||
private void refreshContentDescription() {
|
||||
String currentUser = null;
|
||||
if (UserSwitcherController.isUserSwitcherAvailable(mUserManager)
|
||||
&& mUserSwitcherController != null) {
|
||||
currentUser = mUserSwitcherController.getCurrentUserName(mContext);
|
||||
}
|
||||
|
||||
String text = null;
|
||||
if (isClickable()) {
|
||||
String text;
|
||||
if (UserSwitcherController.isUserSwitcherAvailable(mUserManager)) {
|
||||
String currentUser = null;
|
||||
if (mQsPanel != null) {
|
||||
UserSwitcherController controller = mQsPanel.getHost()
|
||||
.getUserSwitcherController();
|
||||
if (controller != null) {
|
||||
currentUser = controller.getCurrentUserName(mContext);
|
||||
}
|
||||
}
|
||||
if (TextUtils.isEmpty(currentUser)) {
|
||||
text = mContext.getString(R.string.accessibility_multi_user_switch_switcher);
|
||||
} else {
|
||||
@@ -124,11 +153,17 @@ public class MultiUserSwitch extends FrameLayout implements View.OnClickListener
|
||||
} else {
|
||||
text = mContext.getString(R.string.accessibility_multi_user_switch_quick_contact);
|
||||
}
|
||||
if (!TextUtils.isEmpty(text)) {
|
||||
event.getText().add(text);
|
||||
} else {
|
||||
if (!TextUtils.isEmpty(currentUser)) {
|
||||
text = mContext.getString(
|
||||
R.string.accessibility_multi_user_switch_inactive,
|
||||
currentUser);
|
||||
}
|
||||
}
|
||||
|
||||
if (!TextUtils.equals(getContentDescription(), text)) {
|
||||
setContentDescription(text);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -858,6 +858,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
||||
// User info. Trigger first load.
|
||||
mHeader.setUserInfoController(mUserInfoController);
|
||||
mKeyguardStatusBar.setUserInfoController(mUserInfoController);
|
||||
mKeyguardStatusBar.setUserSwitcherController(mUserSwitcherController);
|
||||
mUserInfoController.reloadUserInfo();
|
||||
|
||||
mHeader.setBatteryController(mBatteryController);
|
||||
|
||||
Reference in New Issue
Block a user