use of com.android.settings.deviceinfo.storage.StorageUtils.MountTask in project android_packages_apps_Settings by omnirom.
the class VolumeOptionMenuController method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (!mFragment.isAdded()) {
return false;
}
final int menuId = menuItem.getItemId();
if (menuId == R.id.storage_mount) {
if (mStorageEntry.isUnmounted()) {
new MountTask(mFragment.getActivity(), mStorageEntry.getVolumeInfo()).execute();
return true;
}
return false;
}
if (menuId == R.id.storage_unmount) {
if (mStorageEntry.isMounted()) {
if (mStorageEntry.isPublic()) {
new UnmountTask(mFragment.getActivity(), mStorageEntry.getVolumeInfo()).execute();
return true;
}
if (mStorageEntry.isPrivate() && !mStorageEntry.isDefaultInternalStorage()) {
final Bundle args = new Bundle();
args.putString(VolumeInfo.EXTRA_VOLUME_ID, mStorageEntry.getId());
new SubSettingLauncher(mContext).setDestination(PrivateVolumeUnmount.class.getCanonicalName()).setTitleRes(R.string.storage_menu_unmount).setSourceMetricsCategory(SettingsEnums.DEVICEINFO_STORAGE).setArguments(args).launch();
return true;
}
}
return false;
}
if (menuId == R.id.storage_rename) {
if ((mStorageEntry.isPrivate() && !mStorageEntry.isDefaultInternalStorage()) || mStorageEntry.isPublic()) {
StorageRenameFragment.show(mFragment, mStorageEntry.getVolumeInfo());
return true;
}
return false;
}
if (menuId == R.id.storage_format) {
if (mStorageEntry.isDiskInfoUnsupported() || mStorageEntry.isPublic()) {
StorageWizardFormatConfirm.showPublic(mFragment.getActivity(), mStorageEntry.getDiskId());
return true;
}
return false;
}
if (menuId == R.id.storage_format_as_portable) {
if (mStorageEntry.isPrivate()) {
final Bundle args = new Bundle();
args.putString(VolumeInfo.EXTRA_VOLUME_ID, mStorageEntry.getId());
new SubSettingLauncher(mContext).setDestination(PrivateVolumeFormat.class.getCanonicalName()).setTitleRes(R.string.storage_menu_format).setSourceMetricsCategory(SettingsEnums.DEVICEINFO_STORAGE).setArguments(args).launch();
return true;
}
return false;
}
if (menuId == R.id.storage_format_as_internal) {
if (mStorageEntry.isPublic()) {
StorageWizardFormatConfirm.showPrivate(mFragment.getActivity(), mStorageEntry.getDiskId());
return true;
}
return false;
}
if (menuId == R.id.storage_migrate) {
if (mStorageEntry.isPrivate()) {
final Intent intent = new Intent(mContext, StorageWizardMigrateConfirm.class);
intent.putExtra(VolumeInfo.EXTRA_VOLUME_ID, mStorageEntry.getId());
mContext.startActivity(intent);
return true;
}
return false;
}
if (menuId == R.id.storage_forget) {
if (mStorageEntry.isVolumeRecordMissed()) {
StorageUtils.launchForgetMissingVolumeRecordFragment(mContext, mStorageEntry);
return true;
}
return false;
}
return false;
}
Aggregations