From 610e43f90eae6da890e9c237dd1866668be9779f Mon Sep 17 00:00:00 2001 From: Brian Isganitis Date: Tue, 29 Jun 2021 18:12:38 -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. Fix: 191623924 Change-Id: Iac7eab057ec33ff491365a993af75a0b06a27f7e Merged-In: 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 2a1aec84a3..cf3da4b9b7 100644 --- a/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java +++ b/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java @@ -43,6 +43,7 @@ import android.os.Process; import android.util.AttributeSet; import android.view.ContextThemeWrapper; import android.view.LayoutInflater; +import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.WindowInsets; @@ -467,4 +468,16 @@ public class LauncherPreviewRenderer extends ContextWrapper view.measure(makeMeasureSpec(width, EXACTLY), makeMeasureSpec(height, EXACTLY)); view.layout(0, 0, width, height); } + + /** 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; + } + } }