Merge "Reduce flickers when launching Storage Settings" into sc-dev am: 0462ffaffc
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/14716098 Change-Id: Ica0382ee70461df52b380225ef1cae67a5b09684
This commit is contained in:
@@ -104,14 +104,16 @@ public class StorageCategoryFragment extends DashboardFragment
|
||||
return;
|
||||
}
|
||||
|
||||
mPreferenceController.setVolume(mSelectedStorageEntry.getVolumeInfo());
|
||||
|
||||
if (!mSelectedStorageEntry.isMounted()) {
|
||||
// Set null volume to hide category stats.
|
||||
mPreferenceController.setVolume(null);
|
||||
return;
|
||||
}
|
||||
if (mSelectedStorageEntry.isPrivate()) {
|
||||
mStorageInfo = null;
|
||||
mAppsResult = null;
|
||||
maybeSetLoading(isQuotaSupported());
|
||||
|
||||
// Stats data is only available on private volumes.
|
||||
getLoaderManager().restartLoader(STORAGE_JOB_ID, Bundle.EMPTY, this);
|
||||
getLoaderManager()
|
||||
@@ -156,7 +158,6 @@ public class StorageCategoryFragment extends DashboardFragment
|
||||
public void onViewCreated(View v, Bundle savedInstanceState) {
|
||||
super.onViewCreated(v, savedInstanceState);
|
||||
initializeCacheProvider();
|
||||
maybeSetLoading(isQuotaSupported());
|
||||
|
||||
EntityHeaderController.newInstance(getActivity(), this /*fragment*/,
|
||||
null /* header view */)
|
||||
@@ -179,33 +180,27 @@ public class StorageCategoryFragment extends DashboardFragment
|
||||
}
|
||||
|
||||
private void onReceivedSizes() {
|
||||
boolean stopLoading = false;
|
||||
if (mStorageInfo != null) {
|
||||
final long privateUsedBytes = mStorageInfo.totalBytes - mStorageInfo.freeBytes;
|
||||
mPreferenceController.setVolume(mSelectedStorageEntry.getVolumeInfo());
|
||||
mPreferenceController.setUsedSize(privateUsedBytes);
|
||||
mPreferenceController.setTotalSize(mStorageInfo.totalBytes);
|
||||
for (int i = 0, size = mSecondaryUsers.size(); i < size; i++) {
|
||||
final AbstractPreferenceController controller = mSecondaryUsers.get(i);
|
||||
if (controller instanceof SecondaryUserController) {
|
||||
SecondaryUserController userController = (SecondaryUserController) controller;
|
||||
userController.setTotalSize(mStorageInfo.totalBytes);
|
||||
}
|
||||
}
|
||||
stopLoading = true;
|
||||
if (mStorageInfo == null || mAppsResult == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mAppsResult != null) {
|
||||
mPreferenceController.onLoadFinished(mAppsResult, mUserId);
|
||||
updateSecondaryUserControllers(mSecondaryUsers, mAppsResult);
|
||||
stopLoading = true;
|
||||
final long privateUsedBytes = mStorageInfo.totalBytes - mStorageInfo.freeBytes;
|
||||
mPreferenceController.setVolume(mSelectedStorageEntry.getVolumeInfo());
|
||||
mPreferenceController.setUsedSize(privateUsedBytes);
|
||||
mPreferenceController.setTotalSize(mStorageInfo.totalBytes);
|
||||
for (int i = 0, size = mSecondaryUsers.size(); i < size; i++) {
|
||||
final AbstractPreferenceController controller = mSecondaryUsers.get(i);
|
||||
if (controller instanceof SecondaryUserController) {
|
||||
SecondaryUserController userController = (SecondaryUserController) controller;
|
||||
userController.setTotalSize(mStorageInfo.totalBytes);
|
||||
}
|
||||
}
|
||||
|
||||
// setLoading always causes a flicker, so let's avoid doing it.
|
||||
if (stopLoading) {
|
||||
if (getView().findViewById(R.id.loading_container).getVisibility() == View.VISIBLE) {
|
||||
setLoading(false, true);
|
||||
}
|
||||
mPreferenceController.onLoadFinished(mAppsResult, mUserId);
|
||||
updateSecondaryUserControllers(mSecondaryUsers, mAppsResult);
|
||||
|
||||
if (getView().findViewById(R.id.loading_container).getVisibility() == View.VISIBLE) {
|
||||
setLoading(false, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -232,14 +232,16 @@ public class StorageDashboardFragment extends DashboardFragment
|
||||
mOptionMenuController.setSelectedStorageEntry(mSelectedStorageEntry);
|
||||
getActivity().invalidateOptionsMenu();
|
||||
|
||||
mPreferenceController.setVolume(mSelectedStorageEntry.getVolumeInfo());
|
||||
|
||||
if (!mSelectedStorageEntry.isMounted()) {
|
||||
// Set null volume to hide category stats.
|
||||
mPreferenceController.setVolume(null);
|
||||
return;
|
||||
}
|
||||
if (mSelectedStorageEntry.isPrivate()) {
|
||||
mStorageInfo = null;
|
||||
mAppsResult = null;
|
||||
maybeSetLoading(isQuotaSupported());
|
||||
|
||||
// Stats data is only available on private volumes.
|
||||
getLoaderManager().restartLoader(STORAGE_JOB_ID, Bundle.EMPTY, this);
|
||||
getLoaderManager()
|
||||
@@ -315,7 +317,6 @@ public class StorageDashboardFragment extends DashboardFragment
|
||||
public void onViewCreated(View v, Bundle savedInstanceState) {
|
||||
super.onViewCreated(v, savedInstanceState);
|
||||
initializeCacheProvider();
|
||||
maybeSetLoading(isQuotaSupported());
|
||||
|
||||
EntityHeaderController.newInstance(getActivity(), this /*fragment*/,
|
||||
null /* header view */)
|
||||
@@ -350,33 +351,27 @@ public class StorageDashboardFragment extends DashboardFragment
|
||||
}
|
||||
|
||||
private void onReceivedSizes() {
|
||||
boolean stopLoading = false;
|
||||
if (mStorageInfo != null) {
|
||||
final long privateUsedBytes = mStorageInfo.totalBytes - mStorageInfo.freeBytes;
|
||||
mPreferenceController.setVolume(mSelectedStorageEntry.getVolumeInfo());
|
||||
mPreferenceController.setUsedSize(privateUsedBytes);
|
||||
mPreferenceController.setTotalSize(mStorageInfo.totalBytes);
|
||||
for (int i = 0, size = mSecondaryUsers.size(); i < size; i++) {
|
||||
final AbstractPreferenceController controller = mSecondaryUsers.get(i);
|
||||
if (controller instanceof SecondaryUserController) {
|
||||
SecondaryUserController userController = (SecondaryUserController) controller;
|
||||
userController.setTotalSize(mStorageInfo.totalBytes);
|
||||
}
|
||||
}
|
||||
stopLoading = true;
|
||||
if (mStorageInfo == null || mAppsResult == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mAppsResult != null) {
|
||||
mPreferenceController.onLoadFinished(mAppsResult, mUserId);
|
||||
updateSecondaryUserControllers(mSecondaryUsers, mAppsResult);
|
||||
stopLoading = true;
|
||||
final long privateUsedBytes = mStorageInfo.totalBytes - mStorageInfo.freeBytes;
|
||||
mPreferenceController.setVolume(mSelectedStorageEntry.getVolumeInfo());
|
||||
mPreferenceController.setUsedSize(privateUsedBytes);
|
||||
mPreferenceController.setTotalSize(mStorageInfo.totalBytes);
|
||||
for (int i = 0, size = mSecondaryUsers.size(); i < size; i++) {
|
||||
final AbstractPreferenceController controller = mSecondaryUsers.get(i);
|
||||
if (controller instanceof SecondaryUserController) {
|
||||
SecondaryUserController userController = (SecondaryUserController) controller;
|
||||
userController.setTotalSize(mStorageInfo.totalBytes);
|
||||
}
|
||||
}
|
||||
|
||||
// setLoading always causes a flicker, so let's avoid doing it.
|
||||
if (stopLoading) {
|
||||
if (getView().findViewById(R.id.loading_container).getVisibility() == View.VISIBLE) {
|
||||
setLoading(false, true);
|
||||
}
|
||||
mPreferenceController.onLoadFinished(mAppsResult, mUserId);
|
||||
updateSecondaryUserControllers(mSecondaryUsers, mAppsResult);
|
||||
|
||||
if (getView().findViewById(R.id.loading_container).getVisibility() == View.VISIBLE) {
|
||||
setLoading(false, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -222,7 +222,6 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
mVolume = volume;
|
||||
|
||||
updateCategoryPreferencesVisibility();
|
||||
updatePrivateStorageCategoryPreferencesOrder();
|
||||
}
|
||||
|
||||
// Stats data is only available on private volumes.
|
||||
@@ -353,14 +352,10 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
mDocumentsAndOtherPreference = screen.findPreference(DOCUMENTS_AND_OTHER_KEY);
|
||||
mSystemPreference = screen.findPreference(SYSTEM_KEY);
|
||||
mTrashPreference = screen.findPreference(TRASH_KEY);
|
||||
|
||||
updateCategoryPreferencesVisibility();
|
||||
updatePrivateStorageCategoryPreferencesOrder();
|
||||
}
|
||||
|
||||
/** Fragments use it to set storage result and update UI of this controller. */
|
||||
public void onLoadFinished(SparseArray<StorageAsyncLoader.StorageResult> result,
|
||||
int userId) {
|
||||
public void onLoadFinished(SparseArray<StorageAsyncLoader.StorageResult> result, int userId) {
|
||||
final StorageAsyncLoader.StorageResult data = result.get(userId);
|
||||
|
||||
mImagesPreference.setStorageSize(data.imagesSize, mTotalSize);
|
||||
@@ -374,8 +369,6 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
if (mSystemPreference != null) {
|
||||
// Everything else that hasn't already been attributed is tracked as
|
||||
// belonging to system.
|
||||
// TODO(b/170918505): Should revamp system size calculation with the data
|
||||
// from media provider.
|
||||
long attributedSize = 0;
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
final StorageAsyncLoader.StorageResult otherData = result.valueAt(i);
|
||||
|
@@ -397,25 +397,6 @@ public class StorageItemPreferenceControllerTest {
|
||||
assertThat(mController.mDocumentsAndOtherPreference.isVisible()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void displayPreference_hideFilePreferenceWhenEmulatedStorageUnreadable() {
|
||||
when(mSvp.findEmulatedForPrivate(nullable(VolumeInfo.class))).thenReturn(mVolume);
|
||||
when(mVolume.isMountedReadable()).thenReturn(false);
|
||||
|
||||
mController.displayPreference(mPreferenceScreen);
|
||||
|
||||
assertThat(mController.mDocumentsAndOtherPreference.isVisible()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void displayPreference_noEmulatedInternalStorage_hidePreference() {
|
||||
when(mSvp.findEmulatedForPrivate(nullable(VolumeInfo.class))).thenReturn(null);
|
||||
|
||||
mController.displayPreference(mPreferenceScreen);
|
||||
|
||||
assertThat(mController.mDocumentsAndOtherPreference.isVisible()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setVolume_updateFilePreferenceToHideAfterSettingVolume_hidePreference() {
|
||||
when(mSvp.findEmulatedForPrivate(nullable(VolumeInfo.class))).thenReturn(mVolume);
|
||||
@@ -430,7 +411,6 @@ public class StorageItemPreferenceControllerTest {
|
||||
assertThat(mController.mDocumentsAndOtherPreference.isVisible()).isFalse();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void setVolume_updateFilePreferenceToShowAfterSettingVolume_showPreference() {
|
||||
// This will hide it initially.
|
||||
|
Reference in New Issue
Block a user