-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat(): Android support & SyntaxHighlighterView #8
Conversation
triniwiz
commented
Mar 10, 2019
@triniwiz Thank you very much for this PR! My main computer has ran out of disk space, so I'm busy installing the Android SDK and the NativeScript CLI on my older (yet more spacious) computer to test out this PR. I'm new to Android development, so may have problems getting it to run today, but will do my best. Have you checked for any regressions on the iOS side? |
IOS is pretty much doing the same thing from your code 🙂 |
Cool. Having git problems... git fetch origin pull/8/head:master Is the correct way to check out your branch, right? It’s giving me errors. Typing on mobile now so can’t specify exact error details. EDIT followed these alternative instructions and have successfully checked out your branch now. |
Looks like a lot of changes to go over; may not manage to review much tonight. My summary so far:
Is there any way you could base the Android implementation on a TextView instead, and therefore expose text change events? |
TextView vs. WebView
Okay, fair enough, if all syntax-highlighting solutions rely on HTML, and TextView doesn't support all the HTML tags needed, then we're forced to use WebView if every syntax-highlighting solution relies on HTML in some way. I had hoped that there would be a non-HTML based competitor, but I can't immediately find one. We could potentially handle key events by having an event handler run before Test runRunning it on Android now. cd demo
tns run android
Looking into this... |
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="index.css">
<link id="mainstyle" rel="stylesheet" href="highlight/styles/default.css">
<script src="highlight/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head> Looks like I also noticed that the
|
Some .js files didn’t make it |
Awesome, that's working now. Improvements to make: Android
iOS
I'll see what I can do on all of these. |
Unless we can prevent auto-correct and auto-capitalisation on the keyboard, and implement live-updating of syntax highlighting, this plugin is unusable for writing code. It can work for just displaying code, but even then, we'd first need to find a way to fit it to the screen properly. Do you have any ideas? |
Solving the syntax highlighting not updating on text changeThis may just require a bit of rethinking the javascript we're using. Alternative projects to possibly solve the keyboard issueI looked into the various options for Android.
I noticed that my iOS plugin uses Directly solving the keyboard issueThere may be a way to do this. This article details how to manage the keyboard on WebView by extending the WebView class. This is probably our best option from here. ✅ Solving the width issueI'm still unsure why |
Another thing I noticed: if you keep adding new lines to the text box in the current implementation's WebView, the page doesn't scroll down to keep the current line in view. It seems like the writing experience in general is bad. I wonder whether we should accept that this plugin will mainly be for displaying text rather than editing it, given that Android has no proper text editors. But 920 Text Editor seems to have done a good job... |
@triniwiz I've had a moment to test the iOS version. No regressions as far as I can see. Given that this PR improves the code quality of the iOS side of the codebase, introduces an XML component, and provides foundational Android support, I'm very happy to merge it. I feel that the remaining Android issues that I've commented on can be deferred to separate PRs for anyone brave enough to solve them. Thank you very much for the high-quality PR! It serves as great guidance for me writing future plugins. |
Glad you liked it 🙂 |