コード例 #1
0
  /** Prepares the header bar layout. */
  void reloadHeaderBarLayout() {
    Resources res = mContext.getResources();
    mWindowRect = mSystemServicesProxy.getWindowRect();
    mStatusBarHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height);
    mNavBarHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_height);
    mNavBarWidth = res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_width);
    mConfig = RecentsConfiguration.reinitialize(mContext, mSystemServicesProxy);
    mConfig.updateOnConfigurationChange();
    Rect searchBarBounds = new Rect();
    // Try and pre-emptively bind the search widget on startup to ensure that we
    // have the right thumbnail bounds to animate to.
    // Note: We have to reload the widget id before we get the task stack bounds below
    if (mSystemServicesProxy.getOrBindSearchAppWidget(mContext, mAppWidgetHost) != null) {
      mConfig.getSearchBarBounds(
          mWindowRect.width(), mWindowRect.height(), mStatusBarHeight, searchBarBounds);
    }
    mConfig.getAvailableTaskStackBounds(
        mWindowRect.width(),
        mWindowRect.height(),
        mStatusBarHeight,
        (mConfig.hasTransposedNavBar ? mNavBarWidth : 0),
        searchBarBounds,
        mTaskStackBounds);
    if (mConfig.isLandscape && mConfig.hasTransposedNavBar) {
      mSystemInsets.set(0, mStatusBarHeight, mNavBarWidth, 0);
    } else {
      mSystemInsets.set(0, mStatusBarHeight, 0, mNavBarHeight);
    }

    // Inflate the header bar layout so that we can rebind and draw it for the transition
    TaskStack stack = new TaskStack();
    mDummyStackView = new TaskStackView(mContext, stack);
    TaskStackViewLayoutAlgorithm algo = mDummyStackView.getStackAlgorithm();
    Rect taskStackBounds = new Rect(mTaskStackBounds);
    taskStackBounds.bottom -= mSystemInsets.bottom;
    algo.computeRects(mWindowRect.width(), mWindowRect.height(), taskStackBounds);
    Rect taskViewSize = algo.getUntransformedTaskViewSize();
    int taskBarHeight = res.getDimensionPixelSize(R.dimen.recents_task_bar_height);
    synchronized (mHeaderBarLock) {
      mHeaderBar =
          (TaskViewHeader) mInflater.inflate(R.layout.recents_task_view_header, null, false);
      mHeaderBar.measure(
          View.MeasureSpec.makeMeasureSpec(taskViewSize.width(), View.MeasureSpec.EXACTLY),
          View.MeasureSpec.makeMeasureSpec(taskBarHeight, View.MeasureSpec.EXACTLY));
      mHeaderBar.layout(0, 0, taskViewSize.width(), taskBarHeight);
    }
  }
コード例 #2
0
 /** Draws the header of a task used for the window animation into a bitmap. */
 Bitmap drawThumbnailTransitionBitmap(Task toTask, TaskViewTransform toTransform) {
   if (toTransform != null && toTask.key != null) {
     Bitmap thumbnail;
     synchronized (mHeaderBarLock) {
       int toHeaderWidth = (int) (mHeaderBar.getMeasuredWidth() * toTransform.scale);
       int toHeaderHeight = (int) (mHeaderBar.getMeasuredHeight() * toTransform.scale);
       thumbnail = Bitmap.createBitmap(toHeaderWidth, toHeaderHeight, Bitmap.Config.ARGB_8888);
       if (Constants.DebugFlags.App.EnableTransitionThumbnailDebugMode) {
         thumbnail.eraseColor(0xFFff0000);
       } else {
         Canvas c = new Canvas(thumbnail);
         c.scale(toTransform.scale, toTransform.scale);
         mHeaderBar.rebindToTask(toTask);
         mHeaderBar.draw(c);
         c.setBitmap(null);
       }
     }
     return thumbnail.createAshmemBitmap();
   }
   return null;
 }