Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0e70d218 authored by Amit Kumar's avatar Amit Kumar 💻
Browse files

Fix widget page lag and add touch listener to grid layout

parent c57957cb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -285,7 +285,7 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
    }

    public void bindAndInitFirstScreen(View view) {
        // Do nothing here.

    }

    public void removeAllWorkspaceScreens() {
+4 −0
Original line number Diff line number Diff line
@@ -174,6 +174,10 @@ open class CellLayout @JvmOverloads constructor(
            })
            mDragOutlineAnims[i] = anim
        }

        setOnClickListener {
            launcher.getLauncherPagedView().setWobbleExpirationAlarm(0) // Stop wobbling immediately if empty space is touched.
        }
    }

    override fun onMeasure(widthSpec: Int, heightSpec: Int) {
+14 −0
Original line number Diff line number Diff line
@@ -19,6 +19,10 @@ public class WidgetsRootView extends HorizontalScrollView {

    private boolean shouldScrollWorkspace = true;

    // The following constants need to be scaled based on density. The scaled versions will be
    // assigned to the corresponding member variables below.
    private static final int FLING_THRESHOLD_VELOCITY = 500;

    public WidgetsRootView(Context context) {
        super(context);
        init();
@@ -55,6 +59,16 @@ public class WidgetsRootView extends HorizontalScrollView {
        }
    }

    @Override
    public void fling(int velocityX) {
        super.fling(velocityX);
        float density = getResources().getDisplayMetrics().density;
        if (Math.abs(velocityX) > FLING_THRESHOLD_VELOCITY * density) {
            shouldScrollWorkspace = !shouldScrollWorkspace;
            overlay.onScrollInteractionEnd();
        }
    }

    @Override
    protected boolean overScrollBy(
        int deltaX,
+5 −2
Original line number Diff line number Diff line
@@ -15,6 +15,9 @@ public class OverlayCallbackImpl implements TestActivity.LauncherOverlay {

    private TestActivity.LauncherOverlayCallbacks mLauncherOverlayCallbacks;

    // The page is moved more than halfway, automatically move to the next page on touch up.
    private static final float SIGNIFICANT_MOVE_THRESHOLD = 0.4f;

    public OverlayCallbackImpl(TestActivity launcher) {
        this.mLauncher = launcher;
    }
@@ -27,10 +30,10 @@ public class OverlayCallbackImpl implements TestActivity.LauncherOverlay {
    @Override
    public void onScrollInteractionEnd() {
        if(scrollFromWorkspace) {
            if(mProgress >= 0.5f) mLauncherOverlayCallbacks.onScrollEnd(1f, true);
            if(mProgress >= SIGNIFICANT_MOVE_THRESHOLD) mLauncherOverlayCallbacks.onScrollEnd(1f, true);
            else mLauncherOverlayCallbacks.onScrollEnd(0f, true);
        } else {
            if(mProgress < 0.5f) mLauncherOverlayCallbacks.onScrollEnd(0f, false);
            if(mProgress < SIGNIFICANT_MOVE_THRESHOLD) mLauncherOverlayCallbacks.onScrollEnd(0f, false);
            else mLauncherOverlayCallbacks.onScrollEnd(1f, false);
        }
    }