Use category icon for pending conversation widgets
Fix: 192333050 Test: Manual Change-Id: Ie3895cd4747f1bec1c8ca9af82347bb0eafa7415
This commit is contained in:
parent
bf60673bbb
commit
12f7a59e5c
|
@ -24,6 +24,7 @@ import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.android.launcher3.LauncherAppState;
|
import com.android.launcher3.LauncherAppState;
|
||||||
import com.android.launcher3.icons.ComponentWithLabelAndIcon;
|
import com.android.launcher3.icons.ComponentWithLabelAndIcon;
|
||||||
|
import com.android.launcher3.model.data.PackageItemInfo;
|
||||||
import com.android.launcher3.util.PackageUserKey;
|
import com.android.launcher3.util.PackageUserKey;
|
||||||
import com.android.launcher3.widget.model.WidgetsListBaseEntry;
|
import com.android.launcher3.widget.model.WidgetsListBaseEntry;
|
||||||
|
|
||||||
|
@ -81,4 +82,9 @@ public class WidgetsModel {
|
||||||
ComponentName providerName) {
|
ComponentName providerName) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns {@link PackageItemInfo} of a pending widget. */
|
||||||
|
public static PackageItemInfo newPendingItemInfo(ComponentName provider) {
|
||||||
|
return new PackageItemInfo(provider.getPackageName());
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -75,7 +75,6 @@ import com.android.launcher3.model.data.FolderInfo;
|
||||||
import com.android.launcher3.model.data.ItemInfo;
|
import com.android.launcher3.model.data.ItemInfo;
|
||||||
import com.android.launcher3.model.data.ItemInfoWithIcon;
|
import com.android.launcher3.model.data.ItemInfoWithIcon;
|
||||||
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
|
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
|
||||||
import com.android.launcher3.model.data.PackageItemInfo;
|
|
||||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||||
import com.android.launcher3.pm.InstallSessionHelper;
|
import com.android.launcher3.pm.InstallSessionHelper;
|
||||||
import com.android.launcher3.pm.PackageInstallInfo;
|
import com.android.launcher3.pm.PackageInstallInfo;
|
||||||
|
@ -791,8 +790,8 @@ public class LoaderTask implements Runnable {
|
||||||
|
|
||||||
if (appWidgetInfo.restoreStatus !=
|
if (appWidgetInfo.restoreStatus !=
|
||||||
LauncherAppWidgetInfo.RESTORE_COMPLETED) {
|
LauncherAppWidgetInfo.RESTORE_COMPLETED) {
|
||||||
String pkg = appWidgetInfo.providerName.getPackageName();
|
appWidgetInfo.pendingItemInfo = WidgetsModel.newPendingItemInfo(
|
||||||
appWidgetInfo.pendingItemInfo = new PackageItemInfo(pkg);
|
appWidgetInfo.providerName);
|
||||||
appWidgetInfo.pendingItemInfo.user = appWidgetInfo.user;
|
appWidgetInfo.pendingItemInfo.user = appWidgetInfo.user;
|
||||||
mIconCache.getTitleAndIconForApp(
|
mIconCache.getTitleAndIconForApp(
|
||||||
appWidgetInfo.pendingItemInfo, false);
|
appWidgetInfo.pendingItemInfo, false);
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package com.android.launcher3.widget;
|
package com.android.launcher3.widget;
|
||||||
|
|
||||||
import static com.android.launcher3.graphics.PreloadIconDrawable.newPendingIcon;
|
import static com.android.launcher3.graphics.PreloadIconDrawable.newPendingIcon;
|
||||||
|
import static com.android.launcher3.model.data.PackageItemInfo.CONVERSATIONS;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
|
@ -35,6 +36,8 @@ import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.widget.RemoteViews;
|
import android.widget.RemoteViews;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.android.launcher3.DeviceProfile;
|
import com.android.launcher3.DeviceProfile;
|
||||||
import com.android.launcher3.R;
|
import com.android.launcher3.R;
|
||||||
import com.android.launcher3.icons.FastBitmapDrawable;
|
import com.android.launcher3.icons.FastBitmapDrawable;
|
||||||
|
@ -146,21 +149,32 @@ public class PendingAppWidgetHostView extends LauncherAppWidgetHostView
|
||||||
mCenterDrawable = null;
|
mCenterDrawable = null;
|
||||||
}
|
}
|
||||||
if (info.bitmap.icon != null) {
|
if (info.bitmap.icon != null) {
|
||||||
|
Drawable widgetCategoryIcon = getWidgetCategoryIcon();
|
||||||
// The view displays three modes,
|
// The view displays three modes,
|
||||||
// 1) App icon in the center
|
// 1) App icon in the center
|
||||||
// 2) Preload icon in the center
|
// 2) Preload icon in the center
|
||||||
// 3) App icon in the center with a setup icon on the top left corner.
|
// 3) App icon in the center with a setup icon on the top left corner.
|
||||||
if (mDisabledForSafeMode) {
|
if (mDisabledForSafeMode) {
|
||||||
FastBitmapDrawable disabledIcon = info.newIcon(getContext());
|
if (widgetCategoryIcon == null) {
|
||||||
disabledIcon.setIsDisabled(true);
|
FastBitmapDrawable disabledIcon = info.newIcon(getContext());
|
||||||
mCenterDrawable = disabledIcon;
|
disabledIcon.setIsDisabled(true);
|
||||||
|
mCenterDrawable = disabledIcon;
|
||||||
|
} else {
|
||||||
|
widgetCategoryIcon.setColorFilter(
|
||||||
|
FastBitmapDrawable.getDisabledFColorFilter(/* disabledAlpha= */ 1f));
|
||||||
|
mCenterDrawable = widgetCategoryIcon;
|
||||||
|
}
|
||||||
mSettingIconDrawable = null;
|
mSettingIconDrawable = null;
|
||||||
} else if (isReadyForClickSetup()) {
|
} else if (isReadyForClickSetup()) {
|
||||||
mCenterDrawable = info.newIcon(getContext());
|
mCenterDrawable = widgetCategoryIcon == null
|
||||||
|
? info.newIcon(getContext())
|
||||||
|
: widgetCategoryIcon;
|
||||||
mSettingIconDrawable = getResources().getDrawable(R.drawable.ic_setting).mutate();
|
mSettingIconDrawable = getResources().getDrawable(R.drawable.ic_setting).mutate();
|
||||||
updateSettingColor(info.bitmap.color);
|
updateSettingColor(info.bitmap.color);
|
||||||
} else {
|
} else {
|
||||||
mCenterDrawable = newPendingIcon(getContext(), info);
|
mCenterDrawable = widgetCategoryIcon == null
|
||||||
|
? newPendingIcon(getContext(), info)
|
||||||
|
: widgetCategoryIcon;
|
||||||
mSettingIconDrawable = null;
|
mSettingIconDrawable = null;
|
||||||
applyState();
|
applyState();
|
||||||
}
|
}
|
||||||
|
@ -316,4 +330,19 @@ public class PendingAppWidgetHostView extends LauncherAppWidgetHostView
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the widget category icon for {@link #mInfo}.
|
||||||
|
*
|
||||||
|
* <p>If {@link #mInfo}'s category is {@code PackageItemInfo#NO_CATEGORY} or unknown, returns
|
||||||
|
* {@code null}.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
private Drawable getWidgetCategoryIcon() {
|
||||||
|
switch (mInfo.pendingItemInfo.category) {
|
||||||
|
case CONVERSATIONS:
|
||||||
|
return getContext().getDrawable(R.drawable.ic_conversations_widget_category);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,6 +225,14 @@ public class WidgetsModel {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns {@link PackageItemInfo} of a pending widget. */
|
||||||
|
public static PackageItemInfo newPendingItemInfo(ComponentName provider) {
|
||||||
|
if (CONVERSATION_WIDGET.equals(provider)) {
|
||||||
|
return new PackageItemInfo(provider.getPackageName(), PackageItemInfo.CONVERSATIONS);
|
||||||
|
}
|
||||||
|
return new PackageItemInfo(provider.getPackageName());
|
||||||
|
}
|
||||||
|
|
||||||
private WidgetPackageOrCategoryKey getWidgetPackageOrCategoryKey(WidgetItem item) {
|
private WidgetPackageOrCategoryKey getWidgetPackageOrCategoryKey(WidgetItem item) {
|
||||||
if (CONVERSATION_WIDGET.equals(item.componentName)) {
|
if (CONVERSATION_WIDGET.equals(item.componentName)) {
|
||||||
return new WidgetPackageOrCategoryKey(PackageItemInfo.CONVERSATIONS, item.user);
|
return new WidgetPackageOrCategoryKey(PackageItemInfo.CONVERSATIONS, item.user);
|
||||||
|
|
Loading…
Reference in New Issue