Merge "Split Documents&Other" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
84bdea6756
@@ -98,15 +98,24 @@ public class StorageAsyncLoader
|
||||
media /* queryArgs */);
|
||||
result.systemSize = getSystemSize();
|
||||
|
||||
final Bundle documentsAndOtherQueryArgs = new Bundle();
|
||||
documentsAndOtherQueryArgs.putString(ContentResolver.QUERY_ARG_SQL_SELECTION,
|
||||
FileColumns.MEDIA_TYPE + "!=" + FileColumns.MEDIA_TYPE_IMAGE
|
||||
+ " AND " + FileColumns.MEDIA_TYPE + "!=" + FileColumns.MEDIA_TYPE_VIDEO
|
||||
+ " AND " + FileColumns.MEDIA_TYPE + "!=" + FileColumns.MEDIA_TYPE_AUDIO
|
||||
+ " AND " + FileColumns.MIME_TYPE + " IS NOT NULL");
|
||||
result.documentsAndOtherSize = getFilesSize(info.id,
|
||||
final Bundle documentsQueryArgs = new Bundle();
|
||||
documentsQueryArgs.putString(ContentResolver.QUERY_ARG_SQL_SELECTION,
|
||||
FileColumns.MEDIA_TYPE + "=" + FileColumns.MEDIA_TYPE_DOCUMENT);
|
||||
result.documentsSize = getFilesSize(info.id,
|
||||
MediaStore.Files.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY),
|
||||
documentsAndOtherQueryArgs);
|
||||
documentsQueryArgs);
|
||||
|
||||
final Bundle otherQueryArgs = new Bundle();
|
||||
otherQueryArgs.putString(ContentResolver.QUERY_ARG_SQL_SELECTION,
|
||||
FileColumns.MEDIA_TYPE + "!=" + FileColumns.MEDIA_TYPE_IMAGE
|
||||
+ " AND " + FileColumns.MEDIA_TYPE + "!=" + FileColumns.MEDIA_TYPE_VIDEO
|
||||
+ " AND " + FileColumns.MEDIA_TYPE + "!=" + FileColumns.MEDIA_TYPE_AUDIO
|
||||
+ " AND " + FileColumns.MEDIA_TYPE + "!="
|
||||
+ FileColumns.MEDIA_TYPE_DOCUMENT
|
||||
+ " AND " + FileColumns.MIME_TYPE + " IS NOT NULL");
|
||||
result.otherSize = getFilesSize(info.id,
|
||||
MediaStore.Files.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY),
|
||||
otherQueryArgs);
|
||||
|
||||
final Bundle trashQueryArgs = new Bundle();
|
||||
trashQueryArgs.putInt(MediaStore.QUERY_ARG_MATCH_TRASHED, MediaStore.MATCH_ONLY);
|
||||
@@ -236,7 +245,8 @@ public class StorageAsyncLoader
|
||||
public long audioSize;
|
||||
public long imagesSize;
|
||||
public long videosSize;
|
||||
public long documentsAndOtherSize;
|
||||
public long documentsSize;
|
||||
public long otherSize;
|
||||
public long trashSize;
|
||||
public long systemSize;
|
||||
|
||||
|
||||
@@ -32,7 +32,8 @@ public class StorageCacheHelper {
|
||||
private static final String AUDIO_SIZE_KEY = "audio_size_key";
|
||||
private static final String APPS_SIZE_KEY = "apps_size_key";
|
||||
private static final String GAMES_SIZE_KEY = "games_size_key";
|
||||
private static final String DOCUMENTS_AND_OTHER_SIZE_KEY = "documents_and_other_size_key";
|
||||
private static final String DOCUMENTS_SIZE_KEY = "documents_size_key";
|
||||
private static final String OTHER_SIZE_KEY = "other_size_key";
|
||||
private static final String TRASH_SIZE_KEY = "trash_size_key";
|
||||
private static final String SYSTEM_SIZE_KEY = "system_size_key";
|
||||
private static final String TEMPORARY_FILES_SIZE_KEY = "temporary_files_size_key";
|
||||
@@ -64,7 +65,8 @@ public class StorageCacheHelper {
|
||||
.putLong(AUDIO_SIZE_KEY, data.audioSize)
|
||||
.putLong(APPS_SIZE_KEY, data.allAppsExceptGamesSize)
|
||||
.putLong(GAMES_SIZE_KEY, data.gamesSize)
|
||||
.putLong(DOCUMENTS_AND_OTHER_SIZE_KEY, data.documentsAndOtherSize)
|
||||
.putLong(DOCUMENTS_SIZE_KEY, data.documentsSize)
|
||||
.putLong(OTHER_SIZE_KEY, data.otherSize)
|
||||
.putLong(TRASH_SIZE_KEY, data.trashSize)
|
||||
.putLong(SYSTEM_SIZE_KEY, data.systemSize)
|
||||
.putLong(TEMPORARY_FILES_SIZE_KEY, data.temporaryFilesSize)
|
||||
@@ -108,7 +110,8 @@ public class StorageCacheHelper {
|
||||
result.audioSize = mSharedPreferences.getLong(AUDIO_SIZE_KEY, 0);
|
||||
result.allAppsExceptGamesSize = mSharedPreferences.getLong(APPS_SIZE_KEY, 0);
|
||||
result.gamesSize = mSharedPreferences.getLong(GAMES_SIZE_KEY, 0);
|
||||
result.documentsAndOtherSize = mSharedPreferences.getLong(DOCUMENTS_AND_OTHER_SIZE_KEY, 0);
|
||||
result.documentsSize = mSharedPreferences.getLong(DOCUMENTS_SIZE_KEY, 0);
|
||||
result.otherSize = mSharedPreferences.getLong(OTHER_SIZE_KEY, 0);
|
||||
result.trashSize = mSharedPreferences.getLong(TRASH_SIZE_KEY, 0);
|
||||
result.systemSize = mSharedPreferences.getLong(SYSTEM_SIZE_KEY, 0);
|
||||
result.temporaryFilesSize = mSharedPreferences.getLong(TEMPORARY_FILES_SIZE_KEY, 0);
|
||||
@@ -126,7 +129,8 @@ public class StorageCacheHelper {
|
||||
public long audioSize;
|
||||
public long imagesSize;
|
||||
public long videosSize;
|
||||
public long documentsAndOtherSize;
|
||||
public long documentsSize;
|
||||
public long otherSize;
|
||||
public long trashSize;
|
||||
public long systemSize;
|
||||
public long temporaryFilesSize;
|
||||
|
||||
@@ -92,7 +92,9 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
@VisibleForTesting
|
||||
static final String GAMES_KEY = "pref_games";
|
||||
@VisibleForTesting
|
||||
static final String DOCUMENTS_AND_OTHER_KEY = "pref_documents_and_other";
|
||||
static final String DOCUMENTS_KEY = "pref_documents";
|
||||
@VisibleForTesting
|
||||
static final String OTHER_KEY = "pref_other";
|
||||
@VisibleForTesting
|
||||
static final String SYSTEM_KEY = "pref_system";
|
||||
@VisibleForTesting
|
||||
@@ -109,7 +111,9 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
@VisibleForTesting
|
||||
final Uri mAudioUri;
|
||||
@VisibleForTesting
|
||||
final Uri mDocumentsAndOtherUri;
|
||||
final Uri mDocumentsUri;
|
||||
@VisibleForTesting
|
||||
final Uri mOtherUri;
|
||||
|
||||
// This value should align with the design of storage_dashboard_fragment.xml
|
||||
private static final int LAST_STORAGE_CATEGORY_PREFERENCE_ORDER = 200;
|
||||
@@ -139,7 +143,9 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
@VisibleForTesting
|
||||
@Nullable StorageItemPreference mGamesPreference;
|
||||
@VisibleForTesting
|
||||
@Nullable StorageItemPreference mDocumentsAndOtherPreference;
|
||||
@Nullable StorageItemPreference mDocumentsPreference;
|
||||
@VisibleForTesting
|
||||
@Nullable StorageItemPreference mOtherPreference;
|
||||
@VisibleForTesting
|
||||
@Nullable StorageItemPreference mTrashPreference;
|
||||
@VisibleForTesting
|
||||
@@ -186,8 +192,10 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
.getString(R.string.config_videos_storage_category_uri));
|
||||
mAudioUri = Uri.parse(context.getResources()
|
||||
.getString(R.string.config_audio_storage_category_uri));
|
||||
mDocumentsAndOtherUri = Uri.parse(context.getResources()
|
||||
.getString(R.string.config_documents_and_other_storage_category_uri));
|
||||
mDocumentsUri = Uri.parse(context.getResources()
|
||||
.getString(R.string.config_documents_storage_category_uri));
|
||||
mOtherUri = Uri.parse(context.getResources()
|
||||
.getString(R.string.config_other_storage_category_uri));
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -224,8 +232,11 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
case GAMES_KEY:
|
||||
launchGamesIntent();
|
||||
return true;
|
||||
case DOCUMENTS_AND_OTHER_KEY:
|
||||
launchActivityWithUri(mDocumentsAndOtherUri);
|
||||
case DOCUMENTS_KEY:
|
||||
launchActivityWithUri(mDocumentsUri);
|
||||
return true;
|
||||
case OTHER_KEY:
|
||||
launchActivityWithUri(mOtherUri);
|
||||
return true;
|
||||
case SYSTEM_KEY:
|
||||
final SystemInfoFragment dialog = new SystemInfoFragment();
|
||||
@@ -311,9 +322,11 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
// If we don't have a shared volume for our internal storage (or the shared volume isn't
|
||||
// mounted as readable for whatever reason), we should hide the File preference.
|
||||
if (visible) {
|
||||
mDocumentsAndOtherPreference.setVisible(mIsDocumentsPrefShown);
|
||||
mDocumentsPreference.setVisible(mIsDocumentsPrefShown);
|
||||
mOtherPreference.setVisible(mIsDocumentsPrefShown);
|
||||
} else {
|
||||
mDocumentsAndOtherPreference.setVisible(false);
|
||||
mDocumentsPreference.setVisible(false);
|
||||
mOtherPreference.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,20 +343,24 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
if (mPrivateStorageItemPreferences == null) {
|
||||
mPrivateStorageItemPreferences = new ArrayList<>();
|
||||
|
||||
mPrivateStorageItemPreferences.add(mImagesPreference);
|
||||
mPrivateStorageItemPreferences.add(mVideosPreference);
|
||||
mPrivateStorageItemPreferences.add(mAudioPreference);
|
||||
mPrivateStorageItemPreferences.add(mAppsPreference);
|
||||
mPrivateStorageItemPreferences.add(mGamesPreference);
|
||||
mPrivateStorageItemPreferences.add(mDocumentsAndOtherPreference);
|
||||
// Adding categories in the reverse order so that
|
||||
// They would be in the right order after sorting
|
||||
mPrivateStorageItemPreferences.add(mTrashPreference);
|
||||
mPrivateStorageItemPreferences.add(mOtherPreference);
|
||||
mPrivateStorageItemPreferences.add(mDocumentsPreference);
|
||||
mPrivateStorageItemPreferences.add(mGamesPreference);
|
||||
mPrivateStorageItemPreferences.add(mAppsPreference);
|
||||
mPrivateStorageItemPreferences.add(mAudioPreference);
|
||||
mPrivateStorageItemPreferences.add(mVideosPreference);
|
||||
mPrivateStorageItemPreferences.add(mImagesPreference);
|
||||
}
|
||||
mScreen.removePreference(mImagesPreference);
|
||||
mScreen.removePreference(mVideosPreference);
|
||||
mScreen.removePreference(mAudioPreference);
|
||||
mScreen.removePreference(mAppsPreference);
|
||||
mScreen.removePreference(mGamesPreference);
|
||||
mScreen.removePreference(mDocumentsAndOtherPreference);
|
||||
mScreen.removePreference(mDocumentsPreference);
|
||||
mScreen.removePreference(mOtherPreference);
|
||||
mScreen.removePreference(mTrashPreference);
|
||||
|
||||
// Sort display order by size.
|
||||
@@ -378,7 +395,8 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
tintPreference(mAudioPreference);
|
||||
tintPreference(mAppsPreference);
|
||||
tintPreference(mGamesPreference);
|
||||
tintPreference(mDocumentsAndOtherPreference);
|
||||
tintPreference(mDocumentsPreference);
|
||||
tintPreference(mOtherPreference);
|
||||
tintPreference(mSystemPreference);
|
||||
tintPreference(mTemporaryFilesPreference);
|
||||
tintPreference(mTrashPreference);
|
||||
@@ -408,7 +426,8 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
mAudioPreference = screen.findPreference(AUDIO_KEY);
|
||||
mAppsPreference = screen.findPreference(APPS_KEY);
|
||||
mGamesPreference = screen.findPreference(GAMES_KEY);
|
||||
mDocumentsAndOtherPreference = screen.findPreference(DOCUMENTS_AND_OTHER_KEY);
|
||||
mDocumentsPreference = screen.findPreference(DOCUMENTS_KEY);
|
||||
mOtherPreference = screen.findPreference(OTHER_KEY);
|
||||
mCategorySplitterPreferenceCategory = screen.findPreference(CATEGORY_SPLITTER);
|
||||
mSystemPreference = screen.findPreference(SYSTEM_KEY);
|
||||
mTemporaryFilesPreference = screen.findPreference(TEMPORARY_FILES_KEY);
|
||||
@@ -434,8 +453,8 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
mAudioPreference.setStorageSize(storageCache.audioSize, mTotalSize, animate);
|
||||
mAppsPreference.setStorageSize(storageCache.allAppsExceptGamesSize, mTotalSize, animate);
|
||||
mGamesPreference.setStorageSize(storageCache.gamesSize, mTotalSize, animate);
|
||||
mDocumentsAndOtherPreference.setStorageSize(storageCache.documentsAndOtherSize, mTotalSize,
|
||||
animate);
|
||||
mDocumentsPreference.setStorageSize(storageCache.documentsSize, mTotalSize, animate);
|
||||
mOtherPreference.setStorageSize(storageCache.otherSize, mTotalSize, animate);
|
||||
mTrashPreference.setStorageSize(storageCache.trashSize, mTotalSize, animate);
|
||||
if (mSystemPreference != null) {
|
||||
mSystemPreference.setStorageSize(storageCache.systemSize, mTotalSize, animate);
|
||||
@@ -471,7 +490,8 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
storageCache.audioSize = data.audioSize;
|
||||
storageCache.allAppsExceptGamesSize = data.allAppsExceptGamesSize;
|
||||
storageCache.gamesSize = data.gamesSize;
|
||||
storageCache.documentsAndOtherSize = data.documentsAndOtherSize;
|
||||
storageCache.documentsSize = data.documentsSize;
|
||||
storageCache.otherSize = data.otherSize;
|
||||
storageCache.trashSize = data.trashSize;
|
||||
storageCache.systemSize = data.systemSize;
|
||||
// Everything else that hasn't already been attributed is tracked as
|
||||
@@ -484,7 +504,8 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
+ otherData.audioSize
|
||||
+ otherData.videosSize
|
||||
+ otherData.imagesSize
|
||||
+ otherData.documentsAndOtherSize
|
||||
+ otherData.documentsSize
|
||||
+ otherData.otherSize
|
||||
+ otherData.trashSize
|
||||
+ otherData.allAppsExceptGamesSize;
|
||||
attributedSize -= otherData.duplicateCodeSize;
|
||||
|
||||
Reference in New Issue
Block a user