-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fixes: #26052 remove WallpaperManager::updateWallpaper #26249
Fixes: #26052 remove WallpaperManager::updateWallpaper #26249
Conversation
24bf695
to
8c1f6a5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couple nits. Unrelated follow-up, I also noticed that the WallpaperThumbnailsPreview
doesn't render, probably because it's using the .components
extension.
when (wallpaper) { | ||
is Wallpaper.Local -> loadWallpaperFromDrawables(context, wallpaper) | ||
is Wallpaper.Remote -> loadWallpaperFromDisk(context, wallpaper) | ||
fun Wallpaper.load(context: Context): Bitmap? = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Should this extension instead live in a extension function file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one technically could, but structuring it this way was an intentional plan for refactoring the WallpaperManager
as a WallpaperUseCase
. It forces a client to have a reference to the UseCase
to be able to load wallpapers. That way, we can treat the UseCase as an abstraction barrier. Right now, all the loading is done using implicit Context
-dependent stuff, but I imagine the callstack would look more like this soon:
with (wallpaperUseCase) {
wallpaper.load() -> wallpaperUseCase.fileManager.loadWallpaper()
}
Not sure that notation really makes sense lol. But basically we could inject the context
(or a WallpaperLoader
or whatever else we wanted to use to actually do disk reading) into the object hierarchy and hide it from call sites of wallpaper.load()
.
Sidenote: the pattern here might be more clear if we were on Kotlin 1.6.20 and could use context receivers.
* correctly fit the aspect ratio of the view, it will be shifted to prioritize the bottom-left | ||
* of the bitmap. | ||
*/ | ||
fun Bitmap.scaleBitmapToBottomOfView(view: ImageView) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Should this extension instead live in a extension function file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one would make more sense to move into an extension function file, IMO, because it isn't necessarily a strictly wallpaper-related function. I just always worry about polluting namespaces without an obvious need. I'd defer to your opinion if you think we should move it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel super strongly either way, so if you feel this will be used elsewhere, I'd lean that way. Otherwise, it can just live here for now.
Oh thanks, that would definitely explain it! Are there any easy ways around that or would I need to manually instantiate anything I use in previews? |
You would need to either manually instantiate the real-world use-case or just abstract-out that dependency so either only a lambda or a list<> can be passed-in. If something further upstream needs the context, then we have to do an |
Note: the test that was removed in the diff was failing, but that functionality will be removed soon anyway in #25985. I was having trouble getting the UI tests to run locally, and there's quite a lot of follow-up work for this PR so I decided to go with the fastest option. I'll squash before I land |
9a0dbb3
to
ecbf9bc
Compare
ecbf9bc
to
9f9ead2
Compare
This is part of #26034. The main point of this PR was to remove
updateWallpaper
, which included the side-effect of updating thecurrentWallpaper
, which should instead now be handled by dispatching theUpdateCurrentWallpaper
.The next step will likely be to refactor the
WallpaperManager
into aWallpaperUseCase
, as filed in #26245. That patch will probably introduce the largest number of changes in this initiative.Pull Request checklist
QA
To download an APK when reviewing a PR (after all CI tasks finished running):
Checks
at the top of the PR page.firefoxci-taskcluster
group on the left to expand all tasks.build-debug
task.View task in Taskcluster
in the newDETAILS
section.GitHub Automation
Fixes #26052