Skip to content

Commit 24ba289

Browse files
committed
Fix non-final R class errors
Starting from AGP 8.0 R class properties are non-final. Switch-case expects properties, therefore, replacing it with plain-old .
1 parent d1a52de commit 24ba289

File tree

6 files changed

+25
-49
lines changed

6 files changed

+25
-49
lines changed

Diff for: demos/custom-tabs-example-app/src/main/java/org/chromium/customtabsdemos/CustomUIActivity.java

+2-6
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,8 @@ protected void onStop() {
8686
@Override
8787
public void onClick(View v) {
8888
int viewId = v.getId();
89-
switch (viewId) {
90-
case R.id.start_custom_tab:
91-
openCustomTab();
92-
break;
93-
default:
94-
//Unknown View Clicked
89+
if (viewId == R.id.start_custom_tab) {
90+
openCustomTab();
9591
}
9692
}
9793

Diff for: demos/custom-tabs-example-app/src/main/java/org/chromium/customtabsdemos/EngagementSignalsActivity.java

+2-6
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,8 @@ private void unbindCustomTabsService() {
183183
@Override
184184
public void onClick(View v) {
185185
int viewId = v.getId();
186-
switch (viewId) {
187-
case R.id.start_custom_tab:
188-
openCustomTab();
189-
break;
190-
default:
191-
// Unknown View Clicked
186+
if (viewId == R.id.start_custom_tab) {
187+
openCustomTab();
192188
}
193189
}
194190

Diff for: demos/custom-tabs-example-app/src/main/java/org/chromium/customtabsdemos/NotificationParentActivity.java

+6-8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
package org.chromium.customtabsdemos;
1616

17+
import static org.chromium.customtabsdemos.R.*;
18+
1719
import android.app.NotificationChannel;
1820
import android.app.NotificationManager;
1921
import android.app.PendingIntent;
@@ -60,13 +62,9 @@ protected void onNewIntent(Intent intent) {
6062
@Override
6163
public void onClick(View v) {
6264
int viewId = v.getId();
63-
switch (viewId) {
64-
case R.id.create_notification:
65-
createAndShowNotification();
66-
finish();
67-
break;
68-
default:
69-
//Unknown view clicked
65+
if (viewId == R.id.create_notification) {
66+
createAndShowNotification();
67+
finish();
7068
}
7169
}
7270

@@ -81,7 +79,7 @@ private void createAndShowNotification() {
8179
}
8280
NotificationCompat.Builder mBuilder =
8381
new NotificationCompat.Builder(this, CT_NOTIFICATION_CHANNEL_ID)
84-
.setSmallIcon(R.drawable.abc_popup_background_mtrl_mult)
82+
.setSmallIcon(androidx.appcompat.R.drawable.abc_popup_background_mtrl_mult)
8583
.setContentTitle(getString(R.string.notification_title))
8684
.setContentText(getString(R.string.notification_text));
8785

Diff for: demos/custom-tabs-example-app/src/main/java/org/chromium/customtabsdemos/PartialCustomTabActivity.java

+2-6
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,8 @@ protected void onStop() {
136136
@Override
137137
public void onClick(View v) {
138138
int viewId = v.getId();
139-
switch (viewId) {
140-
case R.id.start_custom_tab:
141-
openCustomTab();
142-
break;
143-
default:
144-
// Unknown View Clicked
139+
if (viewId == R.id.start_custom_tab) {
140+
openCustomTab();
145141
}
146142
}
147143

Diff for: demos/custom-tabs-example-app/src/main/java/org/chromium/customtabsdemos/ServiceConnectionActivity.java

+8-13
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,14 @@ public void onCustomTabsDisconnected() {
6969
public void onClick(View view) {
7070
int viewId = view.getId();
7171
Uri uri = Uri.parse(mUrlEditText.getText().toString());
72-
switch (viewId) {
73-
case R.id.button_may_launch_url:
74-
customTabActivityHelper.mayLaunchUrl(uri, null, null);
75-
break;
76-
case R.id.start_custom_tab:
77-
CustomTabsIntent customTabsIntent =
78-
new CustomTabsIntent.Builder(customTabActivityHelper.getSession())
79-
.build();
80-
CustomTabActivityHelper.openCustomTab(
81-
this, customTabsIntent, uri, new WebviewFallback());
82-
break;
83-
default:
84-
//Unkown View Clicked
72+
if (viewId == R.id.button_may_launch_url) {
73+
customTabActivityHelper.mayLaunchUrl(uri, null, null);
74+
} else if (viewId == R.id.start_custom_tab) {
75+
CustomTabsIntent customTabsIntent =
76+
new CustomTabsIntent.Builder(customTabActivityHelper.getSession())
77+
.build();
78+
CustomTabActivityHelper.openCustomTab(
79+
this, customTabsIntent, uri, new WebviewFallback());
8580
}
8681
}
8782
}

Diff for: demos/custom-tabs-example-app/src/main/java/org/chromium/customtabsdemos/SimpleCustomTabActivity.java

+5-10
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,11 @@ protected void onCreate(Bundle savedInstanceState) {
4040
@Override
4141
public void onClick(View v) {
4242
int viewId = v.getId();
43-
44-
switch (viewId) {
45-
case R.id.start_custom_tab:
46-
String url = mUrlEditText.getText().toString();
47-
CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder().build();
48-
CustomTabActivityHelper.openCustomTab(
49-
this, customTabsIntent, Uri.parse(url), new WebviewFallback());
50-
break;
51-
default:
52-
//Unknown View Clicked
43+
if (viewId == R.id.start_custom_tab) {
44+
String url = mUrlEditText.getText().toString();
45+
CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder().build();
46+
CustomTabActivityHelper.openCustomTab(
47+
this, customTabsIntent, Uri.parse(url), new WebviewFallback());
5348
}
5449
}
5550
}

0 commit comments

Comments
 (0)