Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for intents to send data to i.e. Tasker #10

Open
Slalamander opened this issue Aug 22, 2023 · 8 comments
Open

Support for intents to send data to i.e. Tasker #10

Slalamander opened this issue Aug 22, 2023 · 8 comments

Comments

@Slalamander
Copy link

Would it be possible to make an intent scheme, or a tasker plugin that can retrieve the data from the headphones (like, charge, anc mode etc)? I managed to retrieve the charge from the huawei app using a logcat read, which I mainly use to be able to remind myself to charge the case. I haven't been able to do something similar with the app (and an intent scheme would be much easier compared to my current method).

@TheLastGimbus
Copy link
Owner

Yesss, I definitley thought of that! When I get stuff organised, there will definitley be a way for other apps to get info from freebuddy 👀

I managed to retrieve the charge from the huawei app using a logcat read

oh that's fun too!

@TheLastGimbus TheLastGimbus pinned this issue Aug 23, 2023
@Slalamander
Copy link
Author

It is fun, but just like the entire original app, it's rather slow and clunky haha

@TheLastGimbus
Copy link
Owner

With recent widget updates, I started to check their battery in background and saving it up in shared preferences so that widget can source it

Looks like best way to leave this info open to other apps is through content provider ??: https://developer.android.com/guide/topics/providers/content-provider-basics

(tho this looks complicated af so would prefer it simpler if possible 👀 )

@TheLastGimbus
Copy link
Owner

oh... https://pub.dev/packages/android_content_provider

will just have to look this up a bit 😅

@Slalamander
Copy link
Author

ahhh I gotta say I have almost 0 experience in Android Development, so I have to admit I can't say anything about the complexity and stuff 😅
What I was thinking of regarding the feature would be to simply have the app send out an intend with for example the battery percentagedata, which it could do whenever the percentage updates for example (or whenever it's easiest to code it in). Tasker (or other apps too) should be able to receive those and the user can just do with it what they want from there.

But as said I have 0 experience and if I just suggested something that's even more complicated let me know 🤞

@TheLastGimbus
Copy link
Owner

Another thing that i could use to share stuff is broadcasts: https://developer.android.com/guide/components/broadcasts

I don't want to send intent from freebuddy because that would require user to select where to send the intent and I want to keep freebuddy simple

Could you click through Tasker or smth and see which option is easier (to listen to Broadcasts or fetch from content providers ?)

@Slalamander
Copy link
Author

If I'm not confusing terms, I think receiving a broadcast in tasker is easy to do:
under receiving intents in the docs it says tasker sets up an intent filter and receives intents from the broadcast receiver:
image

The intent filter is also mentioned on the broadcasts page you linked (See here at point 3).

Let me know if I'm mistaken here though, I'm happy to help out further😌

@Slalamander
Copy link
Author

Hey just a small update: I was able to use a Tasker logcat profile to get the battery levels from the widget. Not quite as straightforward as receiving a broadcast intent, but I thought you'd find it interesting nonetheless :)

I use a profile which has a logcat event, where component is set to flutter. Then the filter is BatteryData.
My task then consists of the following actions:

    Task: Freebuddy Battery Reader
    
    <test logcat message>
    
    A2: Simple Match/Regex [
         Type: Simple
         Text: %lc_text
         Match Pattern: BatteryData(levelLeft: #levelLeft, levelRight: #levelRight, levelCase: #levelCase, chargingLeft: $chargingLeft, chargingRight: $chargingRight, chargingCase: $chargingCase) ]
    
    A5: If [ %mt_match_found eq true ]
    
        A6: Variable Set [
             Name: %4iCase_battery
             To: %levelCase
             Structure Output (JSON, etc): On ]
    
        A7: Flash [
             Text: Case Charge: %levelCase%, Buds: %levelLeft%, %levelRight%
             Continue Task Immediately: On
             Dismiss On Click: On ]
    
    A8: Else
    
        A9: [X] Flash [
             Text: %mt_match_found
             Continue Task Immediately: On
             Dismiss On Click: On ]
    
    A10: End If

The most important one is the regex matching, which maps the data from the logcat to corresponding variables.
I've only just set it up, so I may find out it isn't as reliable as I think, but for now it seems to work quite well. Even better than my previous one with the Huawei app, since now I don't even have to open an app :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants