Add user icon to the other user preferences.
This icon is loaded in the background to avoid doing IO on the main thread. Once we know there are more users and also have the icon loaded, we add the category to the view. Fixes: 36252572 Test: Robotest Change-Id: Ib50287bb7ed323f22fbe407b56be1bf2fe98f121
This commit is contained in:
@@ -18,6 +18,7 @@ package com.android.settings.deviceinfo.storage;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
@@ -37,8 +38,8 @@ import java.util.List;
|
||||
* SecondaryUserController controls the preferences on the Storage screen which had to do with
|
||||
* secondary users.
|
||||
*/
|
||||
public class SecondaryUserController extends PreferenceController implements
|
||||
StorageAsyncLoader.ResultHandler {
|
||||
public class SecondaryUserController extends PreferenceController
|
||||
implements StorageAsyncLoader.ResultHandler, UserIconLoader.UserIconHandler {
|
||||
// PreferenceGroupKey to try to add our preference onto.
|
||||
private static final String TARGET_PREFERENCE_GROUP_KEY = "pref_secondary_users";
|
||||
private static final String PREFERENCE_KEY_BASE = "pref_user_";
|
||||
@@ -69,8 +70,9 @@ public class SecondaryUserController extends PreferenceController implements
|
||||
}
|
||||
|
||||
if (info == null || Utils.isProfileOf(primaryUser, info)) {
|
||||
controllers.add(new UserProfileController(context, info,
|
||||
USER_PROFILE_INSERTION_LOCATION));
|
||||
controllers.add(
|
||||
new UserProfileController(
|
||||
context, info, userManager, USER_PROFILE_INSERTION_LOCATION));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -109,8 +111,6 @@ public class SecondaryUserController extends PreferenceController implements
|
||||
mStoragePreference.setStorageSize(mSize, mTotalSizeBytes);
|
||||
}
|
||||
|
||||
// TODO(b/36252572): Set the user icon appropriately here.
|
||||
|
||||
group.setVisible(true);
|
||||
group.addPreference(mStoragePreference);
|
||||
}
|
||||
@@ -161,6 +161,14 @@ public class SecondaryUserController extends PreferenceController implements
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleUserIcons(SparseArray<Drawable> fetchedIcons) {
|
||||
Drawable userIcon = fetchedIcons.get(mUser.id);
|
||||
if (userIcon != null) {
|
||||
mStoragePreference.setIcon(userIcon);
|
||||
}
|
||||
}
|
||||
|
||||
private static class NoSecondaryUserController extends PreferenceController {
|
||||
public NoSecondaryUserController(Context context) {
|
||||
super(context);
|
||||
|
Reference in New Issue
Block a user