summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com/android/systemui/recents/misc
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2014-09-16 00:58:25 +0200
committerJorim Jaggi <jjaggi@google.com>2014-09-18 18:34:17 +0000
commitbf5dbf1c151eb64f4068f233e72b0a867348bf8c (patch)
tree1fb99527e585c514c8841e8aaf10a948c22490fa /packages/SystemUI/src/com/android/systemui/recents/misc
parenta8433c6512cc53fb0eef58181e364b4ba330811c (diff)
downloadframeworks_base-bf5dbf1c151eb64f4068f233e72b0a867348bf8c.zip
frameworks_base-bf5dbf1c151eb64f4068f233e72b0a867348bf8c.tar.gz
frameworks_base-bf5dbf1c151eb64f4068f233e72b0a867348bf8c.tar.bz2
Enabling recents stack clipping
The taskviews now avoid overdraw by clipping invisible parts. Also adapted some timings of the animation. Bug: 17455301 Change-Id: Ifbf7bab363e530cb2ad842baed50fc16dcfcc4c4
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/recents/misc')
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/misc/Utilities.java77
1 files changed, 77 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/Utilities.java b/packages/SystemUI/src/com/android/systemui/recents/misc/Utilities.java
index 4c6b389..f01d17c 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/misc/Utilities.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/misc/Utilities.java
@@ -18,11 +18,14 @@ package com.android.systemui.recents.misc;
import android.content.Intent;
import android.graphics.Color;
+import android.graphics.Matrix;
import android.graphics.Rect;
+import android.view.View;
import com.android.systemui.recents.RecentsConfiguration;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.ArrayList;
/* Common code */
public class Utilities {
@@ -68,6 +71,80 @@ public class Utilities {
}
}
+ /** Maps a coorindate in a descendant view into the parent. */
+ public static float mapCoordInDescendentToSelf(View descendant, View root,
+ float[] coord, boolean includeRootScroll) {
+ ArrayList<View> ancestorChain = new ArrayList<View>();
+
+ float[] pt = {coord[0], coord[1]};
+
+ View v = descendant;
+ while(v != root && v != null) {
+ ancestorChain.add(v);
+ v = (View) v.getParent();
+ }
+ ancestorChain.add(root);
+
+ float scale = 1.0f;
+ int count = ancestorChain.size();
+ for (int i = 0; i < count; i++) {
+ View v0 = ancestorChain.get(i);
+ // For TextViews, scroll has a meaning which relates to the text position
+ // which is very strange... ignore the scroll.
+ if (v0 != descendant || includeRootScroll) {
+ pt[0] -= v0.getScrollX();
+ pt[1] -= v0.getScrollY();
+ }
+
+ v0.getMatrix().mapPoints(pt);
+ pt[0] += v0.getLeft();
+ pt[1] += v0.getTop();
+ scale *= v0.getScaleX();
+ }
+
+ coord[0] = pt[0];
+ coord[1] = pt[1];
+ return scale;
+ }
+
+ /** Maps a coordinate in the root to a descendent. */
+ public static float mapCoordInSelfToDescendent(View descendant, View root,
+ float[] coord, Matrix tmpInverseMatrix) {
+ ArrayList<View> ancestorChain = new ArrayList<View>();
+
+ float[] pt = {coord[0], coord[1]};
+
+ View v = descendant;
+ while(v != root) {
+ ancestorChain.add(v);
+ v = (View) v.getParent();
+ }
+ ancestorChain.add(root);
+
+ float scale = 1.0f;
+ int count = ancestorChain.size();
+ tmpInverseMatrix.set(Matrix.IDENTITY_MATRIX);
+ for (int i = count - 1; i >= 0; i--) {
+ View ancestor = ancestorChain.get(i);
+ View next = i > 0 ? ancestorChain.get(i-1) : null;
+
+ pt[0] += ancestor.getScrollX();
+ pt[1] += ancestor.getScrollY();
+
+ if (next != null) {
+ pt[0] -= next.getLeft();
+ pt[1] -= next.getTop();
+ next.getMatrix().invert(tmpInverseMatrix);
+ tmpInverseMatrix.mapPoints(pt);
+ scale *= next.getScaleX();
+ }
+ }
+
+ coord[0] = pt[0];
+ coord[1] = pt[1];
+ return scale;
+ }
+
/** Calculates the constrast between two colors, using the algorithm provided by the WCAG v2. */
public static float computeContrastBetweenColors(int bg, int fg) {
float bgR = Color.red(bg) / 255f;