Search in sources :

Example 1 with UnmountTask

use of com.android.settings.deviceinfo.storage.StorageUtils.UnmountTask 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)

Example 2 with UnmountTask

use of com.android.settings.deviceinfo.storage.StorageUtils.UnmountTask in project android_packages_apps_Settings by omnirom.

the class StorageUnmountReceiver method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    final StorageManager storage = context.getSystemService(StorageManager.class);
    final String volId = intent.getStringExtra(VolumeInfo.EXTRA_VOLUME_ID);
    final VolumeInfo vol = storage.findVolumeById(volId);
    if (vol != null) {
        new UnmountTask(context, vol).execute();
    } else {
        Log.w(TAG, "Missing volume " + volId);
    }
}
Also used : StorageManager(android.os.storage.StorageManager) UnmountTask(com.android.settings.deviceinfo.storage.StorageUtils.UnmountTask) VolumeInfo(android.os.storage.VolumeInfo)

Aggregations

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