Merge "Import translations. DO NOT MERGE" into lmp-mr1-dev
diff --git a/docs/html/sdk/index.jd b/docs/html/sdk/index.jd
index 8ad0211..d712196 100644
--- a/docs/html/sdk/index.jd
+++ b/docs/html/sdk/index.jd
@@ -420,7 +420,8 @@
   <li>Rich layout editor with support for theme editing.</li>
   <li>Lint tools to catch performance, usability, version compatibility, and other problems.</li>
   <li>ProGuard and app-signing capabilities.</li>
-  <li>Built-in support for Google Cloud Platform, making it easy to integrate Google Cloud Messaging and App Engine.</li>
+  <li>Built-in support for Google Cloud Platform, making it easy to integrate Google Cloud
+  Messaging and App Engine.</li>
   </ul>
 
 <p style="margin:0">
@@ -449,7 +450,8 @@
 <ul>
 <li>Microsoft&reg;  Windows&reg;  8/7/Vista/2003 (32 or 64-bit)</li>
 <li>2 GB RAM minimum, 4 GB RAM recommended</li>
-<li>400 MB hard disk space + at least 1 GB for Android SDK, emulator system images, and caches</li>
+<li>400 MB hard disk space</li>
+<li>At least 1 GB for Android SDK, emulator system images, and caches</li>
 <li>1280 x 800  minimum screen resolution</li>
 <li>Java Development Kit (JDK) 7 </li>
 <li>Optional for accelerated emulator: Intel® processor with support for Intel® VT-x, Intel® EM64T
diff --git a/docs/html/tools/projects/index.jd b/docs/html/tools/projects/index.jd
index d9456f8..5f4f2cc 100644
--- a/docs/html/tools/projects/index.jd
+++ b/docs/html/tools/projects/index.jd
@@ -334,7 +334,7 @@
     module feature that generates each library module into its own JAR file.
     You can download the tools and platforms using the
     <em>Android SDK Manager</em>, as described in
-    <a href="{@docRoot}sdk/exploring.html">Exploring the SDK</a>.</p>
+    <a href="{@docRoot}tools/help/sdk-manager.html">SDK tools help</a>.</p>
 
     <p>If you have source code and resources that are common to multiple Android projects, you
     can move them to a library module so that it is easier to maintain across applications and
diff --git a/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java b/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java
index 4ce2c2b..910a57e 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java
@@ -86,8 +86,8 @@
     final static int sMinToggleDelay = 350;
 
     final static String sToggleRecentsAction = "com.android.systemui.recents.SHOW_RECENTS";
-    final static String sRecentsPackage = "com.android.systemui";
-    final static String sRecentsActivity = "com.android.systemui.recents.RecentsActivity";
+    public final static String sRecentsPackage = "com.android.systemui";
+    public final static String sRecentsActivity = "com.android.systemui.recents.RecentsActivity";
 
     /**
      * An implementation of ITaskStackListener, that allows us to listen for changes to the system
@@ -111,10 +111,11 @@
         public void run() {
             RecentsConfiguration config = RecentsConfiguration.getInstance();
             if (config.svelteLevel == RecentsConfiguration.SVELTE_NONE) {
-                ActivityManager.RunningTaskInfo runningTaskInfo = getTopMostTask();
+                RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
+                SystemServicesProxy ssp = loader.getSystemServicesProxy();
+                ActivityManager.RunningTaskInfo runningTaskInfo = ssp.getTopMostTask();
 
                 // Load the next task only if we aren't svelte
-                RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
                 RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext);
                 loader.preloadTasks(plan, true /* isTopTaskHome */);
                 RecentsTaskLoadPlan.Options launchOpts = new RecentsTaskLoadPlan.Options();
@@ -272,8 +273,8 @@
     }
     void hideRecents(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) {
         if (mBootCompleted) {
-            ActivityManager.RunningTaskInfo topTask = getTopMostTask();
-            if (topTask != null && isRecentsTopMost(topTask, null)) {
+            ActivityManager.RunningTaskInfo topTask = mSystemServicesProxy.getTopMostTask();
+            if (topTask != null && mSystemServicesProxy.isRecentsTopMost(topTask, null)) {
                 // Notify recents to hide itself
                 Intent intent = createLocalBroadcastIntent(mContext, ACTION_HIDE_RECENTS_ACTIVITY);
                 intent.putExtra(EXTRA_TRIGGERED_FROM_ALT_TAB, triggeredFromAltTab);
@@ -336,7 +337,7 @@
         // Return early if there are no tasks
         if (stack.getTaskCount() == 0) return;
 
-        ActivityManager.RunningTaskInfo runningTask = getTopMostTask();
+        ActivityManager.RunningTaskInfo runningTask = mSystemServicesProxy.getTopMostTask();
         // Return early if there is no running task (can't determine affiliated tasks in this case)
         if (runningTask == null) return;
         // Return early if the running task is in the home stack (optimization)
@@ -480,38 +481,6 @@
         }
     }
 
-    /** Gets the top task. */
-    ActivityManager.RunningTaskInfo getTopMostTask() {
-        SystemServicesProxy ssp = mSystemServicesProxy;
-        List<ActivityManager.RunningTaskInfo> tasks = ssp.getRunningTasks(1);
-        if (!tasks.isEmpty()) {
-            return tasks.get(0);
-        }
-        return null;
-    }
-
-    /** Returns whether the recents is currently running */
-    boolean isRecentsTopMost(ActivityManager.RunningTaskInfo topTask, AtomicBoolean isHomeTopMost) {
-        SystemServicesProxy ssp = mSystemServicesProxy;
-        if (topTask != null) {
-            ComponentName topActivity = topTask.topActivity;
-
-            // Check if the front most activity is recents
-            if (topActivity.getPackageName().equals(sRecentsPackage) &&
-                    topActivity.getClassName().equals(sRecentsActivity)) {
-                if (isHomeTopMost != null) {
-                    isHomeTopMost.set(false);
-                }
-                return true;
-            }
-
-            if (isHomeTopMost != null) {
-                isHomeTopMost.set(ssp.isInHomeStack(topTask.id));
-            }
-        }
-        return false;
-    }
-
     /** Toggles the recents activity */
     void toggleRecentsActivity() {
         // If the user has toggled it too quickly, then just eat up the event here (it's better than
@@ -523,9 +492,9 @@
 
         // If Recents is the front most activity, then we should just communicate with it directly
         // to launch the first task or dismiss itself
-        ActivityManager.RunningTaskInfo topTask = getTopMostTask();
+        ActivityManager.RunningTaskInfo topTask = mSystemServicesProxy.getTopMostTask();
         AtomicBoolean isTopTaskHome = new AtomicBoolean(true);
-        if (topTask != null && isRecentsTopMost(topTask, isTopTaskHome)) {
+        if (topTask != null && mSystemServicesProxy.isRecentsTopMost(topTask, isTopTaskHome)) {
             // Notify recents to toggle itself
             Intent intent = createLocalBroadcastIntent(mContext, ACTION_TOGGLE_RECENTS_ACTIVITY);
             mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT);
@@ -540,9 +509,9 @@
     /** Starts the recents activity if it is not already running */
     void startRecentsActivity() {
         // Check if the top task is in the home stack, and start the recents activity
-        ActivityManager.RunningTaskInfo topTask = getTopMostTask();
+        ActivityManager.RunningTaskInfo topTask = mSystemServicesProxy.getTopMostTask();
         AtomicBoolean isTopTaskHome = new AtomicBoolean(true);
-        if (topTask == null || !isRecentsTopMost(topTask, isTopTaskHome)) {
+        if (topTask == null || !mSystemServicesProxy.isRecentsTopMost(topTask, isTopTaskHome)) {
             startRecentsActivity(topTask, isTopTaskHome.get());
         }
     }
diff --git a/packages/SystemUI/src/com/android/systemui/recents/Constants.java b/packages/SystemUI/src/com/android/systemui/recents/Constants.java
index 4c76af7..0a1718d 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/Constants.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/Constants.java
@@ -65,7 +65,8 @@
         }
 
         public static class TaskStackView {
-            public static final int TaskStackOverscrollRange = 150;
+            public static final int TaskStackMinOverscrollRange = 32;
+            public static final int TaskStackMaxOverscrollRange = 128;
             public static final int FilterStartDelay = 25;
         }
     }
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
index 0f535db..cb1baeb 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
@@ -65,7 +65,6 @@
         DebugOverlayView.DebugOverlayViewCallbacks {
 
     RecentsConfiguration mConfig;
-    boolean mVisible;
     long mLastTabKeyEventTime;
 
     // Top level views
@@ -315,7 +314,8 @@
 
     /** Dismisses recents if we are already visible and the intent is to toggle the recents view */
     boolean dismissRecentsToFocusedTaskOrHome(boolean checkFilteredStackState) {
-        if (mVisible) {
+        SystemServicesProxy ssp = RecentsTaskLoader.getInstance().getSystemServicesProxy();
+        if (ssp.isRecentsTopMost(ssp.getTopMostTask(), null)) {
             // If we currently have filtered stacks, then unfilter those first
             if (checkFilteredStackState &&
                 mRecentsView.unfilterFilteredStacks()) return true;
@@ -349,7 +349,8 @@
 
     /** Dismisses Recents directly to Home if we currently aren't transitioning. */
     boolean dismissRecentsToHome(boolean animated) {
-        if (mVisible) {
+        SystemServicesProxy ssp = RecentsTaskLoader.getInstance().getSystemServicesProxy();
+        if (ssp.isRecentsTopMost(ssp.getTopMostTask(), null)) {
             // Return to Home
             dismissRecentsToHomeRaw(animated);
             return true;
@@ -429,7 +430,6 @@
     @Override
     protected void onStart() {
         super.onStart();
-        mVisible = true;
         RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
         SystemServicesProxy ssp = loader.getSystemServicesProxy();
         AlternateRecentsComponent.notifyVisibilityChanged(this, ssp, true);
@@ -457,7 +457,6 @@
     @Override
     protected void onStop() {
         super.onStop();
-        mVisible = false;
         RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
         SystemServicesProxy ssp = loader.getSystemServicesProxy();
         AlternateRecentsComponent.notifyVisibilityChanged(this, ssp, false);
diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
index 542f21c..90b099c 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
@@ -59,6 +59,7 @@
 import android.view.WindowManager;
 import android.view.accessibility.AccessibilityManager;
 import com.android.systemui.R;
+import com.android.systemui.recents.AlternateRecentsComponent;
 import com.android.systemui.recents.Constants;
 
 import java.io.IOException;
@@ -66,6 +67,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Random;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 /**
  * Acts as a shim around the real system services that we need to access data from, and provides
@@ -217,6 +219,37 @@
         return mAm.getRunningTasks(numTasks);
     }
 
+    /** Returns the top task. */
+    public ActivityManager.RunningTaskInfo getTopMostTask() {
+        List<ActivityManager.RunningTaskInfo> tasks = getRunningTasks(1);
+        if (!tasks.isEmpty()) {
+            return tasks.get(0);
+        }
+        return null;
+    }
+
+    /** Returns whether the recents is currently running */
+    public boolean isRecentsTopMost(ActivityManager.RunningTaskInfo topTask,
+            AtomicBoolean isHomeTopMost) {
+        if (topTask != null) {
+            ComponentName topActivity = topTask.topActivity;
+
+            // Check if the front most activity is recents
+            if (topActivity.getPackageName().equals(AlternateRecentsComponent.sRecentsPackage) &&
+                    topActivity.getClassName().equals(AlternateRecentsComponent.sRecentsActivity)) {
+                if (isHomeTopMost != null) {
+                    isHomeTopMost.set(false);
+                }
+                return true;
+            }
+
+            if (isHomeTopMost != null) {
+                isHomeTopMost.set(isInHomeStack(topTask.id));
+            }
+        }
+        return false;
+    }
+
     /** Returns whether the specified task is in the home stack */
     public boolean isInHomeStack(int taskId) {
         if (mAm == null) return false;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java
index c59f82c..59e38f4 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java
@@ -273,20 +273,21 @@
                 break;
             }
             case MotionEvent.ACTION_UP: {
-                final VelocityTracker velocityTracker = mVelocityTracker;
-                velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
-                int velocity = (int) velocityTracker.getYVelocity(mActivePointerId);
+                mVelocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
+                int velocity = (int) mVelocityTracker.getYVelocity(mActivePointerId);
                 if (mIsScrolling && (Math.abs(velocity) > mMinimumVelocity)) {
-                    int overscrollRange = (int) (Math.min(1f,
-                            Math.abs((float) velocity / mMaximumVelocity)) *
-                            Constants.Values.TaskStackView.TaskStackOverscrollRange);
-                    // Fling scroll
-                    mScroller.mScroller.fling(0, mScroller.progressToScrollRange(mScroller.getStackScroll()),
+                    float overscrollRangePct = Math.abs((float) velocity / mMaximumVelocity);
+                    int overscrollRange = (int) (Math.min(1f, overscrollRangePct) *
+                            (Constants.Values.TaskStackView.TaskStackMaxOverscrollRange -
+                            Constants.Values.TaskStackView.TaskStackMinOverscrollRange));
+                    mScroller.mScroller.fling(0,
+                            mScroller.progressToScrollRange(mScroller.getStackScroll()),
                             0, velocity,
                             0, 0,
                             mScroller.progressToScrollRange(mSv.mLayoutAlgorithm.mMinScrollP),
                             mScroller.progressToScrollRange(mSv.mLayoutAlgorithm.mMaxScrollP),
-                            0, overscrollRange);
+                            0, Constants.Values.TaskStackView.TaskStackMinOverscrollRange +
+                                    overscrollRange);
                     // Invalidate to kick off computeScroll
                     mSv.invalidate();
                 } else if (mScroller.isScrollOutOfBounds()) {