Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 53ec42cb authored by Winson's avatar Winson
Browse files

Moving static RecentsConfiguration instance to Recents.

- Matches the other static instances

Change-Id: I25bf474ceb0b8d6cc52c22e83273ffb2fb64cc9d
parent 23afcae8
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -54,6 +54,7 @@ public class Recents extends SystemUI


    private static SystemServicesProxy sSystemServicesProxy;
    private static SystemServicesProxy sSystemServicesProxy;
    private static RecentsTaskLoader sTaskLoader;
    private static RecentsTaskLoader sTaskLoader;
    private static RecentsConfiguration sConfiguration;


    private Handler mHandler;
    private Handler mHandler;
    private RecentsImpl mImpl;
    private RecentsImpl mImpl;
@@ -129,10 +130,15 @@ public class Recents extends SystemUI
        return sSystemServicesProxy;
        return sSystemServicesProxy;
    }
    }


    public static RecentsConfiguration getConfiguration() {
        return sConfiguration;
    }

    @Override
    @Override
    public void start() {
    public void start() {
        sSystemServicesProxy = new SystemServicesProxy(mContext);
        sSystemServicesProxy = new SystemServicesProxy(mContext);
        sTaskLoader = new RecentsTaskLoader(mContext);
        sTaskLoader = new RecentsTaskLoader(mContext);
        sConfiguration = new RecentsConfiguration(mContext);
        mHandler = new Handler();
        mHandler = new Handler();
        mImpl = new RecentsImpl(mContext);
        mImpl = new RecentsImpl(mContext);


+10 −7
Original line number Original line Diff line number Diff line
@@ -80,7 +80,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView


    public final static int EVENT_BUS_PRIORITY = Recents.EVENT_BUS_PRIORITY + 1;
    public final static int EVENT_BUS_PRIORITY = Recents.EVENT_BUS_PRIORITY + 1;


    RecentsConfiguration mConfig;
    RecentsPackageMonitor mPackageMonitor;
    RecentsPackageMonitor mPackageMonitor;
    long mLastTabKeyEventTime;
    long mLastTabKeyEventTime;
    boolean mFinishedOnStartup;
    boolean mFinishedOnStartup;
@@ -174,7 +173,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
        }
        }


        // Start loading tasks according to the load plan
        // Start loading tasks according to the load plan
        RecentsActivityLaunchState launchState = mConfig.getLaunchState();
        RecentsConfiguration config = Recents.getConfiguration();
        RecentsActivityLaunchState launchState = config.getLaunchState();
        if (!plan.hasTasks()) {
        if (!plan.hasTasks()) {
            loader.preloadTasks(plan, launchState.launchedFromHome);
            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.
     * Dismisses recents if we are already visible and the intent is to toggle the recents view.
     */
     */
    boolean dismissRecentsToFocusedTaskOrHome(boolean checkFilteredStackState) {
    boolean dismissRecentsToFocusedTaskOrHome(boolean checkFilteredStackState) {
        RecentsActivityLaunchState launchState = mConfig.getLaunchState();
        RecentsConfiguration config = Recents.getConfiguration();
        RecentsActivityLaunchState launchState = config.getLaunchState();
        SystemServicesProxy ssp = Recents.getSystemServices();
        SystemServicesProxy ssp = Recents.getSystemServices();
        if (ssp.isRecentsTopMost(ssp.getTopMostTask(), null)) {
        if (ssp.isRecentsTopMost(ssp.getTopMostTask(), null)) {
            // If we currently have filtered stacks, then unfilter those first
            // 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);
        EventBus.getDefault().register(this, EVENT_BUS_PRIORITY);


        // Initialize the widget host (the host id is static and does not change)
        // Initialize the widget host (the host id is static and does not change)
        mConfig = RecentsConfiguration.getInstance();
        if (!Constants.DebugFlags.App.DisableSearchBar) {
        if (!Constants.DebugFlags.App.DisableSearchBar) {
            mAppWidgetHost = new RecentsAppWidgetHost(this, Constants.Values.App.AppWidgetHostId);
            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
        // 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 enter animation state, or if recents was relaunched by AM, without going through
        // the normal mechanisms
        // the normal mechanisms
        RecentsActivityLaunchState launchState = mConfig.getLaunchState();
        RecentsConfiguration config = Recents.getConfiguration();
        RecentsActivityLaunchState launchState = config.getLaunchState();
        boolean wasLaunchedByAm = !launchState.launchedFromHome &&
        boolean wasLaunchedByAm = !launchState.launchedFromHome &&
                !launchState.launchedFromAppWithThumbnail;
                !launchState.launchedFromAppWithThumbnail;
        if (launchState.launchedHasConfigurationChanged || wasLaunchedByAm) {
        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
        // 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
        // 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.
        // 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.launchedFromHome = false;
        launchState.launchedFromSearchHome = false;
        launchState.launchedFromSearchHome = false;
        launchState.launchedFromAppWithThumbnail = false;
        launchState.launchedFromAppWithThumbnail = false;
@@ -629,7 +631,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
            public void run() {
            public void run() {
                // If we are not launching with alt-tab and fast-toggle is enabled, then start
                // If we are not launching with alt-tab and fast-toggle is enabled, then start
                // the dozer now
                // the dozer now
                RecentsActivityLaunchState launchState = mConfig.getLaunchState();
                RecentsConfiguration config = Recents.getConfiguration();
                RecentsActivityLaunchState launchState = config.getLaunchState();
                if (Constants.DebugFlags.App.EnableFastToggleRecents &&
                if (Constants.DebugFlags.App.EnableFastToggleRecents &&
                        !launchState.launchedWithAltTab) {
                        !launchState.launchedWithAltTab) {
                    mIterateTrigger.startDozing();
                    mIterateTrigger.startDozing();
+2 −7
Original line number Original line Diff line number Diff line
@@ -28,8 +28,6 @@ package com.android.systemui.recents;
 */
 */
public class RecentsActivityLaunchState {
public class RecentsActivityLaunchState {


    public RecentsConfiguration mConfig;

    public boolean launchedWithAltTab;
    public boolean launchedWithAltTab;
    public boolean launchedWithNoRecentTasks;
    public boolean launchedWithNoRecentTasks;
    public boolean launchedFromAppWithThumbnail;
    public boolean launchedFromAppWithThumbnail;
@@ -41,10 +39,6 @@ public class RecentsActivityLaunchState {
    public int launchedNumVisibleTasks;
    public int launchedNumVisibleTasks;
    public int launchedNumVisibleThumbnails;
    public int launchedNumVisibleThumbnails;


    RecentsActivityLaunchState(RecentsConfiguration config) {
        mConfig = config;
    }

    /** Called when the configuration has changed, and we want to reset any configuration specific
    /** Called when the configuration has changed, and we want to reset any configuration specific
     * members. */
     * members. */
    public void updateOnConfigurationChange() {
    public void updateOnConfigurationChange() {
@@ -72,6 +66,7 @@ public class RecentsActivityLaunchState {
    /** Returns whether the nav bar scrim should be visible. */
    /** Returns whether the nav bar scrim should be visible. */
    public boolean hasNavBarScrim() {
    public boolean hasNavBarScrim() {
        // Only show the scrim if we have recent tasks, and if the nav bar is not transposed
        // 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;
    }
    }
}
}
+3 −17
Original line number Original line Diff line number Diff line
@@ -28,7 +28,6 @@ import com.android.systemui.recents.misc.SystemServicesProxy;
 * tied to the current activity.
 * tied to the current activity.
 */
 */
public class RecentsConfiguration {
public class RecentsConfiguration {
    static RecentsConfiguration sInstance;


    private static final int LARGE_SCREEN_MIN_DP = 600;
    private static final int LARGE_SCREEN_MIN_DP = 600;
    private static final int XLARGE_SCREEN_MIN_DP = 720;
    private static final int XLARGE_SCREEN_MIN_DP = 720;
@@ -53,7 +52,7 @@ public class RecentsConfiguration {
    public static final int SVELTE_DISABLE_LOADING = 3;
    public static final int SVELTE_DISABLE_LOADING = 3;


    // Launch states
    // 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
    // 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
    //       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 */
    /** Dev options and global settings */
    public boolean lockToAppEnabled;
    public boolean lockToAppEnabled;


    /** Private constructor */
    public RecentsConfiguration(Context context) {
    private RecentsConfiguration(Context context, SystemServicesProxy ssp) {
        // Load only resources that can not change after the first load either through developer
        // Load only resources that can not change after the first load either through developer
        // settings or via multi window
        // settings or via multi window
        SystemServicesProxy ssp = Recents.getSystemServices();
        Context appContext = context.getApplicationContext();
        Context appContext = context.getApplicationContext();
        Resources res = appContext.getResources();
        Resources res = appContext.getResources();
        useHardwareLayers = res.getBoolean(R.bool.config_recents_use_hardware_layers);
        useHardwareLayers = res.getBoolean(R.bool.config_recents_use_hardware_layers);
@@ -121,19 +120,6 @@ public class RecentsConfiguration {
        hasTransposedSearchBar = isLandscape && isLargeScreen && !isXLargeScreen;
        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.
     * Returns the activity launch state.
     * TODO: This will be refactored out of RecentsConfiguration.
     * TODO: This will be refactored out of RecentsConfiguration.
+9 −9
Original line number Original line Diff line number Diff line
@@ -135,7 +135,6 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub
    boolean mCanReuseTaskStackViews = true;
    boolean mCanReuseTaskStackViews = true;


    // Task launching
    // Task launching
    RecentsConfiguration mConfig;
    Rect mSearchBarBounds = new Rect();
    Rect mSearchBarBounds = new Rect();
    Rect mTaskStackBounds = new Rect();
    Rect mTaskStackBounds = new Rect();
    Rect mLastTaskViewBounds = new Rect();
    Rect mLastTaskViewBounds = new Rect();
@@ -174,7 +173,6 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub
        ssp.registerTaskStackListener(mTaskStackListener);
        ssp.registerTaskStackListener(mTaskStackListener);


        // Initialize the static configuration resources
        // Initialize the static configuration resources
        mConfig = RecentsConfiguration.initialize(mContext, ssp);
        mStatusBarHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height);
        mStatusBarHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height);
        mNavBarHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_height);
        mNavBarHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_height);
        mNavBarWidth = res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_width);
        mNavBarWidth = res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_width);
@@ -205,7 +203,7 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub
    public void onConfigurationChanged() {
    public void onConfigurationChanged() {
        // Don't reuse task stack views if the configuration changes
        // Don't reuse task stack views if the configuration changes
        mCanReuseTaskStackViews = false;
        mCanReuseTaskStackViews = false;
        mConfig.updateOnConfigurationChange();
        Recents.getConfiguration().updateOnConfigurationChange();
    }
    }


    /**
    /**
@@ -445,24 +443,25 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub
     *                               is not already bound (can be expensive)
     *                               is not already bound (can be expensive)
     */
     */
    private void reloadHeaderBarLayout(boolean tryAndBindSearchWidget) {
    private void reloadHeaderBarLayout(boolean tryAndBindSearchWidget) {
        RecentsConfiguration config = Recents.getConfiguration();
        SystemServicesProxy ssp = Recents.getSystemServices();
        SystemServicesProxy ssp = Recents.getSystemServices();
        Rect windowRect = ssp.getWindowRect();
        Rect windowRect = ssp.getWindowRect();


        // Update the configuration for the current state
        // 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) {
        if (!Constants.DebugFlags.App.DisableSearchBar && tryAndBindSearchWidget) {
            // Try and pre-emptively bind the search widget on startup to ensure that we
            // Try and pre-emptively bind the search widget on startup to ensure that we
            // have the right thumbnail bounds to animate to.
            // have the right thumbnail bounds to animate to.
            // Note: We have to reload the widget id before we get the task stack bounds below
            // Note: We have to reload the widget id before we get the task stack bounds below
            if (ssp.getOrBindSearchAppWidget(mContext, mAppWidgetHost) != null) {
            if (ssp.getOrBindSearchAppWidget(mContext, mAppWidgetHost) != null) {
                mConfig.getSearchBarBounds(windowRect, mStatusBarHeight, mSearchBarBounds);
                config.getSearchBarBounds(windowRect, mStatusBarHeight, mSearchBarBounds);
            }
            }
        }
        }
        Rect systemInsets = new Rect(0, mStatusBarHeight,
        Rect systemInsets = new Rect(0, mStatusBarHeight,
                (mConfig.hasTransposedNavBar ? mNavBarWidth : 0),
                (config.hasTransposedNavBar ? mNavBarWidth : 0),
                (mConfig.hasTransposedNavBar ? 0 : mNavBarHeight));
                (config.hasTransposedNavBar ? 0 : mNavBarHeight));
        mConfig.getTaskStackBounds(windowRect, systemInsets.top, systemInsets.right,
        config.getTaskStackBounds(windowRect, systemInsets.top, systemInsets.right,
                mSearchBarBounds, mTaskStackBounds);
                mSearchBarBounds, mTaskStackBounds);


        // Rebind the header bar and draw it for the transition
        // Rebind the header bar and draw it for the transition
@@ -718,7 +717,8 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub
        mStartAnimationTriggered = false;
        mStartAnimationTriggered = false;


        // Update the configuration based on the launch options
        // 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.launchedFromHome = fromSearchHome || fromHome;
        launchState.launchedFromSearchHome = fromSearchHome;
        launchState.launchedFromSearchHome = fromSearchHome;
        launchState.launchedFromAppWithThumbnail = fromThumbnail;
        launchState.launchedFromAppWithThumbnail = fromThumbnail;
Loading