summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authord34d <clark@cyngn.com>2015-04-23 11:23:15 -0700
committerClark Scheff <clark@cyngn.com>2015-04-27 16:46:58 +0000
commitd2d923c8ba9856e9540a7d32e3fdd9d2a0dd4fa4 (patch)
tree7f273afd7d0b338ab362693b58456d12c034f802 /src
parent2082fea1fbad21dc9d6e07c98151640bfbc169c2 (diff)
downloadpackages_apps_ThemeChooser-d2d923c8ba9856e9540a7d32e3fdd9d2a0dd4fa4.zip
packages_apps_ThemeChooser-d2d923c8ba9856e9540a7d32e3fdd9d2a0dd4fa4.tar.gz
packages_apps_ThemeChooser-d2d923c8ba9856e9540a7d32e3fdd9d2a0dd4fa4.tar.bz2
AppThemer: Animate FAB in when App Themer clicked
When the user presses the app themer icon, the FAB would immediately show up on the screen. This patch animates it in rather than abruptly show it. Change-Id: I89bb198b36a1d6d66fc0cb0fb9b675f1f95e6463
Diffstat (limited to 'src')
-rw-r--r--src/com/cyngn/theme/perapptheming/PerAppThemingWindow.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/com/cyngn/theme/perapptheming/PerAppThemingWindow.java b/src/com/cyngn/theme/perapptheming/PerAppThemingWindow.java
index 1b2000a..f550e62 100644
--- a/src/com/cyngn/theme/perapptheming/PerAppThemingWindow.java
+++ b/src/com/cyngn/theme/perapptheming/PerAppThemingWindow.java
@@ -28,6 +28,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
+import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;
@@ -158,6 +159,7 @@ public class PerAppThemingWindow extends Service implements OnTouchListener,
mDraggableIcon.setOnTouchListener(this);
View.inflate(getContext(), R.layout.per_app_fab_floating_window_icon, mDraggableIcon);
mDraggableIconImage = mDraggableIcon.findViewById(R.id.box);
+ mDraggableIconImage.getViewTreeObserver().addOnWindowAttachListener(mWindowAttachListener);
mParams = addView(mDraggableIcon, 0, 0);
updateIconPosition(MARGIN_HORIZONTAL, STARTING_POINT_Y);
@@ -597,6 +599,28 @@ public class PerAppThemingWindow extends Service implements OnTouchListener,
}
};
+ private ViewTreeObserver.OnWindowAttachListener mWindowAttachListener =
+ new ViewTreeObserver.OnWindowAttachListener() {
+ @Override
+ public void onWindowAttached() {
+ // Remove the this OnWindowAttachListener now that we are done with it.
+ mDraggableIconImage.getViewTreeObserver().removeOnWindowAttachListener(this);
+
+ final float fabWidth = getResources().getDimension(R.dimen.floating_window_icon);
+ mDraggableIconImage.setAlpha(0);
+ mDraggableIconImage.setX(-fabWidth);
+ mDraggableIconImage.animate()
+ .alpha(1f)
+ .xBy(fabWidth)
+ .setDuration(ANIMATION_DURATION)
+ .start();
+ }
+
+ @Override
+ public void onWindowDetached() {
+ }
+ };
+
private void showThemeList(final int listSide) {
if (mListLayoutParams == null) {
mListLayoutParams = new WindowManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,