diff options
Diffstat (limited to 'packages/SystemUI/src')
33 files changed, 535 insertions, 480 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/ExpandHelper.java b/packages/SystemUI/src/com/android/systemui/ExpandHelper.java index fece07f..b0e2afa 100644 --- a/packages/SystemUI/src/com/android/systemui/ExpandHelper.java +++ b/packages/SystemUI/src/com/android/systemui/ExpandHelper.java @@ -25,6 +25,7 @@ import android.media.AudioAttributes; import android.os.Vibrator; import android.util.Log; import android.view.Gravity; +import android.view.HapticFeedbackConstants; import android.view.MotionEvent; import android.view.ScaleGestureDetector; import android.view.ScaleGestureDetector.OnScaleGestureListener; @@ -64,15 +65,6 @@ public class ExpandHelper implements Gefingerpoken { // 2f: maximum brightness is stretching a 1U to 3U, or a 4U to 6U private static final float STRETCH_INTERVAL = 2f; - // level of glow for a touch, without overstretch - // overstretch fills the range (GLOW_BASE, 1.0] - private static final float GLOW_BASE = 0.5f; - - private static final AudioAttributes VIBRATION_ATTRIBUTES = new AudioAttributes.Builder() - .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) - .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION) - .build(); - @SuppressWarnings("unused") private Context mContext; @@ -94,13 +86,11 @@ public class ExpandHelper implements Gefingerpoken { private float mLastSpanY; private int mTouchSlop; private float mLastMotionY; - private int mPopDuration; private float mPullGestureMinXSpan; private Callback mCallback; private ScaleGestureDetector mSGD; private ViewScaler mScaler; private ObjectAnimator mScaleAnimation; - private Vibrator mVibrator; private boolean mEnabled = true; private ExpandableView mResizedView; private float mCurrentHeight; @@ -174,7 +164,6 @@ public class ExpandHelper implements Gefingerpoken { mScaler = new ViewScaler(); mGravity = Gravity.TOP; mScaleAnimation = ObjectAnimator.ofFloat(mScaler, "height", 0f); - mPopDuration = mContext.getResources().getInteger(R.integer.blinds_pop_duration_ms); mPullGestureMinXSpan = mContext.getResources().getDimension(R.dimen.pull_span_min); final ViewConfiguration configuration = ViewConfiguration.get(mContext); @@ -452,7 +441,9 @@ public class ExpandHelper implements Gefingerpoken { } if (!mHasPopped) { - vibrate(mPopDuration); + if (mEventSource != null) { + mEventSource.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); + } mHasPopped = true; } @@ -600,16 +591,5 @@ public class ExpandHelper implements Gefingerpoken { public void onlyObserveMovements(boolean onlyMovements) { mOnlyMovements = onlyMovements; } - - /** - * Triggers haptic feedback. - */ - private synchronized void vibrate(long duration) { - if (mVibrator == null) { - mVibrator = (android.os.Vibrator) - mContext.getSystemService(Context.VIBRATOR_SERVICE); - } - mVibrator.vibrate(duration, VIBRATION_ATTRIBUTES); - } } diff --git a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java index 6888d0e..6acd137 100644 --- a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java +++ b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java @@ -22,10 +22,8 @@ import static javax.microedition.khronos.egl.EGL10.*; import android.app.ActivityManager; import android.app.WallpaperManager; import android.content.ComponentCallbacks2; -import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; -import android.graphics.Point; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.Region.Op; @@ -35,6 +33,7 @@ import android.renderscript.Matrix4f; import android.service.wallpaper.WallpaperService; import android.util.Log; import android.view.Display; +import android.view.DisplayInfo; import android.view.MotionEvent; import android.view.SurfaceHolder; import android.view.WindowManager; @@ -111,6 +110,9 @@ public class ImageWallpaper extends WallpaperService { float mYOffset = 0.5f; float mScale = 1f; + private Display mDefaultDisplay; + private final DisplayInfo mTmpDisplayInfo = new DisplayInfo(); + boolean mVisible = true; boolean mRedrawNeeded; boolean mOffsetsChanged; @@ -172,7 +174,9 @@ public class ImageWallpaper extends WallpaperService { super.onCreate(surfaceHolder); - updateSurfaceSize(surfaceHolder); + mDefaultDisplay = getSystemService(WindowManager.class).getDefaultDisplay(); + + updateSurfaceSize(surfaceHolder, getDefaultDisplayInfo()); setOffsetNotificationsEnabled(false); } @@ -184,9 +188,7 @@ public class ImageWallpaper extends WallpaperService { mWallpaperManager.forgetLoadedWallpaper(); } - void updateSurfaceSize(SurfaceHolder surfaceHolder) { - Point p = getDefaultDisplaySize(); - + void updateSurfaceSize(SurfaceHolder surfaceHolder, DisplayInfo displayInfo) { // Load background image dimensions, if we haven't saved them yet if (mBackgroundWidth <= 0 || mBackgroundHeight <= 0) { // Need to load the image to get dimensions @@ -194,14 +196,14 @@ public class ImageWallpaper extends WallpaperService { updateWallpaperLocked(); if (mBackgroundWidth <= 0 || mBackgroundHeight <= 0) { // Default to the display size if we can't find the dimensions - mBackgroundWidth = p.x; - mBackgroundHeight = p.y; + mBackgroundWidth = displayInfo.logicalWidth; + mBackgroundHeight = displayInfo.logicalHeight; } } // Force the wallpaper to cover the screen in both dimensions - int surfaceWidth = Math.max(p.x, mBackgroundWidth); - int surfaceHeight = Math.max(p.y, mBackgroundHeight); + int surfaceWidth = Math.max(displayInfo.logicalWidth, mBackgroundWidth); + int surfaceHeight = Math.max(displayInfo.logicalHeight, mBackgroundHeight); // If the surface dimensions haven't changed, then just return final Rect frame = surfaceHolder.getSurfaceFrame(); @@ -297,26 +299,22 @@ public class ImageWallpaper extends WallpaperService { drawFrame(); } - private Point getDefaultDisplaySize() { - Point p = new Point(); - Context c = ImageWallpaper.this.getApplicationContext(); - WindowManager wm = (WindowManager)c.getSystemService(Context.WINDOW_SERVICE); - Display d = wm.getDefaultDisplay(); - d.getRealSize(p); - return p; + private DisplayInfo getDefaultDisplayInfo() { + mDefaultDisplay.getDisplayInfo(mTmpDisplayInfo); + return mTmpDisplayInfo; } void drawFrame() { try { - int newRotation = ((WindowManager) getSystemService(WINDOW_SERVICE)). - getDefaultDisplay().getRotation(); + DisplayInfo displayInfo = getDefaultDisplayInfo(); + int newRotation = displayInfo.rotation; // Sometimes a wallpaper is not large enough to cover the screen in one dimension. // Call updateSurfaceSize -- it will only actually do the update if the dimensions // should change if (newRotation != mLastRotation) { // Update surface size (if necessary) - updateSurfaceSize(getSurfaceHolder()); + updateSurfaceSize(getSurfaceHolder(), displayInfo); } SurfaceHolder sh = getSurfaceHolder(); final Rect frame = sh.getSurfaceFrame(); diff --git a/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java b/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java index f129288..1e7ee98 100644 --- a/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java +++ b/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java @@ -9,14 +9,15 @@ import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.res.Resources; +import android.database.ContentObserver; import android.graphics.PixelFormat; import android.media.AudioAttributes; import android.os.AsyncTask; import android.os.Bundle; +import android.os.Handler; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; -import android.os.Vibrator; import android.provider.Settings; import android.util.Log; import android.view.Gravity; @@ -56,6 +57,8 @@ public class AssistManager { private final PhoneStatusBar mBar; private final IVoiceInteractionManagerService mVoiceInteractionManagerService; + private ComponentName mAssistComponent; + private IVoiceInteractionSessionShowCallback mShowCallback = new IVoiceInteractionSessionShowCallback.Stub() { @@ -78,12 +81,24 @@ public class AssistManager { } }; + private final ContentObserver mAssistSettingsObserver = new ContentObserver(new Handler()) { + @Override + public void onChange(boolean selfChange) { + updateAssistInfo(); + } + }; + public AssistManager(PhoneStatusBar bar, Context context) { mContext = context; mBar = bar; mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); mVoiceInteractionManagerService = IVoiceInteractionManagerService.Stub.asInterface( ServiceManager.getService(Context.VOICE_INTERACTION_MANAGER_SERVICE)); + + mContext.getContentResolver().registerContentObserver( + Settings.Secure.getUriFor(Settings.Secure.ASSISTANT), false, + mAssistSettingsObserver); + mAssistSettingsObserver.onChange(false); } public void onConfigurationChanged() { @@ -101,23 +116,23 @@ public class AssistManager { | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); WindowManager.LayoutParams lp = getLayoutParams(); mWindowManager.addView(mView, lp); - mBar.getNavigationBarView().setDelegateView(mView); if (visible) { mView.show(true /* show */, false /* animate */); } } public void onGestureInvoked(boolean vibrate) { - boolean isVoiceInteractorActive = getVoiceInteractorSupportsAssistGesture(); - if (!isVoiceInteractorActive && !isAssistantIntentAvailable()) { + if (mAssistComponent == null) { return; } + if (vibrate) { vibrate(); } - if (!isVoiceInteractorActive || !isVoiceSessionRunning()) { + final boolean isService = isAssistantService(); + if (isService || !isVoiceSessionRunning()) { showOrb(); - mView.postDelayed(mHideRunnable, isVoiceInteractorActive + mView.postDelayed(mHideRunnable, isService ? TIMEOUT_SERVICE : TIMEOUT_ACTIVITY); } @@ -157,10 +172,12 @@ public class AssistManager { } private void startAssist() { - if (getVoiceInteractorSupportsAssistGesture()) { - startVoiceInteractor(); - } else { - startAssistActivity(); + if (mAssistComponent != null) { + if (isAssistantService()) { + startVoiceInteractor(); + } else { + startAssistActivity(); + } } } @@ -178,6 +195,9 @@ public class AssistManager { if (intent == null) { return; } + if (mAssistComponent != null) { + intent.setComponent(mAssistComponent); + } try { final ActivityOptions opts = ActivityOptions.makeCustomAnimation(mContext, @@ -255,19 +275,9 @@ public class AssistManager { } private void maybeSwapSearchIcon() { - Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)) - .getAssistIntent(mContext, false, UserHandle.USER_CURRENT); - ComponentName component = null; - boolean isService = false; - if (getVoiceInteractorSupportsAssistGesture()) { - component = getVoiceInteractorComponentName(); - isService = true; - } else if (intent != null) { - component = intent.getComponent(); - } - if (component != null) { - replaceDrawable(mView.getOrb().getLogo(), component, ASSIST_ICON_METADATA_NAME, - isService); + if (mAssistComponent != null) { + replaceDrawable(mView.getOrb().getLogo(), mAssistComponent, ASSIST_ICON_METADATA_NAME, + isAssistantService()); } else { mView.getOrb().getLogo().setImageDrawable(null); } @@ -308,8 +318,32 @@ public class AssistManager { mView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); } - public boolean isAssistantIntentAvailable() { - return ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)) - .getAssistIntent(mContext, false, UserHandle.USER_CURRENT) != null; + private boolean isAssistantService() { + return mAssistComponent == null ? + false : mAssistComponent.equals(getVoiceInteractorComponentName()); + } + + private void updateAssistInfo() { + final String setting = Settings.Secure.getStringForUser(mContext.getContentResolver(), + Settings.Secure.ASSISTANT, UserHandle.USER_CURRENT); + if (setting != null) { + mAssistComponent = ComponentName.unflattenFromString(setting); + return; + } + + // Fallback to keep backward compatible behavior when there is no user setting. + if (getVoiceInteractorSupportsAssistGesture()) { + mAssistComponent = getVoiceInteractorComponentName(); + return; + } + + Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)) + .getAssistIntent(mContext, false, UserHandle.USER_CURRENT); + if (intent != null) { + mAssistComponent = intent.getComponent(); + return; + } + + mAssistComponent = null; } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSFooter.java b/packages/SystemUI/src/com/android/systemui/qs/QSFooter.java index f59e864..ca38528 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSFooter.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSFooter.java @@ -110,15 +110,13 @@ public class QSFooter implements OnClickListener, DialogInterface.OnClickListene } private void handleRefreshState() { - boolean hasDeviceOwner = mSecurityController.hasDeviceOwner(); - boolean hasVpn = mSecurityController.isVpnEnabled(); - - mIsVisible = (hasVpn || hasDeviceOwner); - mIsIconVisible = hasVpn; - if (hasDeviceOwner) { + mIsIconVisible = mSecurityController.isVpnEnabled(); + if (mSecurityController.hasDeviceOwner()) { mFooterTextId = R.string.device_owned_footer; + mIsVisible = true; } else { mFooterTextId = R.string.vpn_footer; + mIsVisible = mIsIconVisible; } mMainHandler.post(mUpdateDisplayState); } @@ -132,15 +130,17 @@ public class QSFooter implements OnClickListener, DialogInterface.OnClickListene } private void createDialog() { - boolean hasDeviceOwner = mSecurityController.hasDeviceOwner(); - boolean hasProfile = mSecurityController.hasProfileOwner(); - boolean hasVpn = mSecurityController.isVpnEnabled(); + String deviceOwner = mSecurityController.getDeviceOwnerName(); + String profileOwner = mSecurityController.getProfileOwnerName(); + String primaryVpn = mSecurityController.getPrimaryVpnName(); + String profileVpn = mSecurityController.getProfileVpnName(); + boolean managed = mSecurityController.hasProfileOwner(); mDialog = new SystemUIDialog(mContext); - mDialog.setTitle(getTitle(hasDeviceOwner, hasProfile)); - mDialog.setMessage(getMessage(hasDeviceOwner, hasProfile, hasVpn)); + mDialog.setTitle(getTitle(deviceOwner)); + mDialog.setMessage(getMessage(deviceOwner, profileOwner, primaryVpn, profileVpn, managed)); mDialog.setButton(DialogInterface.BUTTON_POSITIVE, getPositiveButton(), this); - if (hasVpn) { + if (mSecurityController.isVpnEnabled()) { mDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getNegativeButton(), this); } mDialog.show(); @@ -154,31 +154,42 @@ public class QSFooter implements OnClickListener, DialogInterface.OnClickListene return mContext.getString(R.string.quick_settings_done); } - private String getMessage(boolean hasDeviceOwner, boolean hasProfile, boolean hasVpn) { - if (hasDeviceOwner) { - if (hasVpn) { - return mContext.getString(R.string.monitoring_description_vpn_device_owned, - mSecurityController.getDeviceOwnerName()); + private String getMessage(String deviceOwner, String profileOwner, String primaryVpn, + String profileVpn, boolean primaryUserIsManaged) { + if (deviceOwner != null) { + if (primaryVpn != null) { + return mContext.getString(R.string.monitoring_description_vpn_app_device_owned, + deviceOwner, primaryVpn); } else { return mContext.getString(R.string.monitoring_description_device_owned, - mSecurityController.getDeviceOwnerName()); + deviceOwner); + } + } else if (primaryVpn != null) { + if (profileVpn != null) { + return mContext.getString(R.string.monitoring_description_app_personal_work, + profileOwner, profileVpn, primaryVpn); + } else { + return mContext.getString(R.string.monitoring_description_app_personal, + primaryVpn); } - } else if (hasProfile) { - return mContext.getString( - R.string.monitoring_description_vpn_profile_owned, - mSecurityController.getProfileOwnerName()); + } else if (profileVpn != null) { + return mContext.getString(R.string.monitoring_description_app_work, + profileOwner, profileVpn); + } else if (profileOwner != null && primaryUserIsManaged) { + return mContext.getString(R.string.monitoring_description_device_owned, + profileOwner); } else { - return mContext.getString(R.string.monitoring_description_vpn); + // No device owner, no personal VPN, no work VPN, no user owner. Why are we here? + return null; } } - private int getTitle(boolean hasDeviceOwner, boolean hasProfile) { - if (hasDeviceOwner) { + private int getTitle(String deviceOwner) { + if (deviceOwner != null) { return R.string.monitoring_title_device_owned; - } else if (hasProfile) { - return R.string.monitoring_title_profile_owned; + } else { + return R.string.monitoring_title; } - return R.string.monitoring_title; } private final Runnable mUpdateDisplayState = new Runnable() { diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java index 25e3d10..49eb9b2 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java @@ -360,7 +360,7 @@ public class QSPanel extends ViewGroup { } private void handleShowDetailTile(TileRecord r, boolean show) { - if ((mDetailRecord != null) == show) return; + if ((mDetailRecord != null) == show && mDetailRecord == r) return; if (show) { r.detailAdapter = r.tile.getDetailAdapter(); @@ -373,7 +373,8 @@ public class QSPanel extends ViewGroup { } private void handleShowDetailImpl(Record r, boolean show, int x, int y) { - if ((mDetailRecord != null) == show) return; // already in right state + boolean visibleDiff = (mDetailRecord != null) != show; + if (!visibleDiff && mDetailRecord == r) return; // already in right state DetailAdapter detailAdapter = null; AnimatorListener listener = null; if (show) { @@ -399,7 +400,7 @@ public class QSPanel extends ViewGroup { mContext.getString(detailAdapter.getTitle()))); setDetailRecord(r); listener = mHideGridContentWhenDone; - if (r instanceof TileRecord) { + if (r instanceof TileRecord && visibleDiff) { ((TileRecord) r).openingDetail = true; } } else { @@ -411,7 +412,9 @@ public class QSPanel extends ViewGroup { } sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); fireShowingDetail(show ? detailAdapter : null); - mClipper.animateCircularClip(x, y, show, listener); + if (visibleDiff) { + mClipper.animateCircularClip(x, y, show, listener); + } } private void setGridContentVisibility(boolean visible) { diff --git a/packages/SystemUI/src/com/android/systemui/recents/Recents.java b/packages/SystemUI/src/com/android/systemui/recents/Recents.java index 7d2b5c87..442af90 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/Recents.java +++ b/packages/SystemUI/src/com/android/systemui/recents/Recents.java @@ -365,7 +365,7 @@ public class Recents extends SystemUI void preloadRecentsInternal() { // Preload only the raw task list into a new load plan (which will be consumed by the - // RecentsActivity) + // RecentsActivity) only if there is a task to animate to. ActivityManager.RunningTaskInfo topTask = mSystemServicesProxy.getTopMostTask(); MutableBoolean topTaskHome = new MutableBoolean(true); RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); @@ -374,8 +374,10 @@ public class Recents extends SystemUI sInstanceLoadPlan.preloadRawTasks(topTaskHome.value); loader.preloadTasks(sInstanceLoadPlan, topTaskHome.value); TaskStack top = sInstanceLoadPlan.getAllTaskStacks().get(0); - preCacheThumbnailTransitionBitmapAsync(topTask, top, mDummyStackView, - topTaskHome.value); + if (top.getTaskCount() > 0) { + preCacheThumbnailTransitionBitmapAsync(topTask, top, mDummyStackView, + topTaskHome.value); + } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java index c0b3a9b..7cde44c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java @@ -21,15 +21,8 @@ import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.BitmapShader; import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.PorterDuff; -import android.graphics.PorterDuffColorFilter; import android.graphics.RectF; -import android.graphics.Shader; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; @@ -100,7 +93,6 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView private boolean mDark; private int mBgTint = 0; - private final int mRoundedRectCornerRadius; /** * Flag to indicate that the notification has been touched once and the second touch will @@ -126,10 +118,8 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView private NotificationBackgroundView mBackgroundDimmed; private ObjectAnimator mBackgroundAnimator; private RectF mAppearAnimationRect = new RectF(); - private PorterDuffColorFilter mAppearAnimationFilter; private float mAnimationTranslationY; private boolean mDrawingAppearAnimation; - private Paint mAppearPaint = new Paint(); private ValueAnimator mAppearAnimator; private float mAppearAnimationFraction = -1.0f; private float mAppearAnimationTranslation; @@ -151,9 +141,6 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView mLinearInterpolator = new LinearInterpolator(); setClipChildren(false); setClipToPadding(false); - mAppearAnimationFilter = new PorterDuffColorFilter(0, PorterDuff.Mode.SRC_ATOP); - mRoundedRectCornerRadius = getResources().getDimensionPixelSize( - R.dimen.notification_material_rounded_rect_radius); mLegacyColor = context.getColor(R.color.notification_legacy_background_color); mNormalColor = context.getColor(R.color.notification_material_background_color); mLowPriorityColor = context.getColor( @@ -540,9 +527,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView private void startAppearAnimation(boolean isAppearing, float translationDirection, long delay, long duration, final Runnable onFinishedRunnable) { - if (mAppearAnimator != null) { - mAppearAnimator.cancel(); - } + cancelAppearAnimation(); mAnimationTranslationY = translationDirection * getActualHeight(); if (mAppearAnimationFraction == -1.0f) { // not initialized yet, we start anew @@ -613,6 +598,17 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView mAppearAnimator.start(); } + private void cancelAppearAnimation() { + if (mAppearAnimator != null) { + mAppearAnimator.cancel(); + } + } + + public void cancelAppearDrawing() { + cancelAppearAnimation(); + enableAppearDrawing(false); + } + private void updateAppearRect() { float inverseFraction = (1.0f - mAppearAnimationFraction); float translationFraction = mCurrentAppearInterpolator.getInterpolation(inverseFraction); @@ -652,20 +648,26 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView } private void updateAppearAnimationAlpha() { - int backgroundColor = getBgColor(); - if (backgroundColor != -1) { - float contentAlphaProgress = mAppearAnimationFraction; - contentAlphaProgress = contentAlphaProgress / (1.0f - ALPHA_ANIMATION_END); - contentAlphaProgress = Math.min(1.0f, contentAlphaProgress); - contentAlphaProgress = mCurrentAlphaInterpolator.getInterpolation(contentAlphaProgress); - int sourceColor = Color.argb((int) (255 * (1.0f - contentAlphaProgress)), - Color.red(backgroundColor), Color.green(backgroundColor), - Color.blue(backgroundColor)); - mAppearAnimationFilter.setColor(sourceColor); - mAppearPaint.setColorFilter(mAppearAnimationFilter); + float contentAlphaProgress = mAppearAnimationFraction; + contentAlphaProgress = contentAlphaProgress / (1.0f - ALPHA_ANIMATION_END); + contentAlphaProgress = Math.min(1.0f, contentAlphaProgress); + contentAlphaProgress = mCurrentAlphaInterpolator.getInterpolation(contentAlphaProgress); + setContentAlpha(contentAlphaProgress); + } + + private void setContentAlpha(float contentAlpha) { + int layerType = contentAlpha == 0.0f || contentAlpha == 1.0f ? LAYER_TYPE_NONE + : LAYER_TYPE_HARDWARE; + View contentView = getContentView(); + int currentLayerType = contentView.getLayerType(); + if (currentLayerType != layerType) { + contentView.setLayerType(layerType, null); } + contentView.setAlpha(contentAlpha); } + protected abstract View getContentView(); + private int getBgColor() { if (mBgTint != 0) { return mBgTint; @@ -699,41 +701,24 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView */ private void enableAppearDrawing(boolean enable) { if (enable != mDrawingAppearAnimation) { - if (enable) { - if (getWidth() == 0 || getActualHeight() == 0) { - // TODO: This should not happen, but it can during expansion. Needs - // investigation - return; - } - Bitmap bitmap = Bitmap.createBitmap(getWidth(), getActualHeight(), - Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(bitmap); - draw(canvas); - mAppearPaint.setShader(new BitmapShader(bitmap, Shader.TileMode.CLAMP, - Shader.TileMode.CLAMP)); - } else { - mAppearPaint.setShader(null); - } mDrawingAppearAnimation = enable; + if (!enable) { + setContentAlpha(1.0f); + } invalidate(); } } @Override protected void dispatchDraw(Canvas canvas) { - if (!mDrawingAppearAnimation) { - super.dispatchDraw(canvas); - } else { - drawAppearRect(canvas); + if (mDrawingAppearAnimation) { + canvas.save(); + canvas.translate(0, mAppearAnimationTranslation); + } + super.dispatchDraw(canvas); + if (mDrawingAppearAnimation) { + canvas.restore(); } - } - - private void drawAppearRect(Canvas canvas) { - canvas.save(); - canvas.translate(0, mAppearAnimationTranslation); - canvas.drawRoundRect(mAppearAnimationRect, mRoundedRectCornerRadius, - mRoundedRectCornerRadius, mAppearPaint); - canvas.restore(); } public void setOnActivatedListener(OnActivatedListener onActivatedListener) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index c945fc9..ef8c5db 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -82,6 +82,7 @@ import android.widget.RemoteViews; import android.widget.TextView; import android.widget.Toast; +import com.android.internal.logging.MetricsLogger; import com.android.internal.statusbar.IStatusBarService; import com.android.internal.statusbar.StatusBarIcon; import com.android.internal.statusbar.StatusBarIconList; @@ -909,6 +910,7 @@ public abstract class BaseStatusBar extends SystemUI implements final int appUidF = appUid; settingsButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { + MetricsLogger.action(mContext, MetricsLogger.ACTION_NOTE_INFO); startAppNotificationSettingsActivity(pkg, appUidF); } }); @@ -929,6 +931,7 @@ public abstract class BaseStatusBar extends SystemUI implements .setClassName(pkg, infos.get(0).activityInfo.name); appSettingsButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { + MetricsLogger.action(mContext, MetricsLogger.ACTION_APP_NOTE_SETTINGS); startAppOwnNotificationSettingsActivity(appSettingsLaunchIntent, sbn.getId(), sbn.getTag(), @@ -975,6 +978,7 @@ public abstract class BaseStatusBar extends SystemUI implements return false; } + MetricsLogger.action(mContext, MetricsLogger.ACTION_NOTE_CONTROLS); guts.setVisibility(View.VISIBLE); final double horz = Math.max(guts.getWidth() - x, x); final double vert = Math.max(guts.getActualHeight() - y, y); @@ -1844,11 +1848,8 @@ public abstract class BaseStatusBar extends SystemUI implements } } - if (onKeyguard && mKeyguardIconOverflowContainer.getIconsView().getChildCount() > 0) { - mKeyguardIconOverflowContainer.setVisibility(View.VISIBLE); - } else { - mKeyguardIconOverflowContainer.setVisibility(View.GONE); - } + mStackScroller.updateOverflowContainerVisibility(onKeyguard + && mKeyguardIconOverflowContainer.getIconsView().getChildCount() > 0); mStackScroller.changeViewPosition(mDismissView, mStackScroller.getChildCount() - 1); mStackScroller.changeViewPosition(mEmptyShadeView, mStackScroller.getChildCount() - 2); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/DelegateViewHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/DelegateViewHelper.java deleted file mode 100644 index 2dc521e..0000000 --- a/packages/SystemUI/src/com/android/systemui/statusbar/DelegateViewHelper.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.statusbar; - -import android.app.StatusBarManager; -import android.content.res.Resources; -import android.graphics.RectF; -import android.view.MotionEvent; -import android.view.View; -import com.android.systemui.R; -import com.android.systemui.statusbar.phone.PhoneStatusBar; - -public class DelegateViewHelper { - private View mDelegateView; - private View mSourceView; - private PhoneStatusBar mBar; - private int[] mTempPoint = new int[2]; - private float[] mDownPoint = new float[2]; - private float mTriggerThreshhold; - private boolean mPanelShowing; - - RectF mInitialTouch = new RectF(); - private boolean mStarted; - private boolean mSwapXY = false; - private boolean mDisabled; - - public DelegateViewHelper(View sourceView) { - setSourceView(sourceView); - } - - public void setDelegateView(View view) { - mDelegateView = view; - } - - public void setBar(PhoneStatusBar phoneStatusBar) { - mBar = phoneStatusBar; - } - - public boolean onInterceptTouchEvent(MotionEvent event) { - if (mSourceView == null || mDelegateView == null || mBar.shouldDisableNavbarGestures()) { - return false; - } - - mSourceView.getLocationOnScreen(mTempPoint); - final float sourceX = mTempPoint[0]; - final float sourceY = mTempPoint[1]; - - final int action = event.getAction(); - switch (action) { - case MotionEvent.ACTION_DOWN: - mPanelShowing = mDelegateView.getVisibility() == View.VISIBLE; - mDownPoint[0] = event.getX(); - mDownPoint[1] = event.getY(); - mStarted = mInitialTouch.contains(mDownPoint[0] + sourceX, mDownPoint[1] + sourceY); - break; - } - - if (!mStarted) { - return false; - } - - if (!mDisabled && !mPanelShowing && action == MotionEvent.ACTION_MOVE) { - final int historySize = event.getHistorySize(); - for (int k = 0; k < historySize + 1; k++) { - float x = k < historySize ? event.getHistoricalX(k) : event.getX(); - float y = k < historySize ? event.getHistoricalY(k) : event.getY(); - final float distance = mSwapXY ? (mDownPoint[0] - x) : (mDownPoint[1] - y); - if (distance > mTriggerThreshhold) { - mBar.invokeAssistGesture(false /* vibrate */); - mPanelShowing = true; - break; - } - } - } - - if (action == MotionEvent.ACTION_DOWN) { - mBar.setInteracting(StatusBarManager.WINDOW_NAVIGATION_BAR, true); - } else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) { - mBar.setInteracting(StatusBarManager.WINDOW_NAVIGATION_BAR, false); - } - - mDelegateView.getLocationOnScreen(mTempPoint); - final float delegateX = mTempPoint[0]; - final float delegateY = mTempPoint[1]; - - float deltaX = sourceX - delegateX; - float deltaY = sourceY - delegateY; - event.offsetLocation(deltaX, deltaY); - mDelegateView.dispatchTouchEvent(event); - event.offsetLocation(-deltaX, -deltaY); - return mPanelShowing; - } - - public void abortCurrentGesture() { - if (mStarted) { - mStarted = false; - mBar.setInteracting(StatusBarManager.WINDOW_NAVIGATION_BAR, false); - } - } - - public void setSourceView(View view) { - mSourceView = view; - if (mSourceView != null) { - Resources r = mSourceView.getContext().getResources(); - mTriggerThreshhold = r.getDimensionPixelSize(R.dimen.navigation_bar_min_swipe_distance); - } - } - - /** - * Selects the initial touch region based on a list of views. This is meant to be called by - * a container widget on children over which the initial touch should be detected. Note this - * will compute a minimum bound that contains all specified views. - * - * @param views - */ - public void setInitialTouchRegion(View ... views) { - RectF bounds = new RectF(); - int p[] = new int[2]; - for (int i = 0; i < views.length; i++) { - View view = views[i]; - if (view == null) continue; - view.getLocationOnScreen(p); - if (i == 0) { - bounds.set(p[0], p[1], p[0] + view.getWidth(), p[1] + view.getHeight()); - } else { - bounds.union(p[0], p[1], p[0] + view.getWidth(), p[1] + view.getHeight()); - } - } - mInitialTouch.set(bounds); - } - - /** - * When rotation is set to NO_SENSOR, then this allows swapping x/y for gesture detection - * @param swap - */ - public void setSwapXY(boolean swap) { - mSwapXY = swap; - } - - public void setDisabled(boolean disabled) { - mDisabled = disabled; - } -}
\ No newline at end of file diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/DismissViewButton.java b/packages/SystemUI/src/com/android/systemui/statusbar/DismissViewButton.java index 00665f4..a323684 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/DismissViewButton.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/DismissViewButton.java @@ -48,15 +48,14 @@ public class DismissViewButton extends Button { public DismissViewButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); - mAnimatedDismissDrawable = (AnimatedVectorDrawable) getContext().getResources().getDrawable( + mAnimatedDismissDrawable = (AnimatedVectorDrawable) getContext().getDrawable( R.drawable.dismiss_all_shape_animation).mutate(); mAnimatedDismissDrawable.setCallback(this); mAnimatedDismissDrawable.setBounds(0, 0, mAnimatedDismissDrawable.getIntrinsicWidth(), mAnimatedDismissDrawable.getIntrinsicHeight()); - mStaticDismissDrawable = getContext().getResources().getDrawable( - R.drawable.dismiss_all_shape); + mStaticDismissDrawable = getContext().getDrawable(R.drawable.dismiss_all_shape); mStaticDismissDrawable.setBounds(0, 0, mStaticDismissDrawable.getIntrinsicWidth(), diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java index d444ea8..b88e5ca 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java @@ -856,6 +856,11 @@ public class ExpandableNotificationRow extends ActivatableNotificationView { } @Override + protected View getContentView() { + return getShowingLayout(); + } + + @Override public void setActualHeight(int height, boolean notifyListeners) { super.setActualHeight(height, notifyListeners); int contentHeight = calculateContentHeightFromActualHeight(height); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableOutlineView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableOutlineView.java index a18fff2..d77e050 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableOutlineView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableOutlineView.java @@ -24,16 +24,21 @@ import android.util.AttributeSet; import android.view.View; import android.view.ViewOutlineProvider; +import com.android.systemui.R; + /** * Like {@link ExpandableView}, but setting an outline for the height and clipping. */ public abstract class ExpandableOutlineView extends ExpandableView { private final Rect mOutlineRect = new Rect(); + protected final int mRoundedRectCornerRadius; private boolean mCustomOutline; public ExpandableOutlineView(Context context, AttributeSet attrs) { super(context, attrs); + mRoundedRectCornerRadius = getResources().getDimensionPixelSize( + R.dimen.notification_material_rounded_rect_radius); setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { @@ -43,7 +48,7 @@ public abstract class ExpandableOutlineView extends ExpandableView { getWidth(), Math.max(getActualHeight(), mClipTopAmount)); } else { - outline.setRect(mOutlineRect); + outline.setRoundRect(mOutlineRect, mRoundedRectCornerRadius); } } }); @@ -66,12 +71,14 @@ public abstract class ExpandableOutlineView extends ExpandableView { setOutlineRect(rect.left, rect.top, rect.right, rect.bottom); } else { mCustomOutline = false; + setClipToOutline(false); invalidateOutline(); } } protected void setOutlineRect(float left, float top, float right, float bottom) { mCustomOutline = true; + setClipToOutline(true); mOutlineRect.set((int) left, (int) top, (int) right, (int) bottom); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java index 3feec9e..03d0482 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java @@ -43,6 +43,7 @@ public abstract class ExpandableView extends FrameLayout { private ArrayList<View> mMatchParentViews = new ArrayList<View>(); private int mClipTopOptimization; private static Rect mClipRect = new Rect(); + private boolean mWillBeGone; public ExpandableView(Context context, AttributeSet attrs) { super(context, attrs); @@ -339,6 +340,12 @@ public abstract class ExpandableView extends FrameLayout { outRect.top += getTranslationY() + getClipTopAmount(); } + @Override + public void getBoundsOnScreen(Rect outRect, boolean clipToParent) { + super.getBoundsOnScreen(outRect, clipToParent); + outRect.bottom = (int) (outRect.top + getActualHeight()); + } + public int getContentHeight() { return mActualHeight - getBottomDecorHeight(); } @@ -374,6 +381,14 @@ public abstract class ExpandableView extends FrameLayout { updateClipping(); } + public boolean willBeGone() { + return mWillBeGone; + } + + public void setWillBeGone(boolean willBeGone) { + mWillBeGone = willBeGone; + } + /** * A listener notifying when {@link #getActualHeight} changes. */ diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationOverflowContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationOverflowContainer.java index 5fa7070..9653b67 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationOverflowContainer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationOverflowContainer.java @@ -18,6 +18,7 @@ package com.android.systemui.statusbar; import android.content.Context; import android.util.AttributeSet; +import android.view.View; import android.widget.TextView; import com.android.systemui.R; @@ -32,6 +33,7 @@ public class NotificationOverflowContainer extends ActivatableNotificationView { private NotificationOverflowIconsView mIconsView; private ViewInvertHelper mViewInvertHelper; private boolean mDark; + private View mContent; public NotificationOverflowContainer(Context context, AttributeSet attrs) { super(context, attrs); @@ -43,7 +45,8 @@ public class NotificationOverflowContainer extends ActivatableNotificationView { mIconsView = (NotificationOverflowIconsView) findViewById(R.id.overflow_icons_view); mIconsView.setMoreText((TextView) findViewById(R.id.more_text)); mIconsView.setOverflowIndicator(findViewById(R.id.more_icon_overflow)); - mViewInvertHelper = new ViewInvertHelper(findViewById(R.id.content), + mContent = findViewById(R.id.content); + mViewInvertHelper = new ViewInvertHelper(mContent, NotificationPanelView.DOZE_ANIMATION_DURATION); } @@ -59,6 +62,11 @@ public class NotificationOverflowContainer extends ActivatableNotificationView { } } + @Override + protected View getContentView() { + return mContent; + } + public NotificationOverflowIconsView getIconsView() { return mIconsView; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StackScrollerDecorView.java b/packages/SystemUI/src/com/android/systemui/statusbar/StackScrollerDecorView.java index 64d80cc..2f66c41 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/StackScrollerDecorView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/StackScrollerDecorView.java @@ -32,7 +32,6 @@ public abstract class StackScrollerDecorView extends ExpandableView { protected View mContent; private boolean mIsVisible; private boolean mAnimating; - private boolean mWillBeGone; public StackScrollerDecorView(Context context, AttributeSet attrs) { super(context, attrs); @@ -134,13 +133,5 @@ public abstract class StackScrollerDecorView extends ExpandableView { mContent.animate().cancel(); } - public boolean willBeGone() { - return mWillBeGone; - } - - public void setWillBeGone(boolean willBeGone) { - mWillBeGone = willBeGone; - } - protected abstract View findContentView(); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java index 13b3898..b93fc76 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java @@ -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 diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java index f11d83c..e70d146 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java @@ -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; - - center.getLocationInWindow(mTmpInt2); - mTmpInt2[0] += center.getWidth() / 2; - mTmpInt2[1] += center.getHeight() / 2; - - mQsPanel.showDetailAdapter(true, - userSwitcherController.userDetailAdapter, - mTmpInt2); - } - } + } 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; + + 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 diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java index 636c511..f40f501 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java @@ -47,7 +47,6 @@ import android.widget.ImageView; import android.widget.LinearLayout; import com.android.systemui.R; -import com.android.systemui.statusbar.DelegateViewHelper; import com.android.systemui.statusbar.policy.DeadZone; import com.android.systemui.statusbar.policy.KeyButtonView; @@ -79,7 +78,6 @@ public class NavigationBarView extends LinearLayout { private Drawable mRecentLandIcon; private NavigationBarViewTaskSwitchHelper mTaskSwitchHelper; - private DelegateViewHelper mDelegateHelper; private DeadZone mDeadZone; private final NavigationBarTransitions mBarTransitions; @@ -92,7 +90,6 @@ public class NavigationBarView extends LinearLayout { private OnVerticalChangedListener mOnVerticalChangedListener; private boolean mIsLayoutRtl; - private boolean mDelegateIntercepted; private class NavTransitionListener implements TransitionListener { private boolean mBackTransitioning; @@ -180,7 +177,6 @@ public class NavigationBarView extends LinearLayout { mBarSize = res.getDimensionPixelSize(R.dimen.navigation_bar_size); mVertical = false; mShowMenu = false; - mDelegateHelper = new DelegateViewHelper(this); mTaskSwitchHelper = new NavigationBarViewTaskSwitchHelper(context); getIcons(res); @@ -192,13 +188,8 @@ public class NavigationBarView extends LinearLayout { return mBarTransitions; } - public void setDelegateView(View view) { - mDelegateHelper.setDelegateView(view); - } - public void setBar(PhoneStatusBar phoneStatusBar) { mTaskSwitchHelper.setBar(phoneStatusBar); - mDelegateHelper.setBar(phoneStatusBar); } public void setOnVerticalChangedListener(OnVerticalChangedListener onVerticalChangedListener) { @@ -208,44 +199,21 @@ public class NavigationBarView extends LinearLayout { @Override public boolean onTouchEvent(MotionEvent event) { - initDownStates(event); - if (!mDelegateIntercepted && mTaskSwitchHelper.onTouchEvent(event)) { + if (mTaskSwitchHelper.onTouchEvent(event)) { return true; } if (mDeadZone != null && event.getAction() == MotionEvent.ACTION_OUTSIDE) { mDeadZone.poke(event); } - if (mDelegateHelper != null && mDelegateIntercepted) { - boolean ret = mDelegateHelper.onInterceptTouchEvent(event); - if (ret) return true; - } return super.onTouchEvent(event); } - private void initDownStates(MotionEvent ev) { - if (ev.getAction() == MotionEvent.ACTION_DOWN) { - mDelegateIntercepted = false; - } - } - @Override public boolean onInterceptTouchEvent(MotionEvent event) { - initDownStates(event); - boolean intercept = mTaskSwitchHelper.onInterceptTouchEvent(event); - if (!intercept) { - mDelegateIntercepted = mDelegateHelper.onInterceptTouchEvent(event); - intercept = mDelegateIntercepted; - } else { - MotionEvent cancelEvent = MotionEvent.obtain(event); - cancelEvent.setAction(MotionEvent.ACTION_CANCEL); - mDelegateHelper.onInterceptTouchEvent(cancelEvent); - cancelEvent.recycle(); - } - return intercept; + return mTaskSwitchHelper.onInterceptTouchEvent(event); } public void abortCurrentGesture() { - mDelegateHelper.abortCurrentGesture(); getHomeButton().abortCurrentGesture(); } @@ -461,10 +429,6 @@ public class NavigationBarView extends LinearLayout { Log.d(TAG, "reorient(): rot=" + mDisplay.getRotation()); } - // swap to x coordinate if orientation is not in vertical - if (mDelegateHelper != null) { - mDelegateHelper.setSwapXY(mVertical); - } updateTaskSwitchHelper(); setNavigationIconHints(mNavigationIconHints, true); @@ -476,12 +440,6 @@ public class NavigationBarView extends LinearLayout { } @Override - protected void onLayout(boolean changed, int l, int t, int r, int b) { - super.onLayout(changed, l, t, r, b); - mDelegateHelper.setInitialTouchRegion(getHomeButton(), getBackButton(), getRecentsButton()); - } - - @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { if (DEBUG) Log.d(TAG, String.format( "onSizeChanged: (%dx%d) old: (%dx%d)", w, h, oldw, oldh)); 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 9e1af82..a750572 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -487,6 +487,7 @@ public class NotificationPanelView extends PanelView implements mStatusBar.dismissPopups(); mNotificationStackScroller.setOverScrollAmount(0f, true /* onTop */, false /* animate */, true /* cancelAnimators */); + mNotificationStackScroller.resetScrollPosition(); } public void closeQs() { @@ -1716,12 +1717,16 @@ public class NotificationPanelView extends PanelView implements float alphaQsExpansion = 1 - Math.min(1, getQsExpansionFraction() * 2); mKeyguardStatusBar.setAlpha(Math.min(getKeyguardContentsAlpha(), alphaQsExpansion) * mKeyguardStatusBarAnimateAlpha); + mKeyguardStatusBar.setVisibility(mKeyguardStatusBar.getAlpha() != 0f ? VISIBLE : INVISIBLE); setQsTranslation(mQsExpansionHeight); } private void updateKeyguardBottomAreaAlpha() { - mKeyguardBottomArea.setAlpha( - Math.min(getKeyguardContentsAlpha(), 1 - getQsExpansionFraction())); + float alpha = Math.min(getKeyguardContentsAlpha(), 1 - getQsExpansionFraction()); + mKeyguardBottomArea.setAlpha(alpha); + mKeyguardBottomArea.setImportantForAccessibility(alpha == 0f + ? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS + : IMPORTANT_FOR_ACCESSIBILITY_AUTO); } private float getNotificationsTopY() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java index 54bd3e9..552a0b2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java @@ -81,10 +81,13 @@ public class PanelBar extends FrameLayout { } public void setBouncerShowing(boolean showing) { + int important = showing ? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS + : IMPORTANT_FOR_ACCESSIBILITY_AUTO; + + setImportantForAccessibility(important); + if (mPanelHolder != null) { - mPanelHolder.setImportantForAccessibility( - showing ? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS - : IMPORTANT_FOR_ACCESSIBILITY_AUTO); + mPanelHolder.setImportantForAccessibility(important); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 569b918..33e8e59 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -232,6 +232,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, /** Allow some time inbetween the long press for back and recents. */ private static final int LOCK_TO_APP_GESTURE_TOLERENCE = 200; + /** If true, the system is in the half-boot-to-decryption-screen state. + * Prudently disable QS and notifications. */ private static final boolean ONLY_CORE_APPS; static { @@ -705,7 +707,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, R.layout.status_bar_notification_keyguard_overflow, mStackScroller, false); mKeyguardIconOverflowContainer.setOnActivatedListener(this); mKeyguardIconOverflowContainer.setOnClickListener(mOverflowClickListener); - mStackScroller.addView(mKeyguardIconOverflowContainer); + mStackScroller.setOverflowContainer(mKeyguardIconOverflowContainer); SpeedBumpView speedBump = (SpeedBumpView) LayoutInflater.from(mContext).inflate( R.layout.status_bar_notification_speed_bump, mStackScroller, false); @@ -858,6 +860,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); @@ -1858,6 +1861,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, public void setQsExpanded(boolean expanded) { mStatusBarWindowManager.setQsExpanded(expanded); + mKeyguardStatusView.setImportantForAccessibility(expanded + ? View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS + : View.IMPORTANT_FOR_ACCESSIBILITY_AUTO); } public boolean isGoingToNotificationShade() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java index 0872e06..6a6266e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java @@ -162,7 +162,8 @@ public class PhoneStatusBarPolicy { mCast.addCallback(mCastCallback); // hotspot - mService.setIcon(SLOT_HOTSPOT, R.drawable.stat_sys_hotspot, 0, null); + mService.setIcon(SLOT_HOTSPOT, R.drawable.stat_sys_hotspot, 0, + mContext.getString(R.string.accessibility_status_bar_hotspot)); mService.setIconVisibility(SLOT_HOTSPOT, mHotspot.isHotspotEnabled()); mHotspot.addCallback(mHotspotCallback); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java index 6a8f8ee..7f1fea1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java @@ -18,6 +18,7 @@ package com.android.systemui.statusbar.phone; import android.app.StatusBarManager; import android.content.Context; +import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.PorterDuff; @@ -50,6 +51,8 @@ public class StatusBarWindowView extends FrameLayout { private NotificationPanelView mNotificationPanel; private View mBrightnessMirror; + private int mRightInset = 0; + PhoneStatusBar mService; private final Paint mTransparentSrcPaint = new Paint(); @@ -63,14 +66,18 @@ public class StatusBarWindowView extends FrameLayout { @Override protected boolean fitSystemWindows(Rect insets) { if (getFitsSystemWindows()) { - boolean changed = insets.left != getPaddingLeft() + boolean paddingChanged = insets.left != getPaddingLeft() || insets.top != getPaddingTop() - || insets.right != getPaddingRight() || insets.bottom != getPaddingBottom(); - // Drop top inset, apply right and left inset and pass through bottom inset. - if (changed) { - setPadding(insets.left, 0, insets.right, 0); + // Super-special right inset handling, because scrims and backdrop need to ignore it. + if (insets.right != mRightInset) { + mRightInset = insets.right; + applyMargins(); + } + // Drop top inset, apply left inset and pass through bottom inset. + if (paddingChanged) { + setPadding(insets.left, 0, 0, 0); } insets.left = 0; insets.top = 0; @@ -88,6 +95,30 @@ public class StatusBarWindowView extends FrameLayout { return false; } + private void applyMargins() { + final int N = getChildCount(); + for (int i = 0; i < N; i++) { + View child = getChildAt(i); + if (child.getLayoutParams() instanceof LayoutParams) { + LayoutParams lp = (LayoutParams) child.getLayoutParams(); + if (!lp.ignoreRightInset && lp.rightMargin != mRightInset) { + lp.rightMargin = mRightInset; + child.requestLayout(); + } + } + } + } + + @Override + public FrameLayout.LayoutParams generateLayoutParams(AttributeSet attrs) { + return new LayoutParams(getContext(), attrs); + } + + @Override + protected FrameLayout.LayoutParams generateDefaultLayoutParams() { + return new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); + } + @Override protected void onAttachedToWindow () { super.onAttachedToWindow(); @@ -244,5 +275,23 @@ public class StatusBarWindowView extends FrameLayout { mStackScrollLayout.cancelExpandHelper(); } } + + public class LayoutParams extends FrameLayout.LayoutParams { + + public boolean ignoreRightInset; + + public LayoutParams(int width, int height) { + super(width, height); + } + + public LayoutParams(Context c, AttributeSet attrs) { + super(c, attrs); + + TypedArray a = c.obtainStyledAttributes(attrs, R.styleable.StatusBarWindowView_Layout); + ignoreRightInset = a.getBoolean( + R.styleable.StatusBarWindowView_Layout_ignoreRightInset, false); + a.recycle(); + } + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java index 6e30803..98bbe7c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java @@ -552,6 +552,7 @@ public class HeadsUpManager implements ViewTreeObserver.OnComputeInternalInsetsL } public void updateEntry() { + mSortedEntries.remove(HeadsUpEntry.this); long currentTime = mClock.currentTimeMillis(); earliestRemovaltime = currentTime + mMinimumDisplayTime; postTime = Math.max(postTime, currentTime); @@ -561,13 +562,13 @@ public class HeadsUpManager implements ViewTreeObserver.OnComputeInternalInsetsL long removeDelay = Math.max(finishTime - currentTime, mMinimumDisplayTime); mHandler.postDelayed(mRemoveHeadsUpRunnable, removeDelay); } - updateSortOrder(HeadsUpEntry.this); + mSortedEntries.add(HeadsUpEntry.this); } @Override public int compareTo(HeadsUpEntry o) { return postTime < o.postTime ? 1 - : postTime == o.postTime ? 0 + : postTime == o.postTime ? entry.key.compareTo(o.entry.key) : -1; } @@ -592,16 +593,6 @@ public class HeadsUpManager implements ViewTreeObserver.OnComputeInternalInsetsL } } - /** - * Update the sorted heads up order. - * - * @param headsUpEntry the headsUp that changed - */ - private void updateSortOrder(HeadsUpEntry headsUpEntry) { - mSortedEntries.remove(headsUpEntry); - mSortedEntries.add(headsUpEntry); - } - public static class Clock { public long currentTimeMillis() { return SystemClock.elapsedRealtime(); 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 1460e5f..5cf6156 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java @@ -30,7 +30,7 @@ import android.view.ViewStub; import android.view.animation.AnimationUtils; import android.widget.FrameLayout; -import com.android.keyguard.AppearAnimationUtils; +import com.android.settingslib.animation.AppearAnimationUtils; import com.android.systemui.R; import com.android.systemui.qs.tiles.UserDetailItemView; import com.android.systemui.statusbar.phone.KeyguardStatusBarView; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityController.java index e1e022d..40984d4 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityController.java @@ -22,6 +22,8 @@ public interface SecurityController { String getDeviceOwnerName(); String getProfileOwnerName(); boolean isVpnEnabled(); + String getPrimaryVpnName(); + String getProfileVpnName(); void onUserSwitched(int newUserId); void addCallback(SecurityControllerCallback callback); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java index 4f47cc6..962000a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java @@ -36,6 +36,7 @@ import android.util.SparseArray; import com.android.internal.net.VpnConfig; import com.android.internal.net.VpnInfo; +import com.android.systemui.R; import java.io.FileDescriptor; import java.io.PrintWriter; @@ -61,7 +62,7 @@ public class SecurityControllerImpl implements SecurityController { private final ArrayList<SecurityControllerCallback> mCallbacks = new ArrayList<SecurityControllerCallback>(); - private SparseArray<Boolean> mCurrentVpnUsers = new SparseArray<>(); + private SparseArray<VpnConfig> mCurrentVpns = new SparseArray<>(); private int mCurrentUserId; public SecurityControllerImpl(Context context) { @@ -82,7 +83,16 @@ public class SecurityControllerImpl implements SecurityController { public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { pw.println("SecurityController state:"); - pw.print(" mCurrentVpnUsers=" + mCurrentVpnUsers); + pw.print(" mCurrentVpns={"); + for (int i = 0 ; i < mCurrentVpns.size(); i++) { + if (i > 0) { + pw.print(", "); + } + pw.print(mCurrentVpns.keyAt(i)); + pw.print('='); + pw.print(mCurrentVpns.valueAt(i).user); + } + pw.println("}"); } @Override @@ -97,11 +107,7 @@ public class SecurityControllerImpl implements SecurityController { @Override public boolean hasProfileOwner() { - boolean result = false; - for (UserInfo profile : mUserManager.getProfiles(mCurrentUserId)) { - result |= (mDevicePolicyManager.getProfileOwnerAsUser(profile.id) != null); - } - return result; + return mDevicePolicyManager.getProfileOwnerAsUser(mCurrentUserId) != null; } @Override @@ -116,8 +122,37 @@ public class SecurityControllerImpl implements SecurityController { } @Override + public String getPrimaryVpnName() { + VpnConfig cfg = mCurrentVpns.get(mCurrentUserId); + if (cfg != null) { + return getNameForVpnConfig(cfg, new UserHandle(mCurrentUserId)); + } else { + return null; + } + } + + @Override + public String getProfileVpnName() { + for (UserInfo profile : mUserManager.getProfiles(mCurrentUserId)) { + if (profile.id == mCurrentUserId) { + continue; + } + VpnConfig cfg = mCurrentVpns.get(profile.id); + if (cfg != null) { + return getNameForVpnConfig(cfg, profile.getUserHandle()); + } + } + return null; + } + + @Override public boolean isVpnEnabled() { - return mCurrentVpnUsers.get(mCurrentUserId) != null; + for (UserInfo profile : mUserManager.getProfiles(mCurrentUserId)) { + if (mCurrentVpns.get(profile.id) != null) { + return true; + } + } + return false; } @Override @@ -140,6 +175,22 @@ public class SecurityControllerImpl implements SecurityController { fireCallbacks(); } + private String getNameForVpnConfig(VpnConfig cfg, UserHandle user) { + if (cfg.legacy) { + return mContext.getString(R.string.legacy_vpn_name); + } + // The package name for an active VPN is stored in the 'user' field of its VpnConfig + final String vpnPackage = cfg.user; + try { + Context userContext = mContext.createPackageContextAsUser(mContext.getPackageName(), + 0 /* flags */, user); + return VpnConfig.getVpnLabel(userContext, vpnPackage).toString(); + } catch (NameNotFoundException nnfe) { + Log.e(TAG, "Package " + vpnPackage + " is not present", nnfe); + return null; + } + } + private void fireCallbacks() { for (SecurityControllerCallback callback : mCallbacks) { callback.onStateChanged(); @@ -148,21 +199,20 @@ public class SecurityControllerImpl implements SecurityController { private void updateState() { // Find all users with an active VPN - SparseArray<Boolean> vpnUsers = new SparseArray<>(); + SparseArray<VpnConfig> vpns = new SparseArray<>(); try { - for (VpnInfo vpn : mConnectivityManagerService.getAllVpnInfo()) { - UserInfo user = mUserManager.getUserInfo(UserHandle.getUserId(vpn.ownerUid)); - int groupId = (user.profileGroupId != UserInfo.NO_PROFILE_GROUP_ID ? - user.profileGroupId : user.id); - - vpnUsers.put(groupId, Boolean.TRUE); + for (UserInfo user : mUserManager.getUsers()) { + VpnConfig cfg = mConnectivityManagerService.getVpnConfig(user.id); + if (cfg != null) { + vpns.put(user.id, cfg); + } } } catch (RemoteException rme) { // Roll back to previous state Log.e(TAG, "Unable to list active VPNs", rme); return; } - mCurrentVpnUsers = vpnUsers; + mCurrentVpns = vpns; } private final NetworkCallback mNetworkCallback = new NetworkCallback() { @@ -182,5 +232,4 @@ public class SecurityControllerImpl implements SecurityController { fireCallbacks(); }; }; - } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java index d8f6bcd..1bf4547 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -43,6 +43,7 @@ import com.android.systemui.statusbar.EmptyShadeView; import com.android.systemui.statusbar.ExpandableNotificationRow; import com.android.systemui.statusbar.ExpandableView; import com.android.systemui.statusbar.NotificationData; +import com.android.systemui.statusbar.NotificationOverflowContainer; import com.android.systemui.statusbar.SpeedBumpView; import com.android.systemui.statusbar.StackScrollerDecorView; import com.android.systemui.statusbar.StatusBarState; @@ -226,6 +227,7 @@ public class NotificationStackScrollLayout extends ViewGroup private boolean mTrackingHeadsUp; private ScrimController mScrimController; private boolean mForceNoOverlappingRendering; + private NotificationOverflowContainer mOverflowContainer; public NotificationStackScrollLayout(Context context) { this(context, null); @@ -1368,17 +1370,11 @@ public class NotificationStackScrollLayout extends ViewGroup int childCount = getChildCount(); int count = 0; for (int i = 0; i < childCount; i++) { - View child = getChildAt(i); - if (child.getVisibility() != View.GONE) { + ExpandableView child = (ExpandableView) getChildAt(i); + if (child.getVisibility() != View.GONE && !child.willBeGone()) { count++; } } - if (mDismissView.willBeGone()) { - count--; - } - if (mEmptyShadeView.willBeGone()) { - count--; - } return count; } @@ -2234,6 +2230,11 @@ public class NotificationStackScrollLayout extends ViewGroup } } + public void resetScrollPosition() { + mScroller.abortAnimation(); + mOwnScrollY = 0; + } + private void setIsExpanded(boolean isExpanded) { boolean changed = isExpanded != mIsExpanded; mIsExpanded = isExpanded; @@ -2291,6 +2292,10 @@ public class NotificationStackScrollLayout extends ViewGroup public void onChildAnimationFinished() { requestChildrenUpdate(); + runAnimationFinishedRunnables(); + } + + private void runAnimationFinishedRunnables() { for (Runnable runnable : mAnimationFinishedRunnables) { runnable.run(); } @@ -2348,6 +2353,7 @@ public class NotificationStackScrollLayout extends ViewGroup if (mListener != null) { mListener.onChildLocationsChanged(this); } + runAnimationFinishedRunnables(); } public void setSpeedBumpView(SpeedBumpView speedBumpView) { @@ -2470,7 +2476,7 @@ public class NotificationStackScrollLayout extends ViewGroup mEmptyShadeView.setVisibility(newVisibility); mEmptyShadeView.setWillBeGone(false); updateContentHeight(); - notifyHeightChangeListener(mDismissView); + notifyHeightChangeListener(mEmptyShadeView); } else { Runnable onFinishedRunnable = new Runnable() { @Override @@ -2478,7 +2484,7 @@ public class NotificationStackScrollLayout extends ViewGroup mEmptyShadeView.setVisibility(GONE); mEmptyShadeView.setWillBeGone(false); updateContentHeight(); - notifyHeightChangeListener(mDismissView); + notifyHeightChangeListener(mEmptyShadeView); } }; if (mAnimationsEnabled) { @@ -2492,6 +2498,45 @@ public class NotificationStackScrollLayout extends ViewGroup } } + public void setOverflowContainer(NotificationOverflowContainer overFlowContainer) { + mOverflowContainer = overFlowContainer; + addView(mOverflowContainer); + } + + public void updateOverflowContainerVisibility(boolean visible) { + int oldVisibility = mOverflowContainer.willBeGone() ? GONE + : mOverflowContainer.getVisibility(); + final int newVisibility = visible ? VISIBLE : GONE; + if (oldVisibility != newVisibility) { + Runnable onFinishedRunnable = new Runnable() { + @Override + public void run() { + mOverflowContainer.setVisibility(newVisibility); + mOverflowContainer.setWillBeGone(false); + updateContentHeight(); + notifyHeightChangeListener(mOverflowContainer); + } + }; + if (!mAnimationsEnabled || !mIsExpanded) { + mOverflowContainer.cancelAppearDrawing(); + onFinishedRunnable.run(); + } else if (newVisibility != GONE) { + mOverflowContainer.performAddAnimation(0, + StackStateAnimator.ANIMATION_DURATION_STANDARD); + mOverflowContainer.setVisibility(newVisibility); + mOverflowContainer.setWillBeGone(false); + updateContentHeight(); + notifyHeightChangeListener(mOverflowContainer); + } else { + mOverflowContainer.performRemoveAnimation( + StackStateAnimator.ANIMATION_DURATION_STANDARD, + 0.0f, + onFinishedRunnable); + mOverflowContainer.setWillBeGone(true); + } + } + } + public void updateDismissView(boolean visible) { int oldVisibility = mDismissView.willBeGone() ? GONE : mDismissView.getVisibility(); int newVisibility = visible ? VISIBLE : GONE; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java index feae590..a70ad43 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java @@ -210,7 +210,10 @@ public class StackScrollState { int oldVisibility = view.getVisibility(); int newVisibility = becomesInvisible ? View.INVISIBLE : View.VISIBLE; if (newVisibility != oldVisibility) { - view.setVisibility(newVisibility); + if (!(view instanceof ExpandableView) || !((ExpandableView) view).willBeGone()) { + // We don't want views to change visibility when they are animating to GONE + view.setVisibility(newVisibility); + } } // apply yTranslation diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java index c31244c..c995c8e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java @@ -285,6 +285,10 @@ public class StackStateAnimator { boolean scaleChanging = child.getScaleX() != viewState.scale; float childAlpha = child.getVisibility() == View.INVISIBLE ? 0.0f : child.getAlpha(); boolean alphaChanging = viewState.alpha != childAlpha; + if (child instanceof ExpandableView) { + // We don't want views to change visibility when they are animating to GONE + alphaChanging &= !((ExpandableView) child).willBeGone(); + } // start translationY animation if (yTranslationChanging) { diff --git a/packages/SystemUI/src/com/android/systemui/tuner/QsTuner.java b/packages/SystemUI/src/com/android/systemui/tuner/QsTuner.java index 7472af9..2b76c31 100644 --- a/packages/SystemUI/src/com/android/systemui/tuner/QsTuner.java +++ b/packages/SystemUI/src/com/android/systemui/tuner/QsTuner.java @@ -315,6 +315,16 @@ public class QsTuner extends Fragment implements Callback { } @Override + public String getPrimaryVpnName() { + return null; + } + + @Override + public String getProfileVpnName() { + return null; + } + + @Override public void onUserSwitched(int newUserId) { } diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java index 29bea4d..49278c5 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java +++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java @@ -524,6 +524,7 @@ public class VolumeDialog { } } Util.setVisOrInvis(row.settingsButton, false); + updateVolumeRowHeaderVisibleH(row); row.header.setAlpha(mExpanded && isActive ? 1 : 0.5f); updateVolumeRowSliderTintH(row, isActive); } @@ -606,25 +607,22 @@ public class VolumeDialog { } // update header visible - if (row.cachedShowHeaders != mShowHeaders) { - row.cachedShowHeaders = mShowHeaders; - Util.setVisOrGone(row.header, mShowHeaders); - } + updateVolumeRowHeaderVisibleH(row); // update header text - final String text; - if (isRingZenNone) { - text = mContext.getString(R.string.volume_stream_muted_dnd, ss.name); - } else if (isRingVibrate && isRingLimited) { - text = mContext.getString(R.string.volume_stream_vibrate_dnd, ss.name); - } else if (isRingVibrate) { - text = mContext.getString(R.string.volume_stream_vibrate, ss.name); - } else if (ss.muted || mAutomute && ss.level == 0) { - text = mContext.getString(R.string.volume_stream_muted, ss.name); - } else if (isRingLimited) { - text = mContext.getString(R.string.volume_stream_limited_dnd, ss.name); - } else { - text = ss.name; + String text = ss.name; + if (mShowHeaders) { + if (isRingZenNone) { + text = mContext.getString(R.string.volume_stream_muted_dnd, ss.name); + } else if (isRingVibrate && isRingLimited) { + text = mContext.getString(R.string.volume_stream_vibrate_dnd, ss.name); + } else if (isRingVibrate) { + text = mContext.getString(R.string.volume_stream_vibrate, ss.name); + } else if (ss.muted || mAutomute && ss.level == 0) { + text = mContext.getString(R.string.volume_stream_muted, ss.name); + } else if (isRingLimited) { + text = mContext.getString(R.string.volume_stream_limited_dnd, ss.name); + } } Util.setText(row.header, text); @@ -663,6 +661,15 @@ public class VolumeDialog { updateVolumeRowSliderH(row, enableSlider, vlevel); } + private void updateVolumeRowHeaderVisibleH(VolumeRow row) { + final boolean dynamic = row.ss != null && row.ss.dynamic; + final boolean showHeaders = mShowHeaders || mExpanded && dynamic; + if (row.cachedShowHeaders != showHeaders) { + row.cachedShowHeaders = showHeaders; + Util.setVisOrGone(row.header, showHeaders); + } + } + private void updateVolumeRowSliderTintH(VolumeRow row, boolean isActive) { final ColorStateList tint = isActive && row.slider.isEnabled() ? mActiveSliderTint : mInactiveSliderTint; diff --git a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java index ced1a3c..a0eb61f 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java +++ b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java @@ -153,7 +153,7 @@ public class ZenModePanel extends LinearLayout { mZenButtons = (SegmentedButtons) findViewById(R.id.zen_buttons); mZenButtons.addButton(R.string.interruption_level_none_twoline, - R.string.interruption_level_none, + R.string.interruption_level_none_with_warning, Global.ZEN_MODE_NO_INTERRUPTIONS); mZenButtons.addButton(R.string.interruption_level_alarms_twoline, R.string.interruption_level_alarms, |
