Nov 14 | 8:50 AM |
Mark M. | has entered the room |
Nov 14 | 8:55 AM |
Mark M. | turned on guest access |
Nov 14 | 9:00 AM |
Craig D. | has entered the room |
Mark M. |
hello, Craig!
|
Mark M. |
how can I help you today?
|
Craig D. |
Hi. My Commonsware subscription ends in early December. How can I renew it?
|
Mark M. | |
Mark M. |
and use one of the "Subscribe!" options
|
Mark M. |
those work for renewals as well as for new accounts
|
Craig D. |
Good. Thanks!
|
Craig D. |
I also have a question about setting up SSL and OAuth to work with an Android client that communicates with a REST web service. Do you know any good examples of that?
|
Nov 14 | 9:05 AM |
Mark M. |
not the OAuth part
|
Mark M. |
I'm sure there are examples
|
Mark M. |
but I haven't used it personally
|
Mark M. |
and so I do not know of any resources off the top of my head
|
Craig D. |
Does your book cover SSL?
|
Mark M. |
yes
|
Mark M. |
there's a dedicated chapter on it
|
Craig D. |
Good. I'll take a look. Are there other Auth schemes that you cover?
|
Mark M. |
no, I do not get into authentication
|
Mark M. |
BTW, the SSL chapter starts on page 1943 of Version 6.1's PDF
|
Craig D. |
I just found it. I haven't gotten that far in the book. Sorry.
|
Mark M. |
no worries
|
Mark M. |
I used to have it as part of the Internet chapter
|
Craig D. |
It's a great resource, though.
|
Mark M. |
but that chapter was getting mighty big
|
Mark M. |
glad you like it!
|
Nov 14 | 9:10 AM |
Mark M. |
if you have other questions, go right ahead -- it's a quiet chat room :-)
|
Craig D. |
Not right now outside of the OAuth one. I haven't found a good example online. Please consider adding it to a future edition.
|
Mark M. |
OK, though it's not going to be there any time soon
|
Craig D. |
OK. I
|
Nov 14 | 9:15 AM |
Craig D. |
I'm very glad you modernized the parts of the book that used Action Bar Sherlock.
|
Mark M. |
ActionBarSherlock was the right move at the time
|
Mark M. |
but, yes, the examples needed to move on
|
Craig D. |
Here's another question: What is the advantage of using a ListActivity over using a ListView in a regular activity (or Fragment)?
|
Mark M. |
minor code simplification (setListAdapter(), onListItemClick())
|
Mark M. |
and you can skip the activity layout, if it would just be a ListView
|
Mark M. |
beyond that, not much
|
Craig D. |
Thanks. I am 'at work' on my other computer, so my attention will be diverted at times.
|
Nov 14 | 9:20 AM |
Mark M. |
no worries -- chime in if you have a question
|
Nov 14 | 9:55 AM |
Craig D. | has left the room |
Nov 14 | 10:00 AM |
Mark M. | turned off guest access |
Nov 14 | 10:10 AM |
Mark M. | has left the room |
Nov 14 | 3:50 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Nov 14 | 4:00 PM |
EGHDK | has entered the room |
Mark M. |
hello, EGHDK!
|
Mark M. |
how can I help you today?
|
EGHDK |
Hey Mark, so I have a particular case I'd like your advice on. I have an app on the play store, and I was working recently with a school to get this app on their tablets. I recommended them using some kind of more robust process then this, but since its a small number of devices (5 to be exact) they want to just manually load the apk onto each.
|
EGHDK |
Again, this is fine and won't take much work, but the thing that we have settup is that they want a special token to know that when the devices check in online that they are one of the 5 devices.
|
EGHDK |
But they also want the apk to get the updates pushed from google play.
|
EGHDK |
So this is my solution and let me know if it sounds reasonable.
|
Nov 14 | 4:05 PM |
Ryan M. | has entered the room |
EGHDK |
I want to put a txt file in the raw directory.
|
EGHDK |
that contains the token.
|
Mark M. |
(hello, Ryan -- I will be with you shortly!)
|
EGHDK |
Then when making a network request I just check to see if that file exists.
|
EGHDK |
The only issue is if I update through google play, won't I override that file?
|
Mark M. |
correct
|
EGHDK |
Gah.
|
Mark M. |
mostly because it is not a file
|
Mark M. |
it is an entry in the ZIP archive that is the APK
|
EGHDK |
So is there anyway to put something in this apk that I'll be able to use as a token or something? That will persistantly stay there?
|
Mark M. |
strictly speaking, no
|
Mark M. |
there's nothing stopping you from copying the value out of the raw resource to a file on internal storage, though
|
Mark M. |
that will survive an upgrade (though whether the upgrade will work from the Play Store, I can't say)
|
Mark M. |
it won't survive an uninstall-and-reinstall cycle
|
EGHDK |
It doesn't have to survive uninstall.
|
EGHDK |
Just an upgrade.
|
EGHDK |
But I would have to copy the value on first opening of the application right?
|
Mark M. |
that'd be a likely time
|
Mark M. |
technically, it just has to be before the first upgrade
|
Mark M. |
let me take a question from Ryan, and I'll be back with you shortly
|
Mark M. |
Ryan: your turn! do you have a question?
|
Nov 14 | 4:10 PM |
EGHDK |
Is there a broadcast that I can use when my app has been installed?
|
EGHDK |
No problem.
|
Mark M. |
(EGHDK: not that you receive, but you'd just look to see if your file exists, and if not, see if the raw resource exists and copy it)
|
EGHDK |
I have a lot of little questions regarding this so I'm fine to wait. Hahaha.
|
Ryan M. |
Hey loving the book so far. I am stuck on Tutorial 13, Prefs. Saving chapter position isn't working for me.
|
Mark M. |
what specifically is not working?
|
Ryan M. |
If I scroll to a different chapter after checking the preference, back out of the app then open it again it goes back to the first page.
|
Ryan M. |
mfrag.getPrefs() always returns null
|
Mark M. |
just so that I can give you appropriate links, are you using the Android Studio instructions or the Eclipse instructions?
|
Ryan M. |
Android Studio
|
Ryan M. |
Getting the same behavior with the code on GitHub for this chapter as well.
|
Mark M. |
well, that I can't explain
|
Mark M. |
you can see the code where the preferences are being set
|
Mark M. | |
Nov 14 | 4:15 PM |
Mark M. |
there's no scenario in which the book itself can be seen without the preferences being loaded
|
Mark M. |
out of curiosity, what Android OS version are you testing this on?
|
Ryan M. |
KitKat
|
Mark M. |
that should be fine, other than screen rotation if you're using the emulator
|
Mark M. |
do you have the line that I linked to in your code?
|
Ryan M. |
That prefs reference is being set correctly in the run() method, however in onPause() back in the Activity, mfrag.getPrefs() is returning null which bypasses setting the position
|
Mark M. |
sounds like a timing issue
|
Mark M. |
there's no question that I'm not dotting all the i's and crossing all the t's in the tutorial (let alone the regular samples)
|
Mark M. |
if onPause() is called before that first line of run() completes, the preferences would not be available
|
Mark M. |
I'll work on improving this portion of the tutorials in some future book update
|
Mark M. |
in the meantime, it's probably not something you're doing wrong, so I wouldn't worry about it
|
Nov 14 | 4:20 PM |
Ryan M. |
Cool. Is there a better place for setting prefs in the ModelFragment other than the thread's run()?
|
Mark M. |
well, ideally, we want to load the SharedPreferences in a background thread, as that involves disk I/O
|
Mark M. |
the problem is where I'm using the SharedPreferences
|
Mark M. |
I should be doing that work in setupPager() or something like that
|
Ryan M. |
Gotcha. I can try that or add some Thread.sleep and see if that helps
|
Mark M. |
let me take a question from EGHDK, and I'll be back with you shortly
|
Mark M. |
EGHDK: your turn! do you have another question?
|
EGHDK |
Yeah, I think I might do on boot completed reciever and take that files value and save it somewhere.
|
EGHDK |
Now the question is where?
|
EGHDK |
Do you think a sharedPref might be the easiest.
|
Mark M. |
boot-completed is a lousy time, simply because devices do not usually get rebooted
|
Mark M. |
SharedPreferences or a simple file on internal storage seem like likely candidates
|
Mark M. |
though bear in mind that your *production public app* needs this logic too
|
Mark M. |
otherwise, when the app gets updated, your validation goes goes *poof*
|
EGHDK |
Can I put it in internal sotrage but thats private to the app?
|
Nov 14 | 4:25 PM |
Mark M. |
er, that should have been "validation code goes *poof*"
|
Mark M. |
internal storage is private to the app by definition
|
EGHDK |
Oh. Whats the api for that again?
|
Mark M. |
getFilesDir(), or the combination of openInputStream() and openOutputStream()
|
EGHDK |
Basically I might copy or move the file from RAW to my internal storage... private to the app. Then is should persist.
|
Julius | has entered the room |
Mark M. |
correct
|
Mark M. |
(hello, Julius -- I will be with you shortly!)
|
Julius |
(no hurry I need to compose my question - hi all :) )
|
EGHDK |
Okay cool. So getFilesDir is private and persists?
|
Mark M. |
yes
|
EGHDK |
Great. Thanks.
|
Mark M. |
Julius: you haven't had a shot yet so... do you have a question?
|
Julius |
just composing, happy to wait fo rnow
|
Mark M. |
OK
|
Mark M. |
Ryan: your turn! do you have a question?
|
Ryan M. |
Someone else can go, I am trying some different things :-)
|
Mark M. |
OK
|
Mark M. |
EGHDK: back to you -- do you have another question?
|
EGHDK |
Dang. I had a good question. But forgot it.
|
Nov 14 | 4:30 PM |
Mark M. |
I had an answer for it, but I forgot that too
|
Nov 14 | 4:30 PM |
Julius |
lol
|
EGHDK |
lol
|
Julius |
ok I'll go for it now although I'm not perfectly prepared
|
Mark M. |
Julius: go right ahead
|
Julius |
I'm trying to save a document to PDF
|
Julius |
I would like to use the approach in your book to create the document using the curly braces and HTML.
|
Julius |
but I don't want to print the document
|
Julius |
I would like to save it to a file
|
Julius |
When I use the prepPrintWebView
|
Julius |
it creates an adapter for printing
|
Julius |
which makes sense. :)
|
Julius |
just wondering if it's possible to use the same preparation to generate the PDF, but not print it to a printer
|
Julius |
just save to an outputstream
|
Julius |
(Hope that made sense)
|
Mark M. |
I don't know of any way to accomplish that
|
Nov 14 | 4:35 PM |
Julius |
OK - then I have another question when it comes around on the guitar
|
Mark M. |
ideally, the WebView-to-PDF path would be more directly exposed, in addition to rolling through the adapter
|
Mark M. |
guitar?
|
Julius |
(oh sorry Alice's Restaurant gag)
|
Julius |
just in case someone else wants to go ahead with a question I can wait :)
|
EGHDK |
Can't remember my question. Figures. I'm out for today. See you next time Mark.
|
Mark M. |
ok, see you later!
|
Mark M. |
at this point, we can go free-for-all -- if anyone has a question, go ahead
|
Julius |
View paste
(15 more lines)
|
Mark M. |
right, but that implies drawing to a Canvas
|
Julius |
yeah absolutely
|
Julius |
This makes an A4 size document which is cool.
|
Mark M. |
though now that I think about it, having WebView draw to your own Canvas should be possible
|
Julius |
My trouble is that the content on the canvas doesn't appear scaled and in the right place
|
Mark M. |
I'm doing that in my mirroring code in CWAC-Layout
|
Julius |
(yeah I wondered about that too)
|
Julius |
I think the problem I'm having is that the Canvas is much larger than the "print area"
|
Nov 14 | 4:40 PM |
Julius |
lots more pixels potentially (dpi)
|
Mark M. |
I'm not much of a low-level Canvas guy
|
Julius |
I'm just wondering if I can make a layout that places content on it scaled differently from the device
|
Julius |
nah me neither!
|
Julius |
but you know _everything_
|
Julius |
ok I'll have a bit more of a tinker
|
Mark M. |
I'm confused by your "Canvas is much larger than the print area" statement
|
Julius |
it feels like it's so close to wokring
|
Mark M. |
the Canvas *is* the print area
|
Mark M. |
you're getting it from the PdfDocument.Page
|
Julius | |
Julius |
I'm getting things cut off
|
Mark M. |
you'd need to scale the WebView to be the right size
|
Julius |
yeah I probably don't understand it properly
|
Julius |
ok
|
Mark M. |
I assume that this WebView is not actually on the screen, but rather is a background-y thing you're using for printing... right?
|
Julius |
so I would use pixels for that
|
Julius |
yeah I believe that is how it works
|
Julius |
originally in that upload I was just using the display
|
Julius |
ok I'll try the scaling
|
Julius |
thank you very much for talking it through with me
|
Mark M. |
in that case, I'd try to figure out how to size the WebView such that it was the same size as your target Canvas
|
Mark M. |
you could take a look at my mirroring code in CWAC-Layout (also reviewed in the book)
|
Julius |
ok I'll give that a look.
|
Mark M. |
in my case, it's bitmaps, where auto-scaling happens a bit more
|
Mark M. |
but it might trigger some ideas
|
Julius |
There was a time when I read the entire book every time it came out, but then there was just too much!
|
Nov 14 | 4:45 PM |
Mark M. |
the table of contents shows the sections that changed or were added
|
Mark M. |
and the changebars in those sections show the paragraphs and stuff that changed
|
Julius |
I see - great
|
Julius |
ok thanks again - I'll leave you to your day (or night)
|
Julius |
bye all, hope you get all your things going
|
Julius | has left the room |
Mark M. |
if anyone has any questions, go ahead
|
Nov 14 | 4:50 PM |
EGHDK | has left the room |
Ryan M. | has left the room |
Nov 14 | 4:55 PM |
Mark M. | turned off guest access |