Home | History | Annotate | Download | only in compat
      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 
     18 package com.android.launcher3.compat;
     19 
     20 import android.content.Context;
     21 import android.content.pm.PackageManager;
     22 import android.graphics.drawable.Drawable;
     23 import android.os.UserHandle;
     24 import android.os.UserManager;
     25 
     26 import java.util.ArrayList;
     27 import java.util.Collections;
     28 import java.util.List;
     29 
     30 public class UserManagerCompatVL extends UserManagerCompatV17 {
     31     private final PackageManager mPm;
     32 
     33     UserManagerCompatVL(Context context) {
     34         super(context);
     35         mPm = context.getPackageManager();
     36     }
     37 
     38     @Override
     39     public List<UserHandleCompat> getUserProfiles() {
     40         List<UserHandle> users = mUserManager.getUserProfiles();
     41         if (users == null) {
     42             return Collections.EMPTY_LIST;
     43         }
     44         ArrayList<UserHandleCompat> compatUsers = new ArrayList<UserHandleCompat>(
     45                 users.size());
     46         for (UserHandle user : users) {
     47             compatUsers.add(UserHandleCompat.fromUser(user));
     48         }
     49         return compatUsers;
     50     }
     51 
     52     @Override
     53     public Drawable getBadgedDrawableForUser(Drawable unbadged, UserHandleCompat user) {
     54         return mPm.getUserBadgedIcon(unbadged, user.getUser());
     55     }
     56 
     57     @Override
     58     public CharSequence getBadgedLabelForUser(CharSequence label, UserHandleCompat user) {
     59         if (user == null) {
     60             return label;
     61         }
     62         return mPm.getUserBadgedLabel(label, user.getUser());
     63     }
     64 }
     65 
     66