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

Commit 698f59cc authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Loading widget description on the background thread" into udc-dev

parents 8e7e1596 2185f6f4
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -304,7 +304,8 @@ public class AddItemActivity extends BaseActivity
        mWidgetOptions = pendingInfo.getDefaultSizeOptions(this);
        mWidgetCell.getWidgetView().setTag(pendingInfo);

        applyWidgetItemAsync(() -> new WidgetItem(widgetInfo, mIdp, mApp.getIconCache()));
        applyWidgetItemAsync(() -> new WidgetItem(
                widgetInfo, mIdp, mApp.getIconCache(), mApp.getContext()));
        return WidgetsModel.newPendingItemInfo(this, widgetInfo.getComponent(),
                widgetInfo.getUser());
    }
+5 −1
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ package com.android.launcher3.model;
import static com.android.launcher3.Utilities.ATLEAST_S;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
@@ -25,13 +26,15 @@ public class WidgetItem extends ComponentKey {
    public final ShortcutConfigActivityInfo activityInfo;

    public final String label;
    public final CharSequence description;
    public final int spanX, spanY;

    public WidgetItem(LauncherAppWidgetProviderInfo info,
            InvariantDeviceProfile idp, IconCache iconCache) {
            InvariantDeviceProfile idp, IconCache iconCache, Context context) {
        super(info.provider, info.getProfile());

        label = iconCache.getTitleNoCache(info);
        description = ATLEAST_S ? info.loadDescription(context) : null;
        widgetInfo = info;
        activityInfo = null;

@@ -43,6 +46,7 @@ public class WidgetItem extends ComponentKey {
        super(info.getComponent(), info.getUser());
        label = info.isPersistable() ? iconCache.getTitleNoCache(info) :
                Utilities.trim(info.getLabel(pm));
        description = null;
        widgetInfo = null;
        activityInfo = info;
        spanX = spanY = 1;
+6 −9
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.launcher3.widget;

import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_WIDGETS_TRAY;
import static com.android.launcher3.Utilities.ATLEAST_S;
import static com.android.launcher3.widget.LauncherAppWidgetProviderInfo.fromProviderInfo;
import static com.android.launcher3.widget.util.WidgetSizes.getWidgetItemSizePx;

@@ -25,6 +24,7 @@ import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.os.Process;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Size;
@@ -219,15 +219,12 @@ public class WidgetCell extends LinearLayout {
                mItem.spanX, mItem.spanY));
        mWidgetDims.setContentDescription(context.getString(
                R.string.widget_accessible_dims_format, mItem.spanX, mItem.spanY));
        if (ATLEAST_S && mItem.widgetInfo != null) {
            CharSequence description = mItem.widgetInfo.loadDescription(context);
            if (description != null && description.length() > 0) {
                mWidgetDescription.setText(description);
        if (!TextUtils.isEmpty(mItem.description)) {
            mWidgetDescription.setText(mItem.description);
            mWidgetDescription.setVisibility(VISIBLE);
        } else {
            mWidgetDescription.setVisibility(GONE);
        }
        }

        if (item.activityInfo != null) {
            setTag(new PendingAddShortcutInfo(item.activityInfo));
+3 −2
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ public class WidgetsModel {
                        LauncherAppWidgetProviderInfo.fromProviderInfo(context, widgetInfo);

                widgetsAndShortcuts.add(new WidgetItem(
                        launcherWidgetInfo, idp, app.getIconCache()));
                        launcherWidgetInfo, idp, app.getIconCache(), app.getContext()));
                updatedItems.add(launcherWidgetInfo);
            }

@@ -200,7 +200,8 @@ public class WidgetsModel {
                                    app.getContext().getPackageManager()));
                        } else {
                            items.set(i, new WidgetItem(item.widgetInfo,
                                    app.getInvariantDeviceProfile(), app.getIconCache()));
                                    app.getInvariantDeviceProfile(), app.getIconCache(),
                                    app.getContext()));
                        }
                    }
                }
+1 −1
Original line number Diff line number Diff line
@@ -147,7 +147,7 @@ public final class WidgetsListHeaderViewHolderBinderTest {

            widgetItems.add(new WidgetItem(
                    LauncherAppWidgetProviderInfo.fromProviderInfo(mContext, widgetInfo),
                    mTestProfile, mIconCache));
                    mTestProfile, mIconCache, mContext));
        }
        return widgetItems;
    }
Loading