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