Search in sources :

Example 16 with StorageItemPreference

use of com.android.settings.deviceinfo.StorageItemPreference in project android_packages_apps_Settings by DirtyUnicorns.

the class StorageItemPreferenceControllerTest method displayPreference_hideFilePreferenceWhenNoEmulatedInternalStorage.

@Test
public void displayPreference_hideFilePreferenceWhenNoEmulatedInternalStorage() {
    StorageItemPreference audio = new StorageItemPreference(mContext);
    StorageItemPreference image = new StorageItemPreference(mContext);
    StorageItemPreference games = new StorageItemPreference(mContext);
    StorageItemPreference apps = new StorageItemPreference(mContext);
    StorageItemPreference system = new StorageItemPreference(mContext);
    StorageItemPreference files = new StorageItemPreference(mContext);
    PreferenceScreen screen = mock(PreferenceScreen.class);
    when(screen.findPreference(eq(StorageItemPreferenceController.AUDIO_KEY))).thenReturn(audio);
    when(screen.findPreference(eq(StorageItemPreferenceController.PHOTO_KEY))).thenReturn(image);
    when(screen.findPreference(eq(StorageItemPreferenceController.GAME_KEY))).thenReturn(games);
    when(screen.findPreference(eq(StorageItemPreferenceController.OTHER_APPS_KEY))).thenReturn(apps);
    when(screen.findPreference(eq(StorageItemPreferenceController.SYSTEM_KEY))).thenReturn(system);
    when(screen.findPreference(eq(StorageItemPreferenceController.FILES_KEY))).thenReturn(files);
    when(mSvp.findEmulatedForPrivate(nullable(VolumeInfo.class))).thenReturn(null);
    mController.displayPreference(screen);
    verify(screen).removePreference(files);
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) VolumeInfo(android.os.storage.VolumeInfo) StorageItemPreference(com.android.settings.deviceinfo.StorageItemPreference) Test(org.junit.Test)

Example 17 with StorageItemPreference

use of com.android.settings.deviceinfo.StorageItemPreference in project android_packages_apps_Settings by DirtyUnicorns.

the class StorageItemPreferenceControllerTest method displayPreference_updateFilePreferenceToShowAfterSettingVolume.

@Test
public void displayPreference_updateFilePreferenceToShowAfterSettingVolume() {
    StorageItemPreference audio = new StorageItemPreference(mContext);
    StorageItemPreference image = new StorageItemPreference(mContext);
    StorageItemPreference games = new StorageItemPreference(mContext);
    StorageItemPreference apps = new StorageItemPreference(mContext);
    StorageItemPreference system = new StorageItemPreference(mContext);
    StorageItemPreference files = new StorageItemPreference(mContext);
    PreferenceScreen screen = mock(PreferenceScreen.class);
    when(screen.findPreference(eq(StorageItemPreferenceController.AUDIO_KEY))).thenReturn(audio);
    when(screen.findPreference(eq(StorageItemPreferenceController.PHOTO_KEY))).thenReturn(image);
    when(screen.findPreference(eq(StorageItemPreferenceController.GAME_KEY))).thenReturn(games);
    when(screen.findPreference(eq(StorageItemPreferenceController.OTHER_APPS_KEY))).thenReturn(apps);
    when(screen.findPreference(eq(StorageItemPreferenceController.SYSTEM_KEY))).thenReturn(system);
    when(screen.findPreference(eq(StorageItemPreferenceController.FILES_KEY))).thenReturn(files);
    // This will hide it initially.
    mController.displayPreference(screen);
    when(mSvp.findEmulatedForPrivate(nullable(VolumeInfo.class))).thenReturn(mVolume);
    when(mVolume.isMountedReadable()).thenReturn(true);
    // And we bring it back.
    mController.setVolume(mVolume);
    verify(screen).addPreference(files);
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) VolumeInfo(android.os.storage.VolumeInfo) StorageItemPreference(com.android.settings.deviceinfo.StorageItemPreference) Test(org.junit.Test)

Example 18 with StorageItemPreference

use of com.android.settings.deviceinfo.StorageItemPreference in project android_packages_apps_Settings by DirtyUnicorns.

the class StorageItemPreferenceControllerTest method displayPreference_hideFilePreferenceWhenEmulatedStorageUnreadable.

@Test
public void displayPreference_hideFilePreferenceWhenEmulatedStorageUnreadable() {
    StorageItemPreference audio = new StorageItemPreference(mContext);
    StorageItemPreference image = new StorageItemPreference(mContext);
    StorageItemPreference games = new StorageItemPreference(mContext);
    StorageItemPreference apps = new StorageItemPreference(mContext);
    StorageItemPreference system = new StorageItemPreference(mContext);
    StorageItemPreference files = new StorageItemPreference(mContext);
    PreferenceScreen screen = mock(PreferenceScreen.class);
    when(screen.findPreference(eq(StorageItemPreferenceController.AUDIO_KEY))).thenReturn(audio);
    when(screen.findPreference(eq(StorageItemPreferenceController.PHOTO_KEY))).thenReturn(image);
    when(screen.findPreference(eq(StorageItemPreferenceController.GAME_KEY))).thenReturn(games);
    when(screen.findPreference(eq(StorageItemPreferenceController.OTHER_APPS_KEY))).thenReturn(apps);
    when(screen.findPreference(eq(StorageItemPreferenceController.SYSTEM_KEY))).thenReturn(system);
    when(screen.findPreference(eq(StorageItemPreferenceController.FILES_KEY))).thenReturn(files);
    when(mSvp.findEmulatedForPrivate(nullable(VolumeInfo.class))).thenReturn(mVolume);
    when(mVolume.isMountedReadable()).thenReturn(false);
    mController.displayPreference(screen);
    verify(screen).removePreference(files);
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) VolumeInfo(android.os.storage.VolumeInfo) StorageItemPreference(com.android.settings.deviceinfo.StorageItemPreference) Test(org.junit.Test)

Example 19 with StorageItemPreference

use of com.android.settings.deviceinfo.StorageItemPreference in project android_packages_apps_Settings by DirtyUnicorns.

the class SecondaryUserController method displayPreference.

@Override
public void displayPreference(PreferenceScreen screen) {
    if (mStoragePreference == null) {
        mStoragePreference = new StorageItemPreference(screen.getContext());
        PreferenceGroup group = (PreferenceGroup) screen.findPreference(TARGET_PREFERENCE_GROUP_KEY);
        mStoragePreference.setTitle(mUser.name);
        mStoragePreference.setKey(PREFERENCE_KEY_BASE + mUser.id);
        if (mSize != SIZE_NOT_SET) {
            mStoragePreference.setStorageSize(mSize, mTotalSizeBytes);
        }
        group.setVisible(true);
        group.addPreference(mStoragePreference);
        maybeSetIcon();
    }
}
Also used : PreferenceGroup(android.support.v7.preference.PreferenceGroup) StorageItemPreference(com.android.settings.deviceinfo.StorageItemPreference)

Example 20 with StorageItemPreference

use of com.android.settings.deviceinfo.StorageItemPreference in project platform_packages_apps_Settings by BlissRoms.

the class SecondaryUserController method displayPreference.

@Override
public void displayPreference(PreferenceScreen screen) {
    if (mStoragePreference == null) {
        mStoragePreference = new StorageItemPreference(screen.getContext());
        PreferenceGroup group = (PreferenceGroup) screen.findPreference(TARGET_PREFERENCE_GROUP_KEY);
        mStoragePreference.setTitle(mUser.name);
        mStoragePreference.setKey(PREFERENCE_KEY_BASE + mUser.id);
        if (mSize != SIZE_NOT_SET) {
            mStoragePreference.setStorageSize(mSize, mTotalSizeBytes);
        }
        group.setVisible(true);
        group.addPreference(mStoragePreference);
        maybeSetIcon();
    }
}
Also used : PreferenceGroup(android.support.v7.preference.PreferenceGroup) StorageItemPreference(com.android.settings.deviceinfo.StorageItemPreference)

Aggregations

StorageItemPreference (com.android.settings.deviceinfo.StorageItemPreference)70 Test (org.junit.Test)49 VolumeInfo (android.os.storage.VolumeInfo)42 PreferenceScreen (android.support.v7.preference.PreferenceScreen)42 Drawable (android.graphics.drawable.Drawable)7 UserHandle (android.os.UserHandle)7 SparseArray (android.util.SparseArray)7 LayoutInflater (android.view.LayoutInflater)7 LinearLayout (android.widget.LinearLayout)7 PreferenceScreen (androidx.preference.PreferenceScreen)7 StorageStatsSource (com.android.settingslib.applications.StorageStatsSource)7 Before (org.junit.Before)7 PreferenceGroup (android.support.v7.preference.PreferenceGroup)6 View (android.view.View)6 PreferenceGroup (androidx.preference.PreferenceGroup)1