feat: Better At-a-Glance perceptive wallpaper colour luminance detection

This commit is contained in:
Pun Butrach committed 2026-01-10 20:49:46 +07:00
1 parent 19eb97e405
commit d36845897b
1639 files changed
+93897 -146732

No files matched your search

+26 -8
View File
@@ -65,6 +65,7 @@ import com.android.launcher3.views.ActivityContext;
import java.util.ArrayList;
import java.util.function.Consumer;
import app.lawnchair.preferences.PreferenceManager;
import app.lawnchair.ui.StretchEdgeEffect;
/**
@@ -85,6 +86,8 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
private static final float SIGNIFICANT_MOVE_THRESHOLD = 0.4f;
private static final float MAX_SCROLL_PROGRESS = 1.0f;
private PreferenceManager prefs = PreferenceManager.getInstance(getContext());
private boolean mFreeScroll = false;
@@ -790,6 +793,13 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
}
if (mScroller.isFinished() && pageScrollChanged) {
// TODO(b/246283207): Remove logging once root cause of flake detected.
if (Utilities.isRunningInTestHarness() && !(this instanceof Workspace)) {
Log.d("b/246283207", TAG + "#onLayout() -> "
+ "if(mScroller.isFinished() && pageScrollChanged) -> getNextPage(): "
+ getNextPage() + ", getScrollForPage(getNextPage()): "
+ getScrollForPage(getNextPage()));
}
setCurrentPage(getNextPage());
}
onPageScrollsInitialized();
@@ -1416,19 +1426,27 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
// test for a large move if a fling has been registered. That is, a large
// move to the left and fling to the right will register as a fling to the right.
boolean infiniteScroll = prefs.getInstance(getContext()).getInfiniteScrolling().get();
if (((isSignificantMove && !isDeltaLeft && !isFling) ||
(isFling && !isVelocityLeft)) && mCurrentPage > 0) {
finalPage = returnToOriginalPage
? mCurrentPage : mCurrentPage - getPanelCount();
runOnPageScrollsInitialized(
() -> snapToPageWithVelocity(finalPage, velocity));
} else if (((isSignificantMove && isDeltaLeft && !isFling) ||
(isFling && isVelocityLeft)) &&
mCurrentPage < getChildCount() - 1) {
finalPage = returnToOriginalPage
? mCurrentPage : mCurrentPage + getPanelCount();
runOnPageScrollsInitialized(
() -> snapToPageWithVelocity(finalPage, velocity));
() -> snapToPageWithVelocity(finalPage, velocity));
} else if (((isSignificantMove && isDeltaLeft && !isFling) || (isFling && isVelocityLeft)) && mCurrentPage < getChildCount() - 1) {
finalPage = returnToOriginalPage ? mCurrentPage : mCurrentPage + getPanelCount();
runOnPageScrollsInitialized(() -> snapToPageWithVelocity(finalPage, velocity));
} else if (mCurrentPage == getChildCount() - 1 && infiniteScroll) {
finalPage = returnToOriginalPage ? mCurrentPage : 0;
snapToPageWithVelocity(finalPage, velocity);
} else if (mCurrentPage == 0 && infiniteScroll) {
finalPage = returnToOriginalPage ? mCurrentPage : getChildCount() - 1;
snapToPageWithVelocity(finalPage, velocity);
} else {
runOnPageScrollsInitialized(this::snapToDestination);
}