diff options
author | Winson Chung <winsonc@google.com> | 2014-08-28 20:57:16 -0700 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2014-09-01 23:20:47 +0000 |
commit | bf8871db617d76ee66c5cf803f0bafa5e93998e9 (patch) | |
tree | eb0e6c842146dd2ebdee40c36dac5a60761542a9 /packages/SystemUI/src/com/android/systemui/recents | |
parent | dbbe73ea42c4ab196edfcd5b6ff9e2ed8ab846c7 (diff) | |
download | frameworks_base-bf8871db617d76ee66c5cf803f0bafa5e93998e9.zip frameworks_base-bf8871db617d76ee66c5cf803f0bafa5e93998e9.tar.gz frameworks_base-bf8871db617d76ee66c5cf803f0bafa5e93998e9.tar.bz2 |
Providing a more seamless transition to Home (Bug. 17012456)
- Fixing landscape N7 transition issue
Change-Id: I968d6fd4db693359d520664b1444e699d7ee30ee
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/recents')
4 files changed, 94 insertions, 21 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java b/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java index ec39d77..2d114c0 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java +++ b/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java @@ -18,6 +18,7 @@ package com.android.systemui.recents; import android.app.ActivityManager; import android.app.ActivityOptions; +import android.appwidget.AppWidgetProviderInfo; import android.content.ActivityNotFoundException; import android.content.ComponentName; import android.content.Context; @@ -52,6 +53,7 @@ import java.util.concurrent.atomic.AtomicBoolean; public class AlternateRecentsComponent implements ActivityOptions.OnAnimationStartedListener { final public static String EXTRA_FROM_HOME = "recents.triggeredOverHome"; + final public static String EXTRA_FROM_SEARCH_HOME = "recents.triggeredOverSearchHome"; final public static String EXTRA_FROM_APP_THUMBNAIL = "recents.animatingWithThumbnail"; final public static String EXTRA_FROM_APP_FULL_SCREENSHOT = "recents.thumbnail"; final public static String EXTRA_FROM_TASK_ID = "recents.activeTaskId"; @@ -62,7 +64,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta final public static String ACTION_TOGGLE_RECENTS_ACTIVITY = "action_toggle_recents_activity"; final public static String ACTION_HIDE_RECENTS_ACTIVITY = "action_hide_recents_activity"; - final static int sMinToggleDelay = 425; + final static int sMinToggleDelay = 350; final static String sToggleRecentsAction = "com.android.systemui.recents.SHOW_RECENTS"; final static String sRecentsPackage = "com.android.systemui"; @@ -224,6 +226,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta } public void onConfigurationChanged(Configuration newConfig) { + // Reload the header bar layout reloadHeaderBarLayout(); sLastScreenshot = null; } @@ -344,8 +347,13 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta /** * Creates the activity options for a home->recents transition. */ - ActivityOptions getHomeTransitionActivityOptions() { + ActivityOptions getHomeTransitionActivityOptions(boolean fromSearchHome) { mStartAnimationTriggered = false; + if (fromSearchHome) { + return ActivityOptions.makeCustomAnimation(mContext, + R.anim.recents_from_search_launcher_enter, + R.anim.recents_from_search_launcher_exit, mHandler, this); + } return ActivityOptions.makeCustomAnimation(mContext, R.anim.recents_from_launcher_enter, R.anim.recents_from_launcher_exit, mHandler, this); @@ -470,8 +478,30 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta // If there is no thumbnail transition, but is launching from home into recents, then // use a quick home transition and do the animation from home if (hasRecentTasks) { - ActivityOptions opts = getHomeTransitionActivityOptions(); - startAlternateRecentsActivity(topTask, opts, EXTRA_FROM_HOME); + // Get the home activity info + String homeActivityPackage = mSystemServicesProxy.getHomeActivityPackageName(); + // Get the search widget info + AppWidgetProviderInfo searchWidget = null; + String searchWidgetPackage = null; + if (mConfig.hasSearchBarAppWidget()) { + searchWidget = mSystemServicesProxy.getAppWidgetInfo( + mConfig.searchBarAppWidgetId); + } else { + searchWidget = mSystemServicesProxy.resolveSearchAppWidget(); + } + if (searchWidget != null && searchWidget.provider != null) { + searchWidgetPackage = searchWidget.provider.getPackageName(); + } + // Determine whether we are coming from a search owned home activity + boolean fromSearchHome = false; + if (homeActivityPackage != null && searchWidgetPackage != null && + homeActivityPackage.equals(searchWidgetPackage)) { + fromSearchHome = true; + } + + ActivityOptions opts = getHomeTransitionActivityOptions(fromSearchHome); + startAlternateRecentsActivity(topTask, opts, + fromSearchHome ? EXTRA_FROM_SEARCH_HOME : EXTRA_FROM_HOME); } else { // Otherwise we do the normal fade from an unknown source ActivityOptions opts = getUnknownTransitionActivityOptions(); diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java index 2f9715f..6cae7d4 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java @@ -107,9 +107,9 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView // Finish Recents if (mLaunchIntent != null) { if (mLaunchOpts != null) { - startActivityAsUser(mLaunchIntent, UserHandle.CURRENT); - } else { startActivityAsUser(mLaunchIntent, mLaunchOpts.toBundle(), UserHandle.CURRENT); + } else { + startActivityAsUser(mLaunchIntent, UserHandle.CURRENT); } } else { finish(); @@ -188,7 +188,9 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView } // Update the configuration based on the launch intent - mConfig.launchedFromHome = launchIntent.getBooleanExtra( + boolean fromSearchHome = launchIntent.getBooleanExtra( + AlternateRecentsComponent.EXTRA_FROM_SEARCH_HOME, false); + mConfig.launchedFromHome = fromSearchHome || launchIntent.getBooleanExtra( AlternateRecentsComponent.EXTRA_FROM_HOME, false); mConfig.launchedFromAppWithThumbnail = launchIntent.getBooleanExtra( AlternateRecentsComponent.EXTRA_FROM_APP_THUMBNAIL, false); @@ -200,6 +202,18 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView AlternateRecentsComponent.EXTRA_TRIGGERED_FROM_ALT_TAB, false); mConfig.launchedWithNoRecentTasks = !root.hasTasks(); + // Create the home intent runnable + Intent homeIntent = new Intent(Intent.ACTION_MAIN, null); + homeIntent.addCategory(Intent.CATEGORY_HOME); + homeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | + Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); + mFinishLaunchHomeRunnable = new FinishRecentsRunnable(homeIntent, + ActivityOptions.makeCustomAnimation(this, + fromSearchHome ? R.anim.recents_to_search_launcher_enter : + R.anim.recents_to_launcher_enter, + fromSearchHome ? R.anim.recents_to_search_launcher_exit : + R.anim.recents_to_launcher_exit)); + // Mark the task that is the launch target int taskStackCount = stacks.size(); if (mConfig.launchedToTaskId != -1) { @@ -346,15 +360,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView mConfig = RecentsConfiguration.reinitialize(this, RecentsTaskLoader.getInstance().getSystemServicesProxy()); - // Create the home intent runnable - Intent homeIntent = new Intent(Intent.ACTION_MAIN, null); - homeIntent.addCategory(Intent.CATEGORY_HOME); - homeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | - Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); - mFinishLaunchHomeRunnable = new FinishRecentsRunnable(homeIntent, - ActivityOptions.makeCustomAnimation(this, R.anim.recents_to_launcher_enter, - R.anim.recents_to_launcher_exit)); - // Initialize the widget host (the host id is static and does not change) mAppWidgetHost = new RecentsAppWidgetHost(this, Constants.Values.App.AppWidgetHostId); 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 b29f378..e27c0ac 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java +++ b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java @@ -32,6 +32,7 @@ import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.pm.IPackageManager; import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; @@ -363,23 +364,52 @@ public class SystemServicesProxy { return icon; } + /** Returns the package name of the home activity. */ + public String getHomeActivityPackageName() { + if (mPm == null) return null; + if (Constants.DebugFlags.App.EnableSystemServicesProxy) return null; + + ArrayList<ResolveInfo> homeActivities = new ArrayList<ResolveInfo>(); + ComponentName defaultHomeActivity = mPm.getHomeActivities(homeActivities); + if (defaultHomeActivity != null) { + return defaultHomeActivity.getPackageName(); + } else if (homeActivities.size() == 1) { + ResolveInfo info = homeActivities.get(0); + if (info.activityInfo != null) { + return info.activityInfo.packageName; + } + } + return null; + } + /** - * Resolves and binds the search app widget that is to appear in the recents. + * Resolves and returns the first Recents widget from the same package as the global + * assist activity. */ - public Pair<Integer, AppWidgetProviderInfo> bindSearchAppWidget(AppWidgetHost host) { + public AppWidgetProviderInfo resolveSearchAppWidget() { if (mAwm == null) return null; if (mAssistComponent == null) return null; // Find the first Recents widget from the same package as the global assist activity List<AppWidgetProviderInfo> widgets = mAwm.getInstalledProviders( AppWidgetProviderInfo.WIDGET_CATEGORY_RECENTS); - AppWidgetProviderInfo searchWidgetInfo = null; for (AppWidgetProviderInfo info : widgets) { if (info.provider.getPackageName().equals(mAssistComponent.getPackageName())) { - searchWidgetInfo = info; - break; + return info; } } + return null; + } + + /** + * Resolves and binds the search app widget that is to appear in the recents. + */ + public Pair<Integer, AppWidgetProviderInfo> bindSearchAppWidget(AppWidgetHost host) { + if (mAwm == null) return null; + if (mAssistComponent == null) return null; + + // Find the first Recents widget from the same package as the global assist activity + AppWidgetProviderInfo searchWidgetInfo = resolveSearchAppWidget(); // Return early if there is no search widget if (searchWidgetInfo == null) return null; diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/SystemBarScrimViews.java b/packages/SystemUI/src/com/android/systemui/recents/views/SystemBarScrimViews.java index 5b17b41..162897e 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/SystemBarScrimViews.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/SystemBarScrimViews.java @@ -97,6 +97,14 @@ public class SystemBarScrimViews { * going home). */ public void startExitRecentsAnimation() { + if (mHasStatusBarScrim && mShouldAnimateStatusBarScrim) { + mStatusBarScrimView.animate() + .translationY(-mStatusBarScrimView.getMeasuredHeight()) + .setStartDelay(0) + .setDuration(mConfig.taskBarExitAnimDuration) + .setInterpolator(mConfig.fastOutSlowInInterpolator) + .start(); + } if (mHasNavBarScrim && mShouldAnimateNavBarScrim) { mNavBarScrimView.animate() .translationY(mNavBarScrimView.getMeasuredHeight()) |