Merge "Use if instead of switch for resources" into qt-dev-plus-aosp
This commit is contained in:
@@ -197,28 +197,23 @@ 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);
|
startActivityForResult(intent,
|
||||||
startActivityForResult(intent,
|
ACTIVITY_REQUEST_CONFIRM_CREDENTIAL_FOR_WEAKER_ENCRYPTION);
|
||||||
ACTIVITY_REQUEST_CONFIRM_CREDENTIAL_FOR_WEAKER_ENCRYPTION);
|
} else {
|
||||||
} 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:
|
|
||||||
handleConfirmServiceEnabled(true);
|
handleConfirmServiceEnabled(true);
|
||||||
break;
|
}
|
||||||
default:
|
} else if (view.getId() == R.id.permission_enable_deny_button) {
|
||||||
throw new IllegalArgumentException();
|
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();
|
mDialog.dismiss();
|
||||||
}
|
}
|
||||||
|
@@ -690,38 +690,33 @@ 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);
|
}
|
||||||
}
|
} else if (i == R.id.show_system || i == R.id.hide_system) {
|
||||||
break;
|
mShowSystem = !mShowSystem;
|
||||||
case R.id.show_system:
|
mApplications.rebuild();
|
||||||
case R.id.hide_system:
|
} else if (i == R.id.reset_app_preferences) {
|
||||||
mShowSystem = !mShowSystem;
|
mResetAppsHelper.buildResetDialog();
|
||||||
mApplications.rebuild();
|
return true;
|
||||||
break;
|
} else if (i == R.id.advanced) {
|
||||||
case R.id.reset_app_preferences:
|
if (mListType == LIST_TYPE_NOTIFICATION) {
|
||||||
mResetAppsHelper.buildResetDialog();
|
new SubSettingLauncher(getContext())
|
||||||
return true;
|
.setDestination(ConfigureNotificationSettings.class.getName())
|
||||||
case R.id.advanced:
|
.setTitleRes(R.string.configure_notification_settings)
|
||||||
if (mListType == LIST_TYPE_NOTIFICATION) {
|
.setSourceMetricsCategory(getMetricsCategory())
|
||||||
new SubSettingLauncher(getContext())
|
.setResultListener(this, ADVANCED_SETTINGS)
|
||||||
.setDestination(ConfigureNotificationSettings.class.getName())
|
.launch();
|
||||||
.setTitleRes(R.string.configure_notification_settings)
|
} else {
|
||||||
.setSourceMetricsCategory(getMetricsCategory())
|
Intent intent = new Intent(
|
||||||
.setResultListener(this, ADVANCED_SETTINGS)
|
android.provider.Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS);
|
||||||
.launch();
|
startActivityForResult(intent, ADVANCED_SETTINGS);
|
||||||
} else {
|
}
|
||||||
Intent intent = new Intent(
|
return true;
|
||||||
android.provider.Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS);
|
} else {// Handle the home button
|
||||||
startActivityForResult(intent, ADVANCED_SETTINGS);
|
return false;
|
||||||
}
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
// Handle the home button
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
updateOptionsMenu();
|
updateOptionsMenu();
|
||||||
return true;
|
return true;
|
||||||
@@ -1133,29 +1128,24 @@ 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;
|
break;
|
||||||
break;
|
case SIZE_EXTERNAL:
|
||||||
case SIZE_EXTERNAL:
|
comparatorObj = ApplicationsState.EXTERNAL_SIZE_COMPARATOR;
|
||||||
comparatorObj = ApplicationsState.EXTERNAL_SIZE_COMPARATOR;
|
break;
|
||||||
break;
|
default:
|
||||||
default:
|
comparatorObj = ApplicationsState.SIZE_COMPARATOR;
|
||||||
comparatorObj = ApplicationsState.SIZE_COMPARATOR;
|
break;
|
||||||
break;
|
}
|
||||||
}
|
} else if (mLastSortMode == R.id.sort_order_recent_notification) {
|
||||||
break;
|
comparatorObj = AppStateNotificationBridge.RECENT_NOTIFICATION_COMPARATOR;
|
||||||
case R.id.sort_order_recent_notification:
|
} else if (mLastSortMode == R.id.sort_order_frequent_notification) {
|
||||||
comparatorObj = AppStateNotificationBridge.RECENT_NOTIFICATION_COMPARATOR;
|
comparatorObj = AppStateNotificationBridge.FREQUENCY_NOTIFICATION_COMPARATOR;
|
||||||
break;
|
} else {
|
||||||
case R.id.sort_order_frequent_notification:
|
comparatorObj = ApplicationsState.ALPHA_COMPARATOR;
|
||||||
comparatorObj = AppStateNotificationBridge.FREQUENCY_NOTIFICATION_COMPARATOR;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
comparatorObj = ApplicationsState.ALPHA_COMPARATOR;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
filterObj = new CompoundFilter(filterObj, ApplicationsState.FILTER_NOT_HIDE);
|
filterObj = new CompoundFilter(filterObj, ApplicationsState.FILTER_NOT_HIDE);
|
||||||
|
@@ -424,41 +424,41 @@ 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())
|
||||||
.setTitleRes(R.string.storage_menu_unmount)
|
.setTitleRes(R.string.storage_menu_unmount)
|
||||||
.setSourceMetricsCategory(getMetricsCategory())
|
.setSourceMetricsCategory(getMetricsCategory())
|
||||||
.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())
|
||||||
.setTitleRes(R.string.storage_menu_format)
|
.setTitleRes(R.string.storage_menu_format)
|
||||||
.setSourceMetricsCategory(getMetricsCategory())
|
.setSourceMetricsCategory(getMetricsCategory())
|
||||||
.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);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
@@ -476,56 +476,42 @@ 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());
|
args.putString(ManageApplications.EXTRA_VOLUME_UUID, mVolume.getFsUuid());
|
||||||
args.putString(ManageApplications.EXTRA_VOLUME_UUID, mVolume.getFsUuid());
|
args.putString(ManageApplications.EXTRA_VOLUME_NAME, mVolume.getDescription());
|
||||||
args.putString(ManageApplications.EXTRA_VOLUME_NAME, mVolume.getDescription());
|
args.putInt(
|
||||||
args.putInt(
|
ManageApplications.EXTRA_STORAGE_TYPE,
|
||||||
ManageApplications.EXTRA_STORAGE_TYPE,
|
ManageApplications.STORAGE_TYPE_LEGACY);
|
||||||
ManageApplications.STORAGE_TYPE_LEGACY);
|
intent = new SubSettingLauncher(getActivity())
|
||||||
intent = new SubSettingLauncher(getActivity())
|
.setDestination(ManageApplications.class.getName())
|
||||||
.setDestination(ManageApplications.class.getName())
|
.setArguments(args)
|
||||||
.setArguments(args)
|
.setTitleRes(R.string.apps_storage)
|
||||||
.setTitleRes(R.string.apps_storage)
|
.setSourceMetricsCategory(getMetricsCategory())
|
||||||
.setSourceMetricsCategory(getMetricsCategory())
|
.toIntent();
|
||||||
.toIntent();
|
} else if (itemTitleId == R.string.storage_detail_images) {
|
||||||
|
intent = getIntentForStorage(AUTHORITY_MEDIA, "images_root");
|
||||||
} break;
|
} else if (itemTitleId == R.string.storage_detail_videos) {
|
||||||
case R.string.storage_detail_images: {
|
intent = getIntentForStorage(AUTHORITY_MEDIA, "videos_root");
|
||||||
intent = getIntentForStorage(AUTHORITY_MEDIA, "images_root");
|
} else if (itemTitleId == R.string.storage_detail_audio) {
|
||||||
} break;
|
intent = getIntentForStorage(AUTHORITY_MEDIA, "audio_root");
|
||||||
case R.string.storage_detail_videos: {
|
} else if (itemTitleId == R.string.storage_detail_system) {
|
||||||
intent = getIntentForStorage(AUTHORITY_MEDIA, "videos_root");
|
SystemInfoFragment.show(this);
|
||||||
} break;
|
return true;
|
||||||
case R.string.storage_detail_audio: {
|
} else if (itemTitleId == R.string.storage_detail_other) {
|
||||||
intent = getIntentForStorage(AUTHORITY_MEDIA, "audio_root");
|
OtherInfoFragment.show(this, mStorageManager.getBestVolumeDescription(mVolume),
|
||||||
} break;
|
mSharedVolume, userId);
|
||||||
case R.string.storage_detail_system: {
|
return true;
|
||||||
SystemInfoFragment.show(this);
|
} else if (itemTitleId == R.string.storage_detail_cached) {
|
||||||
return true;
|
ConfirmClearCacheFragment.show(this);
|
||||||
|
return true;
|
||||||
}
|
} else if (itemTitleId == R.string.storage_menu_explore) {
|
||||||
case R.string.storage_detail_other: {
|
intent = mSharedVolume.buildBrowseIntent();
|
||||||
OtherInfoFragment.show(this, mStorageManager.getBestVolumeDescription(mVolume),
|
} else if (itemTitleId == 0) {
|
||||||
mSharedVolume, userId);
|
UserInfoFragment.show(this, pref.getTitle(), pref.getSummary());
|
||||||
return true;
|
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 (intent != null) {
|
if (intent != null) {
|
||||||
@@ -569,75 +555,64 @@ 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);
|
} else if (itemTitleId == R.string.storage_detail_images) {
|
||||||
} break;
|
final long imagesSize = totalValues(details, userId,
|
||||||
case R.string.storage_detail_images: {
|
Environment.DIRECTORY_DCIM, Environment.DIRECTORY_PICTURES);
|
||||||
final long imagesSize = totalValues(details, userId,
|
updatePreference(item, imagesSize);
|
||||||
Environment.DIRECTORY_DCIM, Environment.DIRECTORY_PICTURES);
|
accountedSize += imagesSize;
|
||||||
updatePreference(item, imagesSize);
|
if (LOGV) Log.v(TAG, "imagesSize: " + imagesSize
|
||||||
accountedSize += imagesSize;
|
+ " accountedSize: " + accountedSize);
|
||||||
if (LOGV) Log.v(TAG, "imagesSize: " + imagesSize
|
} else if (itemTitleId == R.string.storage_detail_videos) {
|
||||||
+ " accountedSize: " + accountedSize);
|
final long videosSize = totalValues(details, userId,
|
||||||
} break;
|
Environment.DIRECTORY_MOVIES);
|
||||||
case R.string.storage_detail_videos: {
|
updatePreference(item, videosSize);
|
||||||
final long videosSize = totalValues(details, userId,
|
accountedSize += videosSize;
|
||||||
Environment.DIRECTORY_MOVIES);
|
if (LOGV) Log.v(TAG, "videosSize: " + videosSize
|
||||||
updatePreference(item, videosSize);
|
+ " accountedSize: " + accountedSize);
|
||||||
accountedSize += videosSize;
|
} else if (itemTitleId == R.string.storage_detail_audio) {
|
||||||
if (LOGV) Log.v(TAG, "videosSize: " + videosSize
|
final long audioSize = totalValues(details, userId,
|
||||||
+ " accountedSize: " + accountedSize);
|
Environment.DIRECTORY_MUSIC,
|
||||||
} break;
|
Environment.DIRECTORY_ALARMS, Environment.DIRECTORY_NOTIFICATIONS,
|
||||||
case R.string.storage_detail_audio: {
|
Environment.DIRECTORY_RINGTONES, Environment.DIRECTORY_PODCASTS);
|
||||||
final long audioSize = totalValues(details, userId,
|
updatePreference(item, audioSize);
|
||||||
Environment.DIRECTORY_MUSIC,
|
accountedSize += audioSize;
|
||||||
Environment.DIRECTORY_ALARMS, Environment.DIRECTORY_NOTIFICATIONS,
|
if (LOGV) Log.v(TAG, "audioSize: " + audioSize
|
||||||
Environment.DIRECTORY_RINGTONES, Environment.DIRECTORY_PODCASTS);
|
+ " accountedSize: " + accountedSize);
|
||||||
updatePreference(item, audioSize);
|
} else if (itemTitleId == R.string.storage_detail_other) {
|
||||||
accountedSize += audioSize;
|
final long downloadsSize = totalValues(details, userId,
|
||||||
if (LOGV) Log.v(TAG, "audioSize: " + audioSize
|
Environment.DIRECTORY_DOWNLOADS);
|
||||||
+ " accountedSize: " + accountedSize);
|
final long miscSize = details.miscSize.get(userId);
|
||||||
} break;
|
totalDownloadsSize += downloadsSize;
|
||||||
case R.string.storage_detail_other: {
|
totalMiscSize += miscSize;
|
||||||
final long downloadsSize = totalValues(details, userId,
|
accountedSize += miscSize + downloadsSize;
|
||||||
Environment.DIRECTORY_DOWNLOADS);
|
if (LOGV)
|
||||||
final long miscSize = details.miscSize.get(userId);
|
Log.v(TAG, "miscSize for " + userId + ": " + miscSize + "(total: "
|
||||||
totalDownloadsSize += downloadsSize;
|
+ totalMiscSize + ") \ndownloadsSize: " + downloadsSize + "(total: "
|
||||||
totalMiscSize += miscSize;
|
+ totalDownloadsSize + ") accountedSize: " + accountedSize);
|
||||||
accountedSize += miscSize + downloadsSize;
|
otherItem = item;
|
||||||
|
} else if (itemTitleId == R.string.storage_detail_cached) {
|
||||||
if (LOGV)
|
updatePreference(item, details.cacheSize);
|
||||||
Log.v(TAG, "miscSize for " + userId + ": " + miscSize + "(total: "
|
accountedSize += details.cacheSize;
|
||||||
+ totalMiscSize + ") \ndownloadsSize: " + downloadsSize + "(total: "
|
if (LOGV)
|
||||||
+ totalDownloadsSize + ") accountedSize: " + accountedSize);
|
Log.v(TAG, "cacheSize: " + details.cacheSize + " accountedSize: "
|
||||||
|
+ accountedSize);
|
||||||
// Cannot display 'Other' until all known items are accounted for.
|
} else if (itemTitleId == 0) {
|
||||||
otherItem = item;
|
final long userSize = details.usersSize.get(userId);
|
||||||
} break;
|
updatePreference(item, userSize);
|
||||||
case R.string.storage_detail_cached: {
|
accountedSize += userSize;
|
||||||
updatePreference(item, details.cacheSize);
|
if (LOGV) Log.v(TAG, "userSize: " + userSize
|
||||||
accountedSize += details.cacheSize;
|
+ " accountedSize: " + accountedSize);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (otherItem != null) {
|
if (otherItem != null) {
|
||||||
|
@@ -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;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -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);
|
} else if (viewType == VIEW_TYPE_HALF_WIDTH) {
|
||||||
case VIEW_TYPE_HALF_WIDTH:
|
return mHalfCardHelper.createViewHolder(view);
|
||||||
return mHalfCardHelper.createViewHolder(view);
|
|
||||||
default:
|
|
||||||
return mFullCardHelper.createViewHolder(view);
|
|
||||||
}
|
}
|
||||||
|
return mFullCardHelper.createViewHolder(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -132,30 +130,24 @@ 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);
|
} else if (holder.getItemViewType() == VIEW_TYPE_HALF_WIDTH) {
|
||||||
break;
|
mHalfCardHelper.bindView(holder, card, slice);
|
||||||
case VIEW_TYPE_HALF_WIDTH:
|
} else {
|
||||||
mHalfCardHelper.bindView(holder, card, slice);
|
mFullCardHelper.bindView(holder, card, slice);
|
||||||
break;
|
|
||||||
default:
|
|
||||||
mFullCardHelper.bindView(holder, card, slice);
|
|
||||||
}
|
}
|
||||||
if (swipeBackground != null) {
|
if (swipeBackground != null) {
|
||||||
swipeBackground.setVisibility(View.VISIBLE);
|
swipeBackground.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
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;
|
initDismissalActions(holder, card);
|
||||||
case VIEW_TYPE_HALF_WIDTH:
|
} else {
|
||||||
initDismissalActions(holder, card);
|
initDismissalActions(holder, card);
|
||||||
break;
|
|
||||||
default:
|
|
||||||
initDismissalActions(holder, card);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (card.isPendingDismiss()) {
|
if (card.isPendingDismiss()) {
|
||||||
|
@@ -52,21 +52,20 @@ 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) {
|
||||||
// Disable swiping when we are in the dismissal view
|
// Disable swiping when we are in the dismissal view
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return makeMovementFlags(0 /*dragFlags*/,
|
|
||||||
ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT /*swipeFlags*/);
|
|
||||||
default:
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
return makeMovementFlags(0 /*dragFlags*/,
|
||||||
|
ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT /*swipeFlags*/);
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -117,39 +117,33 @@ 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;
|
}
|
||||||
}
|
} else if (action == R.id.action_drag_move_down) {
|
||||||
break;
|
if (position + 1 < itemCount) {
|
||||||
case R.id.action_drag_move_down:
|
mAdapter.onItemMove(position, position + 1);
|
||||||
if (position + 1 < itemCount) {
|
result = true;
|
||||||
mAdapter.onItemMove(position, position + 1);
|
}
|
||||||
result = true;
|
} else if (action == R.id.action_drag_move_top) {
|
||||||
}
|
if (position != 0) {
|
||||||
break;
|
mAdapter.onItemMove(position, 0);
|
||||||
case R.id.action_drag_move_top:
|
result = true;
|
||||||
if (position != 0) {
|
}
|
||||||
mAdapter.onItemMove(position, 0);
|
} else if (action == R.id.action_drag_move_bottom) {
|
||||||
result = true;
|
if (position != itemCount - 1) {
|
||||||
}
|
mAdapter.onItemMove(position, itemCount - 1);
|
||||||
break;
|
result = true;
|
||||||
case R.id.action_drag_move_bottom:
|
}
|
||||||
if (position != itemCount - 1) {
|
} else if (action == R.id.action_drag_remove) {
|
||||||
mAdapter.onItemMove(position, itemCount - 1);
|
if (itemCount > 1) {
|
||||||
result = true;
|
mAdapter.removeItem(position);
|
||||||
}
|
result = true;
|
||||||
break;
|
}
|
||||||
case R.id.action_drag_remove:
|
} else {
|
||||||
if (itemCount > 1) {
|
return super.performAccessibilityActionForItem(recycler, state, host, action, args);
|
||||||
mAdapter.removeItem(position);
|
|
||||||
result = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return super.performAccessibilityActionForItem(recycler, state, host, action, args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
|
@@ -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;
|
} else if (checkedId == R.id.private_dns_mode_opportunistic) {
|
||||||
break;
|
mMode = PRIVATE_DNS_MODE_OPPORTUNISTIC;
|
||||||
case R.id.private_dns_mode_opportunistic:
|
} else if (checkedId == R.id.private_dns_mode_provider) {
|
||||||
mMode = PRIVATE_DNS_MODE_OPPORTUNISTIC;
|
mMode = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
|
||||||
break;
|
|
||||||
case R.id.private_dns_mode_provider:
|
|
||||||
mMode = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
updateDialogInfo();
|
updateDialogInfo();
|
||||||
}
|
}
|
||||||
|
@@ -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();
|
} else if (v.getId() == R.id.cancel_button) {
|
||||||
break;
|
getActivity().setResult(RESULT_CANCELED);
|
||||||
|
getActivity().finish();
|
||||||
case R.id.cancel_button:
|
|
||||||
getActivity().setResult(RESULT_CANCELED);
|
|
||||||
getActivity().finish();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1086,21 +1086,18 @@ 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());
|
if (removeDisallowedAdmin != null) {
|
||||||
if (removeDisallowedAdmin != null) {
|
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getContext(),
|
||||||
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getContext(),
|
removeDisallowedAdmin);
|
||||||
removeDisallowedAdmin);
|
} else {
|
||||||
} else {
|
onRemoveUserClicked(userId);
|
||||||
onRemoveUserClicked(userId);
|
}
|
||||||
}
|
} else if (v.getId() == UserPreference.SETTINGS_ID) {
|
||||||
break;
|
onManageUserClicked(userId, false);
|
||||||
case UserPreference.SETTINGS_ID:
|
|
||||||
onManageUserClicked(userId, false);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -153,17 +153,15 @@ public class VpnSettings extends RestrictedSettingsFragment implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
// Generate a new key. Here we just use the current time.
|
||||||
case R.id.vpn_create: {
|
if (item.getItemId() == R.id.vpn_create) {
|
||||||
// Generate a new key. Here we just use the current time.
|
long millis = System.currentTimeMillis();
|
||||||
long millis = System.currentTimeMillis();
|
while (mLegacyVpnPreferences.containsKey(Long.toHexString(millis))) {
|
||||||
while (mLegacyVpnPreferences.containsKey(Long.toHexString(millis))) {
|
++millis;
|
||||||
++millis;
|
|
||||||
}
|
|
||||||
VpnProfile profile = new VpnProfile(Long.toHexString(millis));
|
|
||||||
ConfigDialogFragment.show(this, profile, true /* editing */, false /* exists */);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
VpnProfile profile = new VpnProfile(Long.toHexString(millis));
|
||||||
|
ConfigDialogFragment.show(this, profile, true /* editing */, false /* exists */);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
@@ -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();
|
} else if (view.getId() == CANCEL_BUTTON_ID) {
|
||||||
break;
|
handleCancelAction();
|
||||||
case CANCEL_BUTTON_ID:
|
} else if (view.getId() == SSID_SCANNER_BUTTON_ID) {
|
||||||
handleCancelAction();
|
final TextView ssidEditText = getView().findViewById(R.id.ssid);
|
||||||
break;
|
ssid = ssidEditText.getText().toString();
|
||||||
case SSID_SCANNER_BUTTON_ID:
|
// No break and flows to case PASSWORD_SCANNER_BUTTON_ID
|
||||||
final TextView ssidEditText = getView().findViewById(R.id.ssid);
|
|
||||||
ssid = ssidEditText.getText().toString();
|
// Launch QR code scanner to join a network.
|
||||||
// No break and flows to case PASSWORD_SCANNER_BUTTON_ID
|
startActivityForResult(WifiDppUtils.getEnrolleeQrCodeScannerIntent(ssid),
|
||||||
case PASSWORD_SCANNER_BUTTON_ID:
|
REQUEST_CODE_WIFI_DPP_ENROLLEE_QR_CODE_SCANNER);
|
||||||
// Launch QR code scanner to join a network.
|
} else if (view.getId()
|
||||||
startActivityForResult(WifiDppUtils.getEnrolleeQrCodeScannerIntent(ssid),
|
== PASSWORD_SCANNER_BUTTON_ID) {// Launch QR code scanner to join a network.
|
||||||
REQUEST_CODE_WIFI_DPP_ENROLLEE_QR_CODE_SCANNER);
|
startActivityForResult(WifiDppUtils.getEnrolleeQrCodeScannerIntent(ssid),
|
||||||
break;
|
REQUEST_CODE_WIFI_DPP_ENROLLEE_QR_CODE_SCANNER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user