use of com.android.settings.deviceinfo.StorageItemPreference in project android_packages_apps_Settings by omnirom.
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();
}
}
use of com.android.settings.deviceinfo.StorageItemPreference in project android_packages_apps_Settings by crdroidandroid.
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);
}
use of com.android.settings.deviceinfo.StorageItemPreference in project android_packages_apps_Settings by crdroidandroid.
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);
}
use of com.android.settings.deviceinfo.StorageItemPreference in project android_packages_apps_Settings by crdroidandroid.
the class StorageItemPreferenceControllerTest method settingUserIdAppliesNewIcons.
@Test
public void settingUserIdAppliesNewIcons() {
StorageItemPreference audio = spy(new StorageItemPreference(mContext));
audio.setIcon(R.drawable.ic_media_stream);
StorageItemPreference video = spy(new StorageItemPreference(mContext));
video.setIcon(R.drawable.ic_local_movies);
StorageItemPreference image = spy(new StorageItemPreference(mContext));
image.setIcon(R.drawable.ic_photo_library);
StorageItemPreference games = spy(new StorageItemPreference(mContext));
games.setIcon(R.drawable.ic_videogame_vd_theme_24);
StorageItemPreference apps = spy(new StorageItemPreference(mContext));
apps.setIcon(R.drawable.ic_storage_apps);
StorageItemPreference system = spy(new StorageItemPreference(mContext));
system.setIcon(R.drawable.ic_system_update_vd_theme_24);
StorageItemPreference files = spy(new StorageItemPreference(mContext));
files.setIcon(R.drawable.ic_folder_vd_theme_24);
PreferenceScreen screen = mock(PreferenceScreen.class);
when(screen.findPreference(eq(StorageItemPreferenceController.AUDIO_KEY))).thenReturn(audio);
when(screen.findPreference(eq(StorageItemPreferenceController.MOVIES_KEY))).thenReturn(video);
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);
mController.displayPreference(screen);
mController.setUserId(new UserHandle(10));
verify(audio, times(2)).setIcon(nullable(Drawable.class));
verify(video, times(2)).setIcon(nullable(Drawable.class));
verify(image, times(2)).setIcon(nullable(Drawable.class));
verify(games, times(2)).setIcon(nullable(Drawable.class));
verify(apps, times(2)).setIcon(nullable(Drawable.class));
verify(system, times(2)).setIcon(nullable(Drawable.class));
verify(files, times(2)).setIcon(nullable(Drawable.class));
}
use of com.android.settings.deviceinfo.StorageItemPreference in project android_packages_apps_Settings by crdroidandroid.
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);
}
Aggregations