Merge "Close keyguard user switcher on tap outside" into lmp-mr1-dev
This commit is contained in:
@@ -14,13 +14,18 @@
|
|||||||
~ See the License for the specific language governing permissions and
|
~ See the License for the specific language governing permissions and
|
||||||
~ limitations under the License
|
~ limitations under the License
|
||||||
-->
|
-->
|
||||||
<com.android.keyguard.AlphaOptimizedLinearLayout
|
<view xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
class="com.android.systemui.statusbar.policy.KeyguardUserSwitcher$Container"
|
||||||
android:id="@+id/keyguard_user_switcher"
|
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:orientation="vertical"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/status_bar_header_height_keyguard"
|
||||||
|
android:layout_gravity="end"
|
||||||
android:gravity="end"
|
android:gravity="end"
|
||||||
android:visibility="gone"
|
|
||||||
android:paddingTop="4dp">
|
android:paddingTop="4dp">
|
||||||
</com.android.keyguard.AlphaOptimizedLinearLayout>
|
</com.android.keyguard.AlphaOptimizedLinearLayout>
|
||||||
|
</view>
|
||||||
@@ -101,11 +101,9 @@
|
|||||||
|
|
||||||
<ViewStub
|
<ViewStub
|
||||||
android:id="@+id/keyguard_user_switcher"
|
android:id="@+id/keyguard_user_switcher"
|
||||||
android:layout_height="wrap_content"
|
android:layout="@layout/keyguard_user_switcher"
|
||||||
android:layout_width="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="@dimen/status_bar_header_height_keyguard"
|
android:layout_width="match_parent" />
|
||||||
android:layout_gravity="end"
|
|
||||||
android:layout="@layout/keyguard_user_switcher" />
|
|
||||||
|
|
||||||
<include
|
<include
|
||||||
layout="@layout/keyguard_status_bar"
|
layout="@layout/keyguard_status_bar"
|
||||||
|
|||||||
@@ -1012,7 +1012,7 @@ public class NotificationPanelView extends PanelView implements
|
|||||||
? View.VISIBLE
|
? View.VISIBLE
|
||||||
: View.INVISIBLE);
|
: View.INVISIBLE);
|
||||||
if (mKeyguardUserSwitcher != null && mQsExpanded && !mStackScrollerOverscrolling) {
|
if (mKeyguardUserSwitcher != null && mQsExpanded && !mStackScrollerOverscrolling) {
|
||||||
mKeyguardUserSwitcher.hide(true /* animate */);
|
mKeyguardUserSwitcher.hideIfNotSimple(true /* animate */);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,15 +19,16 @@ package com.android.systemui.statusbar.policy;
|
|||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.animation.AnimatorListenerAdapter;
|
import android.animation.AnimatorListenerAdapter;
|
||||||
import android.animation.ObjectAnimator;
|
import android.animation.ObjectAnimator;
|
||||||
import android.animation.ValueAnimator;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.DataSetObserver;
|
import android.database.DataSetObserver;
|
||||||
|
import android.util.AttributeSet;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewStub;
|
import android.view.ViewStub;
|
||||||
import android.view.animation.AnimationUtils;
|
import android.view.animation.AnimationUtils;
|
||||||
import android.widget.TextView;
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
import com.android.keyguard.AppearAnimationUtils;
|
import com.android.keyguard.AppearAnimationUtils;
|
||||||
import com.android.systemui.R;
|
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.KeyguardStatusBarView;
|
||||||
import com.android.systemui.statusbar.phone.NotificationPanelView;
|
import com.android.systemui.statusbar.phone.NotificationPanelView;
|
||||||
import com.android.systemui.statusbar.phone.PhoneStatusBar;
|
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.
|
* Manages the user switcher on the Keyguard.
|
||||||
@@ -46,6 +45,7 @@ public class KeyguardUserSwitcher {
|
|||||||
private static final String TAG = "KeyguardUserSwitcher";
|
private static final String TAG = "KeyguardUserSwitcher";
|
||||||
private static final boolean ALWAYS_ON = false;
|
private static final boolean ALWAYS_ON = false;
|
||||||
|
|
||||||
|
private final Container mUserSwitcherContainer;
|
||||||
private final ViewGroup mUserSwitcher;
|
private final ViewGroup mUserSwitcher;
|
||||||
private final KeyguardStatusBarView mStatusBarView;
|
private final KeyguardStatusBarView mStatusBarView;
|
||||||
private final Adapter mAdapter;
|
private final Adapter mAdapter;
|
||||||
@@ -53,24 +53,29 @@ public class KeyguardUserSwitcher {
|
|||||||
private final KeyguardUserSwitcherScrim mBackground;
|
private final KeyguardUserSwitcherScrim mBackground;
|
||||||
private ObjectAnimator mBgAnimator;
|
private ObjectAnimator mBgAnimator;
|
||||||
private UserSwitcherController mUserSwitcherController;
|
private UserSwitcherController mUserSwitcherController;
|
||||||
|
private boolean mAnimating;
|
||||||
|
|
||||||
public KeyguardUserSwitcher(Context context, ViewStub userSwitcher,
|
public KeyguardUserSwitcher(Context context, ViewStub userSwitcher,
|
||||||
KeyguardStatusBarView statusBarView, NotificationPanelView panelView,
|
KeyguardStatusBarView statusBarView, NotificationPanelView panelView,
|
||||||
UserSwitcherController userSwitcherController) {
|
UserSwitcherController userSwitcherController) {
|
||||||
if (context.getResources().getBoolean(R.bool.config_keyguardUserSwitcher) || ALWAYS_ON) {
|
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);
|
mBackground = new KeyguardUserSwitcherScrim(mUserSwitcher);
|
||||||
mUserSwitcher.setBackground(mBackground);
|
mUserSwitcher.setBackground(mBackground);
|
||||||
mStatusBarView = statusBarView;
|
mStatusBarView = statusBarView;
|
||||||
mStatusBarView.setKeyguardUserSwitcher(this);
|
mStatusBarView.setKeyguardUserSwitcher(this);
|
||||||
panelView.setKeyguardUserSwitcher(this);
|
panelView.setKeyguardUserSwitcher(this);
|
||||||
mAdapter = new Adapter(context, userSwitcherController);
|
mAdapter = new Adapter(context, userSwitcherController, this);
|
||||||
mAdapter.registerDataSetObserver(mDataSetObserver);
|
mAdapter.registerDataSetObserver(mDataSetObserver);
|
||||||
mUserSwitcherController = userSwitcherController;
|
mUserSwitcherController = userSwitcherController;
|
||||||
mAppearAnimationUtils = new AppearAnimationUtils(context, 400, -0.5f, 0.5f,
|
mAppearAnimationUtils = new AppearAnimationUtils(context, 400, -0.5f, 0.5f,
|
||||||
AnimationUtils.loadInterpolator(
|
AnimationUtils.loadInterpolator(
|
||||||
context, android.R.interpolator.fast_out_slow_in));
|
context, android.R.interpolator.fast_out_slow_in));
|
||||||
|
mUserSwitcherContainer.setKeyguardUserSwitcher(this);
|
||||||
} else {
|
} else {
|
||||||
|
mUserSwitcherContainer = null;
|
||||||
mUserSwitcher = null;
|
mUserSwitcher = null;
|
||||||
mStatusBarView = null;
|
mStatusBarView = null;
|
||||||
mAdapter = null;
|
mAdapter = null;
|
||||||
@@ -98,9 +103,9 @@ public class KeyguardUserSwitcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void show(boolean animate) {
|
public void show(boolean animate) {
|
||||||
if (mUserSwitcher != null && mUserSwitcher.getVisibility() != View.VISIBLE) {
|
if (mUserSwitcher != null && mUserSwitcherContainer.getVisibility() != View.VISIBLE) {
|
||||||
cancelAnimations();
|
cancelAnimations();
|
||||||
mUserSwitcher.setVisibility(View.VISIBLE);
|
mUserSwitcherContainer.setVisibility(View.VISIBLE);
|
||||||
mStatusBarView.setKeyguardUserSwitcherShowing(true, animate);
|
mStatusBarView.setKeyguardUserSwitcherShowing(true, animate);
|
||||||
if (animate) {
|
if (animate) {
|
||||||
startAppearAnimation();
|
startAppearAnimation();
|
||||||
@@ -108,13 +113,13 @@ public class KeyguardUserSwitcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hide(boolean animate) {
|
private void hide(boolean animate) {
|
||||||
if (mUserSwitcher != null && mUserSwitcher.getVisibility() == View.VISIBLE) {
|
if (mUserSwitcher != null && mUserSwitcherContainer.getVisibility() == View.VISIBLE) {
|
||||||
cancelAnimations();
|
cancelAnimations();
|
||||||
if (animate) {
|
if (animate) {
|
||||||
startDisappearAnimation();
|
startDisappearAnimation();
|
||||||
} else {
|
} else {
|
||||||
mUserSwitcher.setVisibility(View.GONE);
|
mUserSwitcherContainer.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
mStatusBarView.setKeyguardUserSwitcherShowing(false, animate);
|
mStatusBarView.setKeyguardUserSwitcherShowing(false, animate);
|
||||||
}
|
}
|
||||||
@@ -129,6 +134,7 @@ public class KeyguardUserSwitcher {
|
|||||||
mBgAnimator.cancel();
|
mBgAnimator.cancel();
|
||||||
}
|
}
|
||||||
mUserSwitcher.animate().cancel();
|
mUserSwitcher.animate().cancel();
|
||||||
|
mAnimating = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startAppearAnimation() {
|
private void startAppearAnimation() {
|
||||||
@@ -146,6 +152,7 @@ public class KeyguardUserSwitcher {
|
|||||||
mUserSwitcher.setClipToPadding(true);
|
mUserSwitcher.setClipToPadding(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
mAnimating = true;
|
||||||
mBgAnimator = ObjectAnimator.ofInt(mBackground, "alpha", 0, 255);
|
mBgAnimator = ObjectAnimator.ofInt(mBackground, "alpha", 0, 255);
|
||||||
mBgAnimator.setDuration(400);
|
mBgAnimator.setDuration(400);
|
||||||
mBgAnimator.setInterpolator(PhoneStatusBar.ALPHA_IN);
|
mBgAnimator.setInterpolator(PhoneStatusBar.ALPHA_IN);
|
||||||
@@ -153,12 +160,14 @@ public class KeyguardUserSwitcher {
|
|||||||
@Override
|
@Override
|
||||||
public void onAnimationEnd(Animator animation) {
|
public void onAnimationEnd(Animator animation) {
|
||||||
mBgAnimator = null;
|
mBgAnimator = null;
|
||||||
|
mAnimating = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mBgAnimator.start();
|
mBgAnimator.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startDisappearAnimation() {
|
private void startDisappearAnimation() {
|
||||||
|
mAnimating = true;
|
||||||
mUserSwitcher.animate()
|
mUserSwitcher.animate()
|
||||||
.alpha(0f)
|
.alpha(0f)
|
||||||
.setDuration(300)
|
.setDuration(300)
|
||||||
@@ -166,8 +175,9 @@ public class KeyguardUserSwitcher {
|
|||||||
.withEndAction(new Runnable() {
|
.withEndAction(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
mUserSwitcher.setVisibility(View.GONE);
|
mUserSwitcherContainer.setVisibility(View.GONE);
|
||||||
mUserSwitcher.setAlpha(1f);
|
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() {
|
public final DataSetObserver mDataSetObserver = new DataSetObserver() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged() {
|
public void onChanged() {
|
||||||
@@ -209,10 +229,13 @@ public class KeyguardUserSwitcher {
|
|||||||
View.OnClickListener {
|
View.OnClickListener {
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
private KeyguardUserSwitcher mKeyguardUserSwitcher;
|
||||||
|
|
||||||
public Adapter(Context context, UserSwitcherController controller) {
|
public Adapter(Context context, UserSwitcherController controller,
|
||||||
|
KeyguardUserSwitcher kgu) {
|
||||||
super(controller);
|
super(controller);
|
||||||
mContext = context;
|
mContext = context;
|
||||||
|
mKeyguardUserSwitcher = kgu;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -240,7 +263,37 @@ public class KeyguardUserSwitcher {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class KeyguardUserSwitcherScrim extends Drawable
|
|||||||
|
|
||||||
private int mDarkColor;
|
private int mDarkColor;
|
||||||
private int mTop;
|
private int mTop;
|
||||||
private int mAlpha;
|
private int mAlpha = 255;
|
||||||
private Paint mRadialGradientPaint = new Paint();
|
private Paint mRadialGradientPaint = new Paint();
|
||||||
private int mLayoutWidth;
|
private int mLayoutWidth;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user