blob: ed8d03c47a5a2408dbe0b34cb2e257d40fa5ef49 [file] [log] [blame]
Annie Chin17f85952016-03-24 17:12:30 -07001package com.android.launcher3;
2
Sunny Goyalae2129e2018-01-24 10:26:35 -08003import android.content.Context;
Sunny Goyal3e9be432017-01-05 15:22:41 -08004import android.content.pm.LauncherActivityInfo;
Annie Chin17f85952016-03-24 17:12:30 -07005import android.graphics.drawable.Drawable;
Hyunyoung Song31528272017-08-28 14:27:00 -07006import android.os.Build;
Annie Chin17f85952016-03-24 17:12:30 -07007
Sunny Goyal7f920b82018-06-27 15:47:49 -07008import com.android.launcher3.util.ResourceBasedOverride;
9
Annie Chin17f85952016-03-24 17:12:30 -070010import java.util.Locale;
11
Sunny Goyal7f920b82018-06-27 15:47:49 -070012public class IconProvider implements ResourceBasedOverride {
Annie Chin17f85952016-03-24 17:12:30 -070013
Annie Chin17f85952016-03-24 17:12:30 -070014 protected String mSystemState;
15
Sunny Goyalae2129e2018-01-24 10:26:35 -080016 public static IconProvider newInstance(Context context) {
Sunny Goyal7f920b82018-06-27 15:47:49 -070017 IconProvider provider = Overrides.getObject(
Sunny Goyalae2129e2018-01-24 10:26:35 -080018 IconProvider.class, context, R.string.icon_provider_class);
19 provider.updateSystemStateString(context);
20 return provider;
Annie Chin17f85952016-03-24 17:12:30 -070021 }
22
Sunny Goyalae2129e2018-01-24 10:26:35 -080023 public IconProvider() { }
24
25 public void updateSystemStateString(Context context) {
26 final String locale;
27 if (Utilities.ATLEAST_NOUGAT) {
28 locale = context.getResources().getConfiguration().getLocales().toLanguageTags();
29 } else {
30 locale = Locale.getDefault().toString();
31 }
32
33 mSystemState = locale + "," + Build.VERSION.SDK_INT;
Annie Chin17f85952016-03-24 17:12:30 -070034 }
35
36 public String getIconSystemState(String packageName) {
37 return mSystemState;
38 }
39
Sunny Goyal1da13892017-06-22 11:03:40 -070040 /**
41 * @param flattenDrawable true if the caller does not care about the specification of the
42 * original icon as long as the flattened version looks the same.
43 */
44 public Drawable getIcon(LauncherActivityInfo info, int iconDpi, boolean flattenDrawable) {
Annie Chin17f85952016-03-24 17:12:30 -070045 return info.getIcon(iconDpi);
46 }
47}