Split Documents&Other
Splitting Documents&Other category in Settings > Storage into "Documents" and "Other". "Documents" category is calculated by querying MediaStore for all files with MediaType = "Document". "Other" category is calculated by querying MediaStore for all files with MEDIA_TYPE != "Image" AND MEDIA_TYPE != "Video" AND MEDIA_TYPE != "Audio" AND MEDIA_TYPE != "Document". Bug: 328505030 Test: atest StorageItemPreferenceControllerTest Test: atest StorageCacheHelperTest Change-Id: I413c502c7b3fd66df9a3b5e0d91f8bd024f4b6e0
This commit is contained in:
25
res/drawable/ic_category_vd_theme_24.xml
Normal file
25
res/drawable/ic_category_vd_theme_24.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<!--
|
||||
~ Copyright (C) 2024 The Android Open Source Project
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?android:attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M260,440L480,80L700,440L260,440ZM700,880Q625,880 572.5,827.5Q520,775 520,700Q520,625 572.5,572.5Q625,520 700,520Q775,520 827.5,572.5Q880,625 880,700Q880,775 827.5,827.5Q775,880 700,880ZM120,860L120,540L440,540L440,860L120,860ZM700,800Q742,800 771,771Q800,742 800,700Q800,658 771,629Q742,600 700,600Q658,600 629,629Q600,658 600,700Q600,742 629,771Q658,800 700,800ZM200,780L360,780L360,620L200,620L200,780ZM402,360L558,360L480,234L402,360ZM480,360L480,360L480,360L480,360ZM360,620L360,620L360,620L360,620L360,620ZM700,700Q700,700 700,700Q700,700 700,700Q700,700 700,700Q700,700 700,700Q700,700 700,700Q700,700 700,700Q700,700 700,700Q700,700 700,700Z"/>
|
||||
</vector>
|
@@ -604,8 +604,11 @@
|
||||
<!-- Media Uri to view audio storage category. -->
|
||||
<string name="config_audio_storage_category_uri" translatable="false">content://com.android.providers.media.documents/root/audio_root</string>
|
||||
|
||||
<!-- Media Uri to view documents & other storage category. -->
|
||||
<string name="config_documents_and_other_storage_category_uri" translatable="false">content://com.android.providers.media.documents/root/documents_root</string>
|
||||
<!-- Media Uri to view documents storage category. -->
|
||||
<string name="config_documents_storage_category_uri" translatable="false">content://com.android.providers.media.documents/root/documents_root</string>
|
||||
|
||||
<!-- Media Uri to view "other" storage category. -->
|
||||
<string name="config_other_storage_category_uri" translatable="false">content://com.android.providers.media.documents/root/others_root</string>
|
||||
|
||||
<!-- Whether to show Smart Storage toggle -->
|
||||
<bool name="config_show_smart_storage_toggle">true</bool>
|
||||
|
@@ -10968,9 +10968,6 @@
|
||||
<!-- Preference label for the Apps storage section. [CHAR LIMIT=50] -->
|
||||
<string name="storage_apps">Apps</string>
|
||||
|
||||
<!-- Preference label for the Documents & other storage section. [CHAR LIMIT=50] -->
|
||||
<string name="storage_documents_and_other">Documents & other</string>
|
||||
|
||||
<!-- Old Preference label for the System storage section. [CHAR LIMIT=50] -->
|
||||
<string name="storage_system">System</string>
|
||||
|
||||
|
@@ -57,15 +57,20 @@
|
||||
android:icon="@drawable/ic_videogame_vd_theme_24"
|
||||
android:order="105"/>
|
||||
<com.android.settings.deviceinfo.StorageItemPreference
|
||||
android:key="pref_documents_and_other"
|
||||
android:title="@string/storage_documents_and_other"
|
||||
android:key="pref_documents"
|
||||
android:title="@string/storage_documents"
|
||||
android:icon="@drawable/ic_folder_vd_theme_24"
|
||||
android:order="106"/>
|
||||
<com.android.settings.deviceinfo.StorageItemPreference
|
||||
android:key="pref_other"
|
||||
android:title="@string/storage_other"
|
||||
android:icon="@drawable/ic_category_vd_theme_24"
|
||||
android:order="107"/>
|
||||
<com.android.settings.deviceinfo.StorageItemPreference
|
||||
android:key="pref_trash"
|
||||
android:title="@string/storage_trash"
|
||||
android:icon="@drawable/ic_trash_can"
|
||||
android:order="107"/>
|
||||
android:order="108"/>
|
||||
<!-- Preference order 100~200 are 'ONLY' for storage category
|
||||
preferences that are sorted by size. -->
|
||||
<PreferenceCategory
|
||||
|
@@ -76,15 +76,20 @@
|
||||
android:icon="@drawable/ic_videogame_vd_theme_24"
|
||||
android:order="105"/>
|
||||
<com.android.settings.deviceinfo.StorageItemPreference
|
||||
android:key="pref_documents_and_other"
|
||||
android:title="@string/storage_documents_and_other"
|
||||
android:key="pref_documents"
|
||||
android:title="@string/storage_documents"
|
||||
android:icon="@drawable/ic_folder_vd_theme_24"
|
||||
android:order="106"/>
|
||||
<com.android.settings.deviceinfo.StorageItemPreference
|
||||
android:key="pref_other"
|
||||
android:title="@string/storage_other"
|
||||
android:icon="@drawable/ic_category_vd_theme_24"
|
||||
android:order="107"/>
|
||||
<com.android.settings.deviceinfo.StorageItemPreference
|
||||
android:key="pref_trash"
|
||||
android:title="@string/storage_trash"
|
||||
android:icon="@drawable/ic_trash_can"
|
||||
android:order="107"/>
|
||||
android:order="108"/>
|
||||
<!-- Preference order 100~200 are 'ONLY' for storage category
|
||||
preferences that are sorted by size. -->
|
||||
<PreferenceCategory
|
||||
|
@@ -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;
|
||||
|
@@ -36,6 +36,7 @@ public class StorageCacheHelperTest {
|
||||
private static final long FAKE_APPS_SIZE = 4000L;
|
||||
private static final long FAKE_GAMES_SIZE = 5000L;
|
||||
private static final long FAKE_DOCS_SIZE = 1500L;
|
||||
private static final long FAKE_OTHER_SIZE = 2000L;
|
||||
private static final long FAKE_TRASH_SIZE = 500L;
|
||||
private static final long FAKE_SYSTEM_SIZE = 2300L;
|
||||
private static final long FAKE_TOTAL_SIZE = 256000L;
|
||||
@@ -72,6 +73,8 @@ public class StorageCacheHelperTest {
|
||||
|
||||
assertThat(storageCache.imagesSize).isEqualTo(FAKE_IMAGES_SIZE);
|
||||
assertThat(storageCache.temporaryFilesSize).isEqualTo(FAKE_TEMPORARY_FILES_SIZE);
|
||||
assertThat(storageCache.documentsSize).isEqualTo(FAKE_DOCS_SIZE);
|
||||
assertThat(storageCache.otherSize).isEqualTo(FAKE_OTHER_SIZE);
|
||||
assertThat(storageCache.totalSize).isEqualTo(0);
|
||||
}
|
||||
|
||||
@@ -97,7 +100,8 @@ public class StorageCacheHelperTest {
|
||||
result.trashSize = FAKE_TRASH_SIZE;
|
||||
result.systemSize = FAKE_SYSTEM_SIZE;
|
||||
result.imagesSize = FAKE_IMAGES_SIZE;
|
||||
result.documentsAndOtherSize = FAKE_DOCS_SIZE;
|
||||
result.documentsSize = FAKE_DOCS_SIZE;
|
||||
result.otherSize = FAKE_OTHER_SIZE;
|
||||
result.audioSize = FAKE_AUDIO_SIZE;
|
||||
result.gamesSize = FAKE_GAMES_SIZE;
|
||||
result.videosSize = FAKE_VIDEOS_SIZE;
|
||||
|
@@ -124,8 +124,10 @@ public class StorageItemPreferenceControllerTest {
|
||||
apps.setIcon(R.drawable.ic_storage_apps);
|
||||
final StorageItemPreference games = spy(new StorageItemPreference(mContext));
|
||||
games.setIcon(R.drawable.ic_videogame_vd_theme_24);
|
||||
final StorageItemPreference documentsAndOther = spy(new StorageItemPreference(mContext));
|
||||
documentsAndOther.setIcon(R.drawable.ic_folder_vd_theme_24);
|
||||
final StorageItemPreference documents = spy(new StorageItemPreference(mContext));
|
||||
documents.setIcon(R.drawable.ic_folder_vd_theme_24);
|
||||
final StorageItemPreference other = spy(new StorageItemPreference(mContext));
|
||||
other.setIcon(R.drawable.ic_category_vd_theme_24);
|
||||
final StorageItemPreference system = spy(new StorageItemPreference(mContext));
|
||||
system.setIcon(R.drawable.ic_android_vd_theme_24);
|
||||
final StorageItemPreference temporaryFiles = spy(new StorageItemPreference(mContext));
|
||||
@@ -147,8 +149,10 @@ public class StorageItemPreferenceControllerTest {
|
||||
.thenReturn(apps);
|
||||
when(screen.findPreference(eq(StorageItemPreferenceController.GAMES_KEY)))
|
||||
.thenReturn(games);
|
||||
when(screen.findPreference(eq(StorageItemPreferenceController.DOCUMENTS_AND_OTHER_KEY)))
|
||||
.thenReturn(documentsAndOther);
|
||||
when(screen.findPreference(eq(StorageItemPreferenceController.DOCUMENTS_KEY)))
|
||||
.thenReturn(documents);
|
||||
when(screen.findPreference(eq(StorageItemPreferenceController.OTHER_KEY)))
|
||||
.thenReturn(other);
|
||||
when(screen.findPreference(eq(StorageItemPreferenceController.SYSTEM_KEY)))
|
||||
.thenReturn(system);
|
||||
when(screen.findPreference(eq(StorageItemPreferenceController.TEMPORARY_FILES_KEY)))
|
||||
@@ -225,7 +229,8 @@ public class StorageItemPreferenceControllerTest {
|
||||
assertThat(mController.mAudioPreference.isVisible()).isFalse();
|
||||
assertThat(mController.mAppsPreference.isVisible()).isFalse();
|
||||
assertThat(mController.mGamesPreference.isVisible()).isFalse();
|
||||
assertThat(mController.mDocumentsAndOtherPreference.isVisible()).isFalse();
|
||||
assertThat(mController.mDocumentsPreference.isVisible()).isFalse();
|
||||
assertThat(mController.mOtherPreference.isVisible()).isFalse();
|
||||
assertThat(mController.mSystemPreference.isVisible()).isFalse();
|
||||
assertThat(mController.mTemporaryFilesPreference.isVisible()).isFalse();
|
||||
assertThat(mController.mTrashPreference.isVisible()).isFalse();
|
||||
@@ -278,8 +283,8 @@ public class StorageItemPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void launchDocumentsAndOtherIntent_resolveActionViewNull_settingsIntent() {
|
||||
mPreference.setKey(StorageItemPreferenceController.DOCUMENTS_AND_OTHER_KEY);
|
||||
public void launchDocumentsIntent_resolveActionViewNull_settingsIntent() {
|
||||
mPreference.setKey(StorageItemPreferenceController.DOCUMENTS_KEY);
|
||||
final Context mockContext = getMockContext();
|
||||
mController = new StorageItemPreferenceController(mockContext, mFragment, mVolume,
|
||||
mSvp, ProfileSelectFragment.ProfileType.PERSONAL);
|
||||
@@ -291,7 +296,24 @@ public class StorageItemPreferenceControllerTest {
|
||||
|
||||
Intent intent = argumentCaptor.getValue();
|
||||
assertThat(intent.getAction()).isEqualTo(Intent.ACTION_VIEW);
|
||||
assertThat(intent.getData()).isEqualTo(mController.mDocumentsAndOtherUri);
|
||||
assertThat(intent.getData()).isEqualTo(mController.mDocumentsUri);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void launchOtherIntent_resolveActionViewNull_settingsIntent() {
|
||||
mPreference.setKey(StorageItemPreferenceController.OTHER_KEY);
|
||||
final Context mockContext = getMockContext();
|
||||
mController = new StorageItemPreferenceController(mockContext, mFragment, mVolume,
|
||||
mSvp, ProfileSelectFragment.ProfileType.PERSONAL);
|
||||
mController.handlePreferenceTreeClick(mPreference);
|
||||
|
||||
final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
|
||||
verify(mockContext).startActivityAsUser(argumentCaptor.capture(),
|
||||
nullable(UserHandle.class));
|
||||
|
||||
Intent intent = argumentCaptor.getValue();
|
||||
assertThat(intent.getAction()).isEqualTo(Intent.ACTION_VIEW);
|
||||
assertThat(intent.getData()).isEqualTo(mController.mOtherUri);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -359,7 +381,8 @@ public class StorageItemPreferenceControllerTest {
|
||||
result.imagesSize = MEGABYTE_IN_BYTES * 350;
|
||||
result.videosSize = GIGABYTE_IN_BYTES * 30;
|
||||
result.audioSize = MEGABYTE_IN_BYTES * 40;
|
||||
result.documentsAndOtherSize = MEGABYTE_IN_BYTES * 50;
|
||||
result.documentsSize = MEGABYTE_IN_BYTES * 50;
|
||||
result.otherSize = MEGABYTE_IN_BYTES * 70;
|
||||
result.trashSize = KILOBYTE_IN_BYTES * 100;
|
||||
result.allAppsExceptGamesSize = MEGABYTE_IN_BYTES * 90;
|
||||
result.systemSize = MEGABYTE_IN_BYTES * 60;
|
||||
@@ -373,8 +396,8 @@ public class StorageItemPreferenceControllerTest {
|
||||
assertThat(mController.mAudioPreference.getSummary().toString()).isEqualTo("40 MB");
|
||||
assertThat(mController.mAppsPreference.getSummary().toString()).isEqualTo("90 MB");
|
||||
assertThat(mController.mGamesPreference.getSummary().toString()).isEqualTo("80 MB");
|
||||
assertThat(mController.mDocumentsAndOtherPreference.getSummary().toString())
|
||||
.isEqualTo("50 MB");
|
||||
assertThat(mController.mDocumentsPreference.getSummary().toString()).isEqualTo("50 MB");
|
||||
assertThat(mController.mOtherPreference.getSummary().toString()).isEqualTo("70 MB");
|
||||
assertThat(mController.mTrashPreference.getSummary().toString()).isEqualTo("100 kB");
|
||||
assertThat(mController.mSystemPreference.getSummary().toString())
|
||||
.isEqualTo("60 MB");
|
||||
@@ -392,8 +415,8 @@ public class StorageItemPreferenceControllerTest {
|
||||
verify(mController.mAudioPreference, times(2)).setIcon(nullable(Drawable.class));
|
||||
verify(mController.mAppsPreference, times(2)).setIcon(nullable(Drawable.class));
|
||||
verify(mController.mGamesPreference, times(2)).setIcon(nullable(Drawable.class));
|
||||
verify(mController.mDocumentsAndOtherPreference, times(2))
|
||||
.setIcon(nullable(Drawable.class));
|
||||
verify(mController.mDocumentsPreference, times(2)).setIcon(nullable(Drawable.class));
|
||||
verify(mController.mOtherPreference, times(2)).setIcon(nullable(Drawable.class));
|
||||
verify(mController.mSystemPreference, times(2)).setIcon(nullable(Drawable.class));
|
||||
verify(mController.mTemporaryFilesPreference, times(2)).setIcon(nullable(Drawable.class));
|
||||
verify(mController.mTrashPreference, times(2)).setIcon(nullable(Drawable.class));
|
||||
@@ -408,7 +431,8 @@ public class StorageItemPreferenceControllerTest {
|
||||
|
||||
mController.displayPreference(mPreferenceScreen);
|
||||
|
||||
assertThat(mController.mDocumentsAndOtherPreference.isVisible()).isTrue();
|
||||
assertThat(mController.mDocumentsPreference.isVisible()).isTrue();
|
||||
assertThat(mController.mOtherPreference.isVisible()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -423,7 +447,8 @@ public class StorageItemPreferenceControllerTest {
|
||||
|
||||
mController.setPrivateStorageCategoryPreferencesVisibility(true);
|
||||
|
||||
assertThat(mController.mDocumentsAndOtherPreference.isVisible()).isFalse();
|
||||
assertThat(mController.mDocumentsPreference.isVisible()).isFalse();
|
||||
assertThat(mController.mOtherPreference.isVisible()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -438,7 +463,8 @@ public class StorageItemPreferenceControllerTest {
|
||||
// And we bring it back.
|
||||
mController.setVolume(mVolume);
|
||||
|
||||
assertThat(mController.mDocumentsAndOtherPreference.isVisible()).isTrue();
|
||||
assertThat(mController.mDocumentsPreference.isVisible()).isTrue();
|
||||
assertThat(mController.mOtherPreference.isVisible()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -458,7 +484,8 @@ public class StorageItemPreferenceControllerTest {
|
||||
assertThat(mController.mAudioPreference.isVisible()).isFalse();
|
||||
assertThat(mController.mAppsPreference.isVisible()).isFalse();
|
||||
assertThat(mController.mGamesPreference.isVisible()).isFalse();
|
||||
assertThat(mController.mDocumentsAndOtherPreference.isVisible()).isFalse();
|
||||
assertThat(mController.mDocumentsPreference.isVisible()).isFalse();
|
||||
assertThat(mController.mOtherPreference.isVisible()).isFalse();
|
||||
assertThat(mController.mSystemPreference.isVisible()).isFalse();
|
||||
assertThat(mController.mTemporaryFilesPreference.isVisible()).isFalse();
|
||||
assertThat(mController.mTrashPreference.isVisible()).isFalse();
|
||||
|
Reference in New Issue
Block a user