Use global color extraction in widgets for wallpaper preview
Test: Widgets in wallpaper app should use wallpaper colors Bug: 192205054 Change-Id: I4da9ad1cc88be251f97e86b6c8c9b346ed20f586
This commit is contained in:
parent
0841e93a34
commit
57c8d68001
|
@ -584,4 +584,15 @@
|
||||||
column="17"/>
|
column="17"/>
|
||||||
</issue>
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="NewApi"
|
||||||
|
message="Call requires API level 27 (current min is 26): `android.app.WallpaperManager#getWallpaperColors`"
|
||||||
|
errorLine1=" : WallpaperManager.getInstance(context).getWallpaperColors(FLAG_SYSTEM);"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="packages/apps/Launcher3/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java"
|
||||||
|
line="288"
|
||||||
|
column="61"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
</issues>
|
</issues>
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package com.android.launcher3.graphics;
|
package com.android.launcher3.graphics;
|
||||||
|
|
||||||
|
import static android.app.WallpaperManager.FLAG_SYSTEM;
|
||||||
import static android.view.View.MeasureSpec.EXACTLY;
|
import static android.view.View.MeasureSpec.EXACTLY;
|
||||||
import static android.view.View.MeasureSpec.makeMeasureSpec;
|
import static android.view.View.MeasureSpec.makeMeasureSpec;
|
||||||
import static android.view.View.VISIBLE;
|
import static android.view.View.VISIBLE;
|
||||||
|
@ -27,6 +28,7 @@ import static com.android.launcher3.model.ModelUtils.sortWorkspaceItemsSpatially
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.app.WallpaperColors;
|
import android.app.WallpaperColors;
|
||||||
|
import android.app.WallpaperManager;
|
||||||
import android.appwidget.AppWidgetHost;
|
import android.appwidget.AppWidgetHost;
|
||||||
import android.appwidget.AppWidgetHostView;
|
import android.appwidget.AppWidgetHostView;
|
||||||
import android.appwidget.AppWidgetProviderInfo;
|
import android.appwidget.AppWidgetProviderInfo;
|
||||||
|
@ -214,7 +216,7 @@ public class LauncherPreviewRenderer extends ContextWrapper
|
||||||
|
|
||||||
public LauncherPreviewRenderer(Context context,
|
public LauncherPreviewRenderer(Context context,
|
||||||
InvariantDeviceProfile idp,
|
InvariantDeviceProfile idp,
|
||||||
WallpaperColors wallpaperColors) {
|
WallpaperColors wallpaperColorsOverride) {
|
||||||
|
|
||||||
super(context);
|
super(context);
|
||||||
mUiHandler = new Handler(Looper.getMainLooper());
|
mUiHandler = new Handler(Looper.getMainLooper());
|
||||||
|
@ -280,16 +282,18 @@ public class LauncherPreviewRenderer extends ContextWrapper
|
||||||
mDp.workspacePadding.bottom);
|
mDp.workspacePadding.bottom);
|
||||||
mWorkspaceScreens.put(FIRST_SCREEN_ID, firstScreen);
|
mWorkspaceScreens.put(FIRST_SCREEN_ID, firstScreen);
|
||||||
|
|
||||||
if (FeatureFlags.WIDGETS_IN_LAUNCHER_PREVIEW.get()) {
|
if (Utilities.ATLEAST_S) {
|
||||||
mAppWidgetHost = new LauncherPreviewAppWidgetHost(context);
|
WallpaperColors wallpaperColors = wallpaperColorsOverride != null
|
||||||
mWallpaperColorResources = wallpaperColors != null
|
? wallpaperColorsOverride
|
||||||
? LocalColorExtractor.newInstance(context)
|
: WallpaperManager.getInstance(context).getWallpaperColors(FLAG_SYSTEM);
|
||||||
.generateColorsOverride(wallpaperColors)
|
mWallpaperColorResources = LocalColorExtractor.newInstance(context)
|
||||||
: null;
|
.generateColorsOverride(wallpaperColors);
|
||||||
} else {
|
} else {
|
||||||
mAppWidgetHost = null;
|
|
||||||
mWallpaperColorResources = null;
|
mWallpaperColorResources = null;
|
||||||
}
|
}
|
||||||
|
mAppWidgetHost = FeatureFlags.WIDGETS_IN_LAUNCHER_PREVIEW.get()
|
||||||
|
? new LauncherPreviewAppWidgetHost(context)
|
||||||
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Populate preview and render it. */
|
/** Populate preview and render it. */
|
||||||
|
@ -405,6 +409,10 @@ public class LauncherPreviewRenderer extends ContextWrapper
|
||||||
view.updateAppWidget(null);
|
view.updateAppWidget(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mWallpaperColorResources != null) {
|
||||||
|
view.setColorResources(mWallpaperColorResources);
|
||||||
|
}
|
||||||
|
|
||||||
view.setTag(info);
|
view.setTag(info);
|
||||||
addInScreenFromBind(view, info);
|
addInScreenFromBind(view, info);
|
||||||
}
|
}
|
||||||
|
@ -537,12 +545,9 @@ public class LauncherPreviewRenderer extends ContextWrapper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class LauncherPreviewAppWidgetHostView extends BaseLauncherAppWidgetHostView {
|
private static class LauncherPreviewAppWidgetHostView extends BaseLauncherAppWidgetHostView {
|
||||||
private LauncherPreviewAppWidgetHostView(Context context) {
|
private LauncherPreviewAppWidgetHostView(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
if (Utilities.ATLEAST_S && mWallpaperColorResources != null) {
|
|
||||||
setColorResources(mWallpaperColorResources);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue