Open lrq3000 opened 6 years ago
In my reasearch Kivy come out as a candidate as well.
I do not anticipate using graphical parts of Kivy, just the packaging as a wrapper for an HTML view.
Please have a look at the wiki pages for this repository (link in README) for further notes.
On Thu, Dec 14, 2017 at 10:18 AM Stephen L. notifications@github.com wrote:
Kivy is a python based cross platform graphical backend for mobile and desktop apps. It can compile to both Android and iOS.
I would like to discuss this library as a potential backend for Zim Desktop Wiki on mobile phones, does someone with experience on it think it might be feasible? Do you Jan already considered it and rejected for any reason?
Btw there is also https://github.com/kivy/python-for-android if we only want a python to android packager and builder, but i think we can as well use kivy which is cross-platform aed provide the graphical backend.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jaap-karssenberg/zim-android-mockapp/issues/4, or mute the thread https://github.com/notifications/unsubscribe-auth/ABMMHsnAYqU050fV7QAeUiysdNBekiLfks5tAOftgaJpZM4RBwhj .
Ah sorry I missed this part of the wiki, I guess you are referring to this.
I'm just starting with Kivy for my own apps, if I can get the hang of it I might give it a try for Zim Notes. Worth having a look for a starting point, beside the native embedded browser, is demo/kivycatalog
in the kivy-examples
package, this is a two-pane renderer for RST syntax, and it can render more complex objects than Zim supports (buttons, radio boxes, etc) so I guess Kivy is a very good candidate for Zim Notes rendering!
I have taken a look into this issue, I will now start documenting here because I begin to accumulate too much info and I risk losing some leads in case one fails.
About integrating a webview widget (to see a webpage), I have found two ways: either via Kivy + pyJnius calling native Android Java WebView widget (more infos in the Kivy news here about performances and stuff), or a pure python approach using pyWebView + python-for-android (with the advantage that it should work the same on all platforms, not just Android, which could accelerate development as the app would be testable as-is on desktop).
Of interesting note, there is also Remi, to generate a GUI using only Python and no HTML, with a standalone webserver and it can interface with pyWebView using the argument start(myApp, standalone=True)
. This can be a lightweight interesting alternative to Kivy. There were also some attempts to port CEF-python (Chrome as embedded browser) to Kivy but they never went beyond alpha (see here and here).
About using Kivy to compile for Android, I have found a great tutorial. Basically, since we need webview, we need:
However, Buildozer works only on Linux and OSX at the moment. But Kivy provides a VirtualBox virtual machine with Buildozer and python-for-android pre-installed.
This is the most tricky part. Although viewing a webpage won't be too problematic once we figure out how to build a webview apk, which was already done be several people, the tricky thing is how to manage edition of a note.
The easiest way is to just mimic what most apps (and even Kivy examples) do:
However, to be really perfect, we would need a WYSIWYG editor, similar to a rich text editor, where we can both see the markup render and modify on the same view.
Here are the solutions/issues I found to make a WYSIWYG editor in Android:
Per the specifications on the wiki and after my research, it seems that:
@jaap-karssenberg some questions for you: the wiki specification does not really detail the big plan: why do you want the app to work with HTML pages? I guess you plan the renderer and editor to be coded in Javascript? Or do you have something else in mind?
@jaap-karssenberg Ah I forgot my last and most important question: how do you plan the editor to work with the renderer? By converting back and forth from/to HTML and Zim code?
My current idea of something that would work fast would be to convert ZIM code to HTML for rendering, and then the editing would happen directly on the HTML page (using a specialized editor like CKEditor or maybe better Trix), and after change it would be converted back to ZIM. As there is already an HTML export from ZIM, the first part is covered. All that would remain would be to code a simple converter of HTML to ZIM.
Is this what you had in mind?
@jaap-karssenberg And lastly, can you outline how you accomplish the feat of having a WYSIWYG editor in Zim Desktop? In particular, how can you render, allow edition on the render, all the while saving the markup behind the scenes transparently to the user? Because maybe we can use the same trick even if the mobile app is using a different technology.
BTW, there are lots of HTML to Markdown javascript WYSIWYG editors:
Let me know if there is one that looks close to what you had in mind for Zim, this can be great for inspiration!
Update: I tried to compile an APK using the following steps:
pip install git+https://github.com/kivy/python-for-android.git
. In case you have issues with the latest release, I used the commit 8829312fd187121384939627ec09354657821ae9 specifically.In the end, I ran into several issues and could not compile anything (see here for more infos).
I think that for the moment, python-for-android is not mature enough, it is probably better to postpone the project for now (unless if a python-for-android wizard pass by, feel free to give it a try).
I have advanced a bit, I made a theoretically functional app to display webpages generated from a background webserver as a service.
Why theoretically? Because I cannot test with Kivy Launcher, because even though Twisted is supported by Kivy, it is apparently not supported as a background service in Kivy Launcher (Kivy Launcher supports background services otherwise, such as OSC server).
Also, Kivy Launcher should be able to launch any pure python library, so I tried with native wsgiref and cherrypy and waitress, but none of them work, it seems Kivy Launcher is not 100% compatible with the basic CPython stack, it's only a partial implementation.
Thus, the only way is to compile via Python-For-Android, which should support this kind of application (webserver + webview client), using for example the flask backend.
All my work is available on my repo:
https://github.com/lrq3000/zim-android-mockapp
I left multiple implementations of the background service, just rename the folder you want to use to "service", and it should work the same. It's also testable under Windows, Linux and MacOSX by using python main_desktop.py
, so once we figure out how to run the service under Android, it will be possible to develop & test most of ZimAndroid on desktop computers.
Also note that a current limitation of using webview on Android is that it's not possible to add any other widget on-screen, thus by going this route, ZimAndroid will need to have a purely web interface, to control parameters configuration, browsing to other notes etc
The specific test I did for twisted is here: https://github.com/lrq3000/kivy-twisted-android
The app connects but does nothing afterwards...
Also might be interesting:
Finally I could make it!
See PR #5 for PACK-1 & PACK-2 proposal :-)
Kivy is a python based cross platform graphical backend for mobile and desktop apps. It can compile to both Android and iOS.
I would like to discuss this library as a potential backend for Zim Desktop Wiki on mobile phones, does someone with experience on it think it might be feasible? Do you Jan already considered it and rejected for any reason?
Btw there is also https://github.com/kivy/python-for-android if we only want a python to android packager and builder, but i think we can as well use kivy which is cross-platform aed provide the graphical backend.