diff options
| author | 2014-10-28 20:27:39 +0000 | |
|---|---|---|
| committer | 2014-10-28 20:27:41 +0000 | |
| commit | 579a7f99408a5d310ab8eb2e1b6bc938e1a74c4a (patch) | |
| tree | 73afbca5704deb6ee274774f72316cf8c1a9116a | |
| parent | 2896517ba13d9b670a749a626ea1270bb446017c (diff) | |
| parent | 2d1ef3012c98c07877816f3587514cca98609550 (diff) | |
Merge "Close keyguard user switcher on tap outside" into lmp-mr1-dev
5 files changed, 87 insertions, 31 deletions
diff --git a/packages/SystemUI/res/layout/keyguard_user_switcher.xml b/packages/SystemUI/res/layout/keyguard_user_switcher.xml index 3730bbe1ee56..773da9a32440 100644 --- a/packages/SystemUI/res/layout/keyguard_user_switcher.xml +++ b/packages/SystemUI/res/layout/keyguard_user_switcher.xml @@ -14,13 +14,18 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License --> -<com.android.keyguard.AlphaOptimizedLinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/keyguard_user_switcher" - android:orientation="vertical" - android:layout_height="wrap_content" - android:layout_width="wrap_content" - android:gravity="end" - android:visibility="gone" - android:paddingTop="4dp"> -</com.android.keyguard.AlphaOptimizedLinearLayout> +<view xmlns:android="http://schemas.android.com/apk/res/android" + class="com.android.systemui.statusbar.policy.KeyguardUserSwitcher$Container" + android:layout_height="match_parent" + android:layout_width="match_parent"> + <com.android.keyguard.AlphaOptimizedLinearLayout + android:id="@+id/keyguard_user_switcher_inner" + android:orientation="vertical" + android:layout_height="wrap_content" + android:layout_width="wrap_content" + android:layout_marginTop="@dimen/status_bar_header_height_keyguard" + android:layout_gravity="end" + android:gravity="end" + android:paddingTop="4dp"> + </com.android.keyguard.AlphaOptimizedLinearLayout> +</view>
\ No newline at end of file diff --git a/packages/SystemUI/res/layout/status_bar_expanded.xml b/packages/SystemUI/res/layout/status_bar_expanded.xml index 96f9b91278d7..f6d4be54bfd2 100644 --- a/packages/SystemUI/res/layout/status_bar_expanded.xml +++ b/packages/SystemUI/res/layout/status_bar_expanded.xml @@ -101,11 +101,9 @@ <ViewStub android:id="@+id/keyguard_user_switcher" - android:layout_height="wrap_content" - android:layout_width="wrap_content" - android:layout_marginTop="@dimen/status_bar_header_height_keyguard" - android:layout_gravity="end" - android:layout="@layout/keyguard_user_switcher" /> + android:layout="@layout/keyguard_user_switcher" + android:layout_height="match_parent" + android:layout_width="match_parent" /> <include layout="@layout/keyguard_status_bar" diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java index c19bdffaf466..bc2196ae40bf 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -1012,7 +1012,7 @@ public class NotificationPanelView extends PanelView implements ? View.VISIBLE : View.INVISIBLE); if (mKeyguardUserSwitcher != null && mQsExpanded && !mStackScrollerOverscrolling) { - mKeyguardUserSwitcher.hide(true /* animate */); + mKeyguardUserSwitcher.hideIfNotSimple(true /* animate */); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java index 8f0000fd4d88..297ff7095850 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java @@ -19,15 +19,16 @@ package com.android.systemui.statusbar.policy; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; -import android.animation.ValueAnimator; import android.content.Context; import android.database.DataSetObserver; +import android.util.AttributeSet; import android.view.LayoutInflater; +import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.ViewStub; import android.view.animation.AnimationUtils; -import android.widget.TextView; +import android.widget.FrameLayout; import com.android.keyguard.AppearAnimationUtils; import com.android.systemui.R; @@ -35,8 +36,6 @@ import com.android.systemui.qs.tiles.UserDetailItemView; import com.android.systemui.statusbar.phone.KeyguardStatusBarView; import com.android.systemui.statusbar.phone.NotificationPanelView; import com.android.systemui.statusbar.phone.PhoneStatusBar; -import com.android.systemui.statusbar.phone.StatusBarHeaderView; -import com.android.systemui.statusbar.phone.UserAvatarView; /** * Manages the user switcher on the Keyguard. @@ -46,6 +45,7 @@ public class KeyguardUserSwitcher { private static final String TAG = "KeyguardUserSwitcher"; private static final boolean ALWAYS_ON = false; + private final Container mUserSwitcherContainer; private final ViewGroup mUserSwitcher; private final KeyguardStatusBarView mStatusBarView; private final Adapter mAdapter; @@ -53,24 +53,29 @@ public class KeyguardUserSwitcher { private final KeyguardUserSwitcherScrim mBackground; private ObjectAnimator mBgAnimator; private UserSwitcherController mUserSwitcherController; + private boolean mAnimating; public KeyguardUserSwitcher(Context context, ViewStub userSwitcher, KeyguardStatusBarView statusBarView, NotificationPanelView panelView, UserSwitcherController userSwitcherController) { if (context.getResources().getBoolean(R.bool.config_keyguardUserSwitcher) || ALWAYS_ON) { - mUserSwitcher = (ViewGroup) userSwitcher.inflate(); + mUserSwitcherContainer = (Container) userSwitcher.inflate(); + mUserSwitcher = (ViewGroup) + mUserSwitcherContainer.findViewById(R.id.keyguard_user_switcher_inner); mBackground = new KeyguardUserSwitcherScrim(mUserSwitcher); mUserSwitcher.setBackground(mBackground); mStatusBarView = statusBarView; mStatusBarView.setKeyguardUserSwitcher(this); panelView.setKeyguardUserSwitcher(this); - mAdapter = new Adapter(context, userSwitcherController); + mAdapter = new Adapter(context, userSwitcherController, this); mAdapter.registerDataSetObserver(mDataSetObserver); mUserSwitcherController = userSwitcherController; mAppearAnimationUtils = new AppearAnimationUtils(context, 400, -0.5f, 0.5f, AnimationUtils.loadInterpolator( context, android.R.interpolator.fast_out_slow_in)); + mUserSwitcherContainer.setKeyguardUserSwitcher(this); } else { + mUserSwitcherContainer = null; mUserSwitcher = null; mStatusBarView = null; mAdapter = null; @@ -98,9 +103,9 @@ public class KeyguardUserSwitcher { } public void show(boolean animate) { - if (mUserSwitcher != null && mUserSwitcher.getVisibility() != View.VISIBLE) { + if (mUserSwitcher != null && mUserSwitcherContainer.getVisibility() != View.VISIBLE) { cancelAnimations(); - mUserSwitcher.setVisibility(View.VISIBLE); + mUserSwitcherContainer.setVisibility(View.VISIBLE); mStatusBarView.setKeyguardUserSwitcherShowing(true, animate); if (animate) { startAppearAnimation(); @@ -108,13 +113,13 @@ public class KeyguardUserSwitcher { } } - public void hide(boolean animate) { - if (mUserSwitcher != null && mUserSwitcher.getVisibility() == View.VISIBLE) { + private void hide(boolean animate) { + if (mUserSwitcher != null && mUserSwitcherContainer.getVisibility() == View.VISIBLE) { cancelAnimations(); if (animate) { startDisappearAnimation(); } else { - mUserSwitcher.setVisibility(View.GONE); + mUserSwitcherContainer.setVisibility(View.GONE); } mStatusBarView.setKeyguardUserSwitcherShowing(false, animate); } @@ -129,6 +134,7 @@ public class KeyguardUserSwitcher { mBgAnimator.cancel(); } mUserSwitcher.animate().cancel(); + mAnimating = false; } private void startAppearAnimation() { @@ -146,6 +152,7 @@ public class KeyguardUserSwitcher { mUserSwitcher.setClipToPadding(true); } }); + mAnimating = true; mBgAnimator = ObjectAnimator.ofInt(mBackground, "alpha", 0, 255); mBgAnimator.setDuration(400); mBgAnimator.setInterpolator(PhoneStatusBar.ALPHA_IN); @@ -153,12 +160,14 @@ public class KeyguardUserSwitcher { @Override public void onAnimationEnd(Animator animation) { mBgAnimator = null; + mAnimating = false; } }); mBgAnimator.start(); } private void startDisappearAnimation() { + mAnimating = true; mUserSwitcher.animate() .alpha(0f) .setDuration(300) @@ -166,8 +175,9 @@ public class KeyguardUserSwitcher { .withEndAction(new Runnable() { @Override public void run() { - mUserSwitcher.setVisibility(View.GONE); + mUserSwitcherContainer.setVisibility(View.GONE); mUserSwitcher.setAlpha(1f); + mAnimating = false; } }); } @@ -198,6 +208,16 @@ public class KeyguardUserSwitcher { } } + public void hideIfNotSimple(boolean animate) { + if (mUserSwitcherContainer != null && !mUserSwitcherController.isSimpleUserSwitcher()) { + hide(animate); + } + } + + boolean isAnimating() { + return mAnimating; + } + public final DataSetObserver mDataSetObserver = new DataSetObserver() { @Override public void onChanged() { @@ -209,10 +229,13 @@ public class KeyguardUserSwitcher { View.OnClickListener { private Context mContext; + private KeyguardUserSwitcher mKeyguardUserSwitcher; - public Adapter(Context context, UserSwitcherController controller) { + public Adapter(Context context, UserSwitcherController controller, + KeyguardUserSwitcher kgu) { super(controller); mContext = context; + mKeyguardUserSwitcher = kgu; } @Override @@ -240,7 +263,37 @@ public class KeyguardUserSwitcher { @Override public void onClick(View v) { - switchTo(((UserSwitcherController.UserRecord)v.getTag())); + UserSwitcherController.UserRecord user = (UserSwitcherController.UserRecord) v.getTag(); + if (user.isCurrent && !user.isGuest) { + // Close the switcher if tapping the current user. Guest is excluded because + // tapping the guest user while it's current clears the session. + mKeyguardUserSwitcher.hideIfNotSimple(true /* animate */); + } else { + switchTo(user); + } + } + } + + public static class Container extends FrameLayout { + + private KeyguardUserSwitcher mKeyguardUserSwitcher; + + public Container(Context context, AttributeSet attrs) { + super(context, attrs); + setClipChildren(false); + } + + public void setKeyguardUserSwitcher(KeyguardUserSwitcher keyguardUserSwitcher) { + mKeyguardUserSwitcher = keyguardUserSwitcher; + } + + @Override + public boolean onTouchEvent(MotionEvent ev) { + // Hide switcher if it didn't handle the touch event (and let the event go through). + if (mKeyguardUserSwitcher != null && !mKeyguardUserSwitcher.isAnimating()) { + mKeyguardUserSwitcher.hideIfNotSimple(true /* animate */); + } + return false; } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherScrim.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherScrim.java index 43630375633f..a5fc2fe8ce31 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherScrim.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherScrim.java @@ -42,7 +42,7 @@ public class KeyguardUserSwitcherScrim extends Drawable private int mDarkColor; private int mTop; - private int mAlpha; + private int mAlpha = 255; private Paint mRadialGradientPaint = new Paint(); private int mLayoutWidth; |