private boolean showSurface(float alpha) { if (!mSurfaceVisible || mSurfaceAlpha != alpha) { SurfaceControl.openTransaction(); try { mSurfaceControl.setLayer(ELECTRON_BEAM_LAYER); mSurfaceControl.setAlpha(alpha); mSurfaceControl.show(); } finally { SurfaceControl.closeTransaction(); } mSurfaceVisible = true; mSurfaceAlpha = alpha; } return true; }
public ViewportWindow(Context context) { SurfaceControl surfaceControl = null; try { mWindowManager.getDefaultDisplay().getRealSize(mTempPoint); surfaceControl = new SurfaceControl( mWindowManagerService.mFxSession, SURFACE_TITLE, mTempPoint.x, mTempPoint.y, PixelFormat.TRANSLUCENT, SurfaceControl.HIDDEN); } catch (OutOfResourcesException oore) { /* ignore */ } mSurfaceControl = surfaceControl; mSurfaceControl.setLayerStack(mWindowManager.getDefaultDisplay().getLayerStack()); mSurfaceControl.setLayer( mWindowManagerService.mPolicy.windowTypeToLayerLw( WindowManager.LayoutParams.TYPE_MAGNIFICATION_OVERLAY) * WindowManagerService.TYPE_LAYER_MULTIPLIER); mSurfaceControl.setPosition(0, 0); mSurface.copyFrom(mSurfaceControl); TypedValue typedValue = new TypedValue(); context.getTheme().resolveAttribute(R.attr.colorActivatedHighlight, typedValue, true); final int borderColor = context.getResources().getColor(typedValue.resourceId); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeWidth(mBorderWidth); mPaint.setColor(borderColor); Interpolator interpolator = new DecelerateInterpolator(2.5f); final long longAnimationDuration = context.getResources().getInteger(com.android.internal.R.integer.config_longAnimTime); mShowHideFrameAnimator = ObjectAnimator.ofInt(this, PROPERTY_NAME_ALPHA, MIN_ALPHA, MAX_ALPHA); mShowHideFrameAnimator.setInterpolator(interpolator); mShowHideFrameAnimator.setDuration(longAnimationDuration); mInvalidated = true; }