Mark M. | has entered the room |
Mark M. | turned on guest access |
Jun 5 | 3:55 PM |
Dimitris K. | has entered the room |
Dimitris K. |
Greetings from Germany Mark!
|
Mark M. |
hello, Dimitris!
|
Mark M. |
how can I help you today?
|
Mark M. |
(or tonight, in your case)
|
Dimitris K. |
I am a huge fan and this is the first time I really need your help and the book is not enough to guide me through!
|
Dimitris K. |
So I would like to know if somehow its possible to load any website on a webview and get the focused text elements that the user focuses and paste some data inside.
|
Mark M. |
I assume that there are some JavaScript events for focus change
|
Mark M. |
but I am not aware of a way to get it purely from Java
|
Dimitris K. |
Just to point the use case. There is a strange tablet with a laser barcode scanner pre installed and I get the scanned data through a USB port
|
Dimitris K. |
I need to paste the data
|
Dimitris K. |
inside textfields on a website
|
Mark M. |
it is at least theoretically possible to use evaluateJavascript() (or the older loadUrl()) to inject some JavaScript that hooks those focus-change events, passing the information along to your Java code via some object injected via addJavascriptInterface()
|
Mark M. |
I don't know how easy it is to identify and hook up listeners for all focusable elements, as I'm not a DOM/JavaScript expert
|
Mark M. |
but I would attack the problem that way, looking to see how to accomplish your aims via injected JavaScript
|
Dimitris K. |
I'm really not into web and I kinda hate javascript but from what I found it guest ok if you are willing to set up methods on the website first
|
Jun 5 | 4:00 PM |
Dimitris K. |
but I need a solution that should work with any website
|
Mark M. | |
Dimitris K. |
So maybe my first thought should be the real solution and that was to use a custom keyboard implementation that pastes from the port (if data is coming)
|
Mark M. |
a custom IME is a possibility -- I have heard of people doing that
|
Dimitris K. |
I though maybe the Anysoftkeyboard open source project could be used for that
|
Dimitris K. |
but somehow (on windows) I cant build the project
|
Mark M. |
the challenge there is either switching over to that IME when needed or having a dual-purpose IME (normal text entry plus data from the scanner)
|
Dimitris K. |
(issues with native code)
|
Dimitris K. |
I was considering to map a special character for the paste
|
Mark M. |
I have not written a custom IME, and so I do not know all of the tricks you might need there
|
Dimitris K. |
Is there any alternative to the Anysoftkeyboard that doesnt really need native code to be compiled ?
|
Mark M. |
um, I seem to recall the Hacker's Keyboard was open source
|
Mark M. |
I see a few others on F-Droid (after the loooooooooooooong list of AnySoftKeyboard language-specific apps)
|
Jun 5 | 4:05 PM |
Mark M. |
AFAIK there is nothing intrinsic to writing an IME that requires NDK code
|
Dimitris K. |
nice suggestion I will try that one as well, it does have some native code but looks a bit more structured so probably I will be able to make it run
|
Mark M. |
back on the JavaScript front, it seems relatively easy to find the element with the focus: https://stackoverflow.com/a/497108/115145
|
Dimitris K. |
they use native for dictionaries
|
Mark M. |
ah, OK
|
Dimitris K. |
I tried that but it kinda didnt work
|
Dimitris K. |
maybe I just didnt implement it properly though
|
Dimitris K. |
everything is a bit mysterious when it comes to the webview :P
|
Dimitris K. |
View paste
|
Dimitris K. |
I kinda imagine that this should be the expected call
|
Mark M. |
I don't know that returning something will be useful
|
Mark M. |
I would have the scriptSrc actually put the text into the DOM element
|
Dimitris K. |
hmm should I be able to somehow get a callback that something is focused ?
|
Dimitris K. |
(maybe not since there is nothing defined for that on the websites side)
|
Mark M. |
oh, if that is what you were aiming for, I suppose that could work
|
Mark M. |
did you not get a value back, or was the value unintelligible, or what was the specific issue with this code?
|
Dimitris K. |
well I need to paste the data inside the element but first I need to know when to trigger that action
|
Jun 5 | 4:10 PM |
Dimitris K. |
I got null
|
Mark M. |
and something definitely had the focus then?
|
Mark M. |
I haven't tried requestFocus() with WebView
|
Dimitris K. |
well there are many posts suggesting that it works
|
Dimitris K. |
but sadly everyone used local html websites
|
Mark M. |
they key is whether it works for the specific version of Android you are running -- what's on the tablet?
|
Dimitris K. |
so there was no post about doing such on a real website that you dont really have access to
|
Dimitris K. |
4.4
|
Mark M. |
I would not expect the behavior of requestFocus() to vary based on where the HTML is coming from, though it might vary by version of Android
|
Mark M. |
when you looked at the WebView after executing that code snippet, did something visually have the focus?
|
Dimitris K. |
hmm I think the version should be ok
|
Dimitris K. |
by default the webview focuses the 1st focusable element
|
Mark M. |
it may also be a synchronization issue
|
Dimitris K. |
wv.setWebChromeClient(new CustomWebChromeClient());
|
Dimitris K. |
View paste
|
Dimitris K. |
maybe I should also use something like that
|
Mark M. |
for debugging purposes, it might be useful, though console.log statements should go to LogCat
|
Jun 5 | 4:15 PM |
Dimitris K. |
so I can get a response each time something happens (currently I only got data on onPageFinished)
|
Mark M. |
back on the synchronization point, requestFocus() might get queued and wind up occurring after your evaluateJavascript() or something
|
Dimitris K. |
that would actually be an issue
|
Dimitris K. |
:/
|
Mark M. |
you might poke around JavaScript, see what the equivalent code is to set the focus, and try embedding that in with the rest of your JavaScript
|
Mark M. |
and see if that changes anything
|
Dimitris K. |
I guess I need to experiment a bit more with that
|
Dimitris K. |
do you still think thats a better option than the keyboard ?
|
Mark M. |
how much control do you have over the tablet?
|
Mark M. |
do you have to worry about people switching to this IME, or switching away from it?
|
Dimitris K. |
no thats not an issue
|
Mark M. |
do you have i18n concerns? how many character sets would the keyboard need to support?
|
Dimitris K. |
there wont be more than 10 tablets and the people using them just want to optimize the efficiency
|
Dimitris K. |
it should be a basic french supporting keyboard
|
Mark M. |
oh, OK, that's smaller than I was envisioning :-)
|
Dimitris K. |
yeah its small
|
Mark M. |
the advantage of the IME is that it could work for things other than the WebView
|
Mark M. |
it's a more general-purpose solution
|
Dimitris K. |
(really small for the trouble it is giving me :P)
|
Mark M. |
but, as I noted, I haven't messed with writing one, so I have no idea how easy or hard it will be to add in your logic
|
Dimitris K. |
they do have a past functionality built it so I should be able to use that in a custom way (I guess)
|
Dimitris K. |
paste*
|
Dimitris K. |
built in*
|
Jun 5 | 4:20 PM |
Mark M. |
BTW, this looks to be the code for setting the focus from JavaScript: https://stackoverflow.com/q/277544/115145
|
yannie | has entered the room |
yannie |
Hi mark
|
Mark M. |
Dimitris: let me take a question from yannie, and I will be back with you in a bit
|
Mark M. |
yannie: hi! how can I help you today?
|
yannie |
Having some issues with Espresso, it's not seeing views that I can see on the app
|
yannie |
any suggestions on how to debug that
|
Mark M. |
what do you mean by "not seeing views"?
|
yannie |
submit button for example
|
yannie |
I can see it, and it's active
|
yannie |
but espresso throws an error saying it's not present
|
yannie |
could be a sync issue?
|
yannie |
idling issue?
|
Mark M. |
I have no idea
|
Mark M. |
so, onView(withId(...)) is throwing an exception?
|
yannie |
sometimes, other times the test goes OK
|
Mark M. |
or how are you identifying the button?
|
yannie |
id
|
Mark M. |
OK, I can see why you might think it's a sync issue, as "it's a timing thing" certainly leads in that direction...
|
Mark M. |
is there anything unusual about when/how the button is added to the UI?
|
Mark M. |
(e.g., you are adding it via addView() based on some work that is being done)
|
yannie |
it waits for a download
|
yannie |
so it could be the idlingResource?
|
Mark M. |
possibly, perhaps the IdlingResource is yielding too soon
|
Jun 5 | 4:25 PM |
Mark M. |
I'm not a deep Espresso user, so I will have difficulty giving you specific advice
|
yannie |
ok, but I'm on the right track debugging that?
|
the_new_mr | has entered the room |
yannie |
would that be your thought process?
|
Mark M. |
it's certainly worth an experiment
|
yannie |
ok
|
yannie |
thanks
|
yannie |
one last thing
|
Mark M. |
for example, if there is another widget that has similar characteristics to the submit button vis a vis timing, you might check to see if it too results in the same error
|
yannie |
when are the "mini books" coming out?
|
Mark M. | |
yannie |
ok
|
Mark M. |
I have some stuff coming out later this month (I hope -- waiting on a third party) and July
|
yannie |
cool
|
Mark M. |
so, stay tuned!
|
yannie |
thanks
|
the_new_mr |
ok. thanks
|
Mark M. |
yannie: let me take questions from the others, and I will back with you in a bit
|
Mark M. |
the_new_mr: your turn! do you have a question?
|
yannie |
ok
|
the_new_mr |
hi Mark
|
the_new_mr |
how's things?
|
Mark M. |
um, Things are on Developer Preview 4
|
Mark M. |
:-)
|
the_new_mr |
lol
|
the_new_mr |
ah man... cheesy... that's the way i like my jokes :)
|
yannie | has left the room |
the_new_mr |
speaking of things, i sold my vacuum cleaner the other day... well, it was only gathering dust
|
the_new_mr |
aaaaanyway.... to my question....
|
Dimitris K. |
nice one
|
Mark M. |
neither of us should quit our day jobs
|
the_new_mr |
lol
|
Jun 5 | 4:30 PM |
the_new_mr |
there's a guy who makes a living out of this. Tim Vine. check him out
|
Jun 5 | 4:30 PM |
the_new_mr |
that's one of his jokes
|
the_new_mr |
so.... i have a general question that has a specific element
|
the_new_mr |
i'll start with the general question
|
the_new_mr |
if something is deprecated and will be removed, what is it that will put one in a situation where it is actually deprecated?
|
the_new_mr |
compile sdk version? target sdk? or the sdk of the device?
|
the_new_mr |
or rather, actually removed. not just deprecated
|
Mark M. |
are you referring to items in the Android SDK that are deprecated?
|
the_new_mr |
yes
|
Mark M. |
they are almost never removed
|
Mark M. |
at least, in terms of core classes
|
Mark M. |
stuff gets removed from the Support Libraries, under the premise that if you need it, don't upgrade the library
|
the_new_mr |
wyeah
|
the_new_mr |
here's the specific question...
|
the_new_mr |
View paste
|
Mark M. |
deprecated things in the core SDK usually stick around, perhaps with reduced functionality, to ensure binary compatibility
|
the_new_mr |
they say they are "deprecating the implementation of the SHA1PRNG algorithm and the Crypto provider altogether"
|
Mark M. |
that's something that they *could* remove, as it did not break any true compile-time contract
|
Mark M. |
yes, and this SO post suggests that it is truly gone: https://stackoverflow.com/q/36813098/115145
|
the_new_mr |
there's a warning message that appears in logcat that says you should "not rely on it being available in the future" (or something like that)
|
Jun 5 | 4:35 PM |
Mark M. |
I'll take your word for that
|
Mark M. |
but I would get off of that provider ASAP
|
Mark M. |
and I would test your code on Android O even more ASAP-ly
|
the_new_mr |
yeah. we don't want to use it
|
the_new_mr |
honestly, i don't
|
the_new_mr |
i wanted to move but business etc etc
|
the_new_mr |
plus the app is being sunset soon
|
the_new_mr |
thing is, if we don't change our compile sdk version or target sdk version, do we still get affected?
|
Mark M. |
as was mentioned in the SO question that I linked to, you can always copy that provider into your app
|
Mark M. |
probably
|
the_new_mr |
true
|
the_new_mr |
might do that
|
Mark M. |
they're being somewhat cagey on that point
|
the_new_mr |
well, that's my question
|
the_new_mr |
when they remove it, is it gone off of the device or off of the sdk we're using?
|
Mark M. |
the device
|
the_new_mr |
the sdk we're compiling against?
|
the_new_mr |
the device?
|
Mark M. |
yes
|
the_new_mr |
ok. that's a major OMG momwn
|
the_new_mr |
moment
|
Mark M. |
it's not strictly in the SDK
|
Mark M. |
the SDK has the javax.crypto classes
|
Mark M. |
and they aren't going away
|
Mark M. |
but SPIs are not compile-time contracts
|
Mark M. |
they're just strings (e.g., "Crypto")
|
the_new_mr |
ok. quite scary. so basically, someone may get an OS update and boom, it's gone!
|
Mark M. |
yes
|
Mark M. |
now, it is possible that they might have some targetSdkVersion check in there
|
the_new_mr |
ok. mega ouch. thanks for that. that's basically all i needed to know
|
Mark M. |
so they would still return it for targetSdkVersion less than such-and-so
|
the_new_mr |
yeah. but then who knows?!
|
Mark M. |
agreed
|
the_new_mr |
ok. good to know. thanks
|
Mark M. |
particularly with security things like this, they tend to take a harder line
|
the_new_mr |
yeah, can't blame them on that really
|
Mark M. |
but, test on Android O
|
Jun 5 | 4:40 PM |
the_new_mr |
ok. we're probably in trouble then. thanks for your help!
|
the_new_mr |
yeah, we did
|
Mark M. |
you're welcome!
|
the_new_mr |
but i must test this functionality..
|
the_new_mr |
and see if the key is being generated differently
|
Mark M. |
let me switch back to Dmitris, and I'll return to you shortly
|
Mark M. |
Dmitris: your turn! do you have another question?
|
Dimitris K. |
Well I guess I need to experiment first with all the things we talked about
|
the_new_mr |
well, i think i'm okay with that. thanks Mark as always
|
Dimitris K. |
but you will hear from me often since on my main job im in a huge project alone ^^
|
Mark M. |
if nothing else, Thursday's chat is in a more Germany-friendly time slot :-)
|
the_new_mr | has left the room |
Dimitris K. |
I will be back with more ! ^^ thank you for your time! Btw for more personalized private solutions I can send you a mail for business inquires right ?
|
Mark M. |
yes, private consulting/training is certainly an option
|
Mark M. | |
Mark M. |
(or, really, pretty.much.anything@commonsware.com)
|
Dimitris K. |
Do you have any experience with device owner apps
|
Mark M. |
nope
|
Dimitris K. |
apps that should run as system apps
|
Mark M. |
I know the general device owner concept, but I have not tried setting it up
|
Jun 5 | 4:45 PM |
Dimitris K. |
I'm gonna have to make an updater tool that will control a "visual" app makes sure every thing is fluid and be able to update both itself and the "visual"
|
Dimitris K. |
all of that in a custom kiosk mode
|
Mark M. |
most of that is outside my area of expertise
|
Dimitris K. |
so I guess some consulting might be needed
|
Dimitris K. |
If I manage to make it run as smooth as needed I will inform you on the process
|
Dimitris K. |
its an interesting point for digital signage
|
Mark M. |
yes, there are plenty of semi-embedded Android solutions using that sort of stuff
|
Dimitris K. |
all devices there are custom and rooted
|
Mark M. |
though, I suspect that long-term, more will move to Android Things
|
Dimitris K. |
your chapter on controlling the second device saved me
|
Dimitris K. |
second screen *
|
the_new_mr | has entered the room |
the_new_mr |
hi Mark
|
Mark M. |
yes, that's an under-utilized part of the SDK, IMHO
|
the_new_mr |
quick follow up when you're ready there
|
Dimitris K. |
so thats all for today, thanks again!!
|
Dimitris K. |
Enjoy the rest of your day
|
Mark M. |
Dimitris: you're welcome!
|
Mark M. |
the_new_mr: go right ahead!
|
Dimitris K. | has left the room |
Jun 5 | 4:50 PM |
the_new_mr |
ok... just realised there's something at the bottom of that blog post
|
the_new_mr |
Note 1: as a temporary measure to keep apps working, we decided to still create the instance for apps targeting SDK version 23, the SDK version for Marshmallow, or less. Please don't rely on the presence of the Crypto provider in the Android SDK, our plan is to delete it completely in the future.
|
the_new_mr |
from that, looks like targeting 22 should be grand
|
Mark M. |
um...
|
Mark M. |
I'd be more worried about the "our plan is to delete it completely in the future" part
|
the_new_mr |
so like... do you think we're okay till we sunset?
|
Mark M. |
as "the future" could be Android O, for all I know
|
the_new_mr |
yeah
|
the_new_mr |
that's the bit that could be open to intepretation
|
Mark M. |
when is the app slated to sunset?
|
the_new_mr |
that's the thing.....
|
the_new_mr |
it was supposed to be july and now they're saying september!!!
|
the_new_mr |
damn business!
|
Mark M. |
of 2017 or 2018?
|
the_new_mr |
they should have listened to me before!
|
the_new_mr |
2017
|
the_new_mr |
next time i'll know to insist
|
the_new_mr |
i'll put it down to experience
|
the_new_mr |
anyway...
|
the_new_mr |
this is the pickle we're in
|
Mark M. |
and is this a hard sunset (i.e., the app isn't supposed to work anymore), or does it just mean that you're no longer supporting it?
|
the_new_mr |
well, bit of both
|
the_new_mr |
as they're transitioning users over to another app
|
Mark M. |
ah
|
the_new_mr |
God knows how its doing its encryption
|
the_new_mr |
i must actually check with them!
|
Mark M. |
well, in the 2017-to-early-2018 timeframe, there is Android O and a possible O MR1
|
the_new_mr |
yeah i know!
|
the_new_mr |
that's the worrying part!
|
Mark M. |
I would be somewhat surprised if they deleted Crypto in an MR1 release
|
the_new_mr |
massive race against time
|
the_new_mr |
you would hope so!
|
Jun 5 | 4:55 PM |
Mark M. |
and, of course, the rollout of O/O MR1 will be glacial as usual
|
the_new_mr |
i must do some testing tomorrow on n and o
|
the_new_mr |
no doubt
|
Mark M. |
so if your stuff works on O, you're probably OK
|
the_new_mr |
what do you mean exactly by glacial?
|
Mark M. |
I don't know if "probably" is sufficient for your situation, though
|
Mark M. |
well, Android 7.x is only at about 5% of the device ecosystem now
|
the_new_mr |
yeah. this is the thing....
|
the_new_mr |
yeah. but there can be a sky is falling situation
|
the_new_mr |
0.1% of our users and the business freaks out
|
the_new_mr |
don't blame them for that either tbh
|
the_new_mr |
so.... IF we were to bring it into our codebase as a safety measure...
|
the_new_mr |
what exactly should we do?
|
Mark M. | |
the_new_mr |
just bring in the whole security package?
|
Mark M. |
just the classes that you need
|
Mark M. |
as you will need to refactor them into some other package
|
the_new_mr |
ok
|
Mark M. |
I have no idea how far down the rabbit hole goes with that code, but my guess is that it won't be too many classes
|
the_new_mr |
trial and error i suppose
|
the_new_mr |
here's hoping anyway!
|
Mark M. |
then, as that answer points out, directly use your local copy, vs. doing the string-based provider lookup
|
the_new_mr |
looks like i have an adventure in wonderland coming up!
|
the_new_mr |
yeah
|
the_new_mr |
one last question....
|
the_new_mr |
do manufacturers remove stuff themselves? i'm wondering if samsung have removed the crypto provider when google haven't yet
|
the_new_mr |
and is there some way to see the changelog for manufacturers OS updates?
|
Mark M. |
I can't rule it out, but their tendency is to add things, more than remove them
|
the_new_mr |
yeah
|
Jun 5 | 5:00 PM |
Mark M. |
and I don't even know if manufacturers *have* a changelog, let alone if others can access it
|
the_new_mr |
was just thinking maybe samsung or whoever would be like "this is insecure. rip it out"
|
Mark M. |
they tend to let sleeping dogs lie
|
the_new_mr |
oh dear =/ would hope they do
|
the_new_mr |
ok. thanks for all your help as always man
|
Mark M. |
happy to be useful!
|
Mark M. |
and that's a wrap for today's chat
|
Mark M. |
next one is tomorrow at 7:30pm US Eastern
|
the_new_mr |
thanks. bye!
|
the_new_mr | has left the room |
Mark M. | turned off guest access |