Dimezis / BlurView

Dynamic iOS-like blur of underlying Views for Android
Apache License 2.0
3.48k stars 331 forks source link

Bring back old setupWith method and allow null `BlurAlgorithm` #188

Closed Fox2Code closed 1 year ago

Fox2Code commented 1 year ago

I recently upgraded from 1.6.6 to 2.0.2 and I noticed setupWith method signature changed.

Bring back the old setupWith by choosing best available algorithm with of few thing I would like as a developer.

Also only using one instance of NoOpController instead of making one for each BlurView.

Fox2Code commented 1 year ago

By doing testes, I found out scaleFactor was the reason why #186 was happening. Adding the fix to this PR as there is no other way to implement it than to add a setupWith parameter, and I don't want to push conflicting PRs.

Dimezis commented 1 year ago

Thanks for trying to help, but this PR is a no-go for me, sorry! I don't agree with the setupWith change, and the scaleFactor can already be changed if you want to (but it's better to mitigate the scaling issue with just a bigger blur radius, as I mentioned in the corresponding issue)

Fox2Code commented 1 year ago

Or overriding scaleFactor on the BlurAlgorithm works too, I thinks it's better like that, I'll revert the last commit.

Fox2Code commented 1 year ago

I reverted the commit, if you are still not ok with only theses changes, feel free to close this PR.

Vittt2008 commented 1 year ago

Hey people, especially @Fox2Code and @Dimezis Why not just have 2 versions of the method? In this case, we could extract all logic into chooseDefaultAlgorithm() method where there would be all API version checks. And on the other hand we have a power to give users create their own BlurAlgorithm


public class BlurView extends FrameLayout {

    public BlurViewFacade setupWith(@NonNull ViewGroup rootView) {
        final BlurAlgorithm algorithm = chooseDefaultAlgorithm();
        setupWith(rootView, algorithm)
    }

    public BlurViewFacade setupWith(@NonNull ViewGroup rootView, BlurAlgorithm algorithm) {
        ...
    }
}
Dimezis commented 1 year ago

I added a convenience setupWith method in 2.0.3