Hi everyone, im using the @DonManfred Sticker4W library for creating sticker packs, but it only works with Assets files, is there a way to use or create on-the-fly a sticker pack from the External or Internal storage?
On the official Stickers GitHub they say it is the way:
Expose files that are stored internally as stickers through ContentProvider
Is there a way to implement this?
A practical use could be: Download an sticker pack and install from the app, or create and encode images saving it to External and then installing the Pack from the app.
Help would be very appreciated.
On the official Stickers GitHub they say it is the way:
Expose files that are stored internally as stickers through ContentProvider
If you would like to expose files saved internally or externally and serve these files as sticker. It is possible, but please follow the guidelines in 'Sticker art and app requirements' to make sure the files meets these requirements. As to how to do that, you can take a look at the following code snippet to get an understanding of how that can be done.
B4X:private AssetFileDescriptor fetchFile(@NonNull Uri uri, @NonNull AssetManager am, @NonNull String fileName, @NonNull String identifier) throws IOException { final File cacheFile = getContext().getExternalCacheDir(); final File file = new File(cacheFile, fileName); try (final InputStream open = am.open(identifier + "/" + fileName); final FileOutputStream fileOutputStream = new FileOutputStream(file)) { byte[] buffer = new byte[1024]; int read; while ((read = in.read(buffer)) != -1) { out.write(buffer, 0, read); } } //The code above is basically copying the assets to storage, and servering the file off of the storage. //If you have the files already downloaded/fetched, you could simply replace above part, and initialize the file parameter with your own file which points to the desired file. //The key here is you can use ParcelFileDescriptor to create an AssetFileDescriptor. return new AssetFileDescriptor(ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY), 0, AssetFileDescriptor.UNKNOWN_LENGTH); }
Is there a way to implement this?
A practical use could be: Download an sticker pack and install from the app, or create and encode images saving it to External and then installing the Pack from the app.
Help would be very appreciated.