2016-03-24 17:12:30 -07:00
|
|
|
package com.android.launcher3;
|
|
|
|
|
|
2018-01-24 10:26:35 -08:00
|
|
|
import android.content.Context;
|
2017-01-05 15:22:41 -08:00
|
|
|
import android.content.pm.LauncherActivityInfo;
|
2016-03-24 17:12:30 -07:00
|
|
|
import android.graphics.drawable.Drawable;
|
2017-08-28 14:27:00 -07:00
|
|
|
import android.os.Build;
|
2016-03-24 17:12:30 -07:00
|
|
|
|
|
|
|
|
import java.util.Locale;
|
|
|
|
|
|
|
|
|
|
public class IconProvider {
|
|
|
|
|
|
|
|
|
|
protected String mSystemState;
|
|
|
|
|
|
2018-01-24 10:26:35 -08:00
|
|
|
public static IconProvider newInstance(Context context) {
|
|
|
|
|
IconProvider provider = Utilities.getOverrideObject(
|
|
|
|
|
IconProvider.class, context, R.string.icon_provider_class);
|
|
|
|
|
provider.updateSystemStateString(context);
|
|
|
|
|
return provider;
|
2016-03-24 17:12:30 -07:00
|
|
|
}
|
|
|
|
|
|
2018-01-24 10:26:35 -08:00
|
|
|
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;
|
2016-03-24 17:12:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getIconSystemState(String packageName) {
|
|
|
|
|
return mSystemState;
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-22 11:03:40 -07:00
|
|
|
/**
|
|
|
|
|
* @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) {
|
2016-03-24 17:12:30 -07:00
|
|
|
return info.getIcon(iconDpi);
|
|
|
|
|
}
|
|
|
|
|
}
|