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

Commit 43c0f58b authored by Rajeev Kumar's avatar Rajeev Kumar
Browse files

Few cleanups in Launcher.java:

1. Fix static member accessed via instance reference
2. Get rid of explicit type arguments
3. Make few instance variables final
4. Get rid of redundant 'public' modifier for interface methods
5. Get rid of an unnecessary return statement

Change-Id: I3beec5ca14e61ed5cdd26b38c1273679c801acc2
parent 48f1135a
Loading
Loading
Loading
Loading
+29 −32
Original line number Original line Diff line number Diff line
@@ -216,9 +216,9 @@ public class Launcher extends BaseActivity
    private static final int ACTIVITY_START_DELAY = 1000;
    private static final int ACTIVITY_START_DELAY = 1000;


    // How long to wait before the new-shortcut animation automatically pans the workspace
    // How long to wait before the new-shortcut animation automatically pans the workspace
    private static int NEW_APPS_PAGE_MOVE_DELAY = 500;
    private static final int NEW_APPS_PAGE_MOVE_DELAY = 500;
    private static int NEW_APPS_ANIMATION_INACTIVE_TIMEOUT_SECONDS = 5;
    private static final int NEW_APPS_ANIMATION_INACTIVE_TIMEOUT_SECONDS = 5;
    @Thunk static int NEW_APPS_ANIMATION_DELAY = 500;
    @Thunk static final int NEW_APPS_ANIMATION_DELAY = 500;


    private final ExtractedColors mExtractedColors = new ExtractedColors();
    private final ExtractedColors mExtractedColors = new ExtractedColors();


@@ -232,7 +232,7 @@ public class Launcher extends BaseActivity
    private AppWidgetManagerCompat mAppWidgetManager;
    private AppWidgetManagerCompat mAppWidgetManager;
    private LauncherAppWidgetHost mAppWidgetHost;
    private LauncherAppWidgetHost mAppWidgetHost;


    private int[] mTmpAddItemCellCoordinates = new int[2];
    private final int[] mTmpAddItemCellCoordinates = new int[2];


    @Thunk Hotseat mHotseat;
    @Thunk Hotseat mHotseat;
    private ViewGroup mOverviewPanel;
    private ViewGroup mOverviewPanel;
@@ -262,15 +262,15 @@ public class Launcher extends BaseActivity
    private boolean mPaused = true;
    private boolean mPaused = true;
    private boolean mOnResumeNeedsLoad;
    private boolean mOnResumeNeedsLoad;


    private ArrayList<Runnable> mBindOnResumeCallbacks = new ArrayList<Runnable>();
    private final ArrayList<Runnable> mBindOnResumeCallbacks = new ArrayList<>();
    private ArrayList<Runnable> mOnResumeCallbacks = new ArrayList<Runnable>();
    private final ArrayList<Runnable> mOnResumeCallbacks = new ArrayList<>();
    private ViewOnDrawExecutor mPendingExecutor;
    private ViewOnDrawExecutor mPendingExecutor;


    private LauncherModel mModel;
    private LauncherModel mModel;
    private ModelWriter mModelWriter;
    private ModelWriter mModelWriter;
    private IconCache mIconCache;
    private IconCache mIconCache;
    private LauncherAccessibilityDelegate mAccessibilityDelegate;
    private LauncherAccessibilityDelegate mAccessibilityDelegate;
    private Handler mHandler = new Handler();
    private final Handler mHandler = new Handler();
    private boolean mIsResumeFromActionScreenOff;
    private boolean mIsResumeFromActionScreenOff;
    private boolean mHasFocus = false;
    private boolean mHasFocus = false;


@@ -284,7 +284,7 @@ public class Launcher extends BaseActivity
    // match the sensor state.
    // match the sensor state.
    private static final int RESTORE_SCREEN_ORIENTATION_DELAY = 500;
    private static final int RESTORE_SCREEN_ORIENTATION_DELAY = 500;


    private final ArrayList<Integer> mSynchronouslyBoundPages = new ArrayList<Integer>();
    private final ArrayList<Integer> mSynchronouslyBoundPages = new ArrayList<>();


    // We only want to get the SharedPreferences once since it does an FS stat each time we get
    // We only want to get the SharedPreferences once since it does an FS stat each time we get
    // it from the context.
    // it from the context.
@@ -297,8 +297,8 @@ public class Launcher extends BaseActivity
    // the press state and keep this reference to reset the press state when we return to launcher.
    // the press state and keep this reference to reset the press state when we return to launcher.
    private BubbleTextView mWaitingForResume;
    private BubbleTextView mWaitingForResume;


    protected static HashMap<String, CustomAppWidget> sCustomAppWidgets =
    protected static final HashMap<String, CustomAppWidget> sCustomAppWidgets =
            new HashMap<String, CustomAppWidget>();
        new HashMap<>();


    static {
    static {
        if (TestingUtils.ENABLE_CUSTOM_WIDGET_TEST) {
        if (TestingUtils.ENABLE_CUSTOM_WIDGET_TEST) {
@@ -311,7 +311,7 @@ public class Launcher extends BaseActivity
    // simply unregister this runnable.
    // simply unregister this runnable.
    private Runnable mExitSpringLoadedModeRunnable;
    private Runnable mExitSpringLoadedModeRunnable;


    @Thunk Runnable mBuildLayersRunnable = new Runnable() {
    @Thunk final Runnable mBuildLayersRunnable = new Runnable() {
        public void run() {
        public void run() {
            if (mWorkspace != null) {
            if (mWorkspace != null) {
                mWorkspace.buildPageHardwareLayers();
                mWorkspace.buildPageHardwareLayers();
@@ -1063,13 +1063,13 @@ public class Launcher extends BaseActivity
    public interface CustomContentCallbacks {
    public interface CustomContentCallbacks {
        // Custom content is completely shown. {@code fromResume} indicates whether this was caused
        // Custom content is completely shown. {@code fromResume} indicates whether this was caused
        // by a onResume or by scrolling otherwise.
        // by a onResume or by scrolling otherwise.
        public void onShow(boolean fromResume);
        void onShow(boolean fromResume);


        // Custom content is completely hidden
        // Custom content is completely hidden
        public void onHide();
        void onHide();


        // Custom content scroll progress changed. From 0 (not showing) to 1 (fully showing).
        // Custom content scroll progress changed. From 0 (not showing) to 1 (fully showing).
        public void onScrollProgressChanged(float progress);
        void onScrollProgressChanged(float progress);


        // Indicates whether the user is allowed to scroll away from the custom content.
        // Indicates whether the user is allowed to scroll away from the custom content.
        boolean isScrollingAllowed();
        boolean isScrollingAllowed();
@@ -1080,28 +1080,28 @@ public class Launcher extends BaseActivity
        /**
        /**
         * Touch interaction leading to overscroll has begun
         * Touch interaction leading to overscroll has begun
         */
         */
        public void onScrollInteractionBegin();
        void onScrollInteractionBegin();


        /**
        /**
         * Touch interaction related to overscroll has ended
         * Touch interaction related to overscroll has ended
         */
         */
        public void onScrollInteractionEnd();
        void onScrollInteractionEnd();


        /**
        /**
         * Scroll progress, between 0 and 100, when the user scrolls beyond the leftmost
         * Scroll progress, between 0 and 100, when the user scrolls beyond the leftmost
         * screen (or in the case of RTL, the rightmost screen).
         * screen (or in the case of RTL, the rightmost screen).
         */
         */
        public void onScrollChange(float progress, boolean rtl);
        void onScrollChange(float progress, boolean rtl);


        /**
        /**
         * Called when the launcher is ready to use the overlay
         * Called when the launcher is ready to use the overlay
         * @param callbacks A set of callbacks provided by Launcher in relation to the overlay
         * @param callbacks A set of callbacks provided by Launcher in relation to the overlay
         */
         */
        public void setOverlayCallbacks(LauncherOverlayCallbacks callbacks);
        void setOverlayCallbacks(LauncherOverlayCallbacks callbacks);
    }
    }


    public interface LauncherOverlayCallbacks {
    public interface LauncherOverlayCallbacks {
        public void onScrollChanged(float progress);
        void onScrollChanged(float progress);
    }
    }


    class LauncherOverlayCallbacksImpl implements LauncherOverlayCallbacks {
    class LauncherOverlayCallbacksImpl implements LauncherOverlayCallbacks {
@@ -1285,7 +1285,7 @@ public class Launcher extends BaseActivity
        mDragController.addDragListener(mWorkspace);
        mDragController.addDragListener(mWorkspace);


        // Get the search/delete/uninstall bar
        // Get the search/delete/uninstall bar
        mDropTargetBar = (DropTargetBar) mDragLayer.findViewById(R.id.drop_target_bar);
        mDropTargetBar = mDragLayer.findViewById(R.id.drop_target_bar);


        // Setup Apps and Widgets
        // Setup Apps and Widgets
        mAppsView = (AllAppsContainerView) findViewById(R.id.apps_view);
        mAppsView = (AllAppsContainerView) findViewById(R.id.apps_view);
@@ -1607,7 +1607,6 @@ public class Launcher extends BaseActivity
                                }
                                }
                            }
                            }
                        });
                        });
                        return;
                    }
                    }
                });
                });
            }
            }
@@ -1744,8 +1743,9 @@ public class Launcher extends BaseActivity
        // as slow logic in the callbacks eat into the time the scroller expects for the snapToPage
        // as slow logic in the callbacks eat into the time the scroller expects for the snapToPage
        // animation.
        // animation.
        if (isActionMain) {
        if (isActionMain) {
            boolean callbackAllowsMoveToDefaultScreen = mLauncherCallbacks != null ?
            boolean callbackAllowsMoveToDefaultScreen =
                    mLauncherCallbacks.shouldMoveToDefaultScreenOnHomeIntent() : true;
                mLauncherCallbacks == null || mLauncherCallbacks
                    .shouldMoveToDefaultScreenOnHomeIntent();
            if (shouldMoveToDefaultScreen && !mWorkspace.isTouchActive()
            if (shouldMoveToDefaultScreen && !mWorkspace.isTouchActive()
                    && callbackAllowsMoveToDefaultScreen) {
                    && callbackAllowsMoveToDefaultScreen) {


@@ -3196,7 +3196,7 @@ public class Launcher extends BaseActivity
                orderedScreenIds.indexOf(Workspace.FIRST_SCREEN_ID) != 0) {
                orderedScreenIds.indexOf(Workspace.FIRST_SCREEN_ID) != 0) {
            orderedScreenIds.remove(Workspace.FIRST_SCREEN_ID);
            orderedScreenIds.remove(Workspace.FIRST_SCREEN_ID);
            orderedScreenIds.add(0, Workspace.FIRST_SCREEN_ID);
            orderedScreenIds.add(0, Workspace.FIRST_SCREEN_ID);
            mModel.updateWorkspaceScreenOrder(this, orderedScreenIds);
            LauncherModel.updateWorkspaceScreenOrder(this, orderedScreenIds);
        } else if (!FeatureFlags.QSB_ON_FIRST_SCREEN && orderedScreenIds.isEmpty()) {
        } else if (!FeatureFlags.QSB_ON_FIRST_SCREEN && orderedScreenIds.isEmpty()) {
            // If there are no screens, we need to have an empty screen
            // If there are no screens, we need to have an empty screen
            mWorkspace.addExtraEmptyScreen();
            mWorkspace.addExtraEmptyScreen();
@@ -3283,7 +3283,7 @@ public class Launcher extends BaseActivity


        // Get the list of added items and intersect them with the set of items here
        // Get the list of added items and intersect them with the set of items here
        final AnimatorSet anim = LauncherAnimUtils.createAnimatorSet();
        final AnimatorSet anim = LauncherAnimUtils.createAnimatorSet();
        final Collection<Animator> bounceAnims = new ArrayList<Animator>();
        final Collection<Animator> bounceAnims = new ArrayList<>();
        final boolean animateIcons = forceAnimateIcons && canRunNewAppsAnimation();
        final boolean animateIcons = forceAnimateIcons && canRunNewAppsAnimation();
        Workspace workspace = mWorkspace;
        Workspace workspace = mWorkspace;
        long newItemsScreenId = -1;
        long newItemsScreenId = -1;
@@ -3667,7 +3667,7 @@ public class Launcher extends BaseActivity
     * multiple calls to bind the same list.)
     * multiple calls to bind the same list.)
     */
     */
    @Thunk ArrayList<AppInfo> mTmpAppsList;
    @Thunk ArrayList<AppInfo> mTmpAppsList;
    private Runnable mBindAllApplicationsRunnable = new Runnable() {
    private final Runnable mBindAllApplicationsRunnable = new Runnable() {
        public void run() {
        public void run() {
            bindAllApplications(mTmpAppsList);
            bindAllApplications(mTmpAppsList);
            mTmpAppsList = null;
            mTmpAppsList = null;
@@ -3871,7 +3871,7 @@ public class Launcher extends BaseActivity
        }
        }
    }
    }


    private Runnable mBindAllWidgetsRunnable = new Runnable() {
    private final Runnable mBindAllWidgetsRunnable = new Runnable() {
            public void run() {
            public void run() {
                bindAllWidgets(mAllWidgets);
                bindAllWidgets(mAllWidgets);
            }
            }
@@ -3942,7 +3942,7 @@ public class Launcher extends BaseActivity
    }
    }


    private boolean shouldShowDiscoveryBounce() {
    private boolean shouldShowDiscoveryBounce() {
        if (mState != mState.WORKSPACE) {
        if (mState != State.WORKSPACE) {
            return false;
            return false;
        }
        }
        if (mLauncherCallbacks != null && mLauncherCallbacks.shouldShowDiscoveryBounce()) {
        if (mLauncherCallbacks != null && mLauncherCallbacks.shouldShowDiscoveryBounce()) {
@@ -3951,10 +3951,7 @@ public class Launcher extends BaseActivity
        if (!mIsResumeFromActionScreenOff) {
        if (!mIsResumeFromActionScreenOff) {
            return false;
            return false;
        }
        }
        if (mSharedPrefs.getBoolean(APPS_VIEW_SHOWN, false)) {
        return !mSharedPrefs.getBoolean(APPS_VIEW_SHOWN, false);
            return false;
        }
        return true;
    }
    }


    protected void moveWorkspaceToDefaultScreen() {
    protected void moveWorkspaceToDefaultScreen() {