mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-03 09:26:51 +00:00
Merge "Fixing shortcuts not getting theme icons" into tm-qpr-dev am: 1330244f0a
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/20546011 Change-Id: Iec0c682a4f1a81a4093a4971929603fc4dc32f21 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -249,12 +249,13 @@ public class TaskIconCache implements DisplayInfoChangeListener {
|
||||
private BitmapInfo getBitmapInfo(Drawable drawable, int userId,
|
||||
int primaryColor, boolean isInstantApp) {
|
||||
try (BaseIconFactory bif = getIconFactory()) {
|
||||
bif.disableColorExtraction();
|
||||
bif.setWrapperBackgroundColor(primaryColor);
|
||||
|
||||
// User version code O, so that the icon is always wrapped in an adaptive icon container
|
||||
return bif.createBadgedIconBitmap(drawable,
|
||||
new IconOptions().setUser(UserHandle.of(userId)).setInstantApp(isInstantApp));
|
||||
new IconOptions().setUser(UserHandle.of(userId))
|
||||
.setInstantApp(isInstantApp)
|
||||
.setExtractedColor(0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.icons.BaseIconFactory.IconOptions;
|
||||
import com.android.launcher3.icons.cache.CachingLogic;
|
||||
import com.android.launcher3.shortcuts.ShortcutKey;
|
||||
import com.android.launcher3.util.Themes;
|
||||
@@ -76,9 +77,8 @@ public class ShortcutCachingLogic implements CachingLogic<ShortcutInfo> {
|
||||
Drawable unbadgedDrawable = ShortcutCachingLogic.getIcon(
|
||||
context, info, LauncherAppState.getIDP(context).fillResIconDpi);
|
||||
if (unbadgedDrawable == null) return BitmapInfo.LOW_RES_INFO;
|
||||
return new BitmapInfo(
|
||||
li.createScaledBitmap(unbadgedDrawable, BaseIconFactory.MODE_WITH_SHADOW),
|
||||
Themes.getColorAccent(context));
|
||||
return li.createBadgedIconBitmap(unbadgedDrawable,
|
||||
new IconOptions().setExtractedColor(Themes.getColorAccent(context)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<shortcut
|
||||
android:shortcutId="shortcut1"
|
||||
android:icon="@drawable/test_theme_icon"
|
||||
android:shortcutShortLabel="@string/shortcut1">
|
||||
<intent android:action="com.android.launcher3.intent.action.test_shortcut"/>
|
||||
</shortcut>
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.android.launcher3.BubbleTextView;
|
||||
import com.android.launcher3.icons.ThemedIconDrawable;
|
||||
import com.android.launcher3.tapl.HomeAllApps;
|
||||
import com.android.launcher3.tapl.HomeAppIcon;
|
||||
import com.android.launcher3.tapl.HomeAppIconMenuItem;
|
||||
import com.android.launcher3.ui.AbstractLauncherUiTest;
|
||||
import com.android.launcher3.ui.TaplTestsLauncher3;
|
||||
|
||||
@@ -49,6 +50,8 @@ import java.util.Queue;
|
||||
public class ThemeIconsTest extends AbstractLauncherUiTest {
|
||||
|
||||
private static final String APP_NAME = "ThemeIconTestActivity";
|
||||
private static final String SHORTCUT_APP_NAME = "LauncherTestApp";
|
||||
private static final String SHORTCUT_NAME = "Shortcut 1";
|
||||
|
||||
@Test
|
||||
public void testIconWithoutTheme() throws Exception {
|
||||
@@ -60,9 +63,28 @@ public class ThemeIconsTest extends AbstractLauncherUiTest {
|
||||
|
||||
try {
|
||||
HomeAppIcon icon = allApps.getAppIcon(APP_NAME);
|
||||
executeOnLauncher(l -> verifyIconTheme(l.getAppsView(), false));
|
||||
executeOnLauncher(l -> verifyIconTheme(APP_NAME, l.getAppsView(), false));
|
||||
icon.dragToWorkspace(false, false);
|
||||
executeOnLauncher(l -> verifyIconTheme(l.getWorkspace(), false));
|
||||
executeOnLauncher(l -> verifyIconTheme(APP_NAME, l.getWorkspace(), false));
|
||||
} finally {
|
||||
allApps.unfreeze();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShortcutIconWithoutTheme() throws Exception {
|
||||
setThemeEnabled(false);
|
||||
TaplTestsLauncher3.initialize(this);
|
||||
|
||||
HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps();
|
||||
allApps.freeze();
|
||||
|
||||
try {
|
||||
HomeAppIcon icon = allApps.getAppIcon(SHORTCUT_APP_NAME);
|
||||
HomeAppIconMenuItem shortcutItem =
|
||||
(HomeAppIconMenuItem) icon.openDeepShortcutMenu().getMenuItem(SHORTCUT_NAME);
|
||||
shortcutItem.dragToWorkspace(false, false);
|
||||
executeOnLauncher(l -> verifyIconTheme(SHORTCUT_NAME, l.getWorkspace(), false));
|
||||
} finally {
|
||||
allApps.unfreeze();
|
||||
}
|
||||
@@ -78,15 +100,34 @@ public class ThemeIconsTest extends AbstractLauncherUiTest {
|
||||
|
||||
try {
|
||||
HomeAppIcon icon = allApps.getAppIcon(APP_NAME);
|
||||
executeOnLauncher(l -> verifyIconTheme(l.getAppsView(), false));
|
||||
executeOnLauncher(l -> verifyIconTheme(APP_NAME, l.getAppsView(), false));
|
||||
icon.dragToWorkspace(false, false);
|
||||
executeOnLauncher(l -> verifyIconTheme(l.getWorkspace(), true));
|
||||
executeOnLauncher(l -> verifyIconTheme(APP_NAME, l.getWorkspace(), true));
|
||||
} finally {
|
||||
allApps.unfreeze();
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyIconTheme(ViewGroup parent, boolean isThemed) {
|
||||
@Test
|
||||
public void testShortcutIconWithTheme() throws Exception {
|
||||
setThemeEnabled(true);
|
||||
TaplTestsLauncher3.initialize(this);
|
||||
|
||||
HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps();
|
||||
allApps.freeze();
|
||||
|
||||
try {
|
||||
HomeAppIcon icon = allApps.getAppIcon(SHORTCUT_APP_NAME);
|
||||
HomeAppIconMenuItem shortcutItem =
|
||||
(HomeAppIconMenuItem) icon.openDeepShortcutMenu().getMenuItem(SHORTCUT_NAME);
|
||||
shortcutItem.dragToWorkspace(false, false);
|
||||
executeOnLauncher(l -> verifyIconTheme(SHORTCUT_NAME, l.getWorkspace(), true));
|
||||
} finally {
|
||||
allApps.unfreeze();
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyIconTheme(String title, ViewGroup parent, boolean isThemed) {
|
||||
// Find the app icon
|
||||
Queue<View> viewQueue = new ArrayDeque<>();
|
||||
viewQueue.add(parent);
|
||||
@@ -100,7 +141,7 @@ public class ThemeIconsTest extends AbstractLauncherUiTest {
|
||||
}
|
||||
} else if (view instanceof BubbleTextView) {
|
||||
BubbleTextView btv = (BubbleTextView) view;
|
||||
if (APP_NAME.equals(btv.getText())) {
|
||||
if (title.equals(btv.getText())) {
|
||||
icon = btv;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user