Re-add the progress bar for storage preferences.

This re-adds the progress bar and unifies the
StorageItemPreference and its alternate.

Change-Id: Iefc12b4b554306c706c83be232175dd2b84227b7
Fixes: 36223433
Test: Settings robotest
This commit is contained in:
Daniel Nishi
2017-03-15 14:00:13 -07:00
parent 9392681afa
commit cf0e659a6c
14 changed files with 183 additions and 203 deletions

View File

@@ -28,6 +28,7 @@ import android.util.SparseArray;
import com.android.settings.Utils;
import com.android.settings.applications.UserManagerWrapper;
import com.android.settings.core.PreferenceController;
import com.android.settings.deviceinfo.StorageItemPreference;
import java.util.ArrayList;
import java.util.List;
@@ -46,8 +47,9 @@ public class SecondaryUserController extends PreferenceController implements
private static final int SIZE_NOT_SET = -1;
private @NonNull UserInfo mUser;
private @Nullable StorageItemPreferenceAlternate mStoragePreference;
private @Nullable StorageItemPreference mStoragePreference;
private long mSize;
private long mTotalSizeBytes;
/**
* Adds the appropriate controllers to a controller list for handling all secondary users on
@@ -98,14 +100,14 @@ public class SecondaryUserController extends PreferenceController implements
@Override
public void displayPreference(PreferenceScreen screen) {
if (mStoragePreference == null) {
mStoragePreference = new StorageItemPreferenceAlternate(screen.getContext());
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);
mStoragePreference.setStorageSize(mSize, mTotalSizeBytes);
}
group.setVisible(true);
group.addPreference(mStoragePreference);
@@ -137,10 +139,18 @@ public class SecondaryUserController extends PreferenceController implements
public void setSize(long size) {
mSize = size;
if (mStoragePreference != null) {
mStoragePreference.setStorageSize(mSize);
mStoragePreference.setStorageSize(mSize, mTotalSizeBytes);
}
}
/**
* Sets the total size for the preference for the progress bar.
* @param totalSizeBytes Total size in bytes.
*/
public void setTotalSize(long totalSizeBytes) {
mTotalSizeBytes = totalSizeBytes;
}
public void handleResult(SparseArray<StorageAsyncLoader.AppsStorageResult> stats) {
int userId = getUser().id;
StorageAsyncLoader.AppsStorageResult result = stats.get(userId);