Loading toruslib/torus-core/src/main/java/com/google/android/torus/core/engine/listener/TorusTouchListener.kt +17 −4 Original line number Diff line number Diff line Loading @@ -20,14 +20,27 @@ import android.view.MotionEvent import com.google.android.torus.core.engine.TorusEngine /** * Allows to receive Touch events. * The Interface must be implemented by a [TorusEngine] instance, * Allows to receive Touch events. The Interface must be implemented by a [TorusEngine] instance, */ interface TorusTouchListener { /** * Called when a touch event has been triggered. * Called when a touch event has been triggered. If the engine is set as a wallpaper and the * device is locked, touch events may be restricted. Only taps on the lock screen's focal area * will be delivered via [onLockscreenFocalAreaTap]. See [onLockscreenFocalAreaTap] for details. * * @param event The new [MotionEvent]. */ fun onTouchEvent(event: MotionEvent) /** * Called when a short tap occurs on the wallpaper's focal area on the lock screen. * * The wallpaper's focal area is the interactive region of the wallpaper that is not obscured by * other lock screen elements. The wallpaper is scaled on the lock screen. These coordinates are * relative to the unscaled wallpaper. * * @param x The x-coordinate of the tap, relative to the unscaled wallpaper dimensions. * @param y The y-coordinate of the tap, relative to the unscaled wallpaper dimensions. */ fun onLockscreenFocalAreaTap(x: Int, y: Int) {} } toruslib/torus-core/src/main/java/com/google/android/torus/core/wallpaper/LiveWallpaper.kt +6 −6 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ abstract class LiveWallpaper : WallpaperService() { const val COMMAND_GOING_TO_SLEEP = "android.wallpaper.goingtosleep" const val COMMAND_PREVIEW_INFO = "android.wallpaper.previewinfo" const val COMMAND_LOCKSCREEN_LAYOUT_CHANGED = "android.wallpaper.lockscreen_layout_changed" const val COMMAND_LOCKSCREEN_TAP_POSITION = "android.wallpaper.lockscreen_tap_position" const val COMMAND_LOCKSCREEN_TAP = "android.wallpaper.lockscreen_tap" const val WALLPAPER_FLAG_NOT_FOUND = -1 } Loading Loading @@ -413,9 +413,9 @@ abstract class LiveWallpaper : WallpaperService() { onLockscreenLayoutChanged(extras) } } COMMAND_LOCKSCREEN_TAP_POSITION -> { COMMAND_LOCKSCREEN_TAP -> { if (extras != null) { onLockscreenFocalAreaTap(extras) onLockscreenFocalAreaTap(x, y) } } } Loading Loading @@ -482,9 +482,9 @@ abstract class LiveWallpaper : WallpaperService() { } } fun onLockscreenFocalAreaTap(extras: Bundle) { if (wallpaperEngine is LiveWallpaperEventListener) { (wallpaperEngine as LiveWallpaperEventListener).onLockscreenFocalAreaTap(extras) fun onLockscreenFocalAreaTap(x: Int, y: Int) { if (wallpaperEngine is TorusTouchListener) { (wallpaperEngine as TorusTouchListener).onLockscreenFocalAreaTap(x, y) } } } Loading toruslib/torus-core/src/main/java/com/google/android/torus/core/wallpaper/listener/LiveWallpaperEventListener.kt +0 −7 Original line number Diff line number Diff line Loading @@ -150,11 +150,4 @@ interface LiveWallpaperEventListener { // TODO: when smartspace is moved from below small clock to the right of the clock, we need to // change all smartspace bottom mentioned above to small clock bottom fun onLockscreenLayoutChanged(extras: Bundle) {} /** * Make wallpaper be able to react to short tap event on lockscreen. Tap should be within the * wallpaper focal area, extras contains position applied on wallpaper, including * "tapInWallpaperFocalAreaX" and "tapInWallpaperFocalAreaY". */ fun onLockscreenFocalAreaTap(extras: Bundle) {} } Loading
toruslib/torus-core/src/main/java/com/google/android/torus/core/engine/listener/TorusTouchListener.kt +17 −4 Original line number Diff line number Diff line Loading @@ -20,14 +20,27 @@ import android.view.MotionEvent import com.google.android.torus.core.engine.TorusEngine /** * Allows to receive Touch events. * The Interface must be implemented by a [TorusEngine] instance, * Allows to receive Touch events. The Interface must be implemented by a [TorusEngine] instance, */ interface TorusTouchListener { /** * Called when a touch event has been triggered. * Called when a touch event has been triggered. If the engine is set as a wallpaper and the * device is locked, touch events may be restricted. Only taps on the lock screen's focal area * will be delivered via [onLockscreenFocalAreaTap]. See [onLockscreenFocalAreaTap] for details. * * @param event The new [MotionEvent]. */ fun onTouchEvent(event: MotionEvent) /** * Called when a short tap occurs on the wallpaper's focal area on the lock screen. * * The wallpaper's focal area is the interactive region of the wallpaper that is not obscured by * other lock screen elements. The wallpaper is scaled on the lock screen. These coordinates are * relative to the unscaled wallpaper. * * @param x The x-coordinate of the tap, relative to the unscaled wallpaper dimensions. * @param y The y-coordinate of the tap, relative to the unscaled wallpaper dimensions. */ fun onLockscreenFocalAreaTap(x: Int, y: Int) {} }
toruslib/torus-core/src/main/java/com/google/android/torus/core/wallpaper/LiveWallpaper.kt +6 −6 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ abstract class LiveWallpaper : WallpaperService() { const val COMMAND_GOING_TO_SLEEP = "android.wallpaper.goingtosleep" const val COMMAND_PREVIEW_INFO = "android.wallpaper.previewinfo" const val COMMAND_LOCKSCREEN_LAYOUT_CHANGED = "android.wallpaper.lockscreen_layout_changed" const val COMMAND_LOCKSCREEN_TAP_POSITION = "android.wallpaper.lockscreen_tap_position" const val COMMAND_LOCKSCREEN_TAP = "android.wallpaper.lockscreen_tap" const val WALLPAPER_FLAG_NOT_FOUND = -1 } Loading Loading @@ -413,9 +413,9 @@ abstract class LiveWallpaper : WallpaperService() { onLockscreenLayoutChanged(extras) } } COMMAND_LOCKSCREEN_TAP_POSITION -> { COMMAND_LOCKSCREEN_TAP -> { if (extras != null) { onLockscreenFocalAreaTap(extras) onLockscreenFocalAreaTap(x, y) } } } Loading Loading @@ -482,9 +482,9 @@ abstract class LiveWallpaper : WallpaperService() { } } fun onLockscreenFocalAreaTap(extras: Bundle) { if (wallpaperEngine is LiveWallpaperEventListener) { (wallpaperEngine as LiveWallpaperEventListener).onLockscreenFocalAreaTap(extras) fun onLockscreenFocalAreaTap(x: Int, y: Int) { if (wallpaperEngine is TorusTouchListener) { (wallpaperEngine as TorusTouchListener).onLockscreenFocalAreaTap(x, y) } } } Loading
toruslib/torus-core/src/main/java/com/google/android/torus/core/wallpaper/listener/LiveWallpaperEventListener.kt +0 −7 Original line number Diff line number Diff line Loading @@ -150,11 +150,4 @@ interface LiveWallpaperEventListener { // TODO: when smartspace is moved from below small clock to the right of the clock, we need to // change all smartspace bottom mentioned above to small clock bottom fun onLockscreenLayoutChanged(extras: Bundle) {} /** * Make wallpaper be able to react to short tap event on lockscreen. Tap should be within the * wallpaper focal area, extras contains position applied on wallpaper, including * "tapInWallpaperFocalAreaX" and "tapInWallpaperFocalAreaY". */ fun onLockscreenFocalAreaTap(extras: Bundle) {} }