Initial changes to enable keyboard support with alternate Recents. (Bug 14067913)

Change-Id: Icc5d2a784ed3c3c27143eb04cbb4305549ee223a
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
index 5fad629..ffcb82b 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
@@ -18,6 +18,7 @@
 
 import android.animation.TimeInterpolator;
 import android.animation.ValueAnimator;
+import android.annotation.Nullable;
 import android.content.Context;
 import android.graphics.Canvas;
 import android.graphics.Outline;
@@ -57,6 +58,7 @@
     Task mTask;
     boolean mTaskDataLoaded;
     boolean mTaskInfoPaneVisible;
+    boolean mIsFocused;
     Point mLastTouchDown = new Point();
     Path mRoundedRectClipPath = new Path();
 
@@ -367,6 +369,34 @@
         }
     }
 
+    /**
+     * Sets the focused task explicitly. We need a separate flag because requestFocus() won't happen
+     * if the view is not currently visible, or we are in touch state (where we still want to keep
+     * track of focus).
+     */
+    public void setFocusedTask() {
+        mIsFocused = true;
+        requestFocus();
+    }
+
+    /**
+     * Updates the explicitly focused state when the view focus changes.
+     */
+    @Override
+    protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
+        super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
+        if (!gainFocus) {
+            mIsFocused = false;
+        }
+    }
+
+    /**
+     * Returns whether we have explicitly been focused.
+     */
+    public boolean isFocusedTask() {
+        return mIsFocused || isFocused();
+    }
+
     /**** TaskCallbacks Implementation ****/
 
     /** Binds this task view to the task */