~eliasnaur/gio

4 2

New cross-platform gio notification library in the works

Details
Message ID
<CAFcc3FSv2kYC1127nM_HofrJu=qC2Lxj2eJuLBfNKrw7ECoVxg@mail.gmail.com>
DKIM signature
pass
Download raw message
Hey all!

I've got a limited-feature library for sending cross-platform
notifications in the works! So far I've got a very simple API that has
backends for Android and Linux. It will fail silently on unsupported
platforms, so you can include it in a Gio app that targets other
platforms without fear.

https://git.sr.ht/~whereswaldon/niotify

I'd appreciate help getting macOS and Windows support up and running
if anyone is interested!

In my gio fork, I have a branch on which I've modified the hello
example to send a notification at startup. You can try that out with:

git clone --branch=niotify https://git.sr.ht/~whereswaldon/gio
cd gio/example/hello
go run .
go run gioui.org/cmd/gogio -target android .
adb install hello.apk
# run the app on your android device

Linux users should see a desktop notification, macOS and Windows users
should just see the app working normally.

I'd welcome any feedback or contributions!

Cheers,
Chris
Gregory Pomerantz
Details
Message ID
<9474751f-5d86-8fd3-2c64-49c3d8a6a3fd@wow.st>
In-Reply-To
<CAFcc3FSv2kYC1127nM_HofrJu=qC2Lxj2eJuLBfNKrw7ECoVxg@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
On 6/20/20 4:36 PM, Chris Waldon wrote:

> Hey all!
>
> I've got a limited-feature library for sending cross-platform
> notifications in the works! So far I've got a very simple API that has
> backends for Android and Linux. It will fail silently on unsupported
> platforms, so you can include it in a Gio app that targets other
> platforms without fear.

I can definitely pitch in on the MacOS side, my binding generator can 
create a Go wrapper for NSNotificationCenter and related methods and 
objects, so it should be straightforward to get this working.

On the Android side, I noticed that the example app imports the android 
implementation directly. Is that necessary or is there a cross platform 
API? Also, since the compiled Java class is required, I think it would 
be better to include the .class file in the git repository so API users 
do not need to manually run any go-generate commands to get things 
working. This will just result in a runtime error if people forget to do 
that.

Are lifecycle issues addressed in the Android implementation, e.g. if 
the Activity is destroyed and re-started, will the notification channel 
still work or will it have to be re-started manually?
Details
Message ID
<CAFcc3FQEXZAF0BDixWtxnOL3UtOO8cBh3nSaTPOOqZFLMRoRNA@mail.gmail.com>
In-Reply-To
<9474751f-5d86-8fd3-2c64-49c3d8a6a3fd@wow.st> (view parent)
DKIM signature
pass
Download raw message
> I can definitely pitch in on the MacOS side, my binding generator can
> create a Go wrapper for NSNotificationCenter and related methods and
> objects, so it should be straightforward to get this working.

That would be awesome! I'd really appreciate the help.

> On the Android side, I noticed that the example app imports the android
> implementation directly. Is that necessary or is there a cross platform
> API?

Whoops! It's not necessary. I wrote the example to demonstrate how to
use the lower-level API before I wrote the higher-level one. I just
updated it to rely on the higher-level cross platform API. Sorry for
the confusion.

> Also, since the compiled Java class is required, I think it would
> be better to include the .class file in the git repository so API users
> do not need to manually run any go-generate commands to get things
> working. This will just result in a runtime error if people forget to do
> that.

Yeah, I see your point. That being said, they'll still need to copy
the JAR file containing that class into the main package of their
project. I couldn't find a way to automate that process. I'm
definitely open to suggestions about how to achieve a smoother
integration here; this was just my first attempt.

> Are lifecycle issues addressed in the Android implementation, e.g. if
> the Activity is destroyed and re-started, will the notification channel
> still work or will it have to be re-started manually?

To be honest, I am not 100% certain. However, I made every effort to
make the notification management logic completely independent of the
other application code. It doesn't reference the GioActivity even
once. I suspect that its lifecycle is, therefore, not bound to that of
the activity. Thank you for bringing this up though! It does require
further investigation.

Also, could you look at this PR? https://git.wow.st/gmp/jni/pulls/1

Merging that would eliminate the replace directive that you current
must use to consume niotify.

Thanks a bunch for your interest and your offer to help! Happy to
collaborate here, in my public inbox on srht, or in slack.

Cheers,
Chris
Gregory Pomerantz
Details
Message ID
<6eb5e618-5238-b7fb-5ca6-d99bddf1c3a7@wow.st>
In-Reply-To
<CAFcc3FQEXZAF0BDixWtxnOL3UtOO8cBh3nSaTPOOqZFLMRoRNA@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
On 6/21/20 9:57 PM, Chris Waldon wrote:

> Yeah, I see your point. That being said, they'll still need to copy
> the JAR file containing that class into the main package of their
> project. I couldn't find a way to automate that process. I'm
> definitely open to suggestions about how to achieve a smoother
> integration here; this was just my first attempt.
gogio will search all included packages (recursively), so if the jar 
file is in the git.sr.ht/~whereswaldon/niotify/android directory, it 
will be included in any apk as long as the Go source for your app 
indirectly imports it. I would just drop it in there and put the 
go:generate commands at the top of android/notify_android.go. You should 
include the jar in the git repository so it automatically gets 
downloaded and will be installed in apks without the app programmer 
needing to do anything.
Details
Message ID
<C3OSEAKKY788.27T2UYZ5LFWCZ@vendetta>
In-Reply-To
<6eb5e618-5238-b7fb-5ca6-d99bddf1c3a7@wow.st> (view parent)
DKIM signature
pass
Download raw message
> gogio will search all included packages (recursively), so if the jar
> file is in the git.sr.ht/~whereswaldon/niotify/android directory, it
> will be included in any apk as long as the Go source for your app
> indirectly imports it.

Whoops, I thought this was just for JARs in your main package. In that case,
I'll definitely include the JAR in the package.


> I would just drop it in there and put the
> go:generate commands at the top of android/notify_android.go. You should
> include the jar in the git repository so it automatically gets
> downloaded and will be installed in apks without the app programmer
> needing to do anything.

Yup, this is clearly superior. Thank you for the tip!
Export thread (mbox)