1package com.android.launcher3; 2 3import android.content.Context; 4import android.content.pm.LauncherActivityInfo; 5import android.graphics.drawable.Drawable; 6import android.os.Build; 7 8import java.util.Locale; 9 10public class IconProvider { 11 12 protected String mSystemState; 13 14 public static IconProvider newInstance(Context context) { 15 IconProvider provider = Utilities.getOverrideObject( 16 IconProvider.class, context, R.string.icon_provider_class); 17 provider.updateSystemStateString(context); 18 return provider; 19 } 20 21 public IconProvider() { } 22 23 public void updateSystemStateString(Context context) { 24 final String locale; 25 if (Utilities.ATLEAST_NOUGAT) { 26 locale = context.getResources().getConfiguration().getLocales().toLanguageTags(); 27 } else { 28 locale = Locale.getDefault().toString(); 29 } 30 31 mSystemState = locale + "," + Build.VERSION.SDK_INT; 32 } 33 34 public String getIconSystemState(String packageName) { 35 return mSystemState; 36 } 37 38 /** 39 * @param flattenDrawable true if the caller does not care about the specification of the 40 * original icon as long as the flattened version looks the same. 41 */ 42 public Drawable getIcon(LauncherActivityInfo info, int iconDpi, boolean flattenDrawable) { 43 return info.getIcon(iconDpi); 44 } 45} 46