Android Question Sticker4W Lib: Problem creating sticker pack from External Storage

Ferdari

Active Member
Licensed User
Longtime User
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.
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

asales

Expert
Licensed User
Longtime User
Upvote 0

Ferdari

Active Member
Licensed User
Longtime User
Hi @DonManfred,
Please check if you can change this line and make it editable on b4a:
StickerContentProvider.java
Line 54
Java:
Private static final String CONTENT_FILE_NAME = "contents.json";
This line defines the file that are read.

Also if you want to share the lib code, maybe we can look and try to make the changes. if i can update the lib ill return to you with the updates so you can publish it, the thing is helping each other.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Also if you want to share the lib code, maybe we can look and try to make the changes.
Sure. This is the old Source from the Library. This works with the Files in Assets.
 

Attachments

  • Sticker4W-src.zip
    17.3 KB · Views: 197
Upvote 0

Ferdari

Active Member
Licensed User
Longtime User
Hi @DonManfred, this was a challenge for me and high learning, i have some updates and almost done the lib.

I have deleted and created some new classes.

I have some questions to continue development:
How do you change the CONTENT_PROVIDER_AUTHORITY dynamically?
Java:
public static final String CONTENT_PROVIDER_AUTHORITY  = "stickers.app";
Currently only works with static package name "stickers.app"

I compiled the lib and it WORKS!, im testing all the new Methods, i have 80% progress, but stuck on this.
 
Last edited:
Upvote 0

Ferdari

Active Member
Licensed User
Longtime User
Can you share the source of what you do it until now?
Now the lib works like this:;
B4X:
    Dim JSON As JSONParser
    Dim Map1 As Map
    Dim JSONString as String
    JSON.Initialize(JSONString) 'it can be a JSON string or file contents.json
    Map1 = JSON.NextObject
 
    Dim StickerPacks As List
 
    StickerPacks = Map1.Get("sticker_packs")

    stpacks.Initialize("",StickerPacks)    ' New method on lib that assigns the packs to ContentProvider
 
    'Test if it assigned the packs from Initialize
    Dim Packs As List = loader.fetchStickerPacks
    For Each Pack As String In Packs
        'It works!
        Log(Pack)
    Next
 
 
    ' Next you can add Pack with:
    stpacks.addStickerPackExisting(NewPack)
 
    ' Or delete Pack with:
    stpacks.deleteStickerPackById(ID)
 
    ' Im stuck on this [B]addStickerPackExisting[/B], figuring what type of data it needs.
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
@asales I sent you a DM

I have some questions to continue development:
How do you change the CONTENT_PROVIDER_AUTHORITY dynamically?
It is not related to this thread. If you have any java question then you should create a thread in the java developer questions forum.
The original code is
Java:
        String shauthority = "StickerContentProvider";
        shauthority = getContext().getApplicationInfo().packageName+".stickercontentprovider";
It uses the Contexts Packagename.
 
Upvote 0

Ferdari

Active Member
Licensed User
Longtime User
Thanks @DonManfred, want to see the changes? i'm stuck on how to get the URI from files loaded through JSON String from B4A, i changed code based on StickerMaker source
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…