Search in sources :

Example 1 with AppFilter

use of com.android.settingslib.applications.ApplicationsState.AppFilter in project android_packages_apps_Settings by LineageOS.

the class ManageApplicationsUnitTest method getCompositeFilter_filtersVolumeForVideo.

@Test
public void getCompositeFilter_filtersVolumeForVideo() {
    AppFilter filter = ManageApplications.getCompositeFilter(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();
}
Also used : AppFilter(com.android.settingslib.applications.ApplicationsState.AppFilter) ApplicationsState(com.android.settingslib.applications.ApplicationsState) ApplicationInfo(android.content.pm.ApplicationInfo) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest)

Example 2 with AppFilter

use of com.android.settingslib.applications.ApplicationsState.AppFilter in project android_packages_apps_Settings by crdroidandroid.

the class ManageApplications method createHeader.

@VisibleForTesting
void createHeader() {
    Activity activity = getActivity();
    FrameLayout pinnedHeader = (FrameLayout) mRootView.findViewById(R.id.pinned_header);
    mSpinnerHeader = activity.getLayoutInflater().inflate(R.layout.apps_filter_spinner, pinnedHeader, false);
    mFilterSpinner = (Spinner) mSpinnerHeader.findViewById(R.id.filter_spinner);
    mFilterAdapter = new FilterSpinnerAdapter(this);
    mFilterSpinner.setAdapter(mFilterAdapter);
    mFilterSpinner.setOnItemSelectedListener(this);
    pinnedHeader.addView(mSpinnerHeader, 0);
    mFilterAdapter.enableFilter(getDefaultFilter());
    if (mListType == LIST_TYPE_MAIN) {
        if (UserManager.get(getActivity()).getUserProfiles().size() > 1) {
            mFilterAdapter.enableFilter(FILTER_APPS_PERSONAL);
            mFilterAdapter.enableFilter(FILTER_APPS_WORK);
        }
    }
    if (mListType == LIST_TYPE_NOTIFICATION) {
        mFilterAdapter.enableFilter(FILTER_APPS_BLOCKED);
    }
    if (mListType == LIST_TYPE_HIGH_POWER) {
        mFilterAdapter.enableFilter(FILTER_APPS_POWER_WHITELIST_ALL);
    }
    AppFilter compositeFilter = getCompositeFilter(mListType, mStorageType, mVolumeUuid);
    if (mIsWorkOnly) {
        compositeFilter = new CompoundFilter(compositeFilter, FILTERS[FILTER_APPS_WORK]);
    }
    if (compositeFilter != null) {
        mApplications.setCompositeFilter(compositeFilter);
    }
}
Also used : AppFilter(com.android.settingslib.applications.ApplicationsState.AppFilter) FrameLayout(android.widget.FrameLayout) PreferenceFrameLayout(android.preference.PreferenceFrameLayout) UsageAccessSettingsActivity(com.android.settings.Settings.UsageAccessSettingsActivity) WriteSettingsActivity(com.android.settings.Settings.WriteSettingsActivity) AllApplicationsActivity(com.android.settings.Settings.AllApplicationsActivity) HighPowerApplicationsActivity(com.android.settings.Settings.HighPowerApplicationsActivity) SettingsActivity(com.android.settings.SettingsActivity) StorageUseActivity(com.android.settings.Settings.StorageUseActivity) GamesStorageActivity(com.android.settings.Settings.GamesStorageActivity) OverlaySettingsActivity(com.android.settings.Settings.OverlaySettingsActivity) NotificationAppListActivity(com.android.settings.Settings.NotificationAppListActivity) MoviesStorageActivity(com.android.settings.Settings.MoviesStorageActivity) ManageExternalSourcesActivity(com.android.settings.Settings.ManageExternalSourcesActivity) Activity(android.app.Activity) CompoundFilter(com.android.settingslib.applications.ApplicationsState.CompoundFilter) VisibleForTesting(android.support.annotation.VisibleForTesting)

Example 3 with AppFilter

use of com.android.settingslib.applications.ApplicationsState.AppFilter in project android_packages_apps_Settings by crdroidandroid.

the class ManageApplicationsUnitTest method getCompositeFilter_filtersVolumeForVideo.

@Test
public void getCompositeFilter_filtersVolumeForVideo() {
    AppFilter filter = ManageApplications.getCompositeFilter(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();
}
Also used : AppFilter(com.android.settingslib.applications.ApplicationsState.AppFilter) ApplicationsState(com.android.settingslib.applications.ApplicationsState) ApplicationInfo(android.content.pm.ApplicationInfo) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest)

Example 4 with AppFilter

use of com.android.settingslib.applications.ApplicationsState.AppFilter in project android_packages_apps_Settings by SudaMod.

the class ManageApplicationsUnitTest method getCompositeFilter_worksWithInstantApps.

@Test
public void getCompositeFilter_worksWithInstantApps() throws Exception {
    Field field = AppUtils.class.getDeclaredField("sInstantAppDataProvider");
    field.setAccessible(true);
    field.set(AppUtils.class, (InstantAppDataProvider) (i -> true));
    AppFilter filter = ManageApplications.getCompositeFilter(ManageApplications.LIST_TYPE_STORAGE, ManageApplications.STORAGE_TYPE_MUSIC, "uuid");
    AppFilter composedFilter = new CompoundFilter(ApplicationsState.FILTER_INSTANT, filter);
    final ApplicationInfo info = new ApplicationInfo();
    info.volumeUuid = "uuid";
    info.category = ApplicationInfo.CATEGORY_AUDIO;
    info.privateFlags = ApplicationInfo.PRIVATE_FLAG_INSTANT;
    final ApplicationsState.AppEntry appEntry = mock(ApplicationsState.AppEntry.class);
    appEntry.info = info;
    assertThat(composedFilter.filterApp(appEntry)).isTrue();
}
Also used : Field(java.lang.reflect.Field) AppFilter(com.android.settingslib.applications.ApplicationsState.AppFilter) ApplicationsState(com.android.settingslib.applications.ApplicationsState) ApplicationInfo(android.content.pm.ApplicationInfo) CompoundFilter(com.android.settingslib.applications.ApplicationsState.CompoundFilter) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest)

Example 5 with AppFilter

use of com.android.settingslib.applications.ApplicationsState.AppFilter in project android_packages_apps_Settings by SudaMod.

the class ManageApplicationsUnitTest method getCompositeFilter_filtersVolumeForVideo.

@Test
public void getCompositeFilter_filtersVolumeForVideo() {
    AppFilter filter = ManageApplications.getCompositeFilter(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();
}
Also used : AppFilter(com.android.settingslib.applications.ApplicationsState.AppFilter) ApplicationsState(com.android.settingslib.applications.ApplicationsState) ApplicationInfo(android.content.pm.ApplicationInfo) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest)

Aggregations

AppFilter (com.android.settingslib.applications.ApplicationsState.AppFilter)34 Test (org.junit.Test)26 ApplicationInfo (android.content.pm.ApplicationInfo)24 ApplicationsState (com.android.settingslib.applications.ApplicationsState)24 SmallTest (android.support.test.filters.SmallTest)18 CompoundFilter (com.android.settingslib.applications.ApplicationsState.CompoundFilter)16 Field (java.lang.reflect.Field)8 Activity (android.app.Activity)7 PreferenceFrameLayout (android.preference.PreferenceFrameLayout)7 FrameLayout (android.widget.FrameLayout)7 GamesStorageActivity (com.android.settings.Settings.GamesStorageActivity)7 HighPowerApplicationsActivity (com.android.settings.Settings.HighPowerApplicationsActivity)7 ManageExternalSourcesActivity (com.android.settings.Settings.ManageExternalSourcesActivity)7 MoviesStorageActivity (com.android.settings.Settings.MoviesStorageActivity)7 OverlaySettingsActivity (com.android.settings.Settings.OverlaySettingsActivity)7 StorageUseActivity (com.android.settings.Settings.StorageUseActivity)7 UsageAccessSettingsActivity (com.android.settings.Settings.UsageAccessSettingsActivity)7 WriteSettingsActivity (com.android.settings.Settings.WriteSettingsActivity)7 SettingsActivity (com.android.settings.SettingsActivity)7 VisibleForTesting (android.support.annotation.VisibleForTesting)6