use of rocks.tbog.tblauncher.handler.IconsHandler in project TBLauncher by TBog.
the class AppEntry method getIconDrawable.
@WorkerThread
public Drawable getIconDrawable(Context context) {
IconsHandler iconsHandler = TBApplication.getApplication(context).iconsHandler();
if (iconInfo.customIcon != 0) {
Drawable drawable = iconsHandler.getCustomIcon(getUserComponentName());
if (drawable != null)
return drawable;
else
iconsHandler.restoreDefaultIcon(this);
}
IconsHandler.IconInfo icon = iconsHandler.getIconForPackage(componentName, userHandle);
iconInfo.setIconInfo(icon);
return icon.getDrawable();
}
use of rocks.tbog.tblauncher.handler.IconsHandler in project TBLauncher by TBog.
the class SearchEntry method getIconDrawable.
// /////////////////////////////////////////////////////////////////////////////////////////////
// Result methods
// /////////////////////////////////////////////////////////////////////////////////////////////
@WorkerThread
public Drawable getIconDrawable(Context context) {
if (hasCustomIcon()) {
IconsHandler iconsHandler = TBApplication.getApplication(context).iconsHandler();
Drawable drawable = iconsHandler.getCustomIcon(this);
if (drawable != null)
return drawable;
else
iconsHandler.restoreDefaultIcon(this);
}
return getDefaultDrawable(context);
}
use of rocks.tbog.tblauncher.handler.IconsHandler in project TBLauncher by TBog.
the class TagsManager method applyChanges.
public void applyChanges(@NonNull Context context) {
TagsHandler tagsHandler = TBApplication.tagsHandler(context);
IconsHandler iconsHandler = TBApplication.iconsHandler(context);
TBLauncherActivity launcherActivity = TBApplication.launcherActivity(context);
boolean changesMade = false;
for (TagInfo tagInfo : mTagList) {
if (tagInfo.staticEntry instanceof ActionEntry) {
// can't delete actions (it's the show untagged action)
if (tagInfo.action == TagInfo.Action.RENAME) {
TBApplication.dataHandler(context).renameStaticEntry(tagInfo.staticEntry, tagInfo.name);
changesMade = true;
}
} else {
switch(tagInfo.action) {
case RENAME:
if (tagsHandler.renameTag(tagInfo.tagName, tagInfo.name))
changesMade = true;
break;
case DELETE:
if (tagInfo.staticEntry != null)
iconsHandler.restoreDefaultIcon(tagInfo.staticEntry);
tagInfo.icon = null;
if (tagsHandler.removeTag(tagInfo.tagName))
changesMade = true;
break;
}
}
if (tagInfo.icon != null && tagInfo.staticEntry != null) {
iconsHandler.changeIcon(tagInfo.staticEntry, tagInfo.icon);
if (launcherActivity != null) {
// force a result refresh to update the icon in the view
launcherActivity.behaviour.refreshSearchRecord(tagInfo.staticEntry);
}
}
}
// make sure we're in sync
if (changesMade) {
if (launcherActivity != null)
launcherActivity.queueDockReload();
afterChangesMade(context);
}
}
use of rocks.tbog.tblauncher.handler.IconsHandler in project TBLauncher by TBog.
the class IconSelectDialog method customIconApp.
private void customIconApp(Bundle args) {
Context context = requireContext();
String name = args.getString("componentName", "");
long customIcon = args.getLong("customIcon", 0);
if (name.isEmpty()) {
dismiss();
String entryName = args.getString("entryName", "");
Toast.makeText(Utilities.getActivity(context), context.getString(R.string.entry_not_found, entryName), Toast.LENGTH_LONG).show();
return;
}
IconsHandler iconsHandler = TBApplication.getApplication(context).iconsHandler();
ComponentName cn = UserHandleCompat.unflattenComponentName(name);
UserHandleCompat userHandle = UserHandleCompat.fromComponentName(context, name);
// Preview
initPreviewIcon(mPreviewLabel, ctx -> {
Drawable drawable = customIcon != 0 ? iconsHandler.getCustomIcon(name) : null;
if (drawable == null)
drawable = iconsHandler.getDrawableIconForPackage(cn, userHandle);
return drawable;
});
}
use of rocks.tbog.tblauncher.handler.IconsHandler in project TBLauncher by TBog.
the class IconSelectDialog method addIconPacks.
/**
* Add ViewPager pages for every icon pack
*
* @param inflater used for inflating the page view
* @return an array of pairs with the icon pack package name and icon pack name
*/
@NonNull
private ArrayList<Pair<String, String>> addIconPacks(LayoutInflater inflater) {
Context context = inflater.getContext();
IconsHandler iconsHandler = TBApplication.iconsHandler(context);
Map<String, String> iconPackNames = iconsHandler.getIconPackNames();
ArrayList<Pair<String, String>> iconPacks = new ArrayList<>(iconPackNames.size());
for (Map.Entry<String, String> packInfo : iconPackNames.entrySet()) iconPacks.add(new Pair<>(packInfo.getKey(), packInfo.getValue()));
IconPack<?> iconPack = iconsHandler.getCustomIconPack();
String selectedPackPackageName = iconPack != null ? iconPack.getPackPackageName() : "";
Collections.sort(iconPacks, (o1, o2) -> {
if (selectedPackPackageName.equals(o1.first))
return -1;
if (selectedPackPackageName.equals(o2.first))
return 1;
return o1.second.compareTo(o2.second);
});
for (Pair<String, String> packInfo : iconPacks) {
String packPackageName = packInfo.first;
String packName = packInfo.second;
if (selectedPackPackageName.equals(packPackageName))
packName = context.getString(R.string.selected_pack, packName);
// add page to ViewPager
addIconPackPage(inflater, mViewPager, packName, packPackageName);
}
return iconPacks;
}
Aggregations