Merge "Use if instead of switch for resources" into qt-dev-plus-aosp

This commit is contained in:
Colin Cross
2019-05-14 23:33:25 +00:00
committed by Android (Google) Code Review
12 changed files with 297 additions and 367 deletions

View File

@@ -197,8 +197,7 @@ public class ToggleAccessibilityServicePreferenceFragment
@Override @Override
public void onClick(View view) { public void onClick(View view) {
switch (view.getId()) { if (view.getId() == R.id.permission_enable_allow_button) {
case R.id.permission_enable_allow_button:
if (isFullDiskEncrypted()) { if (isFullDiskEncrypted()) {
String title = createConfirmCredentialReasonMessage(); String title = createConfirmCredentialReasonMessage();
Intent intent = ConfirmDeviceCredentialActivity.createIntent(title, null); Intent intent = ConfirmDeviceCredentialActivity.createIntent(title, null);
@@ -207,17 +206,13 @@ public class ToggleAccessibilityServicePreferenceFragment
} else { } else {
handleConfirmServiceEnabled(true); handleConfirmServiceEnabled(true);
} }
break; } else if (view.getId() == R.id.permission_enable_deny_button) {
case R.id.permission_enable_deny_button:
handleConfirmServiceEnabled(false); handleConfirmServiceEnabled(false);
break; } else if (view.getId() == R.id.permission_disable_stop_button) {
case R.id.permission_disable_stop_button:
handleConfirmServiceEnabled(false); handleConfirmServiceEnabled(false);
break; } else if (view.getId() == R.id.permission_disable_cancel_button) {
case R.id.permission_disable_cancel_button:
handleConfirmServiceEnabled(true); handleConfirmServiceEnabled(true);
break; } else {
default:
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
mDialog.dismiss(); mDialog.dismiss();

View File

@@ -690,22 +690,18 @@ public class ManageApplications extends InstrumentedFragment
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
int menuId = item.getItemId(); int menuId = item.getItemId();
switch (item.getItemId()) { int i = item.getItemId();
case R.id.sort_order_alpha: if (i == R.id.sort_order_alpha || i == R.id.sort_order_size) {
case R.id.sort_order_size:
if (mApplications != null) { if (mApplications != null) {
mApplications.rebuild(menuId); mApplications.rebuild(menuId);
} }
break; } else if (i == R.id.show_system || i == R.id.hide_system) {
case R.id.show_system:
case R.id.hide_system:
mShowSystem = !mShowSystem; mShowSystem = !mShowSystem;
mApplications.rebuild(); mApplications.rebuild();
break; } else if (i == R.id.reset_app_preferences) {
case R.id.reset_app_preferences:
mResetAppsHelper.buildResetDialog(); mResetAppsHelper.buildResetDialog();
return true; return true;
case R.id.advanced: } else if (i == R.id.advanced) {
if (mListType == LIST_TYPE_NOTIFICATION) { if (mListType == LIST_TYPE_NOTIFICATION) {
new SubSettingLauncher(getContext()) new SubSettingLauncher(getContext())
.setDestination(ConfigureNotificationSettings.class.getName()) .setDestination(ConfigureNotificationSettings.class.getName())
@@ -719,8 +715,7 @@ public class ManageApplications extends InstrumentedFragment
startActivityForResult(intent, ADVANCED_SETTINGS); startActivityForResult(intent, ADVANCED_SETTINGS);
} }
return true; return true;
default: } else {// Handle the home button
// Handle the home button
return false; return false;
} }
updateOptionsMenu(); updateOptionsMenu();
@@ -1133,8 +1128,7 @@ public class ManageApplications extends InstrumentedFragment
ApplicationsState.FILTER_DOWNLOADED_AND_LAUNCHER); ApplicationsState.FILTER_DOWNLOADED_AND_LAUNCHER);
} }
} }
switch (mLastSortMode) { if (mLastSortMode == R.id.sort_order_size) {
case R.id.sort_order_size:
switch (mWhichSize) { switch (mWhichSize) {
case SIZE_INTERNAL: case SIZE_INTERNAL:
comparatorObj = ApplicationsState.INTERNAL_SIZE_COMPARATOR; comparatorObj = ApplicationsState.INTERNAL_SIZE_COMPARATOR;
@@ -1146,16 +1140,12 @@ public class ManageApplications extends InstrumentedFragment
comparatorObj = ApplicationsState.SIZE_COMPARATOR; comparatorObj = ApplicationsState.SIZE_COMPARATOR;
break; break;
} }
break; } else if (mLastSortMode == R.id.sort_order_recent_notification) {
case R.id.sort_order_recent_notification:
comparatorObj = AppStateNotificationBridge.RECENT_NOTIFICATION_COMPARATOR; comparatorObj = AppStateNotificationBridge.RECENT_NOTIFICATION_COMPARATOR;
break; } else if (mLastSortMode == R.id.sort_order_frequent_notification) {
case R.id.sort_order_frequent_notification:
comparatorObj = AppStateNotificationBridge.FREQUENCY_NOTIFICATION_COMPARATOR; comparatorObj = AppStateNotificationBridge.FREQUENCY_NOTIFICATION_COMPARATOR;
break; } else {
default:
comparatorObj = ApplicationsState.ALPHA_COMPARATOR; comparatorObj = ApplicationsState.ALPHA_COMPARATOR;
break;
} }
filterObj = new CompoundFilter(filterObj, ApplicationsState.FILTER_NOT_HIDE); filterObj = new CompoundFilter(filterObj, ApplicationsState.FILTER_NOT_HIDE);

View File

@@ -424,14 +424,14 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
final Context context = getActivity(); final Context context = getActivity();
final Bundle args = new Bundle(); final Bundle args = new Bundle();
switch (item.getItemId()) { int i = item.getItemId();
case R.id.storage_rename: if (i == R.id.storage_rename) {
RenameFragment.show(this, mVolume); RenameFragment.show(this, mVolume);
return true; return true;
case R.id.storage_mount: } else if (i == R.id.storage_mount) {
new MountTask(context, mVolume).execute(); new MountTask(context, mVolume).execute();
return true; return true;
case R.id.storage_unmount: } else if (i == R.id.storage_unmount) {
args.putString(VolumeInfo.EXTRA_VOLUME_ID, mVolume.getId()); args.putString(VolumeInfo.EXTRA_VOLUME_ID, mVolume.getId());
new SubSettingLauncher(context) new SubSettingLauncher(context)
.setDestination(PrivateVolumeUnmount.class.getCanonicalName()) .setDestination(PrivateVolumeUnmount.class.getCanonicalName())
@@ -440,7 +440,7 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
.setArguments(args) .setArguments(args)
.launch(); .launch();
return true; return true;
case R.id.storage_format: } else if (i == R.id.storage_format) {
args.putString(VolumeInfo.EXTRA_VOLUME_ID, mVolume.getId()); args.putString(VolumeInfo.EXTRA_VOLUME_ID, mVolume.getId());
new SubSettingLauncher(context) new SubSettingLauncher(context)
.setDestination(PrivateVolumeFormat.class.getCanonicalName()) .setDestination(PrivateVolumeFormat.class.getCanonicalName())
@@ -449,12 +449,12 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
.setArguments(args) .setArguments(args)
.launch(); .launch();
return true; return true;
case R.id.storage_migrate: } else if (i == R.id.storage_migrate) {
final Intent intent = new Intent(context, StorageWizardMigrateConfirm.class); final Intent intent = new Intent(context, StorageWizardMigrateConfirm.class);
intent.putExtra(VolumeInfo.EXTRA_VOLUME_ID, mVolume.getId()); intent.putExtra(VolumeInfo.EXTRA_VOLUME_ID, mVolume.getId());
startActivity(intent); startActivity(intent);
return true; return true;
case R.id.storage_free: } else if (i == R.id.storage_free) {
final Intent deletion_helper_intent = final Intent deletion_helper_intent =
new Intent(StorageManager.ACTION_MANAGE_STORAGE); new Intent(StorageManager.ACTION_MANAGE_STORAGE);
startActivity(deletion_helper_intent); startActivity(deletion_helper_intent);
@@ -476,8 +476,7 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
itemTitleId = 0; itemTitleId = 0;
} }
Intent intent = null; Intent intent = null;
switch (itemTitleId) { if (itemTitleId == R.string.storage_detail_apps) {
case R.string.storage_detail_apps: {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putString(ManageApplications.EXTRA_CLASSNAME, args.putString(ManageApplications.EXTRA_CLASSNAME,
StorageUseActivity.class.getName()); StorageUseActivity.class.getName());
@@ -492,41 +491,28 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
.setTitleRes(R.string.apps_storage) .setTitleRes(R.string.apps_storage)
.setSourceMetricsCategory(getMetricsCategory()) .setSourceMetricsCategory(getMetricsCategory())
.toIntent(); .toIntent();
} else if (itemTitleId == R.string.storage_detail_images) {
} break;
case R.string.storage_detail_images: {
intent = getIntentForStorage(AUTHORITY_MEDIA, "images_root"); intent = getIntentForStorage(AUTHORITY_MEDIA, "images_root");
} break; } else if (itemTitleId == R.string.storage_detail_videos) {
case R.string.storage_detail_videos: {
intent = getIntentForStorage(AUTHORITY_MEDIA, "videos_root"); intent = getIntentForStorage(AUTHORITY_MEDIA, "videos_root");
} break; } else if (itemTitleId == R.string.storage_detail_audio) {
case R.string.storage_detail_audio: {
intent = getIntentForStorage(AUTHORITY_MEDIA, "audio_root"); intent = getIntentForStorage(AUTHORITY_MEDIA, "audio_root");
} break; } else if (itemTitleId == R.string.storage_detail_system) {
case R.string.storage_detail_system: {
SystemInfoFragment.show(this); SystemInfoFragment.show(this);
return true; return true;
} else if (itemTitleId == R.string.storage_detail_other) {
}
case R.string.storage_detail_other: {
OtherInfoFragment.show(this, mStorageManager.getBestVolumeDescription(mVolume), OtherInfoFragment.show(this, mStorageManager.getBestVolumeDescription(mVolume),
mSharedVolume, userId); mSharedVolume, userId);
return true; return true;
} else if (itemTitleId == R.string.storage_detail_cached) {
}
case R.string.storage_detail_cached: {
ConfirmClearCacheFragment.show(this); ConfirmClearCacheFragment.show(this);
return true; return true;
} else if (itemTitleId == R.string.storage_menu_explore) {
}
case R.string.storage_menu_explore: {
intent = mSharedVolume.buildBrowseIntent(); intent = mSharedVolume.buildBrowseIntent();
} break; } else if (itemTitleId == 0) {
case 0: {
UserInfoFragment.show(this, pref.getTitle(), pref.getSummary()); UserInfoFragment.show(this, pref.getTitle(), pref.getSummary());
return true; return true;
} }
}
if (intent != null) { if (intent != null) {
intent.putExtra(Intent.EXTRA_USER_ID, userId); intent.putExtra(Intent.EXTRA_USER_ID, userId);
@@ -569,36 +555,32 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
itemTitleId = 0; itemTitleId = 0;
} }
switch (itemTitleId) { // Cannot display 'Other' until all known items are accounted for.
case R.string.storage_detail_system: { if (itemTitleId == R.string.storage_detail_system) {
updatePreference(item, mSystemSize); updatePreference(item, mSystemSize);
accountedSize += mSystemSize; accountedSize += mSystemSize;
if (LOGV) Log.v(TAG, "mSystemSize: " + mSystemSize if (LOGV) Log.v(TAG, "mSystemSize: " + mSystemSize
+ " accountedSize: " + accountedSize); + " accountedSize: " + accountedSize);
} break; } else if (itemTitleId == R.string.storage_detail_apps) {
case R.string.storage_detail_apps: {
updatePreference(item, details.appsSize.get(userId)); updatePreference(item, details.appsSize.get(userId));
accountedSize += details.appsSize.get(userId); accountedSize += details.appsSize.get(userId);
if (LOGV) Log.v(TAG, "appsSize: " + details.appsSize.get(userId) if (LOGV) Log.v(TAG, "appsSize: " + details.appsSize.get(userId)
+ " accountedSize: " + accountedSize); + " accountedSize: " + accountedSize);
} break; } else if (itemTitleId == R.string.storage_detail_images) {
case R.string.storage_detail_images: {
final long imagesSize = totalValues(details, userId, final long imagesSize = totalValues(details, userId,
Environment.DIRECTORY_DCIM, Environment.DIRECTORY_PICTURES); Environment.DIRECTORY_DCIM, Environment.DIRECTORY_PICTURES);
updatePreference(item, imagesSize); updatePreference(item, imagesSize);
accountedSize += imagesSize; accountedSize += imagesSize;
if (LOGV) Log.v(TAG, "imagesSize: " + imagesSize if (LOGV) Log.v(TAG, "imagesSize: " + imagesSize
+ " accountedSize: " + accountedSize); + " accountedSize: " + accountedSize);
} break; } else if (itemTitleId == R.string.storage_detail_videos) {
case R.string.storage_detail_videos: {
final long videosSize = totalValues(details, userId, final long videosSize = totalValues(details, userId,
Environment.DIRECTORY_MOVIES); Environment.DIRECTORY_MOVIES);
updatePreference(item, videosSize); updatePreference(item, videosSize);
accountedSize += videosSize; accountedSize += videosSize;
if (LOGV) Log.v(TAG, "videosSize: " + videosSize if (LOGV) Log.v(TAG, "videosSize: " + videosSize
+ " accountedSize: " + accountedSize); + " accountedSize: " + accountedSize);
} break; } else if (itemTitleId == R.string.storage_detail_audio) {
case R.string.storage_detail_audio: {
final long audioSize = totalValues(details, userId, final long audioSize = totalValues(details, userId,
Environment.DIRECTORY_MUSIC, Environment.DIRECTORY_MUSIC,
Environment.DIRECTORY_ALARMS, Environment.DIRECTORY_NOTIFICATIONS, Environment.DIRECTORY_ALARMS, Environment.DIRECTORY_NOTIFICATIONS,
@@ -607,37 +589,30 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
accountedSize += audioSize; accountedSize += audioSize;
if (LOGV) Log.v(TAG, "audioSize: " + audioSize if (LOGV) Log.v(TAG, "audioSize: " + audioSize
+ " accountedSize: " + accountedSize); + " accountedSize: " + accountedSize);
} break; } else if (itemTitleId == R.string.storage_detail_other) {
case R.string.storage_detail_other: {
final long downloadsSize = totalValues(details, userId, final long downloadsSize = totalValues(details, userId,
Environment.DIRECTORY_DOWNLOADS); Environment.DIRECTORY_DOWNLOADS);
final long miscSize = details.miscSize.get(userId); final long miscSize = details.miscSize.get(userId);
totalDownloadsSize += downloadsSize; totalDownloadsSize += downloadsSize;
totalMiscSize += miscSize; totalMiscSize += miscSize;
accountedSize += miscSize + downloadsSize; accountedSize += miscSize + downloadsSize;
if (LOGV) if (LOGV)
Log.v(TAG, "miscSize for " + userId + ": " + miscSize + "(total: " Log.v(TAG, "miscSize for " + userId + ": " + miscSize + "(total: "
+ totalMiscSize + ") \ndownloadsSize: " + downloadsSize + "(total: " + totalMiscSize + ") \ndownloadsSize: " + downloadsSize + "(total: "
+ totalDownloadsSize + ") accountedSize: " + accountedSize); + totalDownloadsSize + ") accountedSize: " + accountedSize);
// Cannot display 'Other' until all known items are accounted for.
otherItem = item; otherItem = item;
} break; } else if (itemTitleId == R.string.storage_detail_cached) {
case R.string.storage_detail_cached: {
updatePreference(item, details.cacheSize); updatePreference(item, details.cacheSize);
accountedSize += details.cacheSize; accountedSize += details.cacheSize;
if (LOGV) if (LOGV)
Log.v(TAG, "cacheSize: " + details.cacheSize + " accountedSize: " Log.v(TAG, "cacheSize: " + details.cacheSize + " accountedSize: "
+ accountedSize); + accountedSize);
} break; } else if (itemTitleId == 0) {
case 0: {
final long userSize = details.usersSize.get(userId); final long userSize = details.usersSize.get(userId);
updatePreference(item, userSize); updatePreference(item, userSize);
accountedSize += userSize; accountedSize += userSize;
if (LOGV) Log.v(TAG, "userSize: " + userSize if (LOGV) Log.v(TAG, "userSize: " + userSize
+ " accountedSize: " + accountedSize); + " accountedSize: " + accountedSize);
} break;
} }
} }
if (otherItem != null) { if (otherItem != null) {

View File

@@ -105,13 +105,11 @@ public class ContextualCardsAdapter extends RecyclerView.Adapter<RecyclerView.Vi
@Override @Override
public int getSpanSize(int position) { public int getSpanSize(int position) {
final int viewType = mContextualCards.get(position).getViewType(); final int viewType = mContextualCards.get(position).getViewType();
switch (viewType) { if (viewType == ConditionContextualCardRenderer.VIEW_TYPE_HALF_WIDTH
case ConditionContextualCardRenderer.VIEW_TYPE_HALF_WIDTH: || viewType == SliceContextualCardRenderer.VIEW_TYPE_HALF_WIDTH) {
case SliceContextualCardRenderer.VIEW_TYPE_HALF_WIDTH:
return HALF_WIDTH; return HALF_WIDTH;
default:
return FULL_WIDTH;
} }
return FULL_WIDTH;
} }
}); });
} }

View File

@@ -84,14 +84,12 @@ public class SliceContextualCardRenderer implements ContextualCardRenderer, Life
@Override @Override
public RecyclerView.ViewHolder createViewHolder(View view, @LayoutRes int viewType) { public RecyclerView.ViewHolder createViewHolder(View view, @LayoutRes int viewType) {
switch (viewType) { if (viewType == VIEW_TYPE_DEFERRED_SETUP) {
case VIEW_TYPE_DEFERRED_SETUP:
return mDeferredSetupCardHelper.createViewHolder(view); return mDeferredSetupCardHelper.createViewHolder(view);
case VIEW_TYPE_HALF_WIDTH: } else if (viewType == VIEW_TYPE_HALF_WIDTH) {
return mHalfCardHelper.createViewHolder(view); return mHalfCardHelper.createViewHolder(view);
default:
return mFullCardHelper.createViewHolder(view);
} }
return mFullCardHelper.createViewHolder(view);
} }
@Override @Override
@@ -132,14 +130,11 @@ public class SliceContextualCardRenderer implements ContextualCardRenderer, Life
return; return;
} }
switch (holder.getItemViewType()) { if (holder.getItemViewType() == VIEW_TYPE_DEFERRED_SETUP) {
case VIEW_TYPE_DEFERRED_SETUP:
mDeferredSetupCardHelper.bindView(holder, card, slice); mDeferredSetupCardHelper.bindView(holder, card, slice);
break; } else if (holder.getItemViewType() == VIEW_TYPE_HALF_WIDTH) {
case VIEW_TYPE_HALF_WIDTH:
mHalfCardHelper.bindView(holder, card, slice); mHalfCardHelper.bindView(holder, card, slice);
break; } else {
default:
mFullCardHelper.bindView(holder, card, slice); mFullCardHelper.bindView(holder, card, slice);
} }
if (swipeBackground != null) { if (swipeBackground != null) {
@@ -147,14 +142,11 @@ public class SliceContextualCardRenderer implements ContextualCardRenderer, Life
} }
}); });
switch (holder.getItemViewType()) { if (holder.getItemViewType()
case VIEW_TYPE_DEFERRED_SETUP: == VIEW_TYPE_DEFERRED_SETUP) {// Deferred setup is never dismissible.
// Deferred setup is never dismissible. } else if (holder.getItemViewType() == VIEW_TYPE_HALF_WIDTH) {
break;
case VIEW_TYPE_HALF_WIDTH:
initDismissalActions(holder, card); initDismissalActions(holder, card);
break; } else {
default:
initDismissalActions(holder, card); initDismissalActions(holder, card);
} }

View File

@@ -52,10 +52,10 @@ public class SwipeDismissalDelegate extends ItemTouchHelper.Callback {
@Override @Override
public int getMovementFlags(@NonNull RecyclerView recyclerView, public int getMovementFlags(@NonNull RecyclerView recyclerView,
@NonNull RecyclerView.ViewHolder viewHolder) { @NonNull RecyclerView.ViewHolder viewHolder) {
switch (viewHolder.getItemViewType()) { if (viewHolder.getItemViewType() == SliceContextualCardRenderer.VIEW_TYPE_FULL_WIDTH
case SliceContextualCardRenderer.VIEW_TYPE_FULL_WIDTH: || viewHolder.getItemViewType()
case SliceContextualCardRenderer.VIEW_TYPE_HALF_WIDTH: == SliceContextualCardRenderer.VIEW_TYPE_HALF_WIDTH) {// Here we are making sure
// Here we are making sure the current displayed view is the initial view of // the current displayed view is the initial view of
// either slice full card or half card, and only allow swipe on these two types. // either slice full card or half card, and only allow swipe on these two types.
if (viewHolder.itemView.findViewById(R.id.dismissal_view).getVisibility() if (viewHolder.itemView.findViewById(R.id.dismissal_view).getVisibility()
== View.VISIBLE) { == View.VISIBLE) {
@@ -64,9 +64,8 @@ public class SwipeDismissalDelegate extends ItemTouchHelper.Callback {
} }
return makeMovementFlags(0 /*dragFlags*/, return makeMovementFlags(0 /*dragFlags*/,
ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT /*swipeFlags*/); ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT /*swipeFlags*/);
default:
return 0;
} }
return 0;
} }
@Override @Override

View File

@@ -117,38 +117,32 @@ public class LocaleLinearLayoutManager extends LinearLayoutManager {
final int position = this.getPosition(host); final int position = this.getPosition(host);
boolean result = false; boolean result = false;
switch (action) { if (action == R.id.action_drag_move_up) {
case R.id.action_drag_move_up:
if (position > 0) { if (position > 0) {
mAdapter.onItemMove(position, position - 1); mAdapter.onItemMove(position, position - 1);
result = true; result = true;
} }
break; } else if (action == R.id.action_drag_move_down) {
case R.id.action_drag_move_down:
if (position + 1 < itemCount) { if (position + 1 < itemCount) {
mAdapter.onItemMove(position, position + 1); mAdapter.onItemMove(position, position + 1);
result = true; result = true;
} }
break; } else if (action == R.id.action_drag_move_top) {
case R.id.action_drag_move_top:
if (position != 0) { if (position != 0) {
mAdapter.onItemMove(position, 0); mAdapter.onItemMove(position, 0);
result = true; result = true;
} }
break; } else if (action == R.id.action_drag_move_bottom) {
case R.id.action_drag_move_bottom:
if (position != itemCount - 1) { if (position != itemCount - 1) {
mAdapter.onItemMove(position, itemCount - 1); mAdapter.onItemMove(position, itemCount - 1);
result = true; result = true;
} }
break; } else if (action == R.id.action_drag_remove) {
case R.id.action_drag_remove:
if (itemCount > 1) { if (itemCount > 1) {
mAdapter.removeItem(position); mAdapter.removeItem(position);
result = true; result = true;
} }
break; } else {
default:
return super.performAccessibilityActionForItem(recycler, state, host, action, args); return super.performAccessibilityActionForItem(recycler, state, host, action, args);
} }

View File

@@ -207,16 +207,12 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat
@Override @Override
public void onCheckedChanged(RadioGroup group, int checkedId) { public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId) { if (checkedId == R.id.private_dns_mode_off) {
case R.id.private_dns_mode_off:
mMode = PRIVATE_DNS_MODE_OFF; mMode = PRIVATE_DNS_MODE_OFF;
break; } else if (checkedId == R.id.private_dns_mode_opportunistic) {
case R.id.private_dns_mode_opportunistic:
mMode = PRIVATE_DNS_MODE_OPPORTUNISTIC; mMode = PRIVATE_DNS_MODE_OPPORTUNISTIC;
break; } else if (checkedId == R.id.private_dns_mode_provider) {
case R.id.private_dns_mode_provider:
mMode = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME; mMode = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
break;
} }
updateDialogInfo(); updateDialogInfo();
} }

View File

@@ -492,15 +492,11 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
} }
public void onClick(View v) { public void onClick(View v) {
switch (v.getId()) { if (v.getId() == R.id.next_button) {
case R.id.next_button:
handleNext(); handleNext();
break; } else if (v.getId() == R.id.cancel_button) {
case R.id.cancel_button:
getActivity().setResult(RESULT_CANCELED); getActivity().setResult(RESULT_CANCELED);
getActivity().finish(); getActivity().finish();
break;
} }
} }

View File

@@ -1086,8 +1086,7 @@ public class UserSettings extends SettingsPreferenceFragment
public void onClick(View v) { public void onClick(View v) {
if (v.getTag() instanceof UserPreference) { if (v.getTag() instanceof UserPreference) {
int userId = ((UserPreference) v.getTag()).getUserId(); int userId = ((UserPreference) v.getTag()).getUserId();
switch (v.getId()) { if (v.getId() == UserPreference.DELETE_ID) {
case UserPreference.DELETE_ID:
final EnforcedAdmin removeDisallowedAdmin = final EnforcedAdmin removeDisallowedAdmin =
RestrictedLockUtilsInternal.checkIfRestrictionEnforced(getContext(), RestrictedLockUtilsInternal.checkIfRestrictionEnforced(getContext(),
UserManager.DISALLOW_REMOVE_USER, UserHandle.myUserId()); UserManager.DISALLOW_REMOVE_USER, UserHandle.myUserId());
@@ -1097,10 +1096,8 @@ public class UserSettings extends SettingsPreferenceFragment
} else { } else {
onRemoveUserClicked(userId); onRemoveUserClicked(userId);
} }
break; } else if (v.getId() == UserPreference.SETTINGS_ID) {
case UserPreference.SETTINGS_ID:
onManageUserClicked(userId, false); onManageUserClicked(userId, false);
break;
} }
} }
} }

View File

@@ -153,9 +153,8 @@ public class VpnSettings extends RestrictedSettingsFragment implements
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.vpn_create: {
// Generate a new key. Here we just use the current time. // Generate a new key. Here we just use the current time.
if (item.getItemId() == R.id.vpn_create) {
long millis = System.currentTimeMillis(); long millis = System.currentTimeMillis();
while (mLegacyVpnPreferences.containsKey(Long.toHexString(millis))) { while (mLegacyVpnPreferences.containsKey(Long.toHexString(millis))) {
++millis; ++millis;
@@ -164,7 +163,6 @@ public class VpnSettings extends RestrictedSettingsFragment implements
ConfigDialogFragment.show(this, profile, true /* editing */, false /* exists */); ConfigDialogFragment.show(this, profile, true /* editing */, false /* exists */);
return true; return true;
} }
}
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }

View File

@@ -94,22 +94,22 @@ public class AddNetworkFragment extends InstrumentedFragment implements WifiConf
public void onClick(View view) { public void onClick(View view) {
String ssid = null; String ssid = null;
switch (view.getId()) { if (view.getId() == SUBMIT_BUTTON_ID) {
case SUBMIT_BUTTON_ID:
handleSubmitAction(); handleSubmitAction();
break; } else if (view.getId() == CANCEL_BUTTON_ID) {
case CANCEL_BUTTON_ID:
handleCancelAction(); handleCancelAction();
break; } else if (view.getId() == SSID_SCANNER_BUTTON_ID) {
case SSID_SCANNER_BUTTON_ID:
final TextView ssidEditText = getView().findViewById(R.id.ssid); final TextView ssidEditText = getView().findViewById(R.id.ssid);
ssid = ssidEditText.getText().toString(); ssid = ssidEditText.getText().toString();
// No break and flows to case PASSWORD_SCANNER_BUTTON_ID // No break and flows to case PASSWORD_SCANNER_BUTTON_ID
case PASSWORD_SCANNER_BUTTON_ID:
// Launch QR code scanner to join a network. // Launch QR code scanner to join a network.
startActivityForResult(WifiDppUtils.getEnrolleeQrCodeScannerIntent(ssid), startActivityForResult(WifiDppUtils.getEnrolleeQrCodeScannerIntent(ssid),
REQUEST_CODE_WIFI_DPP_ENROLLEE_QR_CODE_SCANNER); REQUEST_CODE_WIFI_DPP_ENROLLEE_QR_CODE_SCANNER);
break; } else if (view.getId()
== PASSWORD_SCANNER_BUTTON_ID) {// Launch QR code scanner to join a network.
startActivityForResult(WifiDppUtils.getEnrolleeQrCodeScannerIntent(ssid),
REQUEST_CODE_WIFI_DPP_ENROLLEE_QR_CODE_SCANNER);
} }
} }