Use if instead of switch for resources
Converting to Soong will move some code from directly compiled into the app to compiled into an Android library and then shared between the app and the tests. This will cause resource IDs in the library to become non-final, which means they can no longer be used in case statements. Convert affect case statements to if blocks. Test: m RunSettingsRoboTests Change-Id: I25742a374f06d3fa4decbfc0d223a350acc50881
This commit is contained in:
@@ -153,17 +153,15 @@ public class VpnSettings extends RestrictedSettingsFragment implements
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.vpn_create: {
|
||||
// Generate a new key. Here we just use the current time.
|
||||
long millis = System.currentTimeMillis();
|
||||
while (mLegacyVpnPreferences.containsKey(Long.toHexString(millis))) {
|
||||
++millis;
|
||||
}
|
||||
VpnProfile profile = new VpnProfile(Long.toHexString(millis));
|
||||
ConfigDialogFragment.show(this, profile, true /* editing */, false /* exists */);
|
||||
return true;
|
||||
// Generate a new key. Here we just use the current time.
|
||||
if (item.getItemId() == R.id.vpn_create) {
|
||||
long millis = System.currentTimeMillis();
|
||||
while (mLegacyVpnPreferences.containsKey(Long.toHexString(millis))) {
|
||||
++millis;
|
||||
}
|
||||
VpnProfile profile = new VpnProfile(Long.toHexString(millis));
|
||||
ConfigDialogFragment.show(this, profile, true /* editing */, false /* exists */);
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
Reference in New Issue
Block a user