Office Hours — Today, December 17

Yesterday, December 16

Dec 17
8:55 AM
Mark M.
has entered the room
Mark M.
turned on guest access
Jonatan R.
has entered the room
Mark M.
hello, Jonatan!
how can I help you today?
Jonatan R.
Hey Mark
Drasko
has entered the room
Drasko
hi!
Mark M.
(BTW, hello, Drasko -- I will be with you shortly!)
Jonatan: do you have a question?
9:00 AM
Jonatan R.
I'm having problems saving a bitmap to a file. Do you have an example somewhere I could look at? I've been searching the book but couldn't find anything.
Mark M.
hmmm... the closest thing that I have that I can think of is writing a bitmap to an OutputStream, as part of the andprojector sample in the media projection APIs chapter
saving a bitmap to a file should just be a call to compress() on the Bitmap
passing in a FileOutputStream
Jonatan R.
ok thanks, I'll have a look
Mark M.
let me take a question from Drasko, and I'll be back with you in a bit
Drasko: your turn! do you have a question?
Drasko
View paste
I would like you to check this image:
http://s8.postimg.org/5pw99506t/screens.png

You can see three screens there (1, 2 and 3). This is my client’s request UI and I don’t have any influence to change it. On screen 1 you can see something like tabs on the bottom. By clicking the Menu button in tabs section, I have to provide something that can be functional like NavigationDrawer (let’s call it ND) but without menu that should be defined in case of ND. On it I will have to have implemented some search of current games and maybe to call activities(or fragments?) of chosen betting games. As you can see on screen 3, status bar would be under this activity and it wouldn’t content toolbar. How would you implement these screens?
Mark M.
personally, I'd drop the contract and move on to another gig
Chandra S.
has entered the room
Mark M.
that being said, DrawerLayout does not imply any sort of specific content for the drawer, so that should still be usable for the drawer part
however, AFAIK, unless they are building their own custom ROM, you can't float stuff over the status bar
(BTW, hello, Chandra -- I will be with you shortly!)
9:05 AM
Chandra S.
OK Mark thanks
Drasko
But when I tried to implement DrawerLayout AS asked for menu resources.
Mark M.
it doesn't when I use it
https://github.com/commonsguy/cw-omnibus/tree/m... has a pair of projects demonstrating DrawerLayout
Drasko
hm... I need to check that out.
Mark M.
the only thing in there about menus is the context menu, standard for all Views
now, the Design Support Library has some nav drawer stuff in it, and that requires menu resources IIRC
Drasko
yes, I used nav drawer from Design Support Library
Mark M.
specifically, NavigationView
NavigationView goes *in* a DrawerLayout
and NavigationView implements a typical menu-style system
since you don't want that, don't use NavigationView; just use DrawerLayout
Drasko
ok, thanks a lot!
Mark M.
let me take questions from the others, and I'll be back with you in a bit
Chandra: your turn! do you have a question?
9:10 AM
Mark M.
Chandra: if you come up with a question, let me know, so I can give you some time, but in the meanwhile, I will take questions from the others
Jonatan: your turn! do you have a question?
Hyrodrik
has entered the room
Jonatan R.
Not right now, thanks
Mark M.
OK
Hyrodrik: hi! everyone else has had a chance to ask a question, so it's your turn -- do you have a question?
Hyrodrik
Hi everyone
Mark M.
Hyrodrik: do you have a question?
Hyrodrik
Thanks Mr Mark. Yes I have : with your book I was able to make an app which has a navigation drawer and fragment
Drasko
May I ask a question?
sorry, didn't see .. Had a lag
Mark M.
(Drasko: I'll be back with you in a bit, after Hyrodrik)
Hyrodrik
The users of the app will enter their username and password
I have already build the database on a hosting server
9:15 AM
Hyrodrik
But I have trouble connecting the database and my app
I test the connection on a local server and it works
Chandra S.
has left the room
Hyrodrik
For that I use some php code
Mark M.
Hyrodrik: I am sorry, but I have no means of helping you with this
do you have a *specific* question?
9:20 AM
Mark M.
Hyrodrik: let me take questions from the others, and I will come back to you in a bit, and perhaps we can get to your specific concern
Drasko: your turn! do you have a question?
Drasko
Have you tried Realm database and if you have, would you use it in your future development?
Mark M.
I have seen a presentation on Realm but have not used it personally
Hyrodrik
For now no
Mark M.
it's somewhat intriguing, though I'd go with other NoSQL alternatives over Realm (notably, Couchbase)
Drasko
Did you tried it yet?
I mean Couchbase.
Hyrodrik
I will give it a try
Mark M.
it meaning Couchbase? I played with the original Couchbase Lite (the one that used SQLite as a backing store), but I have not had a chance to circle back and try the revamped engine
Drasko
OK. :) I am just curious about these NoSQL technologies on mobile devices.
Mark M.
my rationale for Couchbase over Realm is partially the longer track record and partially its ability to handle synchronization with a server
Realm, AFAIK, is purely a local store; you're on your own for synchronization with a server, just as you would be with SQLite
9:25 AM
Mark M.
neither offers an encryption option AFAIK, so neither is high on my list at the moment
Drasko
They pushed encryption recently.
Mark M.
OK, at this point, until somebody else joins the chat, it's an open session -- if anyone has a specific question, go ahead and ask!
Drasko: which one is "they"?
Drasko
Realm. Sorry. :)
Mark M.
ah, that's right -- the Realm issue was licensing
Drasko
Isn't it free to use on commercial projects?
Mark M.
yes, it is, but it contains binary blobs; it is not pure open source
leastways, that's how I interpret https://github.com/realm/realm-java#license and the linked-to clause
9:30 AM
Hyrodrik
Sorry my phone crashed
Mark M.
Hyrodrik: that doesn't sound good
Drasko
another question. when I tried to use that very handy feature, called setError(String error) on TextView and of course EditText, I have a problem
Mark M.
Hyrodrik: anyway, right now, it is an open session -- if anyone has a specific question, go ahead and ask
Drasko
WHen EditText got his focus, the error message change its position above and doesn't point to that little exclamation mark.
Hyrodrik
Ok
Drasko
Do you know how can I solve that?
Mark M.
not off the top of my head, sorry
Drasko
error message position is wrong
Mark M.
I have avoided setError() entirely, as I don't trust device manufacturers not to screw it up
9:35 AM
Mark M.
device manufacturers have a long track record of messing around with the behavior of EditText
Drasko
So, what is your favourite UX you use to show validation errors?
Especially for EditText.
Mark M.
the same basic UX, but I'll roll it myself
Hyrodrik
I was also asking to build a "chat session" inside the app, so every user can exchange with each other. I really don't know where to start. What do you suggest me
Drasko
I didn't understand you, what do you mean by that? You create the same UX like setError() was supposed to do?
Mark M.
Drasko: more or less -- the exclamation point is just a drawable associated with the EditText
Hyrodrik: that is a rather broad question, one that is not really suitable for chats, Stack Overflow, etc.
9:40 AM
Mark M.
you'll need to settle on a chat server implementation, whether it's something you're rolling your own or using something off-the-shelf (e.g., XMPP server)
that in turn will drive your protocol that you will have to implement on the client
Hyrodrik
Stack overflow? I don't know it but I will search. Your book is my only reference for Android development
Mark M.
then, and only then, are you in position to worry about UI (though I recall some libraries on the Android Arsenal that might help with a chat-style bubble UI()
95% of your problem has little to do with Android
and so you won't see anything in my book related to it
Hyrodrik
Ok ok I understand
For the navigation drawer, it is possible possible to configure it, so that if the user is left or right handed, the gravity of the drawer will change according to the user choice
Mark M.
Android itself does not know whether the user is right- or left-handed
Hyrodrik
The user will click a button to tell if he is left or right handed
Mark M.
however, if you get that information yourself from the user, you should be able to change the gravity at runtime
9:45 AM
Mark M.
you would have to retrieve the LayoutParams for the content of the nav drawer (e.g., the ListView, the RecyclerView, the NavigationView) and adjust its gravity
then call setLayoutParams() on that same content to have it take into account the revised gravity
that being said, it's entirely possible that the DrawerLayout developers did not take a dynamic gravity change into account
Hyrodrik
Ok ok
Mark M.
if that turns out to be the case, you could always have two layouts, one each for right- and left-handed users, and load the proper layout as needed
that makes the point of the initial switch from right- to left-handed a pain, but in the future it's just an if statement when calling setContentView() for the activity
Hyrodrik
Great
I will work on that
Mark M.
Drasko: if you are using appcompat-v7, you might look at TextInputLayout and see if its error-message handling behaves better for you
Drasko
yes, you are right. only downright is that it occupies a lot of vertical space, but it sounds good.
just remembered, I have one question.
9:50 AM
Mark M.
Drasko: go ahead
Hyrodrik
I have another question
Drasko
I have a form on activity which on smaller devices is bigger than the screen. So, I used NestedScrollView and inside of it LinearLayout, and everything is great for smaller screens, but it is scrollable on bigger screens. How can I set it to be scrollable on smaller screens, but be *static*(can't find poper word) otherwise?
Mark M.
Hyrodrik: go ahead
Drasko: is there a reason you needed NestedScrollView, instead of ScrollView?
I haven't played with NestedScrollView; IMHO having scrollable things inside of other scrollable things is a UX problem in its own right
with ScrollView, if there is enough room for its entire content, there is no scrolling
perhaps NestedScrollView behaves differently
9:55 AM
Drasko
Ok, thanks. I'll try ScrollView instead.
Mark M.
Hyrodrik: we only have a couple of minutes left, so if you have another question, go ahead
Hyrodrik
The users can be notified on their phone through SMS (Short Message Service). It means if an info was leaked out, this info will be sent to them via their respective carrier.
Mark M.
Hyrodrik: that is not really a question
Hyrodrik
We are already teaming with one carrier to test it out, but I don't know how to implement this email
10:00 AM
Mark M.
I am sorry, but I do not know what "email" you are referring to
your first chat item refers to SMS
you can send SMS with SmsManager
Hyrodrik
Sorry # email# is an error
Mark M.
and in this case, I would imagine that the user should be getting the SMS in their regular SMS client
so there should be nothing for you to do on the receiving side
and we are out of time for today's chat
the transcript of this chat will be posted to https://commonsware.com/office-hours/ shortly
Drasko
Good bye and thanks!
Mark M.
the next chat is not until 28 December, at 9am US Eastern
have a pleasant day!
Hyrodrik
In fact the user will post an info in the app, the the app send it to the webserver and then the server will send it via sms
Jonatan R.
has left the room
Drasko
has left the room
Hyrodrik
has left the room
Mark M.
turned off guest access

Yesterday, December 16

 

Office Hours

People in this transcript

  • Chandra Siahaan
  • Drasko
  • Hyrodrik
  • Jonatan Ro
  • Mark Murphy