diff --git a/packages/SystemUI/src/com/android/systemui/recents/Recents.java b/packages/SystemUI/src/com/android/systemui/recents/Recents.java index 94001084b76ae..4d40cb7072f78 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/Recents.java +++ b/packages/SystemUI/src/com/android/systemui/recents/Recents.java @@ -54,6 +54,7 @@ public class Recents extends SystemUI private static SystemServicesProxy sSystemServicesProxy; private static RecentsTaskLoader sTaskLoader; + private static RecentsConfiguration sConfiguration; private Handler mHandler; private RecentsImpl mImpl; @@ -129,10 +130,15 @@ public class Recents extends SystemUI return sSystemServicesProxy; } + public static RecentsConfiguration getConfiguration() { + return sConfiguration; + } + @Override public void start() { sSystemServicesProxy = new SystemServicesProxy(mContext); sTaskLoader = new RecentsTaskLoader(mContext); + sConfiguration = new RecentsConfiguration(mContext); mHandler = new Handler(); mImpl = new RecentsImpl(mContext); diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java index 0adad855628f5..6c8bf0f96bffb 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java @@ -80,7 +80,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView public final static int EVENT_BUS_PRIORITY = Recents.EVENT_BUS_PRIORITY + 1; - RecentsConfiguration mConfig; RecentsPackageMonitor mPackageMonitor; long mLastTabKeyEventTime; boolean mFinishedOnStartup; @@ -174,7 +173,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView } // Start loading tasks according to the load plan - RecentsActivityLaunchState launchState = mConfig.getLaunchState(); + RecentsConfiguration config = Recents.getConfiguration(); + RecentsActivityLaunchState launchState = config.getLaunchState(); if (!plan.hasTasks()) { loader.preloadTasks(plan, launchState.launchedFromHome); } @@ -280,7 +280,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView * Dismisses recents if we are already visible and the intent is to toggle the recents view. */ boolean dismissRecentsToFocusedTaskOrHome(boolean checkFilteredStackState) { - RecentsActivityLaunchState launchState = mConfig.getLaunchState(); + RecentsConfiguration config = Recents.getConfiguration(); + RecentsActivityLaunchState launchState = config.getLaunchState(); SystemServicesProxy ssp = Recents.getSystemServices(); if (ssp.isRecentsTopMost(ssp.getTopMostTask(), null)) { // If we currently have filtered stacks, then unfilter those first @@ -352,7 +353,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView EventBus.getDefault().register(this, EVENT_BUS_PRIORITY); // Initialize the widget host (the host id is static and does not change) - mConfig = RecentsConfiguration.getInstance(); if (!Constants.DebugFlags.App.DisableSearchBar) { mAppWidgetHost = new RecentsAppWidgetHost(this, Constants.Values.App.AppWidgetHostId); } @@ -399,7 +399,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView // If this is a new instance from a configuration change, then we have to manually trigger // the enter animation state, or if recents was relaunched by AM, without going through // the normal mechanisms - RecentsActivityLaunchState launchState = mConfig.getLaunchState(); + RecentsConfiguration config = Recents.getConfiguration(); + RecentsActivityLaunchState launchState = config.getLaunchState(); boolean wasLaunchedByAm = !launchState.launchedFromHome && !launchState.launchedFromAppWithThumbnail; if (launchState.launchedHasConfigurationChanged || wasLaunchedByAm) { @@ -442,7 +443,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView // Workaround for b/22542869, if the RecentsActivity is started again, but without going // through SystemUI, we need to reset the config launch flags to ensure that we do not // wait on the system to send a signal that was never queued. - RecentsActivityLaunchState launchState = mConfig.getLaunchState(); + RecentsConfiguration config = Recents.getConfiguration(); + RecentsActivityLaunchState launchState = config.getLaunchState(); launchState.launchedFromHome = false; launchState.launchedFromSearchHome = false; launchState.launchedFromAppWithThumbnail = false; @@ -629,7 +631,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView public void run() { // If we are not launching with alt-tab and fast-toggle is enabled, then start // the dozer now - RecentsActivityLaunchState launchState = mConfig.getLaunchState(); + RecentsConfiguration config = Recents.getConfiguration(); + RecentsActivityLaunchState launchState = config.getLaunchState(); if (Constants.DebugFlags.App.EnableFastToggleRecents && !launchState.launchedWithAltTab) { mIterateTrigger.startDozing(); diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivityLaunchState.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivityLaunchState.java index 76b666fec1b6f..aca816e7f068e 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivityLaunchState.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivityLaunchState.java @@ -28,8 +28,6 @@ package com.android.systemui.recents; */ public class RecentsActivityLaunchState { - public RecentsConfiguration mConfig; - public boolean launchedWithAltTab; public boolean launchedWithNoRecentTasks; public boolean launchedFromAppWithThumbnail; @@ -41,10 +39,6 @@ public class RecentsActivityLaunchState { public int launchedNumVisibleTasks; public int launchedNumVisibleThumbnails; - RecentsActivityLaunchState(RecentsConfiguration config) { - mConfig = config; - } - /** Called when the configuration has changed, and we want to reset any configuration specific * members. */ public void updateOnConfigurationChange() { @@ -72,6 +66,7 @@ public class RecentsActivityLaunchState { /** Returns whether the nav bar scrim should be visible. */ public boolean hasNavBarScrim() { // Only show the scrim if we have recent tasks, and if the nav bar is not transposed - return !launchedWithNoRecentTasks && !mConfig.hasTransposedNavBar; + RecentsConfiguration config = Recents.getConfiguration(); + return !launchedWithNoRecentTasks && !config.hasTransposedNavBar; } } diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java index d8f40238eaf46..e2f20fdefbb37 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java @@ -28,7 +28,6 @@ import com.android.systemui.recents.misc.SystemServicesProxy; * tied to the current activity. */ public class RecentsConfiguration { - static RecentsConfiguration sInstance; private static final int LARGE_SCREEN_MIN_DP = 600; private static final int XLARGE_SCREEN_MIN_DP = 720; @@ -53,7 +52,7 @@ public class RecentsConfiguration { public static final int SVELTE_DISABLE_LOADING = 3; // Launch states - public RecentsActivityLaunchState mLaunchState = new RecentsActivityLaunchState(this); + public RecentsActivityLaunchState mLaunchState = new RecentsActivityLaunchState(); // TODO: Values determined by the current context, needs to be refactored into something that is // agnostic of the activity context, but still calculable from the Recents component for @@ -79,10 +78,10 @@ public class RecentsConfiguration { /** Dev options and global settings */ public boolean lockToAppEnabled; - /** Private constructor */ - private RecentsConfiguration(Context context, SystemServicesProxy ssp) { + public RecentsConfiguration(Context context) { // Load only resources that can not change after the first load either through developer // settings or via multi window + SystemServicesProxy ssp = Recents.getSystemServices(); Context appContext = context.getApplicationContext(); Resources res = appContext.getResources(); useHardwareLayers = res.getBoolean(R.bool.config_recents_use_hardware_layers); @@ -121,19 +120,6 @@ public class RecentsConfiguration { hasTransposedSearchBar = isLandscape && isLargeScreen && !isXLargeScreen; } - /** Updates the configuration to the current context */ - public static RecentsConfiguration initialize(Context context, SystemServicesProxy ssp) { - if (sInstance == null) { - sInstance = new RecentsConfiguration(context, ssp); - } - return sInstance; - } - - /** Returns the current recents configuration */ - public static RecentsConfiguration getInstance() { - return sInstance; - } - /** * Returns the activity launch state. * TODO: This will be refactored out of RecentsConfiguration. diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java index 23836ab762165..2042668c084e2 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java @@ -135,7 +135,6 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub boolean mCanReuseTaskStackViews = true; // Task launching - RecentsConfiguration mConfig; Rect mSearchBarBounds = new Rect(); Rect mTaskStackBounds = new Rect(); Rect mLastTaskViewBounds = new Rect(); @@ -174,7 +173,6 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub ssp.registerTaskStackListener(mTaskStackListener); // Initialize the static configuration resources - mConfig = RecentsConfiguration.initialize(mContext, ssp); mStatusBarHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); mNavBarHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_height); mNavBarWidth = res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_width); @@ -205,7 +203,7 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub public void onConfigurationChanged() { // Don't reuse task stack views if the configuration changes mCanReuseTaskStackViews = false; - mConfig.updateOnConfigurationChange(); + Recents.getConfiguration().updateOnConfigurationChange(); } /** @@ -445,24 +443,25 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub * is not already bound (can be expensive) */ private void reloadHeaderBarLayout(boolean tryAndBindSearchWidget) { + RecentsConfiguration config = Recents.getConfiguration(); SystemServicesProxy ssp = Recents.getSystemServices(); Rect windowRect = ssp.getWindowRect(); // Update the configuration for the current state - mConfig.update(mContext, ssp, ssp.getWindowRect()); + config.update(mContext, ssp, ssp.getWindowRect()); if (!Constants.DebugFlags.App.DisableSearchBar && tryAndBindSearchWidget) { // Try and pre-emptively bind the search widget on startup to ensure that we // have the right thumbnail bounds to animate to. // Note: We have to reload the widget id before we get the task stack bounds below if (ssp.getOrBindSearchAppWidget(mContext, mAppWidgetHost) != null) { - mConfig.getSearchBarBounds(windowRect, mStatusBarHeight, mSearchBarBounds); + config.getSearchBarBounds(windowRect, mStatusBarHeight, mSearchBarBounds); } } Rect systemInsets = new Rect(0, mStatusBarHeight, - (mConfig.hasTransposedNavBar ? mNavBarWidth : 0), - (mConfig.hasTransposedNavBar ? 0 : mNavBarHeight)); - mConfig.getTaskStackBounds(windowRect, systemInsets.top, systemInsets.right, + (config.hasTransposedNavBar ? mNavBarWidth : 0), + (config.hasTransposedNavBar ? 0 : mNavBarHeight)); + config.getTaskStackBounds(windowRect, systemInsets.top, systemInsets.right, mSearchBarBounds, mTaskStackBounds); // Rebind the header bar and draw it for the transition @@ -718,7 +717,8 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub mStartAnimationTriggered = false; // Update the configuration based on the launch options - RecentsActivityLaunchState launchState = mConfig.getLaunchState(); + RecentsConfiguration config = Recents.getConfiguration(); + RecentsActivityLaunchState launchState = config.getLaunchState(); launchState.launchedFromHome = fromSearchHome || fromHome; launchState.launchedFromSearchHome = fromSearchHome; launchState.launchedFromAppWithThumbnail = fromThumbnail; diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java index 8de8e15f94278..6fc4e20a9810b 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java +++ b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java @@ -41,6 +41,7 @@ import java.util.List; * options specified, such that we can transition into the Recents activity seamlessly */ public class RecentsTaskLoadPlan { + private static String TAG = "RecentsTaskLoadPlan"; private static boolean DEBUG = false; @@ -58,39 +59,50 @@ public class RecentsTaskLoadPlan { } Context mContext; - RecentsConfiguration mConfig; List mRawTasks; TaskStack mStack; /** Package level ctor */ - RecentsTaskLoadPlan(Context context, RecentsConfiguration config) { + RecentsTaskLoadPlan(Context context) { mContext = context; - mConfig = config; } /** - * An optimization to preload the raw list of tasks. + * An optimization to preload the raw list of tasks. The raw tasks are saved in least-recent + * to most-recent order. */ public synchronized void preloadRawTasks(boolean isTopTaskHome) { SystemServicesProxy ssp = Recents.getSystemServices(); mRawTasks = ssp.getRecentTasks(ActivityManager.getMaxRecentTasksStatic(), UserHandle.CURRENT.getIdentifier(), isTopTaskHome); + // Since the raw tasks are given in most-recent to least-recent order, we need to reverse it Collections.reverse(mRawTasks); - if (DEBUG) Log.d(TAG, "preloadRawTasks, tasks: " + mRawTasks.size()); + if (DEBUG) { + Log.d(TAG, "preloadRawTasks, tasks: " + mRawTasks.size()); + for (ActivityManager.RecentTaskInfo info : mRawTasks) { + Log.d(TAG, " " + info.baseIntent + ", " + info.lastActiveTime); + } + } } /** * Preloads the list of recent tasks from the system. After this call, the TaskStack will * have a list of all the recent tasks with their metadata, not including icons or * thumbnails which were not cached and have to be loaded. + * + * The tasks will be ordered by: + * - least-recent to most-recent stack tasks + * - least-recent to most-recent freeform tasks */ public synchronized void preloadPlan(RecentsTaskLoader loader, boolean isTopTaskHome) { if (DEBUG) Log.d(TAG, "preloadPlan"); + RecentsConfiguration config = Recents.getConfiguration(); SystemServicesProxy ssp = Recents.getSystemServices(); Resources res = mContext.getResources(); + ArrayList freeformTasks = new ArrayList<>(); ArrayList stackTasks = new ArrayList<>(); if (mRawTasks == null) { preloadRawTasks(isTopTaskHome); @@ -113,16 +125,14 @@ public class RecentsTaskLoadPlan { int activityColor = loader.getActivityPrimaryColor(t.taskDescription); Bitmap icon = t.taskDescription != null - ? t.taskDescription.getInMemoryIcon() - : null; + ? t.taskDescription.getInMemoryIcon() : null; String iconFilename = t.taskDescription != null - ? t.taskDescription.getIconFilename() - : null; + ? t.taskDescription.getIconFilename() : null; // Add the task to the stack Task task = new Task(taskKey, (t.id != INVALID_TASK_ID), t.affiliatedTaskId, t.affiliatedTaskColor, activityLabel, contentDescription, activityIcon, - activityColor, (i == (taskCount - 1)), mConfig.lockToAppEnabled, icon, + activityColor, (i == (taskCount - 1)), config.lockToAppEnabled, icon, iconFilename); task.thumbnail = loader.getAndUpdateThumbnail(taskKey, ssp, false); if (DEBUG) Log.d(TAG, "\tthumbnail: " + taskKey + ", " + task.thumbnail); @@ -145,6 +155,7 @@ public class RecentsTaskLoadPlan { ", # thumbnails: " + opts.numVisibleTaskThumbnails + ", running task id: " + opts.runningTaskId); + RecentsConfiguration config = Recents.getConfiguration(); SystemServicesProxy ssp = Recents.getSystemServices(); Resources res = mContext.getResources(); @@ -175,9 +186,9 @@ public class RecentsTaskLoadPlan { if (opts.loadThumbnails && (isRunningTask || isVisibleThumbnail)) { if (task.thumbnail == null || isRunningTask) { if (DEBUG) Log.d(TAG, "\tLoading thumbnail: " + taskKey); - if (mConfig.svelteLevel <= RecentsConfiguration.SVELTE_LIMIT_CACHE) { + if (config.svelteLevel <= RecentsConfiguration.SVELTE_LIMIT_CACHE) { task.thumbnail = loader.getAndUpdateThumbnail(taskKey, ssp, true); - } else if (mConfig.svelteLevel == RecentsConfiguration.SVELTE_DISABLE_CACHE) { + } else if (config.svelteLevel == RecentsConfiguration.SVELTE_DISABLE_CACHE) { loadQueue.addTask(task); } } diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java index ea97b712dedb8..71e39573537a8 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java +++ b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java @@ -155,7 +155,7 @@ class BackgroundTaskLoader implements Runnable { } } } else { - RecentsConfiguration config = RecentsConfiguration.getInstance(); + RecentsConfiguration config = Recents.getConfiguration(); SystemServicesProxy ssp = Recents.getSystemServices(); // If we've stopped the loader, then fall through to the above logic to wait on // the load thread @@ -320,8 +320,7 @@ public class RecentsTaskLoader { /** Creates a new plan for loading the recent tasks. */ public RecentsTaskLoadPlan createLoadPlan(Context context) { - RecentsConfiguration config = RecentsConfiguration.getInstance(); - RecentsTaskLoadPlan plan = new RecentsTaskLoadPlan(context, config); + RecentsTaskLoadPlan plan = new RecentsTaskLoadPlan(context); return plan; } @@ -383,7 +382,7 @@ public class RecentsTaskLoader { * out of memory. */ public void onTrimMemory(int level) { - RecentsConfiguration config = RecentsConfiguration.getInstance(); + RecentsConfiguration config = Recents.getConfiguration(); switch (level) { case ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN: // Stop the loader immediately when the UI is no longer visible @@ -528,7 +527,7 @@ public class RecentsTaskLoader { } if (loadIfNotCached) { - RecentsConfiguration config = RecentsConfiguration.getInstance(); + RecentsConfiguration config = Recents.getConfiguration(); if (config.svelteLevel < RecentsConfiguration.SVELTE_DISABLE_LOADING) { // Load the thumbnail from the system thumbnail = ssp.getTaskThumbnail(taskKey.id); diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/AnimateableViewBounds.java b/packages/SystemUI/src/com/android/systemui/recents/views/AnimateableViewBounds.java index fb05c01e5de97..21b6bd88bcbf8 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/AnimateableViewBounds.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/AnimateableViewBounds.java @@ -20,13 +20,12 @@ import android.graphics.Outline; import android.graphics.Rect; import android.view.View; import android.view.ViewOutlineProvider; +import com.android.systemui.recents.Recents; import com.android.systemui.recents.RecentsConfiguration; /* An outline provider that has a clip and outline that can be animated. */ public class AnimateableViewBounds extends ViewOutlineProvider { - RecentsConfiguration mConfig; - TaskView mSourceView; Rect mClipRect = new Rect(); Rect mClipBounds = new Rect(); @@ -35,7 +34,6 @@ public class AnimateableViewBounds extends ViewOutlineProvider { final float mMinAlpha = 0.25f; public AnimateableViewBounds(TaskView source, int cornerRadius) { - mConfig = RecentsConfiguration.getInstance(); mSourceView = source; mCornerRadius = cornerRadius; setClipBottom(getClipBottom()); @@ -64,7 +62,9 @@ public class AnimateableViewBounds extends ViewOutlineProvider { mClipRect.bottom = bottom; mSourceView.invalidateOutline(); updateClipBounds(); - if (!mConfig.useHardwareLayers) { + + RecentsConfiguration config = Recents.getConfiguration(); + if (!config.useHardwareLayers) { mSourceView.mThumbnailView.updateThumbnailVisibility( bottom - mSourceView.getPaddingBottom()); } diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java index d5d07131701ae..a8a8259e79e57 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java @@ -81,7 +81,6 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV public void runAfterPause(Runnable r); } - RecentsConfiguration mConfig; LayoutInflater mInflater; ArrayList mStacks; @@ -117,7 +116,6 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV public RecentsView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); setWillNotDraw(false); - mConfig = RecentsConfiguration.getInstance(); mInflater = LayoutInflater.from(context); mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, com.android.internal.R.interpolator.fast_out_slow_in); @@ -131,7 +129,8 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV /** Set/get the bsp root node */ public void setTaskStack(TaskStack stack) { - if (mConfig.getLaunchState().launchedReuseTaskStackViews) { + RecentsConfiguration config = Recents.getConfiguration(); + if (config.getLaunchState().launchedReuseTaskStackViews) { if (mTaskStackView != null) { // If onRecentsHidden is not triggered, we need to the stack view again here mTaskStackView.reset(); @@ -311,13 +310,14 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV */ @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + RecentsConfiguration config = Recents.getConfiguration(); int width = MeasureSpec.getSize(widthMeasureSpec); int height = MeasureSpec.getSize(heightMeasureSpec); // Get the search bar bounds and measure the search bar layout Rect searchBarSpaceBounds = new Rect(); if (mSearchBar != null) { - mConfig.getSearchBarBounds(new Rect(0, 0, width, height), mSystemInsets.top, + config.getSearchBarBounds(new Rect(0, 0, width, height), mSystemInsets.top, searchBarSpaceBounds); mSearchBar.measure( MeasureSpec.makeMeasureSpec(searchBarSpaceBounds.width(), MeasureSpec.EXACTLY), @@ -325,7 +325,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV } Rect taskStackBounds = new Rect(); - mConfig.getTaskStackBounds(new Rect(0, 0, width, height), mSystemInsets.top, + config.getTaskStackBounds(new Rect(0, 0, width, height), mSystemInsets.top, mSystemInsets.right, searchBarSpaceBounds, taskStackBounds); if (mTaskStackView != null && mTaskStackView.getVisibility() != GONE) { mTaskStackView.setTaskStackBounds(taskStackBounds, mSystemInsets); @@ -346,11 +346,13 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV */ @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + RecentsConfiguration config = Recents.getConfiguration(); + // Get the search bar bounds so that we lay it out Rect measuredRect = new Rect(0, 0, getMeasuredWidth(), getMeasuredHeight()); Rect searchBarSpaceBounds = new Rect(); if (mSearchBar != null) { - mConfig.getSearchBarBounds(measuredRect, + config.getSearchBarBounds(measuredRect, mSystemInsets.top, searchBarSpaceBounds); mSearchBar.layout(searchBarSpaceBounds.left, searchBarSpaceBounds.top, searchBarSpaceBounds.right, searchBarSpaceBounds.bottom); diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsViewTouchHandler.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsViewTouchHandler.java index bf045f91b6930..f3a43905a823d 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsViewTouchHandler.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsViewTouchHandler.java @@ -19,6 +19,7 @@ package com.android.systemui.recents.views; import android.content.res.Configuration; import android.graphics.Point; import android.view.MotionEvent; +import com.android.systemui.recents.Recents; import com.android.systemui.recents.RecentsConfiguration; import com.android.systemui.recents.events.EventBus; import com.android.systemui.recents.events.ui.dragndrop.DragDockStateChangedEvent; @@ -73,7 +74,7 @@ class RecentsViewTouchHandler { public TaskStack.DockState[] getDockStatesForCurrentOrientation() { boolean isLandscape = mRv.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; - RecentsConfiguration config = RecentsConfiguration.getInstance(); + RecentsConfiguration config = Recents.getConfiguration(); TaskStack.DockState[] dockStates = isLandscape ? (config.isLargeScreen ? DockRegion.TABLET_LANDSCAPE : DockRegion.PHONE_LANDSCAPE) : (config.isLargeScreen ? DockRegion.TABLET_PORTRAIT : DockRegion.PHONE_PORTRAIT); 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 5fbea00b00d5a..c4e2d8a92c425 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/SystemBarScrimViews.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/SystemBarScrimViews.java @@ -22,6 +22,7 @@ import android.view.View; import android.view.animation.AnimationUtils; import android.view.animation.Interpolator; import com.android.systemui.R; +import com.android.systemui.recents.Recents; import com.android.systemui.recents.RecentsActivityLaunchState; import com.android.systemui.recents.RecentsConfiguration; import com.android.systemui.recents.events.activity.DismissRecentsToHomeAnimationStarted; @@ -31,7 +32,6 @@ import com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationS public class SystemBarScrimViews { Context mContext; - RecentsConfiguration mConfig; View mStatusBarScrimView; View mNavBarScrimView; @@ -48,7 +48,6 @@ public class SystemBarScrimViews { public SystemBarScrimViews(Activity activity) { mContext = activity; - mConfig = RecentsConfiguration.getInstance(); mStatusBarScrimView = activity.findViewById(R.id.status_bar_scrim); mNavBarScrimView = activity.findViewById(R.id.nav_bar_scrim); mNavBarScrimEnterDuration = activity.getResources().getInteger( @@ -64,7 +63,8 @@ public class SystemBarScrimViews { * the first draw. */ public void prepareEnterRecentsAnimation() { - RecentsActivityLaunchState launchState = mConfig.getLaunchState(); + RecentsConfiguration config = Recents.getConfiguration(); + RecentsActivityLaunchState launchState = config.getLaunchState(); mHasNavBarScrim = launchState.hasNavBarScrim(); mShouldAnimateNavBarScrim = launchState.shouldAnimateNavBarScrim(); mHasStatusBarScrim = launchState.hasStatusBarScrim(); @@ -82,7 +82,8 @@ public class SystemBarScrimViews { * Starts animating the scrim views when entering Recents. */ public final void onBusEvent(EnterRecentsWindowAnimationStartedEvent event) { - RecentsActivityLaunchState launchState = mConfig.getLaunchState(); + RecentsConfiguration config = Recents.getConfiguration(); + RecentsActivityLaunchState launchState = config.getLaunchState(); int transitionEnterFromAppDelay = mContext.getResources().getInteger( R.integer.recents_enter_from_app_transition_duration); int transitionEnterFromHomeDelay = mContext.getResources().getInteger( diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java index 21ceb338677d1..dfa36d81affbd 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java @@ -23,11 +23,11 @@ import android.graphics.Canvas; import android.graphics.Rect; import android.graphics.RectF; import android.os.Bundle; -import android.os.SystemService; import android.util.Log; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; +import android.view.ViewGroup; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import android.widget.FrameLayout; @@ -77,7 +77,6 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal public void onTaskStackFilterTriggered(); public void onTaskStackUnfilterTriggered(); } - RecentsConfiguration mConfig; TaskStack mStack; TaskStackViewLayoutAlgorithm mLayoutAlgorithm; @@ -121,7 +120,6 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal super(context); // Set the stack first setStack(stack); - mConfig = RecentsConfiguration.getInstance(); mViewPool = new ViewPool<>(context, this); mInflater = LayoutInflater.from(context); mLayoutAlgorithm = new TaskStackViewLayoutAlgorithm(context); @@ -774,7 +772,8 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal setFocusedTask(mStack.indexOfTask(launchTargetTask), false /* scrollToTask */, false /* animated */, false /* requestViewFocus */); } else { - RecentsActivityLaunchState launchState = mConfig.getLaunchState(); + RecentsConfiguration config = Recents.getConfiguration(); + RecentsActivityLaunchState launchState = config.getLaunchState(); int taskOffset = launchState.launchedFromHome ? -1 : -2; setFocusedTask(mStack.getTaskCount() + taskOffset, false /* scrollToTask */, false /* animated */, false /* requestViewFocus */); @@ -834,7 +833,8 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal // animate the focused state if we are alt-tabbing now, after the window enter // animation is completed if (mFocusedTaskIndex != -1) { - RecentsActivityLaunchState launchState = mConfig.getLaunchState(); + RecentsConfiguration config = Recents.getConfiguration(); + RecentsActivityLaunchState launchState = config.getLaunchState(); setFocusedTask(mFocusedTaskIndex, false /* scrollToTask */, launchState.launchedWithAltTab); } @@ -1250,7 +1250,8 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal if (taskWasFocused || ssp.isTouchExplorationEnabled()) { // If the dismissed task was focused or if we are in touch exploration mode, then focus // the next task - RecentsActivityLaunchState launchState = mConfig.getLaunchState(); + RecentsConfiguration config = Recents.getConfiguration(); + RecentsActivityLaunchState launchState = config.getLaunchState(); setFocusedTask(taskIndex - 1, true /* scrollToTask */, launchState.launchedWithAltTab); } } diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewLayoutAlgorithm.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewLayoutAlgorithm.java index d81f3f6ea6a59..c74c65456bdb0 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewLayoutAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewLayoutAlgorithm.java @@ -175,7 +175,7 @@ public class TaskStackViewLayoutAlgorithm { * Computes the stack and task rects. */ public void computeRects(Rect taskStackBounds) { - RecentsConfiguration config = RecentsConfiguration.getInstance(); + RecentsConfiguration config = Recents.getConfiguration(); int widthPadding = (int) (config.taskStackWidthPaddingPct * taskStackBounds.width()); int heightPadding = mContext.getResources().getDimensionPixelSize( R.dimen.recents_stack_top_padding); diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java index 0a5ee79b4cb84..aaacc6cf99b55 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java @@ -66,8 +66,6 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, public void onTaskViewClipStateChanged(TaskView tv); } - RecentsConfiguration mConfig; - float mTaskProgress; ObjectAnimator mTaskProgressAnimator; float mMaxDimScale; @@ -121,8 +119,8 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, public TaskView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); + RecentsConfiguration config = Recents.getConfiguration(); Resources res = context.getResources(); - mConfig = RecentsConfiguration.getInstance(); mMaxDimScale = res.getInteger(R.integer.recents_max_task_stack_view_dim) / 255f; mClipViewInStack = true; mViewBounds = new AnimateableViewBounds(this, res.getDimensionPixelSize( @@ -135,8 +133,8 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, com.android.internal.R.interpolator.decelerate_quint); setTaskProgress(getTaskProgress()); setDim(getDim()); - if (mConfig.fakeShadows) { - setBackground(new FakeShadowDrawable(res, mConfig)); + if (config.fakeShadows) { + setBackground(new FakeShadowDrawable(res, config)); } setOutlineProvider(mViewBounds); } @@ -224,9 +222,11 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, void updateViewPropertiesToTaskTransform(TaskViewTransform toTransform, int duration, ValueAnimator.AnimatorUpdateListener updateCallback) { + RecentsConfiguration config = Recents.getConfiguration(); + // Apply the transform toTransform.applyToTaskView(this, duration, mFastOutSlowInInterpolator, false, - !mConfig.fakeShadows, updateCallback); + !config.fakeShadows, updateCallback); // Update the task progress Utilities.cancelAnimationWithoutCallbacks(mTaskProgressAnimator); @@ -277,7 +277,8 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, * first layout because the actual animation into recents may take a long time. */ void prepareEnterRecentsAnimation(boolean isTaskViewLaunchTargetTask, boolean occludesLaunchTarget, int offscreenY) { - RecentsActivityLaunchState launchState = mConfig.getLaunchState(); + RecentsConfiguration config = Recents.getConfiguration(); + RecentsActivityLaunchState launchState = config.getLaunchState(); int initialDim = getDim(); if (launchState.launchedHasConfigurationChanged) { // Just load the views as-is @@ -307,7 +308,8 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, /** Animates this task view as it enters recents */ void startEnterRecentsAnimation(final ViewAnimation.TaskViewEnterContext ctx) { - RecentsActivityLaunchState launchState = mConfig.getLaunchState(); + RecentsConfiguration config = Recents.getConfiguration(); + RecentsActivityLaunchState launchState = config.getLaunchState(); Resources res = mContext.getResources(); final TaskViewTransform transform = ctx.currentTaskTransform; final int transitionEnterFromAppDelay = res.getInteger( @@ -322,7 +324,6 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, R.integer.recents_task_enter_from_home_stagger_delay); final int taskViewAffiliateGroupEnterOffset = res.getDimensionPixelSize( R.dimen.recents_task_view_affiliate_group_enter_offset); - int startDelay = 0; if (launchState.launchedFromAppWithThumbnail) { if (mTask.isLaunchTarget) { @@ -371,7 +372,6 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, ctx.postAnimationTrigger.increment(); } } - startDelay = transitionEnterFromAppDelay; } else if (launchState.launchedFromHome) { // Animate the tasks up @@ -381,7 +381,7 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, setScaleX(transform.scale); setScaleY(transform.scale); - if (!mConfig.fakeShadows) { + if (!config.fakeShadows) { animate().translationZ(transform.translationZ); } animate() @@ -400,7 +400,6 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, }) .start(); ctx.postAnimationTrigger.increment(); - startDelay = delay; } } @@ -580,8 +579,10 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, /** Returns the current dim. */ public void setDim(int dim) { + RecentsConfiguration config = Recents.getConfiguration(); + mDimAlpha = dim; - if (mConfig.useHardwareLayers) { + if (config.useHardwareLayers) { // Defer setting hardware layers if we have not yet measured, or there is no dim to draw if (getMeasuredWidth() > 0 && getMeasuredHeight() > 0) { mDimColorFilter.setColor(Color.argb(mDimAlpha, 0, 0, 0)); @@ -703,13 +704,14 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, @Override public void onTaskDataLoaded() { + RecentsConfiguration config = Recents.getConfiguration(); if (mThumbnailView != null && mHeaderView != null) { // Bind each of the views to the new task data mThumbnailView.rebindToTask(mTask); mHeaderView.rebindToTask(mTask); // Rebind any listeners mActionButtonView.setOnClickListener(this); - setOnLongClickListener(mConfig.hasDockedTasks ? null : this); + setOnLongClickListener(config.hasDockedTasks ? null : this); } mTaskDataLoaded = true; }