Add a movies & tv apps category to storage settings.
Change-Id: Idfabe83739272b19cbef4b13a82339170f8f97b3
Fixes: 36223441
Test: Settings Robotest
diff --git a/res/drawable/ic_theaters_vd_theme_24.xml b/res/drawable/ic_theaters_vd_theme_24.xml
new file mode 100644
index 0000000..d0bad19
--- /dev/null
+++ b/res/drawable/ic_theaters_vd_theme_24.xml
@@ -0,0 +1,25 @@
+<!--
+ Copyright (C) 2017 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="24.0"
+ android:viewportHeight="24.0"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M18,3v2h-2L16,3L8,3v2L6,5L6,3L4,3v18h2v-2h2v2h8v-2h2v2h2L20,3h-2zM8,17L6,17v-2h2v2zM8,13L6,13v-2h2v2zM8,9L6,9L6,7h2v2zM18,17h-2v-2h2v2zM18,13h-2v-2h2v2zM18,9h-2L16,7h2v2z"/>
+</vector>
\ No newline at end of file
diff --git a/res/xml/storage_dashboard_fragment.xml b/res/xml/storage_dashboard_fragment.xml
index 354a700..b31d0eb 100644
--- a/res/xml/storage_dashboard_fragment.xml
+++ b/res/xml/storage_dashboard_fragment.xml
@@ -47,15 +47,20 @@
android:icon="@drawable/ic_videogame_vd_theme_24"
android:order="4" />
<com.android.settings.deviceinfo.StorageItemPreference
+ android:key="pref_movies"
+ android:title="@string/storage_movies_tv"
+ android:icon="@drawable/ic_theaters_vd_theme_24"
+ android:order="5" />
+ <com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_other_apps"
android:title="@string/storage_other_apps"
android:icon="@drawable/ic_apps_vd_theme_24"
- android:order="5" />
+ android:order="6" />
<com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_files"
android:title="@string/storage_files"
android:icon="@drawable/ic_folder_vd_theme_24"
- android:order="6" />
+ android:order="7" />
<com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_system"
android:title="@string/storage_detail_system"
diff --git a/res/xml/storage_profile_fragment.xml b/res/xml/storage_profile_fragment.xml
index 98cb1dc..0485279 100644
--- a/res/xml/storage_profile_fragment.xml
+++ b/res/xml/storage_profile_fragment.xml
@@ -34,6 +34,9 @@
android:icon="@drawable/ic_videogame_vd_theme_24"
android:order="4" />
<com.android.settings.deviceinfo.StorageItemPreference
+ android:key="pref_movies"
+ android:title="@string/storage_movies_tv" />
+ <com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_other_apps"
android:title="@string/storage_other_apps"
android:icon="@drawable/ic_apps_vd_theme_24"
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 8f645f8..9313281 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -118,6 +118,7 @@
public static class ManageDomainUrlsActivity extends SettingsActivity { /* empty */ }
public static class AutomaticStorageManagerSettingsActivity extends SettingsActivity { /* empty */ }
public static class GamesStorageActivity extends SettingsActivity { /* empty */ }
+ public static class MoviesStorageActivity extends SettingsActivity { /* empty */ }
public static class TopLevelSettings extends SettingsActivity { /* empty */ }
public static class ApnSettingsActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/applications/ManageApplications.java b/src/com/android/settings/applications/ManageApplications.java
index f83dfeb..3499df6 100644
--- a/src/com/android/settings/applications/ManageApplications.java
+++ b/src/com/android/settings/applications/ManageApplications.java
@@ -61,6 +61,7 @@
import com.android.settings.Settings.GamesStorageActivity;
import com.android.settings.Settings.HighPowerApplicationsActivity;
import com.android.settings.Settings.ManageExternalSourcesActivity;
+import com.android.settings.Settings.MoviesStorageActivity;
import com.android.settings.Settings.NotificationAppListActivity;
import com.android.settings.Settings.OverlaySettingsActivity;
import com.android.settings.Settings.StorageUseActivity;
@@ -253,6 +254,7 @@
public static final int LIST_TYPE_WRITE_SETTINGS = 7;
public static final int LIST_TYPE_MANAGE_SOURCES = 8;
public static final int LIST_TYPE_GAMES = 9;
+ public static final int LIST_TYPE_MOVIES = 10;
private View mRootView;
@@ -307,6 +309,9 @@
} else if (className.equals(GamesStorageActivity.class.getName())) {
mListType = LIST_TYPE_GAMES;
mSortOrder = R.id.sort_order_size;
+ } else if (className.equals(MoviesStorageActivity.class.getName())) {
+ mListType = LIST_TYPE_MOVIES;
+ mSortOrder = R.id.sort_order_size;
} else {
mListType = LIST_TYPE_MAIN;
}
@@ -415,6 +420,8 @@
}
if (mListType == LIST_TYPE_GAMES) {
mApplications.setOverrideFilter(ApplicationsState.FILTER_GAMES);
+ } else if (mListType == LIST_TYPE_MOVIES) {
+ mApplications.setOverrideFilter(ApplicationsState.FILTER_MOVIES);
}
}
@@ -441,6 +448,7 @@
case LIST_TYPE_NOTIFICATION:
case LIST_TYPE_STORAGE:
case LIST_TYPE_GAMES:
+ case LIST_TYPE_MOVIES:
return mSortOrder == R.id.sort_order_alpha;
default:
return false;
@@ -461,6 +469,8 @@
return MetricsEvent.APPLICATIONS_STORAGE_APPS;
case LIST_TYPE_GAMES:
return MetricsEvent.APPLICATIONS_STORAGE_GAMES;
+ case LIST_TYPE_MOVIES:
+ return MetricsEvent.APPLICATIONS_STORAGE_MOVIES;
case LIST_TYPE_USAGE_ACCESS:
return MetricsEvent.USAGE_ACCESS;
case LIST_TYPE_HIGH_POWER:
@@ -568,6 +578,9 @@
case LIST_TYPE_GAMES:
startAppInfoFragment(AppStorageSettings.class, R.string.game_storage_settings);
break;
+ case LIST_TYPE_MOVIES:
+ startAppInfoFragment(AppStorageSettings.class, R.string.storage_movies_tv);
+ break;
// TODO: Figure out if there is a way where we can spin up the profile's settings
// process ahead of time, to avoid a long load of data when user clicks on a managed app.
// Maybe when they load the list of apps that contains managed profile apps.
diff --git a/src/com/android/settings/deviceinfo/StorageProfileFragment.java b/src/com/android/settings/deviceinfo/StorageProfileFragment.java
index c5d1045..7e2d941 100644
--- a/src/com/android/settings/deviceinfo/StorageProfileFragment.java
+++ b/src/com/android/settings/deviceinfo/StorageProfileFragment.java
@@ -140,6 +140,7 @@
// TODO(b/35927909): Attribute app sizes better than zeroing out for profiles.
result.gamesSize = 0;
result.musicAppsSize = 0;
+ result.videoAppsSize = 0;
result.otherAppsSize = 0;
return result;
}
diff --git a/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java b/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java
index ae5e5f1..e83c5d2 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java
@@ -18,6 +18,7 @@
import static android.content.pm.ApplicationInfo.CATEGORY_AUDIO;
import static android.content.pm.ApplicationInfo.CATEGORY_GAME;
+import static android.content.pm.ApplicationInfo.CATEGORY_VIDEO;
import android.content.Context;
import android.content.pm.ApplicationInfo;
@@ -99,6 +100,9 @@
case CATEGORY_AUDIO:
result.musicAppsSize += attributedAppSizeInBytes;
break;
+ case CATEGORY_VIDEO:
+ result.videoAppsSize += attributedAppSizeInBytes;
+ break;
default:
// The deprecated game flag does not set the category.
if ((app.flags & ApplicationInfo.FLAG_IS_GAME) != 0) {
@@ -123,6 +127,7 @@
public static class AppsStorageResult {
public long gamesSize;
public long musicAppsSize;
+ public long videoAppsSize;
public long otherAppsSize;
public long systemSize;
public StorageStatsSource.ExternalStorageStats externalStats;
diff --git a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
index 5b27592..36694f0 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
@@ -65,6 +65,8 @@
@VisibleForTesting
static final String GAME_KEY = "pref_games";
@VisibleForTesting
+ static final String MOVIES_KEY = "pref_movies";
+ @VisibleForTesting
static final String OTHER_APPS_KEY = "pref_other_apps";
@VisibleForTesting
static final String SYSTEM_KEY = "pref_system";
@@ -82,6 +84,7 @@
private StorageItemPreference mPhotoPreference;
private StorageItemPreference mAudioPreference;
private StorageItemPreference mGamePreference;
+ private StorageItemPreference mMoviesPreference;
private StorageItemPreference mAppPreference;
private StorageItemPreference mFilePreference;
private StorageItemPreference mSystemPreference;
@@ -123,6 +126,9 @@
case GAME_KEY:
intent = getGamesIntent();
break;
+ case MOVIES_KEY:
+ intent = getMoviesIntent();
+ break;
case OTHER_APPS_KEY:
// Because we are likely constructed with a null volume, this is theoretically
// possible.
@@ -204,6 +210,7 @@
mPhotoPreference = (StorageItemPreference) screen.findPreference(PHOTO_KEY);
mAudioPreference = (StorageItemPreference) screen.findPreference(AUDIO_KEY);
mGamePreference = (StorageItemPreference) screen.findPreference(GAME_KEY);
+ mMoviesPreference = (StorageItemPreference) screen.findPreference(MOVIES_KEY);
mAppPreference = (StorageItemPreference) screen.findPreference(OTHER_APPS_KEY);
mSystemPreference = (StorageItemPreference) screen.findPreference(SYSTEM_KEY);
mFilePreference = (StorageItemPreference) screen.findPreference(FILES_KEY);
@@ -217,6 +224,7 @@
mAudioPreference.setStorageSize(
data.musicAppsSize + data.externalStats.audioBytes, mTotalSize);
mGamePreference.setStorageSize(data.gamesSize, mTotalSize);
+ mMoviesPreference.setStorageSize(data.videoAppsSize, mTotalSize);
mAppPreference.setStorageSize(data.otherAppsSize, mTotalSize);
if (mSystemPreference != null) {
mSystemPreference.setStorageSize(mSystemSize + data.systemSize, mTotalSize);
@@ -243,6 +251,7 @@
list.add(PHOTO_KEY);
list.add(AUDIO_KEY);
list.add(GAME_KEY);
+ list.add(MOVIES_KEY);
list.add(OTHER_APPS_KEY);
list.add(SYSTEM_KEY);
list.add(FILES_KEY);
@@ -281,12 +290,21 @@
}
private Intent getGamesIntent() {
- Bundle args = new Bundle(1);
- args.putString(ManageApplications.EXTRA_CLASSNAME,
- Settings.GamesStorageActivity.class.getName());
- return Utils.onBuildStartFragmentIntent(mContext,
- ManageApplications.class.getName(), args, null, R.string.game_storage_settings,
- null, false, mMetricsFeatureProvider.getMetricsCategory(mFragment));
+ Bundle args = new Bundle(1);
+ args.putString(ManageApplications.EXTRA_CLASSNAME,
+ Settings.GamesStorageActivity.class.getName());
+ return Utils.onBuildStartFragmentIntent(mContext,
+ ManageApplications.class.getName(), args, null, R.string.game_storage_settings,
+ null, false, mMetricsFeatureProvider.getMetricsCategory(mFragment));
+ }
+
+ private Intent getMoviesIntent() {
+ Bundle args = new Bundle(1);
+ args.putString(ManageApplications.EXTRA_CLASSNAME,
+ Settings.MoviesStorageActivity.class.getName());
+ return Utils.onBuildStartFragmentIntent(mContext,
+ ManageApplications.class.getName(), args, null, R.string.storage_movies_tv,
+ null, false, mMetricsFeatureProvider.getMetricsCategory(mFragment));
}
private Intent getFilesIntent() {
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/StorageProfileFragmentTest.java b/tests/robotests/src/com/android/settings/deviceinfo/StorageProfileFragmentTest.java
index 8da2a9c..8d48e63 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/StorageProfileFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/StorageProfileFragmentTest.java
@@ -44,6 +44,7 @@
result.musicAppsSize = 100;
result.otherAppsSize = 200;
result.gamesSize = 300;
+ result.videoAppsSize = 400;
result.externalStats = new StorageStatsSource.ExternalStorageStats(6, 1, 2, 3);
SparseArray<StorageAsyncLoader.AppsStorageResult> resultsArray = new SparseArray<>();
resultsArray.put(0, result);
@@ -57,6 +58,7 @@
StorageAsyncLoader.AppsStorageResult extractedResult = resultCaptor.getValue();
assertThat(extractedResult.musicAppsSize).isEqualTo(0);
+ assertThat(extractedResult.videoAppsSize).isEqualTo(0);
assertThat(extractedResult.otherAppsSize).isEqualTo(0);
assertThat(extractedResult.gamesSize).isEqualTo(0);
assertThat(extractedResult.externalStats.audioBytes).isEqualTo(1);
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
index 7d1f79b..47faf92 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
@@ -190,6 +190,24 @@
}
@Test
+ public void testClickMovies() {
+ mPreference.setKey("pref_movies");
+ mController.handlePreferenceTreeClick(mPreference);
+
+ final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
+ verify(mFragment.getActivity()).startActivityAsUser(argumentCaptor.capture(),
+ any(UserHandle.class));
+
+ Intent intent = argumentCaptor.getValue();
+ assertThat(intent.getAction()).isEqualTo(Intent.ACTION_MAIN);
+ assertThat(intent.getComponent().getClassName()).isEqualTo(SubSettings.class.getName());
+ assertThat(intent.getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT)).isEqualTo(
+ ManageApplications.class.getName());
+ assertThat(intent.getIntExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID, 0))
+ .isEqualTo(R.string.storage_movies_tv);
+ }
+
+ @Test
public void testClickSystem() {
mPreference.setKey("pref_system");
assertThat(mController.handlePreferenceTreeClick(mPreference)).isTrue();
@@ -203,6 +221,7 @@
StorageItemPreference audio = new StorageItemPreference(mContext);
StorageItemPreference image = new StorageItemPreference(mContext);
StorageItemPreference games = new StorageItemPreference(mContext);
+ StorageItemPreference movies = new StorageItemPreference(mContext);
StorageItemPreference apps = new StorageItemPreference(mContext);
StorageItemPreference system = new StorageItemPreference(mContext);
StorageItemPreference files = new StorageItemPreference(mContext);
@@ -214,6 +233,8 @@
when(screen.findPreference(
eq(StorageItemPreferenceController.GAME_KEY))).thenReturn(games);
when(screen.findPreference(
+ eq(StorageItemPreferenceController.MOVIES_KEY))).thenReturn(movies);
+ when(screen.findPreference(
eq(StorageItemPreferenceController.OTHER_APPS_KEY))).thenReturn(apps);
when(screen.findPreference(
eq(StorageItemPreferenceController.SYSTEM_KEY))).thenReturn(system);
@@ -224,6 +245,7 @@
mController.setSystemSize(KILOBYTE * 6);
StorageAsyncLoader.AppsStorageResult result = new StorageAsyncLoader.AppsStorageResult();
result.gamesSize = KILOBYTE * 8;
+ result.videoAppsSize = KILOBYTE * 16;
result.musicAppsSize = KILOBYTE * 4;
result.otherAppsSize = KILOBYTE * 9;
result.systemSize = KILOBYTE * 10;
@@ -240,6 +262,7 @@
assertThat(audio.getSummary().toString()).isEqualTo("14.00KB"); // 4KB apps + 10KB files
assertThat(image.getSummary().toString()).isEqualTo("35.00KB"); // 15KB video + 20KB images
assertThat(games.getSummary().toString()).isEqualTo("8.00KB");
+ assertThat(movies.getSummary().toString()).isEqualTo("16.00KB");
assertThat(apps.getSummary().toString()).isEqualTo("9.00KB");
assertThat(system.getSummary().toString()).isEqualTo("16.00KB");
assertThat(files.getSummary().toString()).isEqualTo("5.00KB");
diff --git a/tests/unit/src/com/android/settings/deviceinfo/storage/StorageAsyncLoaderTest.java b/tests/unit/src/com/android/settings/deviceinfo/storage/StorageAsyncLoaderTest.java
index 617e9bb..e82482e 100644
--- a/tests/unit/src/com/android/settings/deviceinfo/storage/StorageAsyncLoaderTest.java
+++ b/tests/unit/src/com/android/settings/deviceinfo/storage/StorageAsyncLoaderTest.java
@@ -169,6 +169,17 @@
assertThat(result.get(PRIMARY_USER_ID).otherAppsSize).isEqualTo(11L);
}
+ @Test
+ public void testVideoAppsAreFiltered() throws Exception {
+ addPackage(PACKAGE_NAME_1, 0, 1, 10, ApplicationInfo.CATEGORY_VIDEO);
+
+ SparseArray<StorageAsyncLoader.AppsStorageResult> result = mLoader.loadInBackground();
+
+ assertThat(result.size()).isEqualTo(1);
+ assertThat(result.get(PRIMARY_USER_ID).videoAppsSize).isEqualTo(11L);
+ assertThat(result.get(PRIMARY_USER_ID).otherAppsSize).isEqualTo(0);
+ }
+
private ApplicationInfo addPackage(
String packageName, long cacheSize, long codeSize, long dataSize, int category) {
StorageStatsSource.AppStorageStats storageStats =