summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChet Haase <chet@google.com>2015-02-17 22:40:35 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-02-17 22:40:36 +0000
commitea292fe7625d92db103fdf50c1019c4a1b1912f2 (patch)
tree4634fa75a91c64eefe850751a6b91e02a148f7ed /src
parent387f4a7b36104d3e7f57d02bf386f86ff3c3472e (diff)
parenta8f996d03982d76f59b2694fe9446d2a30eae97a (diff)
downloadandroid_packages_apps_Trebuchet-ea292fe7625d92db103fdf50c1019c4a1b1912f2.tar.gz
android_packages_apps_Trebuchet-ea292fe7625d92db103fdf50c1019c4a1b1912f2.tar.bz2
android_packages_apps_Trebuchet-ea292fe7625d92db103fdf50c1019c4a1b1912f2.zip
Merge "Add clip-reveal animation to Launcher" into ub-launcher3-master
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/Launcher.java54
1 files changed, 51 insertions, 3 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 7e2ae4ede..58b085480 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -95,6 +95,7 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.Advanceable;
import android.widget.FrameLayout;
import android.widget.ImageView;
+import android.widget.TextView;
import android.widget.Toast;
import com.android.launcher3.DropTarget.DragObject;
@@ -115,6 +116,9 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Collection;
@@ -355,6 +359,18 @@ public class Launcher extends Activity
}
}
+ // TODO: remove this field and call method directly when Launcher3 can depend on M APIs
+ private static Method sClipRevealMethod = null;
+ static {
+ Class<?> activityOptionsClass = ActivityOptions.class;
+ try {
+ sClipRevealMethod = activityOptionsClass.getDeclaredMethod("makeClipRevealAnimation",
+ View.class, int.class, int.class, int.class, int.class);
+ } catch (Exception e) {
+ // Earlier version
+ }
+ }
+
private Runnable mBuildLayersRunnable = new Runnable() {
public void run() {
if (mWorkspace != null) {
@@ -2893,9 +2909,41 @@ public class Launcher extends Activity
Bundle optsBundle = null;
if (useLaunchAnimation) {
- ActivityOptions opts = Utilities.isLmpOrAbove() ?
- ActivityOptions.makeCustomAnimation(this, R.anim.task_open_enter, R.anim.no_anim) :
- ActivityOptions.makeScaleUpAnimation(v, 0, 0, v.getMeasuredWidth(), v.getMeasuredHeight());
+ ActivityOptions opts = null;
+ if (sClipRevealMethod != null) {
+ // TODO: call method directly when Launcher3 can depend on M APIs
+ int left = 0, top = 0;
+ int width = v.getMeasuredWidth(), height = v.getMeasuredHeight();
+ if (v instanceof TextView) {
+ // Launch from center of icon, not entire view
+ TextView tv = (TextView) v;
+ Drawable[] drawables = tv.getCompoundDrawables();
+ if (drawables != null && drawables[1] != null) {
+ Rect bounds = drawables[1].getBounds();
+ left = (width - bounds.width()) / 2;
+ top = tv.getPaddingTop();
+ width = bounds.width();
+ height = bounds.height();
+ }
+ }
+ try {
+ opts = (ActivityOptions) sClipRevealMethod.invoke(null, v,
+ left, top, width, height);
+ } catch (IllegalAccessException e) {
+ Log.d(TAG, "Could not call makeClipRevealAnimation: " + e);
+ sClipRevealMethod = null;
+ } catch (InvocationTargetException e) {
+ Log.d(TAG, "Could not call makeClipRevealAnimation: " + e);
+ sClipRevealMethod = null;
+ }
+ }
+ if (opts == null) {
+ opts = Utilities.isLmpOrAbove() ?
+ ActivityOptions.makeCustomAnimation(this,
+ R.anim.task_open_enter, R.anim.no_anim) :
+ ActivityOptions.makeScaleUpAnimation(v, 0, 0,
+ v.getMeasuredWidth(), v.getMeasuredHeight());
+ }
optsBundle = opts.toBundle();
}