summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authord34d <clark@cyngn.com>2014-08-29 08:50:39 -0700
committerd34d <clark@cyngn.com>2014-08-29 08:52:53 -0700
commit808c76b501fa561ff455f3814ec91f21dd087a51 (patch)
tree4cb2d05a6c080be869854b5f48f4059d798ea5f0 /src
parent18a8da670df5d97763f05ccf8bd1f172870f4d55 (diff)
downloadpackages_apps_ThemeChooser-808c76b501fa561ff455f3814ec91f21dd087a51.zip
packages_apps_ThemeChooser-808c76b501fa561ff455f3814ec91f21dd087a51.tar.gz
packages_apps_ThemeChooser-808c76b501fa561ff455f3814ec91f21dd087a51.tar.bz2
Animate content in if we are resuming from the launcher
Change-Id: Id631d75b8bc14530a75feda43090bba3732e52f4
Diffstat (limited to 'src')
-rw-r--r--src/com/cyngn/theme/chooser/ChooserActivity.java6
-rw-r--r--src/com/cyngn/theme/util/Utils.java39
2 files changed, 45 insertions, 0 deletions
diff --git a/src/com/cyngn/theme/chooser/ChooserActivity.java b/src/com/cyngn/theme/chooser/ChooserActivity.java
index 7ffd453..f969631 100644
--- a/src/com/cyngn/theme/chooser/ChooserActivity.java
+++ b/src/com/cyngn/theme/chooser/ChooserActivity.java
@@ -238,6 +238,12 @@ public class ChooserActivity extends FragmentActivity
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
+ if (Utils.isRecentTaskHome(this)) {
+ mContainer.setAlpha(0f);
+ mShopThemesLayout.setAlpha(0f);
+ mAnimateContentIn = true;
+ mAnimateContentInDelay = ANIMATE_CONTENT_DELAY;
+ }
handleIntent(intent);
}
diff --git a/src/com/cyngn/theme/util/Utils.java b/src/com/cyngn/theme/util/Utils.java
index 153e774..94fb5df 100644
--- a/src/com/cyngn/theme/util/Utils.java
+++ b/src/com/cyngn/theme/util/Utils.java
@@ -3,8 +3,13 @@
*/
package com.cyngn.theme.util;
+import android.app.ActivityManager;
import android.app.WallpaperManager;
+import android.content.ComponentName;
import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ActivityInfo;
+import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.database.Cursor;
@@ -23,6 +28,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.util.List;
public class Utils {
private static final String TAG = Utils.class.getSimpleName();
@@ -370,4 +376,37 @@ public class Utils {
}
return bitmap;
}
+
+ public static boolean isRecentTaskHome(Context context) {
+ final ActivityManager am =
+ (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
+
+ final List<ActivityManager.RecentTaskInfo> recentTasks = am.getRecentTasks(
+ 2, ActivityManager.RECENT_IGNORE_UNAVAILABLE);
+ if (recentTasks.size() > 1) {
+ ActivityManager.RecentTaskInfo recentInfo = recentTasks.get(1);
+
+ Intent intent = new Intent(recentInfo.baseIntent);
+ if (recentInfo.origActivity != null) {
+ intent.setComponent(recentInfo.origActivity);
+ }
+
+ // Now check if this recent task is a launcher
+ if (isCurrentHomeActivity(context, intent.getComponent())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static boolean isCurrentHomeActivity(Context context,
+ ComponentName component) {
+ final PackageManager pm = context.getPackageManager();
+ ActivityInfo homeInfo = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME)
+ .resolveActivityInfo(pm, 0);
+
+ return homeInfo != null
+ && homeInfo.packageName.equals(component.getPackageName())
+ && homeInfo.name.equals(component.getClassName());
+ }
}