Moving resources out of ResourceConfiguration.

- We can no longer make assumptions about the ability to
  get resources for the RecentsActivity before the activity
  is launched (the configuration of the launched activity
  can differ than the current configuration if a window
  is docked).  As such, we reduce RecentsConfiguration
  to the set of values that are context agnostic, or can
  be calculated directly given an application context.
  This ensures that we will continue to be able to compute
  the target task bounds given any context.

Change-Id: I423c90635eb294aa2d78a6f56771b98ee2b9d5e4
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
index 9685a24..92ed0f1 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
@@ -38,8 +38,9 @@
 import android.view.View;
 import android.view.WindowInsets;
 import android.view.WindowManagerGlobal;
+import android.view.animation.AnimationUtils;
+import android.view.animation.Interpolator;
 import android.widget.FrameLayout;
-
 import com.android.internal.logging.MetricsLogger;
 import com.android.systemui.R;
 import com.android.systemui.recents.Constants;
@@ -83,6 +84,9 @@
     TaskStackView mTaskStackView;
     RecentsAppWidgetHostView mSearchBar;
     RecentsViewCallbacks mCb;
+    Interpolator mFastOutSlowInInterpolator;
+
+    Rect mSystemInsets = new Rect();
 
     public RecentsView(Context context) {
         super(context);
@@ -100,6 +104,8 @@
         super(context, attrs, defStyleAttr, defStyleRes);
         mConfig = RecentsConfiguration.getInstance();
         mInflater = LayoutInflater.from(context);
+        mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context,
+                com.android.internal.R.interpolator.fast_out_slow_in);
     }
 
     /** Sets the callbacks */
@@ -109,7 +115,7 @@
 
     /** Set/get the bsp root node */
     public void setTaskStack(TaskStack stack) {
-        if (mConfig.launchedReuseTaskStackViews) {
+        if (mConfig.getLaunchState().launchedReuseTaskStackViews) {
             if (mTaskStackView != null) {
                 // If onRecentsHidden is not triggered, we need to the stack view again here
                 mTaskStackView.reset();
@@ -278,7 +284,7 @@
         // Get the search bar bounds and measure the search bar layout
         Rect searchBarSpaceBounds = new Rect();
         if (mSearchBar != null) {
-            mConfig.getSearchBarBounds(new Rect(0, 0, width, height), mConfig.systemInsets.top,
+            mConfig.getSearchBarBounds(new Rect(0, 0, width, height), mSystemInsets.top,
                     searchBarSpaceBounds);
             mSearchBar.measure(
                     MeasureSpec.makeMeasureSpec(searchBarSpaceBounds.width(), MeasureSpec.EXACTLY),
@@ -286,8 +292,8 @@
         }
 
         Rect taskStackBounds = new Rect();
-        mConfig.getAvailableTaskStackBounds(new Rect(0, 0, width, height), mConfig.systemInsets.top,
-                mConfig.systemInsets.right, searchBarSpaceBounds, taskStackBounds);
+        mConfig.getAvailableTaskStackBounds(new Rect(0, 0, width, height), mSystemInsets.top,
+                mSystemInsets.right, searchBarSpaceBounds, taskStackBounds);
         if (mTaskStackView != null && mTaskStackView.getVisibility() != GONE) {
             mTaskStackView.setTaskStackBounds(taskStackBounds);
             mTaskStackView.measure(widthMeasureSpec, heightMeasureSpec);
@@ -306,7 +312,7 @@
         Rect searchBarSpaceBounds = new Rect();
         if (mSearchBar != null) {
             mConfig.getSearchBarBounds(measuredRect,
-                    mConfig.systemInsets.top, searchBarSpaceBounds);
+                    mSystemInsets.top, searchBarSpaceBounds);
             mSearchBar.layout(searchBarSpaceBounds.left, searchBarSpaceBounds.top,
                     searchBarSpaceBounds.right, searchBarSpaceBounds.bottom);
         }
@@ -318,8 +324,7 @@
 
     @Override
     public WindowInsets onApplyWindowInsets(WindowInsets insets) {
-        // Update the configuration with the latest system insets and trigger a relayout
-        mConfig.updateSystemInsets(insets.getSystemWindowInsets());
+        mSystemInsets.set(insets.getSystemWindowInsets());
         requestLayout();
         return insets.consumeSystemWindowInsets();
     }
@@ -548,7 +553,7 @@
             // outside the display rect (to ensure we don't animate from too far away)
             sourceView = stackView;
             offsetX = transform.rect.left;
-            offsetY = mConfig.displayRect.height();
+            offsetY = getMeasuredHeight();
         } else {
             sourceView = tv.mThumbnailView;
         }
@@ -700,11 +705,13 @@
     public void onTaskStackFilterTriggered() {
         // Hide the search bar
         if (mSearchBar != null) {
+            int filterDuration = getResources().getInteger(
+                    R.integer.recents_filter_animate_current_views_duration);
             mSearchBar.animate()
                     .alpha(0f)
                     .setStartDelay(0)
-                    .setInterpolator(mConfig.fastOutSlowInInterpolator)
-                    .setDuration(mConfig.filteringCurrentViewsAnimDuration)
+                    .setInterpolator(mFastOutSlowInInterpolator)
+                    .setDuration(filterDuration)
                     .withLayer()
                     .start();
         }
@@ -714,11 +721,13 @@
     public void onTaskStackUnfilterTriggered() {
         // Show the search bar
         if (mSearchBar != null) {
+            int filterDuration = getResources().getInteger(
+                    R.integer.recents_filter_animate_new_views_duration);
             mSearchBar.animate()
                     .alpha(1f)
                     .setStartDelay(0)
-                    .setInterpolator(mConfig.fastOutSlowInInterpolator)
-                    .setDuration(mConfig.filteringNewViewsAnimDuration)
+                    .setInterpolator(mFastOutSlowInInterpolator)
+                    .setDuration(filterDuration)
                     .withLayer()
                     .start();
         }