Make photos/videos storage preference normal.
We had special behavior for it in the past, but this defines new behavior that is much closer to what the other storage preferences do. A photo app filter is used and a photos/video files preference exists on it which intents over to the gallery app. Fixes: 64147318 Test: Settings robotests Change-Id: I47284515fe2dfcc924ae61a44bc47051e9f5fda6
This commit is contained in:
@@ -18,6 +18,7 @@ package com.android.settings.deviceinfo.storage;
|
||||
|
||||
import static android.content.pm.ApplicationInfo.CATEGORY_AUDIO;
|
||||
import static android.content.pm.ApplicationInfo.CATEGORY_GAME;
|
||||
import static android.content.pm.ApplicationInfo.CATEGORY_IMAGE;
|
||||
import static android.content.pm.ApplicationInfo.CATEGORY_VIDEO;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -134,6 +135,9 @@ public class StorageAsyncLoader
|
||||
case CATEGORY_VIDEO:
|
||||
result.videoAppsSize += blamedSize;
|
||||
break;
|
||||
case CATEGORY_IMAGE:
|
||||
result.photosAppsSize += blamedSize;
|
||||
break;
|
||||
default:
|
||||
// The deprecated game flag does not set the category.
|
||||
if ((app.flags & ApplicationInfo.FLAG_IS_GAME) != 0) {
|
||||
@@ -163,6 +167,7 @@ public class StorageAsyncLoader
|
||||
public static class AppsStorageResult {
|
||||
public long gamesSize;
|
||||
public long musicAppsSize;
|
||||
public long photosAppsSize;
|
||||
public long videoAppsSize;
|
||||
public long otherAppsSize;
|
||||
public long cacheSize;
|
||||
|
||||
@@ -59,7 +59,6 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
PreferenceControllerMixin {
|
||||
private static final String TAG = "StorageItemPreference";
|
||||
|
||||
private static final String IMAGE_MIME_TYPE = "image/*";
|
||||
private static final String SYSTEM_FRAGMENT_TAG = "SystemInfo";
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -93,9 +92,9 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
private StorageItemPreference mAppPreference;
|
||||
private StorageItemPreference mFilePreference;
|
||||
private StorageItemPreference mSystemPreference;
|
||||
private boolean mIsWorkProfile;
|
||||
|
||||
private static final String AUTHORITY_MEDIA = "com.android.providers.media.documents";
|
||||
private boolean mIsWorkProfile;
|
||||
|
||||
public StorageItemPreferenceController(
|
||||
Context context, Fragment hostFragment, VolumeInfo volume, StorageVolumeProvider svp) {
|
||||
@@ -259,7 +258,8 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
// TODO(b/35927909): Figure out how to split out apps which are only installed for work
|
||||
// profiles in order to attribute those app's code bytes only to that profile.
|
||||
mPhotoPreference.setStorageSize(
|
||||
data.externalStats.imageBytes + data.externalStats.videoBytes, mTotalSize);
|
||||
data.photosAppsSize + data.externalStats.imageBytes + data.externalStats.videoBytes,
|
||||
mTotalSize);
|
||||
mAudioPreference.setStorageSize(
|
||||
data.musicAppsSize + data.externalStats.audioBytes, mTotalSize);
|
||||
mGamePreference.setStorageSize(data.gamesSize, mTotalSize);
|
||||
@@ -280,10 +280,12 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
long attributedSize = 0;
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
final StorageAsyncLoader.AppsStorageResult otherData = result.valueAt(i);
|
||||
attributedSize += otherData.gamesSize
|
||||
+ otherData.musicAppsSize
|
||||
+ otherData.videoAppsSize
|
||||
+ otherData.otherAppsSize;
|
||||
attributedSize +=
|
||||
otherData.gamesSize
|
||||
+ otherData.musicAppsSize
|
||||
+ otherData.videoAppsSize
|
||||
+ otherData.photosAppsSize
|
||||
+ otherData.otherAppsSize;
|
||||
attributedSize += otherData.externalStats.totalBytes
|
||||
- otherData.externalStats.appBytes;
|
||||
}
|
||||
@@ -317,12 +319,21 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
}
|
||||
|
||||
private Intent getPhotosIntent() {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(android.content.Intent.ACTION_VIEW);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
||||
intent.setType(IMAGE_MIME_TYPE);
|
||||
intent.putExtra(Intent.EXTRA_FROM_STORAGE, true);
|
||||
return intent;
|
||||
Bundle args = new Bundle(2);
|
||||
args.putString(
|
||||
ManageApplications.EXTRA_CLASSNAME, Settings.PhotosStorageActivity.class.getName());
|
||||
args.putInt(
|
||||
ManageApplications.EXTRA_STORAGE_TYPE,
|
||||
ManageApplications.STORAGE_TYPE_PHOTOS_VIDEOS);
|
||||
return Utils.onBuildStartFragmentIntent(
|
||||
mContext,
|
||||
ManageApplications.class.getName(),
|
||||
args,
|
||||
null,
|
||||
R.string.storage_photos_videos,
|
||||
null,
|
||||
false,
|
||||
mMetricsFeatureProvider.getMetricsCategory(mFragment));
|
||||
}
|
||||
|
||||
private Intent getAudioIntent() {
|
||||
|
||||
Reference in New Issue
Block a user