diff --git a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java index b28d8b5e541..d1adf3c6023 100644 --- a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java +++ b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java @@ -197,28 +197,23 @@ public class ToggleAccessibilityServicePreferenceFragment @Override public void onClick(View view) { - switch (view.getId()) { - case R.id.permission_enable_allow_button: - if (isFullDiskEncrypted()) { - String title = createConfirmCredentialReasonMessage(); - Intent intent = ConfirmDeviceCredentialActivity.createIntent(title, null); - startActivityForResult(intent, - ACTIVITY_REQUEST_CONFIRM_CREDENTIAL_FOR_WEAKER_ENCRYPTION); - } else { - handleConfirmServiceEnabled(true); - } - break; - case R.id.permission_enable_deny_button: - handleConfirmServiceEnabled(false); - break; - case R.id.permission_disable_stop_button: - handleConfirmServiceEnabled(false); - break; - case R.id.permission_disable_cancel_button: + if (view.getId() == R.id.permission_enable_allow_button) { + if (isFullDiskEncrypted()) { + String title = createConfirmCredentialReasonMessage(); + Intent intent = ConfirmDeviceCredentialActivity.createIntent(title, null); + startActivityForResult(intent, + ACTIVITY_REQUEST_CONFIRM_CREDENTIAL_FOR_WEAKER_ENCRYPTION); + } else { handleConfirmServiceEnabled(true); - break; - default: - throw new IllegalArgumentException(); + } + } else if (view.getId() == R.id.permission_enable_deny_button) { + handleConfirmServiceEnabled(false); + } else if (view.getId() == R.id.permission_disable_stop_button) { + handleConfirmServiceEnabled(false); + } else if (view.getId() == R.id.permission_disable_cancel_button) { + handleConfirmServiceEnabled(true); + } else { + throw new IllegalArgumentException(); } mDialog.dismiss(); } diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java index d2b21b0158a..2c811da797e 100644 --- a/src/com/android/settings/applications/manageapplications/ManageApplications.java +++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java @@ -690,38 +690,33 @@ public class ManageApplications extends InstrumentedFragment @Override public boolean onOptionsItemSelected(MenuItem item) { int menuId = item.getItemId(); - switch (item.getItemId()) { - case R.id.sort_order_alpha: - case R.id.sort_order_size: - if (mApplications != null) { - mApplications.rebuild(menuId); - } - break; - case R.id.show_system: - case R.id.hide_system: - mShowSystem = !mShowSystem; - mApplications.rebuild(); - break; - case R.id.reset_app_preferences: - mResetAppsHelper.buildResetDialog(); - return true; - case R.id.advanced: - if (mListType == LIST_TYPE_NOTIFICATION) { - new SubSettingLauncher(getContext()) - .setDestination(ConfigureNotificationSettings.class.getName()) - .setTitleRes(R.string.configure_notification_settings) - .setSourceMetricsCategory(getMetricsCategory()) - .setResultListener(this, ADVANCED_SETTINGS) - .launch(); - } else { - Intent intent = new Intent( - android.provider.Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS); - startActivityForResult(intent, ADVANCED_SETTINGS); - } - return true; - default: - // Handle the home button - return false; + int i = item.getItemId(); + if (i == R.id.sort_order_alpha || i == R.id.sort_order_size) { + if (mApplications != null) { + mApplications.rebuild(menuId); + } + } else if (i == R.id.show_system || i == R.id.hide_system) { + mShowSystem = !mShowSystem; + mApplications.rebuild(); + } else if (i == R.id.reset_app_preferences) { + mResetAppsHelper.buildResetDialog(); + return true; + } else if (i == R.id.advanced) { + if (mListType == LIST_TYPE_NOTIFICATION) { + new SubSettingLauncher(getContext()) + .setDestination(ConfigureNotificationSettings.class.getName()) + .setTitleRes(R.string.configure_notification_settings) + .setSourceMetricsCategory(getMetricsCategory()) + .setResultListener(this, ADVANCED_SETTINGS) + .launch(); + } else { + Intent intent = new Intent( + android.provider.Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS); + startActivityForResult(intent, ADVANCED_SETTINGS); + } + return true; + } else {// Handle the home button + return false; } updateOptionsMenu(); return true; @@ -1133,29 +1128,24 @@ public class ManageApplications extends InstrumentedFragment ApplicationsState.FILTER_DOWNLOADED_AND_LAUNCHER); } } - switch (mLastSortMode) { - case R.id.sort_order_size: - switch (mWhichSize) { - case SIZE_INTERNAL: - comparatorObj = ApplicationsState.INTERNAL_SIZE_COMPARATOR; - break; - case SIZE_EXTERNAL: - comparatorObj = ApplicationsState.EXTERNAL_SIZE_COMPARATOR; - break; - default: - comparatorObj = ApplicationsState.SIZE_COMPARATOR; - break; - } - break; - case R.id.sort_order_recent_notification: - comparatorObj = AppStateNotificationBridge.RECENT_NOTIFICATION_COMPARATOR; - break; - case R.id.sort_order_frequent_notification: - comparatorObj = AppStateNotificationBridge.FREQUENCY_NOTIFICATION_COMPARATOR; - break; - default: - comparatorObj = ApplicationsState.ALPHA_COMPARATOR; - break; + if (mLastSortMode == R.id.sort_order_size) { + switch (mWhichSize) { + case SIZE_INTERNAL: + comparatorObj = ApplicationsState.INTERNAL_SIZE_COMPARATOR; + break; + case SIZE_EXTERNAL: + comparatorObj = ApplicationsState.EXTERNAL_SIZE_COMPARATOR; + break; + default: + comparatorObj = ApplicationsState.SIZE_COMPARATOR; + break; + } + } else if (mLastSortMode == R.id.sort_order_recent_notification) { + comparatorObj = AppStateNotificationBridge.RECENT_NOTIFICATION_COMPARATOR; + } else if (mLastSortMode == R.id.sort_order_frequent_notification) { + comparatorObj = AppStateNotificationBridge.FREQUENCY_NOTIFICATION_COMPARATOR; + } else { + comparatorObj = ApplicationsState.ALPHA_COMPARATOR; } filterObj = new CompoundFilter(filterObj, ApplicationsState.FILTER_NOT_HIDE); diff --git a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java index e68f851480a..8e6158ba233 100644 --- a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java +++ b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java @@ -424,41 +424,41 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment { public boolean onOptionsItemSelected(MenuItem item) { final Context context = getActivity(); final Bundle args = new Bundle(); - switch (item.getItemId()) { - case R.id.storage_rename: - RenameFragment.show(this, mVolume); - return true; - case R.id.storage_mount: - new MountTask(context, mVolume).execute(); - return true; - case R.id.storage_unmount: - args.putString(VolumeInfo.EXTRA_VOLUME_ID, mVolume.getId()); - new SubSettingLauncher(context) - .setDestination(PrivateVolumeUnmount.class.getCanonicalName()) - .setTitleRes(R.string.storage_menu_unmount) - .setSourceMetricsCategory(getMetricsCategory()) - .setArguments(args) - .launch(); - return true; - case R.id.storage_format: - args.putString(VolumeInfo.EXTRA_VOLUME_ID, mVolume.getId()); - new SubSettingLauncher(context) - .setDestination(PrivateVolumeFormat.class.getCanonicalName()) - .setTitleRes(R.string.storage_menu_format) - .setSourceMetricsCategory(getMetricsCategory()) - .setArguments(args) - .launch(); - return true; - case R.id.storage_migrate: - final Intent intent = new Intent(context, StorageWizardMigrateConfirm.class); - intent.putExtra(VolumeInfo.EXTRA_VOLUME_ID, mVolume.getId()); - startActivity(intent); - return true; - case R.id.storage_free: - final Intent deletion_helper_intent = - new Intent(StorageManager.ACTION_MANAGE_STORAGE); - startActivity(deletion_helper_intent); - return true; + int i = item.getItemId(); + if (i == R.id.storage_rename) { + RenameFragment.show(this, mVolume); + return true; + } else if (i == R.id.storage_mount) { + new MountTask(context, mVolume).execute(); + return true; + } else if (i == R.id.storage_unmount) { + args.putString(VolumeInfo.EXTRA_VOLUME_ID, mVolume.getId()); + new SubSettingLauncher(context) + .setDestination(PrivateVolumeUnmount.class.getCanonicalName()) + .setTitleRes(R.string.storage_menu_unmount) + .setSourceMetricsCategory(getMetricsCategory()) + .setArguments(args) + .launch(); + return true; + } else if (i == R.id.storage_format) { + args.putString(VolumeInfo.EXTRA_VOLUME_ID, mVolume.getId()); + new SubSettingLauncher(context) + .setDestination(PrivateVolumeFormat.class.getCanonicalName()) + .setTitleRes(R.string.storage_menu_format) + .setSourceMetricsCategory(getMetricsCategory()) + .setArguments(args) + .launch(); + return true; + } else if (i == R.id.storage_migrate) { + final Intent intent = new Intent(context, StorageWizardMigrateConfirm.class); + intent.putExtra(VolumeInfo.EXTRA_VOLUME_ID, mVolume.getId()); + startActivity(intent); + return true; + } else if (i == R.id.storage_free) { + final Intent deletion_helper_intent = + new Intent(StorageManager.ACTION_MANAGE_STORAGE); + startActivity(deletion_helper_intent); + return true; } return super.onOptionsItemSelected(item); } @@ -476,56 +476,42 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment { itemTitleId = 0; } Intent intent = null; - switch (itemTitleId) { - case R.string.storage_detail_apps: { - Bundle args = new Bundle(); - args.putString(ManageApplications.EXTRA_CLASSNAME, - StorageUseActivity.class.getName()); - args.putString(ManageApplications.EXTRA_VOLUME_UUID, mVolume.getFsUuid()); - args.putString(ManageApplications.EXTRA_VOLUME_NAME, mVolume.getDescription()); - args.putInt( - ManageApplications.EXTRA_STORAGE_TYPE, - ManageApplications.STORAGE_TYPE_LEGACY); - intent = new SubSettingLauncher(getActivity()) - .setDestination(ManageApplications.class.getName()) - .setArguments(args) - .setTitleRes(R.string.apps_storage) - .setSourceMetricsCategory(getMetricsCategory()) - .toIntent(); - - } break; - case R.string.storage_detail_images: { - intent = getIntentForStorage(AUTHORITY_MEDIA, "images_root"); - } break; - case R.string.storage_detail_videos: { - intent = getIntentForStorage(AUTHORITY_MEDIA, "videos_root"); - } break; - case R.string.storage_detail_audio: { - intent = getIntentForStorage(AUTHORITY_MEDIA, "audio_root"); - } break; - case R.string.storage_detail_system: { - SystemInfoFragment.show(this); - return true; - - } - case R.string.storage_detail_other: { - OtherInfoFragment.show(this, mStorageManager.getBestVolumeDescription(mVolume), - mSharedVolume, userId); - return true; - - } - case R.string.storage_detail_cached: { - ConfirmClearCacheFragment.show(this); - return true; - - } - case R.string.storage_menu_explore: { - intent = mSharedVolume.buildBrowseIntent(); - } break; - case 0: { - UserInfoFragment.show(this, pref.getTitle(), pref.getSummary()); - return true; - } + if (itemTitleId == R.string.storage_detail_apps) { + Bundle args = new Bundle(); + args.putString(ManageApplications.EXTRA_CLASSNAME, + StorageUseActivity.class.getName()); + args.putString(ManageApplications.EXTRA_VOLUME_UUID, mVolume.getFsUuid()); + args.putString(ManageApplications.EXTRA_VOLUME_NAME, mVolume.getDescription()); + args.putInt( + ManageApplications.EXTRA_STORAGE_TYPE, + ManageApplications.STORAGE_TYPE_LEGACY); + intent = new SubSettingLauncher(getActivity()) + .setDestination(ManageApplications.class.getName()) + .setArguments(args) + .setTitleRes(R.string.apps_storage) + .setSourceMetricsCategory(getMetricsCategory()) + .toIntent(); + } else if (itemTitleId == R.string.storage_detail_images) { + intent = getIntentForStorage(AUTHORITY_MEDIA, "images_root"); + } else if (itemTitleId == R.string.storage_detail_videos) { + intent = getIntentForStorage(AUTHORITY_MEDIA, "videos_root"); + } else if (itemTitleId == R.string.storage_detail_audio) { + intent = getIntentForStorage(AUTHORITY_MEDIA, "audio_root"); + } else if (itemTitleId == R.string.storage_detail_system) { + SystemInfoFragment.show(this); + return true; + } else if (itemTitleId == R.string.storage_detail_other) { + OtherInfoFragment.show(this, mStorageManager.getBestVolumeDescription(mVolume), + mSharedVolume, userId); + return true; + } else if (itemTitleId == R.string.storage_detail_cached) { + ConfirmClearCacheFragment.show(this); + return true; + } else if (itemTitleId == R.string.storage_menu_explore) { + intent = mSharedVolume.buildBrowseIntent(); + } else if (itemTitleId == 0) { + UserInfoFragment.show(this, pref.getTitle(), pref.getSummary()); + return true; } if (intent != null) { @@ -569,75 +555,64 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment { } catch (NumberFormatException e) { itemTitleId = 0; } - switch (itemTitleId) { - case R.string.storage_detail_system: { - updatePreference(item, mSystemSize); - accountedSize += mSystemSize; - if (LOGV) Log.v(TAG, "mSystemSize: " + mSystemSize - + " accountedSize: " + accountedSize); - } break; - case R.string.storage_detail_apps: { - updatePreference(item, details.appsSize.get(userId)); - accountedSize += details.appsSize.get(userId); - if (LOGV) Log.v(TAG, "appsSize: " + details.appsSize.get(userId) - + " accountedSize: " + accountedSize); - } break; - case R.string.storage_detail_images: { - final long imagesSize = totalValues(details, userId, - Environment.DIRECTORY_DCIM, Environment.DIRECTORY_PICTURES); - updatePreference(item, imagesSize); - accountedSize += imagesSize; - if (LOGV) Log.v(TAG, "imagesSize: " + imagesSize - + " accountedSize: " + accountedSize); - } break; - case R.string.storage_detail_videos: { - final long videosSize = totalValues(details, userId, - Environment.DIRECTORY_MOVIES); - updatePreference(item, videosSize); - accountedSize += videosSize; - if (LOGV) Log.v(TAG, "videosSize: " + videosSize - + " accountedSize: " + accountedSize); - } break; - case R.string.storage_detail_audio: { - final long audioSize = totalValues(details, userId, - Environment.DIRECTORY_MUSIC, - Environment.DIRECTORY_ALARMS, Environment.DIRECTORY_NOTIFICATIONS, - Environment.DIRECTORY_RINGTONES, Environment.DIRECTORY_PODCASTS); - updatePreference(item, audioSize); - accountedSize += audioSize; - if (LOGV) Log.v(TAG, "audioSize: " + audioSize - + " accountedSize: " + accountedSize); - } break; - case R.string.storage_detail_other: { - final long downloadsSize = totalValues(details, userId, - Environment.DIRECTORY_DOWNLOADS); - final long miscSize = details.miscSize.get(userId); - totalDownloadsSize += downloadsSize; - totalMiscSize += miscSize; - accountedSize += miscSize + downloadsSize; - - if (LOGV) - Log.v(TAG, "miscSize for " + userId + ": " + miscSize + "(total: " - + totalMiscSize + ") \ndownloadsSize: " + downloadsSize + "(total: " - + totalDownloadsSize + ") accountedSize: " + accountedSize); - - // Cannot display 'Other' until all known items are accounted for. - otherItem = item; - } break; - case R.string.storage_detail_cached: { - updatePreference(item, details.cacheSize); - accountedSize += details.cacheSize; - if (LOGV) - Log.v(TAG, "cacheSize: " + details.cacheSize + " accountedSize: " - + accountedSize); - } break; - case 0: { - final long userSize = details.usersSize.get(userId); - updatePreference(item, userSize); - accountedSize += userSize; - if (LOGV) Log.v(TAG, "userSize: " + userSize - + " accountedSize: " + accountedSize); - } break; + // Cannot display 'Other' until all known items are accounted for. + if (itemTitleId == R.string.storage_detail_system) { + updatePreference(item, mSystemSize); + accountedSize += mSystemSize; + if (LOGV) Log.v(TAG, "mSystemSize: " + mSystemSize + + " accountedSize: " + accountedSize); + } else if (itemTitleId == R.string.storage_detail_apps) { + updatePreference(item, details.appsSize.get(userId)); + accountedSize += details.appsSize.get(userId); + if (LOGV) Log.v(TAG, "appsSize: " + details.appsSize.get(userId) + + " accountedSize: " + accountedSize); + } else if (itemTitleId == R.string.storage_detail_images) { + final long imagesSize = totalValues(details, userId, + Environment.DIRECTORY_DCIM, Environment.DIRECTORY_PICTURES); + updatePreference(item, imagesSize); + accountedSize += imagesSize; + if (LOGV) Log.v(TAG, "imagesSize: " + imagesSize + + " accountedSize: " + accountedSize); + } else if (itemTitleId == R.string.storage_detail_videos) { + final long videosSize = totalValues(details, userId, + Environment.DIRECTORY_MOVIES); + updatePreference(item, videosSize); + accountedSize += videosSize; + if (LOGV) Log.v(TAG, "videosSize: " + videosSize + + " accountedSize: " + accountedSize); + } else if (itemTitleId == R.string.storage_detail_audio) { + final long audioSize = totalValues(details, userId, + Environment.DIRECTORY_MUSIC, + Environment.DIRECTORY_ALARMS, Environment.DIRECTORY_NOTIFICATIONS, + Environment.DIRECTORY_RINGTONES, Environment.DIRECTORY_PODCASTS); + updatePreference(item, audioSize); + accountedSize += audioSize; + if (LOGV) Log.v(TAG, "audioSize: " + audioSize + + " accountedSize: " + accountedSize); + } else if (itemTitleId == R.string.storage_detail_other) { + final long downloadsSize = totalValues(details, userId, + Environment.DIRECTORY_DOWNLOADS); + final long miscSize = details.miscSize.get(userId); + totalDownloadsSize += downloadsSize; + totalMiscSize += miscSize; + accountedSize += miscSize + downloadsSize; + if (LOGV) + Log.v(TAG, "miscSize for " + userId + ": " + miscSize + "(total: " + + totalMiscSize + ") \ndownloadsSize: " + downloadsSize + "(total: " + + totalDownloadsSize + ") accountedSize: " + accountedSize); + otherItem = item; + } else if (itemTitleId == R.string.storage_detail_cached) { + updatePreference(item, details.cacheSize); + accountedSize += details.cacheSize; + if (LOGV) + Log.v(TAG, "cacheSize: " + details.cacheSize + " accountedSize: " + + accountedSize); + } else if (itemTitleId == 0) { + final long userSize = details.usersSize.get(userId); + updatePreference(item, userSize); + accountedSize += userSize; + if (LOGV) Log.v(TAG, "userSize: " + userSize + + " accountedSize: " + accountedSize); } } if (otherItem != null) { diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardsAdapter.java b/src/com/android/settings/homepage/contextualcards/ContextualCardsAdapter.java index bca55666149..4e010fd2066 100644 --- a/src/com/android/settings/homepage/contextualcards/ContextualCardsAdapter.java +++ b/src/com/android/settings/homepage/contextualcards/ContextualCardsAdapter.java @@ -105,13 +105,11 @@ public class ContextualCardsAdapter extends RecyclerView.Adapter 0) { - mAdapter.onItemMove(position, position - 1); - result = true; - } - break; - case R.id.action_drag_move_down: - if (position + 1 < itemCount) { - mAdapter.onItemMove(position, position + 1); - result = true; - } - break; - case R.id.action_drag_move_top: - if (position != 0) { - mAdapter.onItemMove(position, 0); - result = true; - } - break; - case R.id.action_drag_move_bottom: - if (position != itemCount - 1) { - mAdapter.onItemMove(position, itemCount - 1); - result = true; - } - break; - case R.id.action_drag_remove: - if (itemCount > 1) { - mAdapter.removeItem(position); - result = true; - } - break; - default: - return super.performAccessibilityActionForItem(recycler, state, host, action, args); + if (action == R.id.action_drag_move_up) { + if (position > 0) { + mAdapter.onItemMove(position, position - 1); + result = true; + } + } else if (action == R.id.action_drag_move_down) { + if (position + 1 < itemCount) { + mAdapter.onItemMove(position, position + 1); + result = true; + } + } else if (action == R.id.action_drag_move_top) { + if (position != 0) { + mAdapter.onItemMove(position, 0); + result = true; + } + } else if (action == R.id.action_drag_move_bottom) { + if (position != itemCount - 1) { + mAdapter.onItemMove(position, itemCount - 1); + result = true; + } + } else if (action == R.id.action_drag_remove) { + if (itemCount > 1) { + mAdapter.removeItem(position); + result = true; + } + } else { + return super.performAccessibilityActionForItem(recycler, state, host, action, args); } if (result) { diff --git a/src/com/android/settings/network/PrivateDnsModeDialogPreference.java b/src/com/android/settings/network/PrivateDnsModeDialogPreference.java index 1655c69cea4..0086fecb1dd 100644 --- a/src/com/android/settings/network/PrivateDnsModeDialogPreference.java +++ b/src/com/android/settings/network/PrivateDnsModeDialogPreference.java @@ -207,16 +207,12 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat @Override public void onCheckedChanged(RadioGroup group, int checkedId) { - switch (checkedId) { - case R.id.private_dns_mode_off: - mMode = PRIVATE_DNS_MODE_OFF; - break; - case R.id.private_dns_mode_opportunistic: - mMode = PRIVATE_DNS_MODE_OPPORTUNISTIC; - break; - case R.id.private_dns_mode_provider: - mMode = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME; - break; + if (checkedId == R.id.private_dns_mode_off) { + mMode = PRIVATE_DNS_MODE_OFF; + } else if (checkedId == R.id.private_dns_mode_opportunistic) { + mMode = PRIVATE_DNS_MODE_OPPORTUNISTIC; + } else if (checkedId == R.id.private_dns_mode_provider) { + mMode = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME; } updateDialogInfo(); } diff --git a/src/com/android/settings/password/ConfirmLockPassword.java b/src/com/android/settings/password/ConfirmLockPassword.java index f2b5a359959..2992ebeb8f4 100644 --- a/src/com/android/settings/password/ConfirmLockPassword.java +++ b/src/com/android/settings/password/ConfirmLockPassword.java @@ -492,15 +492,11 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity { } public void onClick(View v) { - switch (v.getId()) { - case R.id.next_button: - handleNext(); - break; - - case R.id.cancel_button: - getActivity().setResult(RESULT_CANCELED); - getActivity().finish(); - break; + if (v.getId() == R.id.next_button) { + handleNext(); + } else if (v.getId() == R.id.cancel_button) { + getActivity().setResult(RESULT_CANCELED); + getActivity().finish(); } } diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java index 98263e29af1..7acf576441a 100644 --- a/src/com/android/settings/users/UserSettings.java +++ b/src/com/android/settings/users/UserSettings.java @@ -1086,21 +1086,18 @@ public class UserSettings extends SettingsPreferenceFragment public void onClick(View v) { if (v.getTag() instanceof UserPreference) { int userId = ((UserPreference) v.getTag()).getUserId(); - switch (v.getId()) { - case UserPreference.DELETE_ID: - final EnforcedAdmin removeDisallowedAdmin = - RestrictedLockUtilsInternal.checkIfRestrictionEnforced(getContext(), - UserManager.DISALLOW_REMOVE_USER, UserHandle.myUserId()); - if (removeDisallowedAdmin != null) { - RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getContext(), - removeDisallowedAdmin); - } else { - onRemoveUserClicked(userId); - } - break; - case UserPreference.SETTINGS_ID: - onManageUserClicked(userId, false); - break; + if (v.getId() == UserPreference.DELETE_ID) { + final EnforcedAdmin removeDisallowedAdmin = + RestrictedLockUtilsInternal.checkIfRestrictionEnforced(getContext(), + UserManager.DISALLOW_REMOVE_USER, UserHandle.myUserId()); + if (removeDisallowedAdmin != null) { + RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getContext(), + removeDisallowedAdmin); + } else { + onRemoveUserClicked(userId); + } + } else if (v.getId() == UserPreference.SETTINGS_ID) { + onManageUserClicked(userId, false); } } } diff --git a/src/com/android/settings/vpn2/VpnSettings.java b/src/com/android/settings/vpn2/VpnSettings.java index 874a9b93b6b..83cdf71eeca 100644 --- a/src/com/android/settings/vpn2/VpnSettings.java +++ b/src/com/android/settings/vpn2/VpnSettings.java @@ -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); } diff --git a/src/com/android/settings/wifi/AddNetworkFragment.java b/src/com/android/settings/wifi/AddNetworkFragment.java index 81b6c85dfc9..52497fc3d66 100644 --- a/src/com/android/settings/wifi/AddNetworkFragment.java +++ b/src/com/android/settings/wifi/AddNetworkFragment.java @@ -94,22 +94,22 @@ public class AddNetworkFragment extends InstrumentedFragment implements WifiConf public void onClick(View view) { String ssid = null; - switch (view.getId()) { - case SUBMIT_BUTTON_ID: - handleSubmitAction(); - break; - case CANCEL_BUTTON_ID: - handleCancelAction(); - break; - case SSID_SCANNER_BUTTON_ID: - final TextView ssidEditText = getView().findViewById(R.id.ssid); - ssid = ssidEditText.getText().toString(); - // No break and flows to case PASSWORD_SCANNER_BUTTON_ID - case PASSWORD_SCANNER_BUTTON_ID: - // Launch QR code scanner to join a network. - startActivityForResult(WifiDppUtils.getEnrolleeQrCodeScannerIntent(ssid), - REQUEST_CODE_WIFI_DPP_ENROLLEE_QR_CODE_SCANNER); - break; + if (view.getId() == SUBMIT_BUTTON_ID) { + handleSubmitAction(); + } else if (view.getId() == CANCEL_BUTTON_ID) { + handleCancelAction(); + } else if (view.getId() == SSID_SCANNER_BUTTON_ID) { + final TextView ssidEditText = getView().findViewById(R.id.ssid); + ssid = ssidEditText.getText().toString(); + // No break and flows to case PASSWORD_SCANNER_BUTTON_ID + + // Launch QR code scanner to join a network. + startActivityForResult(WifiDppUtils.getEnrolleeQrCodeScannerIntent(ssid), + REQUEST_CODE_WIFI_DPP_ENROLLEE_QR_CODE_SCANNER); + } 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); } }