summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/IconProvider.java
blob: ed8d03c47a5a2408dbe0b34cb2e257d40fa5ef49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.android.launcher3;

import android.content.Context;
import android.content.pm.LauncherActivityInfo;
import android.graphics.drawable.Drawable;
import android.os.Build;

import com.android.launcher3.util.ResourceBasedOverride;

import java.util.Locale;

public class IconProvider implements ResourceBasedOverride {

    protected String mSystemState;

    public static IconProvider newInstance(Context context) {
        IconProvider provider = Overrides.getObject(
                IconProvider.class, context, R.string.icon_provider_class);
        provider.updateSystemStateString(context);
        return provider;
    }

    public IconProvider() { }

    public void updateSystemStateString(Context context) {
        final String locale;
        if (Utilities.ATLEAST_NOUGAT) {
            locale = context.getResources().getConfiguration().getLocales().toLanguageTags();
        } else {
            locale = Locale.getDefault().toString();
        }

        mSystemState = locale + "," + Build.VERSION.SDK_INT;
    }

    public String getIconSystemState(String packageName) {
        return mSystemState;
    }

    /**
     * @param flattenDrawable true if the caller does not care about the specification of the
     *                        original icon as long as the flattened version looks the same.
     */
    public Drawable getIcon(LauncherActivityInfo info, int iconDpi, boolean flattenDrawable) {
        return info.getIcon(iconDpi);
    }
}