Search in sources :

Example 1 with MountTask

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;
}
Also used : SubSettingLauncher(com.android.settings.core.SubSettingLauncher) Bundle(android.os.Bundle) UnmountTask(com.android.settings.deviceinfo.storage.StorageUtils.UnmountTask) Intent(android.content.Intent) MountTask(com.android.settings.deviceinfo.storage.StorageUtils.MountTask)

Aggregations

Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 SubSettingLauncher (com.android.settings.core.SubSettingLauncher)1 MountTask (com.android.settings.deviceinfo.storage.StorageUtils.MountTask)1 UnmountTask (com.android.settings.deviceinfo.storage.StorageUtils.UnmountTask)1