Merge "Filter on volume for category storage view." into oc-dev am: a41a190ac3

am: 854acc9e4b

Change-Id: I21c985df9ee34981b47c080756df5dc442f335b6
This commit is contained in:
Daniel Nishi
2017-05-02 17:09:37 +00:00
committed by android-build-merger
2 changed files with 93 additions and 8 deletions

View File

@@ -416,20 +416,28 @@ public class ManageApplications extends InstrumentedPreferenceFragment
if (mListType == LIST_TYPE_HIGH_POWER) {
mFilterAdapter.enableFilter(FILTER_APPS_POWER_WHITELIST_ALL);
}
if (mListType == LIST_TYPE_STORAGE) {
AppFilter filter = new VolumeFilter(mVolumeUuid);
if (mStorageType == STORAGE_TYPE_MUSIC) {
// Storage filters below.
mApplications.setOverrideFilter(getStorageFilter(mListType, mStorageType, mVolumeUuid));
}
@VisibleForTesting
static AppFilter getStorageFilter(int listType, int storageType, String volumeUuid) {
AppFilter filter = new VolumeFilter(volumeUuid);
if (listType == LIST_TYPE_STORAGE) {
if (storageType == STORAGE_TYPE_MUSIC) {
filter = new CompoundFilter(ApplicationsState.FILTER_AUDIO, filter);
} else {
filter = new CompoundFilter(ApplicationsState.FILTER_OTHER_APPS, filter);
}
mApplications.setOverrideFilter(filter);
return filter;
}
if (mListType == LIST_TYPE_GAMES) {
mApplications.setOverrideFilter(ApplicationsState.FILTER_GAMES);
} else if (mListType == LIST_TYPE_MOVIES) {
mApplications.setOverrideFilter(ApplicationsState.FILTER_MOVIES);
if (listType == LIST_TYPE_GAMES) {
return new CompoundFilter(ApplicationsState.FILTER_GAMES, filter);
} else if (listType == LIST_TYPE_MOVIES) {
return new CompoundFilter(ApplicationsState.FILTER_MOVIES, filter);
}
return filter;
}
private int getDefaultFilter() {

View File

@@ -0,0 +1,77 @@
/*
* 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.
*/
package com.android.settings.applications;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.mock;
import android.content.pm.ApplicationInfo;
import com.android.settingslib.applications.ApplicationsState;
import org.junit.Test;
public class ManageApplicationsTest {
@Test
public void getStorageFilter_filtersVolumeForAudio() {
ApplicationsState.AppFilter filter =
ManageApplications.getStorageFilter(
ManageApplications.LIST_TYPE_STORAGE,
ManageApplications.STORAGE_TYPE_MUSIC,
"uuid");
final ApplicationInfo info = new ApplicationInfo();
info.volumeUuid = "uuid";
info.category = ApplicationInfo.CATEGORY_AUDIO;
final ApplicationsState.AppEntry appEntry = mock(ApplicationsState.AppEntry.class);
appEntry.info = info;
assertThat(filter.filterApp(appEntry)).isTrue();
}
@Test
public void getStorageFilter_filtersVolumeForVideo() {
ApplicationsState.AppFilter filter =
ManageApplications.getStorageFilter(
ManageApplications.LIST_TYPE_MOVIES,
ManageApplications.STORAGE_TYPE_DEFAULT,
"uuid");
final ApplicationInfo info = new ApplicationInfo();
info.volumeUuid = "uuid";
info.category = ApplicationInfo.CATEGORY_VIDEO;
final ApplicationsState.AppEntry appEntry = mock(ApplicationsState.AppEntry.class);
appEntry.info = info;
assertThat(filter.filterApp(appEntry)).isTrue();
}
@Test
public void getStorageFilter_filtersVolumeForGames() {
ApplicationsState.AppFilter filter =
ManageApplications.getStorageFilter(
ManageApplications.LIST_TYPE_GAMES,
ManageApplications.STORAGE_TYPE_DEFAULT,
"uuid");
final ApplicationInfo info = new ApplicationInfo();
info.volumeUuid = "uuid";
info.category = ApplicationInfo.CATEGORY_GAME;
final ApplicationsState.AppEntry appEntry = mock(ApplicationsState.AppEntry.class);
appEntry.info = info;
assertThat(filter.filterApp(appEntry)).isTrue();
}
}