• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.android.launcher3;
2 
3 import android.content.Context;
4 import android.content.pm.LauncherActivityInfo;
5 import android.graphics.drawable.Drawable;
6 import android.os.Build;
7 
8 import java.util.Locale;
9 
10 public class IconProvider {
11 
12     protected String mSystemState;
13 
newInstance(Context context)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 
IconProvider()21     public IconProvider() { }
22 
updateSystemStateString(Context context)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 
getIconSystemState(String packageName)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      */
getIcon(LauncherActivityInfo info, int iconDpi, boolean flattenDrawable)42     public Drawable getIcon(LauncherActivityInfo info, int iconDpi, boolean flattenDrawable) {
43         return info.getIcon(iconDpi);
44     }
45 }
46