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

Commit 87f784c2 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Removing static Context access using LauncherAppState

> This ensures that LauncherAppState is only accessed in the presence of
a valid context

Bug: 33032833
Change-Id: I955e5cb022f8bd6374681ae6c0720a2666d5b750
parent 41307051
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -320,7 +320,7 @@ public class AppWidgetResizeFrame extends FrameLayout

    public static Rect getWidgetSizeRanges(Context context, int spanX, int spanY, Rect rect) {
        if (sCellSize == null) {
            InvariantDeviceProfile inv = LauncherAppState.getInstance().getInvariantDeviceProfile();
            InvariantDeviceProfile inv = LauncherAppState.getIDP(context);

            // Initiate cell sizes.
            sCellSize = new Point[2];
+2 −2
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ public class AutoInstallsLayout {

    static AutoInstallsLayout get(Context context, String pkg, Resources targetRes,
            AppWidgetHost appWidgetHost, LayoutParserCallback callback) {
        InvariantDeviceProfile grid = LauncherAppState.getInstance().getInvariantDeviceProfile();
        InvariantDeviceProfile grid = LauncherAppState.getIDP(context);

        // Try with grid size and hotseat count
        String layoutName = String.format(Locale.ENGLISH, FORMATTED_LAYOUT_RES_WITH_HOSTEAT,
@@ -182,7 +182,7 @@ public class AutoInstallsLayout {
        mSourceRes = res;
        mLayoutId = layoutId;

        mIdp = LauncherAppState.getInstance().getInvariantDeviceProfile();
        mIdp = LauncherAppState.getIDP(context);
        mRowCount = mIdp.numRows;
        mColumnCount = mIdp.numColumns;
    }
+1 −1
Original line number Diff line number Diff line
@@ -587,7 +587,7 @@ public class BubbleTextView extends TextView
        if (getTag() instanceof ItemInfoWithIcon) {
            ItemInfoWithIcon info = (ItemInfoWithIcon) getTag();
            if (info.usingLowResIcon) {
                mIconLoadRequest = LauncherAppState.getInstance().getIconCache()
                mIconLoadRequest = LauncherAppState.getInstance(getContext()).getIconCache()
                        .updateIconInBackground(BubbleTextView.this, info);
            }
        }
+1 −1
Original line number Diff line number Diff line
@@ -734,7 +734,7 @@ public class IconCache {

                if (mAppsToUpdate.isEmpty() && !mUpdatedPackages.isEmpty()) {
                    // No more app to update. Notify model.
                    LauncherAppState.getInstance().getModel().onPackageIconsUpdated(
                    LauncherAppState.getInstance(mContext).getModel().onPackageIconsUpdated(
                            mUpdatedPackages, mUserManager.getUserForSerialNumber(mUserSerial));
                }

+5 −6
Original line number Diff line number Diff line
@@ -241,7 +241,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver {

    private static void queuePendingShortcutInfo(PendingInstallShortcutInfo info, Context context) {
        // Queue the item up for adding if launcher has not loaded properly yet
        LauncherAppState app = LauncherAppState.getInstance();
        LauncherAppState app = LauncherAppState.getInstance(context);
        boolean launcherNotLoaded = app.getModel().getCallback() == null;

        addToInstallQueue(Utilities.getPrefs(context), info);
@@ -261,7 +261,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
    static void flushInstallQueue(Context context) {
        ArrayList<PendingInstallShortcutInfo> items = getAndClearInstallQueue(context);
        if (!items.isEmpty()) {
            LauncherAppState.getInstance().getModel().addAndBindAddedWorkspaceItems(
            LauncherAppState.getInstance(context).getModel().addAndBindAddedWorkspaceItems(
                    new LazyShortcutsProvider(context.getApplicationContext(), items));
        }
    }
@@ -438,7 +438,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
        public ItemInfo getItemInfo() {
            if (activityInfo != null) {
                AppInfo appInfo = new AppInfo(mContext, activityInfo, user);
                final LauncherAppState app = LauncherAppState.getInstance();
                final LauncherAppState app = LauncherAppState.getInstance(mContext);
                // Set default values until proper values is loaded.
                appInfo.title = "";
                appInfo.iconBitmap = app.getIconCache().getDefaultIcon(user);
@@ -464,15 +464,14 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
                LauncherAppWidgetInfo widgetInfo = new LauncherAppWidgetInfo(
                        launchIntent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, 0),
                        info.provider);
                InvariantDeviceProfile idp = LauncherAppState.getInstance()
                        .getInvariantDeviceProfile();
                InvariantDeviceProfile idp = LauncherAppState.getIDP(mContext);
                widgetInfo.minSpanX = info.minSpanX;
                widgetInfo.minSpanY = info.minSpanY;
                widgetInfo.spanX = Math.min(info.spanX, idp.numColumns);
                widgetInfo.spanY = Math.min(info.spanY, idp.numRows);
                return widgetInfo;
            } else {
                return createShortcutInfo(data, LauncherAppState.getInstance());
                return createShortcutInfo(data, LauncherAppState.getInstance(mContext));
            }
        }

Loading