/** This is called with the full size of the window since we are handling our own insets. */
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int width = MeasureSpec.getSize(widthMeasureSpec);
    int height = MeasureSpec.getSize(heightMeasureSpec);

    // Get the search bar bounds and measure the search bar layout
    if (mSearchBar != null) {
      Rect searchBarSpaceBounds = new Rect();
      mConfig.getSearchBarBounds(width, height, mConfig.systemInsets.top, searchBarSpaceBounds);
      mSearchBar.measure(
          MeasureSpec.makeMeasureSpec(searchBarSpaceBounds.width(), MeasureSpec.EXACTLY),
          MeasureSpec.makeMeasureSpec(searchBarSpaceBounds.height(), MeasureSpec.EXACTLY));
    }

    Rect taskStackBounds = new Rect();
    mConfig.getTaskStackBounds(
        width, height, mConfig.systemInsets.top, mConfig.systemInsets.right, taskStackBounds);

    // Measure each TaskStackView with the full width and height of the window since the
    // transition view is a child of that stack view
    int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
      View child = getChildAt(i);
      if (child != mSearchBar && child.getVisibility() != GONE) {
        TaskStackView tsv = (TaskStackView) child;
        // Set the insets to be the top/left inset + search bounds
        tsv.setStackInsetRect(taskStackBounds);
        tsv.measure(widthMeasureSpec, heightMeasureSpec);
      }
    }

    setMeasuredDimension(width, height);
  }
Exemple #2
0
  /** This is called with the full size of the window since we are handling our own insets. */
  @Override
  protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    Log.d(TAG, "onLayout: ");
    // Get the search bar bounds so that we lay it out
    if (mSearchBar != null) {
      Rect searchBarSpaceBounds = new Rect();
      mConfig.getSearchBarBounds(
          getMeasuredWidth(), getMeasuredHeight(), mConfig.systemInsets.top, searchBarSpaceBounds);
      mSearchBar.layout(
          searchBarSpaceBounds.left,
          searchBarSpaceBounds.top,
          searchBarSpaceBounds.right,
          searchBarSpaceBounds.bottom);
    }

    // Layout each TaskStackView with the full width and height of the window since the
    // transition view is a child of that stack view
    List<TaskStackView> stackViews = getTaskStackViews();
    int stackCount = stackViews.size();
    for (int i = 0; i < stackCount; i++) {
      TaskStackView stackView = stackViews.get(i);
      if (stackView.getVisibility() != GONE) {
        stackView.layout(
            left, top, left + stackView.getMeasuredWidth(), top + stackView.getMeasuredHeight());
      }
    }
  }
 /**
  * Returns the task stack bounds in the current orientation. These bounds do not account for the
  * system insets.
  */
 public void getTaskStackBounds(
     int windowWidth, int windowHeight, int topInset, int rightInset, Rect taskStackBounds) {
   Rect searchBarBounds = new Rect();
   getSearchBarBounds(windowWidth, windowHeight, topInset, searchBarBounds);
   if (isLandscape && hasTransposedSearchBar) {
     // In landscape, the search bar appears on the left, but we overlay it on top
     taskStackBounds.set(0, topInset, windowWidth - rightInset, windowHeight);
   } else {
     // In portrait, the search bar appears on the top (which already has the inset)
     taskStackBounds.set(0, searchBarBounds.bottom, windowWidth, windowHeight);
   }
 }
  /** 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);
    }
  }
Exemple #5
0
  /** This is called with the full size of the window since we are handling our own insets. */
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    Log.d(TAG, "onMeasure: ");
    int width = MeasureSpec.getSize(widthMeasureSpec);
    int height = MeasureSpec.getSize(heightMeasureSpec);

    // Get the search bar bounds and measure the search bar layout
    Rect searchBarSpaceBounds = new Rect();
    if (mSearchBar != null) {
      mConfig.getSearchBarBounds(width, height, mConfig.systemInsets.top, searchBarSpaceBounds);
      mSearchBar.measure(
          MeasureSpec.makeMeasureSpec(searchBarSpaceBounds.width(), MeasureSpec.EXACTLY),
          MeasureSpec.makeMeasureSpec(searchBarSpaceBounds.height(), MeasureSpec.EXACTLY));
    }

    Rect taskStackBounds = new Rect();
    mConfig.getAvailableTaskStackBounds(
        width,
        height,
        mConfig.systemInsets.top,
        mConfig.systemInsets.right,
        searchBarSpaceBounds,
        taskStackBounds);

    // Measure each TaskStackView with the full width and height of the window since the
    // transition view is a child of that stack view
    List<TaskStackView> stackViews = getTaskStackViews();
    List<Rect> stackViewsBounds = mLayoutAlgorithm.computeStackRects(stackViews, taskStackBounds);
    int stackCount = stackViews.size();
    for (int i = 0; i < stackCount; i++) {
      TaskStackView stackView = stackViews.get(i);
      if (stackView.getVisibility() != GONE) {
        // We are going to measure the TaskStackView with the whole RecentsView dimensions,
        // but the actual stack is going to be inset to the bounds calculated by the layout
        // algorithm
        stackView.setStackInsetRect(stackViewsBounds.get(i));
        stackView.measure(widthMeasureSpec, heightMeasureSpec);
      }
    }

    setMeasuredDimension(width, height);
  }
  /** This is called with the full size of the window since we are handling our own insets. */
  @Override
  protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    // Get the search bar bounds so that we lay it out
    if (mSearchBar != null) {
      Rect searchBarSpaceBounds = new Rect();
      mConfig.getSearchBarBounds(
          getMeasuredWidth(), getMeasuredHeight(), mConfig.systemInsets.top, searchBarSpaceBounds);
      mSearchBar.layout(
          searchBarSpaceBounds.left,
          searchBarSpaceBounds.top,
          searchBarSpaceBounds.right,
          searchBarSpaceBounds.bottom);
    }

    // Layout each TaskStackView with the full width and height of the window since the
    // transition view is a child of that stack view
    int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
      View child = getChildAt(i);
      if (child != mSearchBar && child.getVisibility() != GONE) {
        child.layout(left, top, left + child.getMeasuredWidth(), top + child.getMeasuredHeight());
      }
    }
  }