From 2e1f4a2d313da8d5ecb32bcd97d0ad950c98fb70 Mon Sep 17 00:00:00 2001 From: Charles Munger Date: Fri, 21 Aug 2020 04:57:54 +0000 Subject: [PATCH] Mark the onClick view/menu attribute as deprecated. Bug: 144042891 Change-Id: I62461085e6d507e3b5e725141380dd390c9b8b0b --- api/current.txt | 2 +- core/res/res/values/attrs.xml | 12 ++++++++++-- non-updatable-api/current.txt | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/api/current.txt b/api/current.txt index c6af6beca60be..5b1ff91f0ac2d 100644 --- a/api/current.txt +++ b/api/current.txt @@ -1005,7 +1005,7 @@ package android { field public static final int numericModifiers = 16844111; // 0x101054f field public static final int numericShortcut = 16843236; // 0x10101e4 field public static final int offset = 16844052; // 0x1010514 - field public static final int onClick = 16843375; // 0x101026f + field @Deprecated public static final int onClick = 16843375; // 0x101026f field public static final int oneshot = 16843159; // 0x1010197 field public static final int opacity = 16843550; // 0x101031e field public static final int opticalInsetBottom = 16844171; // 0x101058b diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 2b511706d0241..20ef017f59f8b 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -2784,7 +2784,11 @@ exactly one parameter of type View. For instance, if you specify android:onClick="sayHello", you must declare a public void sayHello(View v) method of your context - (typically, your Activity). --> + (typically, your Activity). + {@deprecated View actually traverses the Context + hierarchy looking for the relevant method, which is fragile (an intermediate + ContextWrapper adding a same-named method would change behavior) and restricts + bytecode optimizers such as R8. Instead, use View.setOnClickListener.}--> + called when the item is clicked. + {@deprecated Menu actually traverses the Context hierarchy looking for the + relevant method, which is fragile (an intermediate ContextWrapper adding a + same-named method would change behavior) and restricts bytecode optimizers + such as R8. Instead, use MenuItem.setOnMenuItemClickListener.} --> diff --git a/non-updatable-api/current.txt b/non-updatable-api/current.txt index e0ebec6cbd014..e1a7d7f05ccd1 100644 --- a/non-updatable-api/current.txt +++ b/non-updatable-api/current.txt @@ -1005,7 +1005,7 @@ package android { field public static final int numericModifiers = 16844111; // 0x101054f field public static final int numericShortcut = 16843236; // 0x10101e4 field public static final int offset = 16844052; // 0x1010514 - field public static final int onClick = 16843375; // 0x101026f + field @Deprecated public static final int onClick = 16843375; // 0x101026f field public static final int oneshot = 16843159; // 0x1010197 field public static final int opacity = 16843550; // 0x101031e field public static final int opticalInsetBottom = 16844171; // 0x101058b