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:
@@ -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();
|
||||
}
|
||||
|
@@ -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);
|
||||
|
@@ -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) {
|
||||
|
@@ -105,13 +105,11 @@ public class ContextualCardsAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
@Override
|
||||
public int getSpanSize(int position) {
|
||||
final int viewType = mContextualCards.get(position).getViewType();
|
||||
switch (viewType) {
|
||||
case ConditionContextualCardRenderer.VIEW_TYPE_HALF_WIDTH:
|
||||
case SliceContextualCardRenderer.VIEW_TYPE_HALF_WIDTH:
|
||||
return HALF_WIDTH;
|
||||
default:
|
||||
return FULL_WIDTH;
|
||||
if (viewType == ConditionContextualCardRenderer.VIEW_TYPE_HALF_WIDTH
|
||||
|| viewType == SliceContextualCardRenderer.VIEW_TYPE_HALF_WIDTH) {
|
||||
return HALF_WIDTH;
|
||||
}
|
||||
return FULL_WIDTH;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -84,14 +84,12 @@ public class SliceContextualCardRenderer implements ContextualCardRenderer, Life
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder createViewHolder(View view, @LayoutRes int viewType) {
|
||||
switch (viewType) {
|
||||
case VIEW_TYPE_DEFERRED_SETUP:
|
||||
return mDeferredSetupCardHelper.createViewHolder(view);
|
||||
case VIEW_TYPE_HALF_WIDTH:
|
||||
return mHalfCardHelper.createViewHolder(view);
|
||||
default:
|
||||
return mFullCardHelper.createViewHolder(view);
|
||||
if (viewType == VIEW_TYPE_DEFERRED_SETUP) {
|
||||
return mDeferredSetupCardHelper.createViewHolder(view);
|
||||
} else if (viewType == VIEW_TYPE_HALF_WIDTH) {
|
||||
return mHalfCardHelper.createViewHolder(view);
|
||||
}
|
||||
return mFullCardHelper.createViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -132,30 +130,24 @@ public class SliceContextualCardRenderer implements ContextualCardRenderer, Life
|
||||
return;
|
||||
}
|
||||
|
||||
switch (holder.getItemViewType()) {
|
||||
case VIEW_TYPE_DEFERRED_SETUP:
|
||||
mDeferredSetupCardHelper.bindView(holder, card, slice);
|
||||
break;
|
||||
case VIEW_TYPE_HALF_WIDTH:
|
||||
mHalfCardHelper.bindView(holder, card, slice);
|
||||
break;
|
||||
default:
|
||||
mFullCardHelper.bindView(holder, card, slice);
|
||||
if (holder.getItemViewType() == VIEW_TYPE_DEFERRED_SETUP) {
|
||||
mDeferredSetupCardHelper.bindView(holder, card, slice);
|
||||
} else if (holder.getItemViewType() == VIEW_TYPE_HALF_WIDTH) {
|
||||
mHalfCardHelper.bindView(holder, card, slice);
|
||||
} else {
|
||||
mFullCardHelper.bindView(holder, card, slice);
|
||||
}
|
||||
if (swipeBackground != null) {
|
||||
swipeBackground.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
switch (holder.getItemViewType()) {
|
||||
case VIEW_TYPE_DEFERRED_SETUP:
|
||||
// Deferred setup is never dismissible.
|
||||
break;
|
||||
case VIEW_TYPE_HALF_WIDTH:
|
||||
initDismissalActions(holder, card);
|
||||
break;
|
||||
default:
|
||||
initDismissalActions(holder, card);
|
||||
if (holder.getItemViewType()
|
||||
== VIEW_TYPE_DEFERRED_SETUP) {// Deferred setup is never dismissible.
|
||||
} else if (holder.getItemViewType() == VIEW_TYPE_HALF_WIDTH) {
|
||||
initDismissalActions(holder, card);
|
||||
} else {
|
||||
initDismissalActions(holder, card);
|
||||
}
|
||||
|
||||
if (card.isPendingDismiss()) {
|
||||
|
@@ -52,21 +52,20 @@ public class SwipeDismissalDelegate extends ItemTouchHelper.Callback {
|
||||
@Override
|
||||
public int getMovementFlags(@NonNull RecyclerView recyclerView,
|
||||
@NonNull RecyclerView.ViewHolder viewHolder) {
|
||||
switch (viewHolder.getItemViewType()) {
|
||||
case SliceContextualCardRenderer.VIEW_TYPE_FULL_WIDTH:
|
||||
case SliceContextualCardRenderer.VIEW_TYPE_HALF_WIDTH:
|
||||
// Here we are making sure the current displayed view is the initial view of
|
||||
// either slice full card or half card, and only allow swipe on these two types.
|
||||
if (viewHolder.itemView.findViewById(R.id.dismissal_view).getVisibility()
|
||||
== View.VISIBLE) {
|
||||
// Disable swiping when we are in the dismissal view
|
||||
return 0;
|
||||
}
|
||||
return makeMovementFlags(0 /*dragFlags*/,
|
||||
ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT /*swipeFlags*/);
|
||||
default:
|
||||
if (viewHolder.getItemViewType() == SliceContextualCardRenderer.VIEW_TYPE_FULL_WIDTH
|
||||
|| viewHolder.getItemViewType()
|
||||
== SliceContextualCardRenderer.VIEW_TYPE_HALF_WIDTH) {// Here we are making sure
|
||||
// the current displayed view is the initial view of
|
||||
// either slice full card or half card, and only allow swipe on these two types.
|
||||
if (viewHolder.itemView.findViewById(R.id.dismissal_view).getVisibility()
|
||||
== View.VISIBLE) {
|
||||
// Disable swiping when we are in the dismissal view
|
||||
return 0;
|
||||
}
|
||||
return makeMovementFlags(0 /*dragFlags*/,
|
||||
ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT /*swipeFlags*/);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -117,39 +117,33 @@ public class LocaleLinearLayoutManager extends LinearLayoutManager {
|
||||
final int position = this.getPosition(host);
|
||||
boolean result = false;
|
||||
|
||||
switch (action) {
|
||||
case R.id.action_drag_move_up:
|
||||
if (position > 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) {
|
||||
|
@@ -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();
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user