Only show historical tasks in history.

- Also only show the history button if there are
  historical tasks (and reflect that in the 
  button text)

Change-Id: I7b9dcf79e2feef61f96b720f586144de4c5033e3
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 0557332..addcc85 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
@@ -32,8 +32,8 @@
 import android.view.animation.AnimationUtils;
 import android.view.animation.Interpolator;
 import android.widget.FrameLayout;
-
 import com.android.internal.logging.MetricsLogger;
+import android.widget.TextView;
 import com.android.systemui.R;
 import com.android.systemui.recents.Recents;
 import com.android.systemui.recents.RecentsActivity;
@@ -81,7 +81,7 @@
     private TaskStack mStack;
     private TaskStackView mTaskStackView;
     private RecentsAppWidgetHostView mSearchBar;
-    private View mHistoryButton;
+    private TextView mHistoryButton;
     private View mEmptyView;
     private boolean mAwaitingFirstLayout = true;
     private boolean mLastTaskLaunchedWasFreeform;
@@ -126,7 +126,7 @@
         mFlingAnimationUtils = new FlingAnimationUtils(context, 0.3f);
 
         LayoutInflater inflater = LayoutInflater.from(context);
-        mHistoryButton = inflater.inflate(R.layout.recents_history_button, this, false);
+        mHistoryButton = (TextView) inflater.inflate(R.layout.recents_history_button, this, false);
         mHistoryButton.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
@@ -609,6 +609,8 @@
         RecentsDebugFlags debugFlags = Recents.getDebugFlags();
         if (!debugFlags.isHistoryEnabled()) {
             hideHistoryButton(100);
+        } else {
+            showHistoryButton(100);
         }
     }
 
@@ -631,6 +633,8 @@
 
         mHistoryButton.setVisibility(View.VISIBLE);
         mHistoryButton.setAlpha(0f);
+        mHistoryButton.setText(getContext().getString(R.string.recents_history_label_format,
+                mStack.getHistoricalTasks().size()));
         postHideHistoryAnimationTrigger.addLastDecrementRunnable(new Runnable() {
             @Override
             public void run() {