1

I'm trying to create a simple Android Launcher.

I'm also using a live wallpaper (Kustom LWP) that I can tap certain areas of to perform actions.

I'm able to see the wallpaper using these style properties:

<item name="android:windowIsTranslucent">true</item>
<item name="android:windowShowWallpaper">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>

But if I try to tap an item on my wallpaper, the touch doesn't pass through.

I've tried android:clickable="false and android:focusable="false", and setting all of my views to have a setOnTouchListener that returns false, but none of these fix the issue.

How would I go about doing this?

1 Answers1

0

Answering my own question: after doing some digging in Launcher3, I found that I needed to use WallpaperManager's sendWallpaperCommand function on the touch listener for your homescreen view:

import android.app.WallpaperManager;

private final int[] mTempXY = new int[2];
WallpaperManager mWallpaperManager = WallpaperManager.getInstance(context);

...

homeScreenView.setOnTouchListener((v, event) -> {
    onWallpaperTap(v,event);
    return true;
});

...

protected void onWallpaperTap(View view, MotionEvent ev) {
    final int[] position = mTempXY;
    view.getLocationOnScreen(position);

    int pointerIndex = ev.getActionIndex();
    position[0] += (int) ev.getX(pointerIndex);
    position[1] += (int) ev.getY(pointerIndex);

    MainActivity.mWallpaperManager.sendWallpaperCommand(view.getWindowToken(),
            ev.getAction() == MotionEvent.ACTION_UP
                    ? WallpaperManager.COMMAND_TAP : WallpaperManager.COMMAND_SECONDARY_TAP,
            position[0], position[1], 0, null);
}

And now my wallpaper can receive touch input.