Merge "Move keyguard multi-user icon into container view" into sc-qpr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
d7997c2497
@@ -15,10 +15,15 @@
|
|||||||
~ limitations under the License
|
~ limitations under the License
|
||||||
-->
|
-->
|
||||||
<!-- This is a view that shows a user switcher in Keyguard. -->
|
<!-- This is a view that shows a user switcher in Keyguard. -->
|
||||||
<com.android.systemui.statusbar.phone.UserAvatarView
|
<FrameLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:systemui="http://schemas.android.com/apk/res-auto"
|
xmlns:systemui="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/keyguard_qs_user_switch_view"
|
android:id="@+id/keyguard_qs_user_switch_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="end">
|
||||||
|
<com.android.systemui.statusbar.phone.UserAvatarView
|
||||||
|
android:id="@+id/kg_multi_user_avatar"
|
||||||
android:layout_width="@dimen/kg_framed_avatar_size"
|
android:layout_width="@dimen/kg_framed_avatar_size"
|
||||||
android:layout_height="@dimen/kg_framed_avatar_size"
|
android:layout_height="@dimen/kg_framed_avatar_size"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
@@ -30,4 +35,5 @@
|
|||||||
systemui:frameColor="@color/kg_user_avatar_frame"
|
systemui:frameColor="@color/kg_user_avatar_frame"
|
||||||
systemui:framePadding="0dp"
|
systemui:framePadding="0dp"
|
||||||
systemui:frameWidth="0dp">
|
systemui:frameWidth="0dp">
|
||||||
</com.android.systemui.statusbar.phone.UserAvatarView>
|
</com.android.systemui.statusbar.phone.UserAvatarView>
|
||||||
|
</FrameLayout>
|
||||||
@@ -16,7 +16,8 @@
|
|||||||
|
|
||||||
package com.android.keyguard.dagger;
|
package com.android.keyguard.dagger;
|
||||||
|
|
||||||
import com.android.systemui.statusbar.phone.UserAvatarView;
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
import com.android.systemui.statusbar.policy.KeyguardQsUserSwitchController;
|
import com.android.systemui.statusbar.policy.KeyguardQsUserSwitchController;
|
||||||
|
|
||||||
import dagger.BindsInstance;
|
import dagger.BindsInstance;
|
||||||
@@ -31,8 +32,7 @@ public interface KeyguardQsUserSwitchComponent {
|
|||||||
/** Simple factory for {@link KeyguardUserSwitcherComponent}. */
|
/** Simple factory for {@link KeyguardUserSwitcherComponent}. */
|
||||||
@Subcomponent.Factory
|
@Subcomponent.Factory
|
||||||
interface Factory {
|
interface Factory {
|
||||||
KeyguardQsUserSwitchComponent build(
|
KeyguardQsUserSwitchComponent build(@BindsInstance FrameLayout userAvatarContainer);
|
||||||
@BindsInstance UserAvatarView userAvatarView);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Builds a {@link KeyguardQsUserSwitchController}. */
|
/** Builds a {@link KeyguardQsUserSwitchController}. */
|
||||||
|
|||||||
@@ -853,13 +853,13 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
mKeyguardStatusBar = mView.findViewById(R.id.keyguard_header);
|
mKeyguardStatusBar = mView.findViewById(R.id.keyguard_header);
|
||||||
mBigClockContainer = mView.findViewById(R.id.big_clock_container);
|
mBigClockContainer = mView.findViewById(R.id.big_clock_container);
|
||||||
|
|
||||||
UserAvatarView userAvatarView = null;
|
FrameLayout userAvatarContainer = null;
|
||||||
KeyguardUserSwitcherView keyguardUserSwitcherView = null;
|
KeyguardUserSwitcherView keyguardUserSwitcherView = null;
|
||||||
|
|
||||||
if (mKeyguardUserSwitcherEnabled && mUserManager.isUserSwitcherEnabled()) {
|
if (mKeyguardUserSwitcherEnabled && mUserManager.isUserSwitcherEnabled()) {
|
||||||
if (mKeyguardQsUserSwitchEnabled) {
|
if (mKeyguardQsUserSwitchEnabled) {
|
||||||
ViewStub stub = mView.findViewById(R.id.keyguard_qs_user_switch_stub);
|
ViewStub stub = mView.findViewById(R.id.keyguard_qs_user_switch_stub);
|
||||||
userAvatarView = (UserAvatarView) stub.inflate();
|
userAvatarContainer = (FrameLayout) stub.inflate();
|
||||||
} else {
|
} else {
|
||||||
ViewStub stub = mView.findViewById(R.id.keyguard_user_switcher_stub);
|
ViewStub stub = mView.findViewById(R.id.keyguard_user_switcher_stub);
|
||||||
keyguardUserSwitcherView = (KeyguardUserSwitcherView) stub.inflate();
|
keyguardUserSwitcherView = (KeyguardUserSwitcherView) stub.inflate();
|
||||||
@@ -868,7 +868,7 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
|
|
||||||
updateViewControllers(
|
updateViewControllers(
|
||||||
mView.findViewById(R.id.keyguard_status_view),
|
mView.findViewById(R.id.keyguard_status_view),
|
||||||
userAvatarView,
|
userAvatarContainer,
|
||||||
mKeyguardStatusBar,
|
mKeyguardStatusBar,
|
||||||
keyguardUserSwitcherView);
|
keyguardUserSwitcherView);
|
||||||
mNotificationContainerParent = mView.findViewById(R.id.notification_container_parent);
|
mNotificationContainerParent = mView.findViewById(R.id.notification_container_parent);
|
||||||
@@ -960,7 +960,7 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateViewControllers(KeyguardStatusView keyguardStatusView,
|
private void updateViewControllers(KeyguardStatusView keyguardStatusView,
|
||||||
UserAvatarView userAvatarView,
|
FrameLayout userAvatarView,
|
||||||
KeyguardStatusBarView keyguardStatusBarView,
|
KeyguardStatusBarView keyguardStatusBarView,
|
||||||
KeyguardUserSwitcherView keyguardUserSwitcherView) {
|
KeyguardUserSwitcherView keyguardUserSwitcherView) {
|
||||||
// Re-associate the KeyguardStatusViewController
|
// Re-associate the KeyguardStatusViewController
|
||||||
@@ -1112,7 +1112,7 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
!mKeyguardQsUserSwitchEnabled
|
!mKeyguardQsUserSwitchEnabled
|
||||||
&& mKeyguardUserSwitcherEnabled
|
&& mKeyguardUserSwitcherEnabled
|
||||||
&& isUserSwitcherEnabled;
|
&& isUserSwitcherEnabled;
|
||||||
UserAvatarView userAvatarView = (UserAvatarView) reInflateStub(
|
FrameLayout userAvatarView = (FrameLayout) reInflateStub(
|
||||||
R.id.keyguard_qs_user_switch_view /* viewId */,
|
R.id.keyguard_qs_user_switch_view /* viewId */,
|
||||||
R.id.keyguard_qs_user_switch_stub /* stubId */,
|
R.id.keyguard_qs_user_switch_stub /* stubId */,
|
||||||
R.layout.keyguard_qs_user_switch /* layoutId */,
|
R.layout.keyguard_qs_user_switch /* layoutId */,
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import android.util.Log;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.accessibility.AccessibilityNodeInfo;
|
import android.view.accessibility.AccessibilityNodeInfo;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
import com.android.keyguard.KeyguardConstants;
|
import com.android.keyguard.KeyguardConstants;
|
||||||
import com.android.keyguard.KeyguardVisibilityHelper;
|
import com.android.keyguard.KeyguardVisibilityHelper;
|
||||||
@@ -56,7 +57,7 @@ import javax.inject.Provider;
|
|||||||
* Manages the user switch on the Keyguard that is used for opening the QS user panel.
|
* Manages the user switch on the Keyguard that is used for opening the QS user panel.
|
||||||
*/
|
*/
|
||||||
@KeyguardUserSwitcherScope
|
@KeyguardUserSwitcherScope
|
||||||
public class KeyguardQsUserSwitchController extends ViewController<UserAvatarView> {
|
public class KeyguardQsUserSwitchController extends ViewController<FrameLayout> {
|
||||||
|
|
||||||
private static final String TAG = "KeyguardQsUserSwitchController";
|
private static final String TAG = "KeyguardQsUserSwitchController";
|
||||||
private static final boolean DEBUG = KeyguardConstants.DEBUG;
|
private static final boolean DEBUG = KeyguardConstants.DEBUG;
|
||||||
@@ -76,6 +77,7 @@ public class KeyguardQsUserSwitchController extends ViewController<UserAvatarVie
|
|||||||
private final KeyguardVisibilityHelper mKeyguardVisibilityHelper;
|
private final KeyguardVisibilityHelper mKeyguardVisibilityHelper;
|
||||||
private final KeyguardUserDetailAdapter mUserDetailAdapter;
|
private final KeyguardUserDetailAdapter mUserDetailAdapter;
|
||||||
private NotificationPanelViewController mNotificationPanelViewController;
|
private NotificationPanelViewController mNotificationPanelViewController;
|
||||||
|
private UserAvatarView mUserAvatarView;
|
||||||
UserSwitcherController.UserRecord mCurrentUser;
|
UserSwitcherController.UserRecord mCurrentUser;
|
||||||
|
|
||||||
// State info for the user switch and keyguard
|
// State info for the user switch and keyguard
|
||||||
@@ -111,7 +113,7 @@ public class KeyguardQsUserSwitchController extends ViewController<UserAvatarVie
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public KeyguardQsUserSwitchController(
|
public KeyguardQsUserSwitchController(
|
||||||
UserAvatarView view,
|
FrameLayout view,
|
||||||
Context context,
|
Context context,
|
||||||
@Main Resources resources,
|
@Main Resources resources,
|
||||||
ScreenLifecycle screenLifecycle,
|
ScreenLifecycle screenLifecycle,
|
||||||
@@ -143,6 +145,7 @@ public class KeyguardQsUserSwitchController extends ViewController<UserAvatarVie
|
|||||||
protected void onInit() {
|
protected void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
if (DEBUG) Log.d(TAG, "onInit");
|
if (DEBUG) Log.d(TAG, "onInit");
|
||||||
|
mUserAvatarView = mView.findViewById(R.id.kg_multi_user_avatar);
|
||||||
mAdapter = new UserSwitcherController.BaseUserAdapter(mUserSwitcherController) {
|
mAdapter = new UserSwitcherController.BaseUserAdapter(mUserSwitcherController) {
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
@@ -150,11 +153,10 @@ public class KeyguardQsUserSwitchController extends ViewController<UserAvatarVie
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
mView.setOnClickListener(v -> {
|
mUserAvatarView.setOnClickListener(v -> {
|
||||||
if (mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) {
|
if (mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isListAnimating()) {
|
if (isListAnimating()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -163,7 +165,7 @@ public class KeyguardQsUserSwitchController extends ViewController<UserAvatarVie
|
|||||||
openQsUserPanel();
|
openQsUserPanel();
|
||||||
});
|
});
|
||||||
|
|
||||||
mView.setAccessibilityDelegate(new View.AccessibilityDelegate() {
|
mUserAvatarView.setAccessibilityDelegate(new View.AccessibilityDelegate() {
|
||||||
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
|
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
|
||||||
super.onInitializeAccessibilityNodeInfo(host, info);
|
super.onInitializeAccessibilityNodeInfo(host, info);
|
||||||
info.addAction(new AccessibilityNodeInfo.AccessibilityAction(
|
info.addAction(new AccessibilityNodeInfo.AccessibilityAction(
|
||||||
@@ -237,12 +239,12 @@ public class KeyguardQsUserSwitchController extends ViewController<UserAvatarVie
|
|||||||
R.string.accessibility_multi_user_switch_switcher);
|
R.string.accessibility_multi_user_switch_switcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!TextUtils.equals(mView.getContentDescription(), contentDescription)) {
|
if (!TextUtils.equals(mUserAvatarView.getContentDescription(), contentDescription)) {
|
||||||
mView.setContentDescription(contentDescription);
|
mUserAvatarView.setContentDescription(contentDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
int userId = mCurrentUser != null ? mCurrentUser.resolveId() : UserHandle.USER_NULL;
|
int userId = mCurrentUser != null ? mCurrentUser.resolveId() : UserHandle.USER_NULL;
|
||||||
mView.setDrawableWithBadge(getCurrentUserIcon().mutate(), userId);
|
mUserAvatarView.setDrawableWithBadge(getCurrentUserIcon().mutate(), userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
Drawable getCurrentUserIcon() {
|
Drawable getCurrentUserIcon() {
|
||||||
@@ -269,7 +271,7 @@ public class KeyguardQsUserSwitchController extends ViewController<UserAvatarVie
|
|||||||
* Get the height of the keyguard user switcher view when closed.
|
* Get the height of the keyguard user switcher view when closed.
|
||||||
*/
|
*/
|
||||||
public int getUserIconHeight() {
|
public int getUserIconHeight() {
|
||||||
return mView.getHeight();
|
return mUserAvatarView.getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user