From 3b39f3164b936527892eb229cedb0b9bdb92aefd Mon Sep 17 00:00:00 2001 From: Brian Isganitis Date: Tue, 29 Jun 2021 16:03:55 -0400 Subject: [PATCH] Intercept touch events for launcher preview root view This change prevents any accidental touches on any widgets in the preview. Test: Tapping on launcher preview in wallpaper app should never activate a widget. Bug: 191623924 Change-Id: I98d462eca699cf368dcd5894f15584f280932ccc --- res/layout/launcher_preview_layout.xml | 4 ++-- .../launcher3/graphics/LauncherPreviewRenderer.java | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/res/layout/launcher_preview_layout.xml b/res/layout/launcher_preview_layout.xml index 16916800f3..cf2f2c75ee 100644 --- a/res/layout/launcher_preview_layout.xml +++ b/res/layout/launcher_preview_layout.xml @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. --> - - \ No newline at end of file + \ No newline at end of file diff --git a/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java b/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java index cfb38e5d6e..1127ff907a 100644 --- a/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java +++ b/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java @@ -46,6 +46,7 @@ import android.util.AttributeSet; import android.util.SparseIntArray; import android.view.ContextThemeWrapper; import android.view.LayoutInflater; +import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.WindowInsets; @@ -534,4 +535,16 @@ public class LauncherPreviewRenderer extends ContextWrapper return false; } } + + /** Root layout for launcher preview that intercepts all touch events. */ + public static class LauncherPreviewLayout extends InsettableFrameLayout { + public LauncherPreviewLayout(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + return true; + } + } }