UserManagerCompatVL.java revision fd449c88316a1caca4f034a339c1e5128c5da849
1 2/* 3 * Copyright (C) 2014 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18package com.android.launcher3.compat; 19 20import android.content.Context; 21import android.graphics.drawable.Drawable; 22import android.os.UserHandle; 23import android.os.UserManager; 24 25import java.util.ArrayList; 26import java.util.Collections; 27import java.util.List; 28 29public class UserManagerCompatVL extends UserManagerCompatV17 { 30 31 UserManagerCompatVL(Context context) { 32 super(context); 33 } 34 35 @Override 36 public List<UserHandleCompat> getUserProfiles() { 37 List<UserHandle> users = mUserManager.getUserProfiles(); 38 if (users == null) { 39 return Collections.EMPTY_LIST; 40 } 41 ArrayList<UserHandleCompat> compatUsers = new ArrayList<UserHandleCompat>( 42 users.size()); 43 for (UserHandle user : users) { 44 compatUsers.add(UserHandleCompat.fromUser(user)); 45 } 46 return compatUsers; 47 } 48 49 @Override 50 public Drawable getBadgedDrawableForUser(Drawable unbadged, UserHandleCompat user) { 51 try { 52 // STOPSHIP(mokani): Clean this up. 53 return mUserManager.getBadgedIconForUser(unbadged, user.getUser()); 54 } catch (Throwable t) { 55 return unbadged; 56 } 57 } 58 59 @Override 60 public CharSequence getBadgedLabelForUser(CharSequence label, UserHandleCompat user) { 61 if (user == null) { 62 return label; 63 } 64 return mUserManager.getBadgedLabelForUser(label, user.getUser()); 65 } 66} 67 68