Refactoring to support groups.

- Removing RecentService, determining animations just in time
- Fixing a few issues with animations of newly picked up tasks from the pool
- Moving helper classes into sub package

Change-Id: Ie10385d1f9ca79eea918b16932f56b60e2802304
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/Task.java b/packages/SystemUI/src/com/android/systemui/recents/model/Task.java
index abfb221..002395f 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/Task.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/Task.java
@@ -19,7 +19,7 @@
 import android.content.Intent;
 import android.graphics.Bitmap;
 import android.graphics.drawable.Drawable;
-import com.android.systemui.recents.Utilities;
+import com.android.systemui.recents.misc.Utilities;
 
 
 /**
@@ -39,12 +39,14 @@
         public final int id;
         public final Intent baseIntent;
         public final int userId;
+        public long firstActiveTime;
         public long lastActiveTime;
 
-        public TaskKey(int id, Intent intent, int userId, long lastActiveTime) {
+        public TaskKey(int id, Intent intent, int userId, long firstActiveTime, long lastActiveTime) {
             this.id = id;
             this.baseIntent = intent;
             this.userId = userId;
+            this.firstActiveTime = firstActiveTime;
             this.lastActiveTime = lastActiveTime;
         }
 
@@ -76,6 +78,7 @@
     }
 
     public TaskKey key;
+    public TaskGrouping group;
     public Drawable applicationIcon;
     public Drawable activityIcon;
     public String activityLabel;
@@ -92,8 +95,9 @@
     }
 
     public Task(int id, boolean isActive, Intent intent, String activityTitle,
-                Drawable activityIcon, int colorPrimary, int userId, long lastActiveTime) {
-        this.key = new TaskKey(id, intent, userId, lastActiveTime);
+                Drawable activityIcon, int colorPrimary, int userId, long firstActiveTime,
+                long lastActiveTime) {
+        this.key = new TaskKey(id, intent, userId, firstActiveTime, lastActiveTime);
         this.activityLabel = activityTitle;
         this.activityIcon = activityIcon;
         this.colorPrimary = colorPrimary;
@@ -107,6 +111,14 @@
         mCb = cb;
     }
 
+    /** Set the grouping */
+    public void setGroup(TaskGrouping group) {
+        if (group != null && this.group != null) {
+            throw new RuntimeException("This task is already assigned to a group.");
+        }
+        this.group = group;
+    }
+
     /** Notifies the callback listeners that this task has been loaded */
     public void notifyTaskDataLoaded(Bitmap thumbnail, Drawable applicationIcon) {
         this.applicationIcon = applicationIcon;
@@ -134,6 +146,11 @@
 
     @Override
     public String toString() {
-        return "Task: " + key.baseIntent.getComponent().getPackageName() + " [" + super.toString() + "]";
+        String groupAffiliation = "no group";
+        if (group != null) {
+            groupAffiliation = group.affiliation;
+        }
+        return "Task (" + groupAffiliation + "): " + key.baseIntent.getComponent().getPackageName() +
+                " [" + super.toString() + "]";
     }
 }