blob: b469a8f4542eda4628e29205603d67c63b63dedc [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
Annie Chin17f85952016-03-24 17:12:30 -07008import java.util.Locale;
9
10public class IconProvider {
11
Annie Chin17f85952016-03-24 17:12:30 -070012 protected String mSystemState;
13
Sunny Goyalae2129e2018-01-24 10:26:35 -080014 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;
Annie Chin17f85952016-03-24 17:12:30 -070019 }
20
Sunny Goyalae2129e2018-01-24 10:26:35 -080021 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;
Annie Chin17f85952016-03-24 17:12:30 -070032 }
33
34 public String getIconSystemState(String packageName) {
35 return mSystemState;
36 }
37
Sunny Goyal1da13892017-06-22 11:03:40 -070038 /**
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) {
Annie Chin17f85952016-03-24 17:12:30 -070043 return info.getIcon(iconDpi);
44 }
45}