Office Hours — Today, June 6

Thursday, June 4

Jun 6
3:55 PM
Mark M.
has entered the room
Mark M.
turned on guest access
Kai H.
has entered the room
Kai H.
Hi there
4:00 PM
Mark M.
hello, Kai!
how can I help you today?
Kai H.
I actually have no question that I could ask :D
The only one I would have had requires some mock up of a UI, which I didn't prepare
So I guess I'm just lurking for now
Mark M.
OK. Statistically, its not too likely anyone else will show up, but you're welcome to hang out. If you think of a question, chime in!
Tad F.
has entered the room
Tad F.
Hi Mark!
Kai H.
Tadaa!
Hi Tad
Mark M.
hi, Tad!
Tad F.
Hey - are you two in the middle of a conversation or can I ask a question?
Mark M.
nope, Kai is lurking at the moment, so go right ahead!
Kai H.
Go ahead
Tad F.
OK - so I have kind of a "best practices" question when it comes to starting to ready for beta testing a new app.
My app has a db that needs to come "preloaded" with data, and other "sample" type assets.
It will live at runtime in getFilesDir()
So is it common practice during development to place this in the assets folder, then on first install have the app move it over?
Mark M.
that's the typical approach for a pre-loaded database, yes -- Room has built-in support for this, or else I would use SQLiteAssetHelper
Tad F.
OK - you may remember I'm currently standardized on Realm.
But its a single file, easy enough to move it over
4:05 PM
Tad F.
This "sample" db also references a bunch of media that I'm shipping as part of the onboarding process.
Same deal - have them in assets, and move them over?
Mark M.
do you need those on the filesystem? or could you just use them as assets?
I'm assuming the database needs to be modified, but media often is not
Tad F.
Well, that's a good question
This app allows users to construct 'playlists' of audio, video and image media.
The playlists and info about the media live in the db
What I've done for my onboarding, is create playlists of the media I'm shipping.
So I could populate the playlist with entries that point to assets
but each media object uses a uri path to reference where the media actually is
So I guess I can use a file:///asset.... uri for these?
Mark M.
yes, though the details will depend on how you are using the media
Tad F.
go on...
Mark M.
technically, file:///android_asset/ is a WebView thing
Tad F.
Well, I've prototyped this, and it seems to work ok.
Mark M.
some libraries might support it as well
Jan
has entered the room
Tad F.
I didn't see anything about this being deprecated - the standard routine I use is to Uri.parse(<string>), and then hand it off to Glide or Exoplayer2
Mark M.
so if it is working for you, then you should be fine -- I wasn't sure if you had tried it yet
Jan
Hi, all
Mark M.
(hi, Jan -- I will be with you shortly!)
Tad F.
They seem to work with the file:/// approach without an issue.
Mark M.
they must have dedicated support for that, and at least for Glide, I am not surprised
Tad F.
But it would be good to know if I'm setting myself up for some failure down the road without realizing it.
Kai H.
has left the room
Kai H.
has entered the room
Tad F.
ok - btw, you remember we were talking about the limit on how many permissions you can "take"?
4:10 PM
Tad F.
There is a hard-coded 128 limit.
I filed a bug for that about 5 months ago, but no movement.
Kind of a drag.
128 gets chewed up really fast.
Mark M.
oh, this is Uri permissions?
Tad F.
y
When someone chooses a media item to put in their playlist, I need to take permission so I can play it later
Mark M.
I forget our discussion, but I remember seeing a ticket about that
I doubt that will change too soon, and even if it does, it would only be for future versions of Android
Tad F.
Well, if you could "goose' them to look at it I'd really appreciate it...
Yeah, ok
Mark M.
yeah, I can't get them to look at my own tickets too much
but this may be a good blog topic
Tad F.
It makes me wonder how other apps like "My Files" that show you tons of files in the file system if they can't persist permissions to see them
I guess they are looking them up each time you run that app...
Mark M.
they only need permission to the tree root
permission on a tree grants you rights to the content in that tree
let me take a question from Jan, and I'll come back to you in a bit
Tad F.
Sure!
Mark M.
Jan: hi! how can I help you today!
Jan
View paste
Hi, Mark.
I am getting ready to take my android app to apple ios.
What can you tell me about using Kotlin native versus dropping all
the kotlin and using swift?
Mark M.
well, Kotlin/Multiplatform is an up-and-coming option, but it's a bit rough around the edges, particularly in some of the Kotlin/Native bits
people are using it for production stuff, but there is only so much knowledge out there in the community
Tad F.
Mark - do you think Kotlin native spells the end of Flutter?
4:15 PM
Mark M.
(Tad: probably not, insofar as Flutter has reasonable momentum)
Tad F.
That was a good question Jan, I'm in the same boat.
Jan
Thanks. I don't want to be a trail blazer. lol
Tad F.
I've been trying to decide whether to go native iOS or port to Flutter though.
I'm in Java right now.
Mark M.
Jan: you might not be strictly "blazing the trail", but there would be a fair bit of undergrowth to hack through
a separate Swift app will be more code in the end, but a simpler path to writing that code
and, eventually, Kotlin/Multiplatform should be comparably straightforward
for a solo project, then, unless Kotlin/Multiplatform is something you want to learn (e.g., for career reasons), my guess is that a full-up Swift port is the better choice
Jan
Thanks. I'll do the Swift.
Mark M.
but, bear in mind that I am not an iOS developer, so my knowledge of that side of matters is modest
Tad F.
Mark - how difficult would you assess learning Swift to get to a professional level if one is already a fairly advanced professional at Java?
weeks?
months?
Mark M.
the Swift language itself is comparable to Kotlin and shouldn't be too hard to learn
4:20 PM
Mark M.
but learning *iOS* is much more than just the language, just as learning Android is more than learning Java or Kotlin
Tad F.
Exactly
Mark M.
I have done extremely little iOS development, so I'm not in position to make estimates regarding picking up iOS
Jan
Learning Kotlin was easy compared to learning Android's OS and Framework.
Tad F.
I'm sure there is a lot of comparable functionality that is handled completely differently.
I'm just curious how different "the Android way" is from "the iOS way"
Kai H.
I have started full time Android development 10 months ago and I am struggling ;-)
It IS a lot to learn, it seems.
Tad F.
Did you read Mark's guide to busy coders? ;)
Kai H.
I am reading "Exploring Jetpack" and have had a look in several other books. But no, I haven't read the 4000 pages of busy coders X)
Jan
Tad, O'Reilly has a book showing both android vs ios code but reviews make it sound like it's already out of date.
Tad F.
Mark's stuff is an amazing reference set.
Mark M.
thanks!
Tad F.
If you want a 'build a project one step at a time', check out Big Nerd Ranch.
Mark M.
I can't speak for the iOS side, but IMHO, in Android, I view the half-life of books and other materials as being about 18 months
Kai H.
I agree. But there is only so much I can get into my mind, and I need to practice too, not only read about it.
Mark M.
so, a 3-year-old book is only about 25% as useful as it was when it first came out, given changes in the ecosystem
Kai H.
Otherwise I would have read Busy Coders already ;-)
That's the beauty of legacy apps: You can use old books no problem :D
4:25 PM
Tad F.
I started with the Ranch, and worked through the entire book - about 4-6 projects I think that show off different aspects of Android and the various frameworks. Then our local Android meet-up did a spotlight on Mark's stuff, and that is really, really helpful.
Kai H.
I wish I knew about it when I started 10 months ago. But better late than never.
Jan
I could have sworn I found Mark's stuff on the recommended list from google but when I went to share with a friend, I couldn't find it. So now I don't even know how I found it.
Kai H.
I would like to ask a question.
Mark M.
yeah, my normal round-robin got somewhat dizzy there
Kai: go ahead!
Kai H.
This is a mockup of a list item I am implementing. And I wondered how you would do it.
The green dot and the date can be invisible
And the three icons on the right should be aligned with "Some title"
Mark M.
that seems fairly straightforward with a ConstraintLayout
Kai H.
The three dots are "get into details of the item"-buttons.
I used three barriers for it.
4:30 PM
Mark M.
I can see perhaps one barrier, depending a bit on how you want that last line to get rendered
Kai H.
And had to put the barrier for the icon alignment at the bottom of "some title". When putting it on top it would push the whole lot downwards.
Mark M.
OK, you lost me there -- give me a minute to write up some notes
View paste
square: constrained top/start to parent
green dot: constrained to square on start and to "Some title" on top+bottom
"Some title": constrained top and start/end between green dot + triangle
three dots: constrained top/bottom/end to parent
star: constrained end to three dots and to "Some title" on top+bottom
speech bubble: constrained end to star and to "Some title" on top+bottom
triangle: constrained end to speech bubble and to "Some title" on top+bottom
a subtitle: constrained to square on start and to "Some title" on top
date: constrained to square on start and to "a subtitle" on top
more information: constrained to date on start and baseline
I'd start there, though I am certain there would be some refinements
4:35 PM
Mark M.
for example, I don't know what happens if more information is much longer than it is in the mockup and what the rules are if it is
and I don't have the column of text anchored on the bottom as a result
the problem with a static mockup like that is there can be lots of subtleties that aren't apparent and would require discussion with a designer
but, in general, a single ConstraintLayout should handle that well, with the right set of constraints
Kai H.
Constraining something to top and bottom of something else makes it align horizontally?
Mark M.
no, it would center it vertically
Kai H.
relative to the other thing?
Mark M.
(depending on which is larger)
yes
Kai H.
I think center vertically is what I meant by align horizontally.
Mark M.
um, I'll take your word for that :-)
(and assuming the height is wrap_content -- if it is 0dp, constraining top+bottom stretches to fill that space)
Kai H.
I guess the equidistance of the three lines of text to the icon is given by the icon margin?
Mark M.
yes, I assumed a simple end margin there
Kai H.
(which I what I used one of my barriers for: Aligning the lines to the icon)
Mark M.
(assuming the icon is the square on the start side)
Kai H.
The total height of the item is supposed to be the combined height of the text fields.
Yes, it's the square
Mark M.
in that case, probably the "more information" gets constrained to the bottom of the parent
4:40 PM
Mark M.
date would have its vertical position constrained to the "more information" baseline
Kai H.
Did you assume that the item has a fixed height?
Mark M.
no
Kai H.
So what would determine the height in your example?
Mark M.
it should be the taller of the column of text or the three dots
Kai H.
fair enough
Mark M.
let me tweak those notes...
View paste
square: constrained top/start to parent
green dot: constrained to square on start and to "Some title" on top+bottom
"Some title": constrained top and start/end between green dot + triangle
three dots: constrained top/bottom/end to parent
star: constrained end to three dots and to "Some title" on top+bottom
speech bubble: constrained end to star and to "Some title" on top+bottom
triangle: constrained end to speech bubble and to "Some title" on top+bottom
a subtitle: constrained to square on start and to "Some title" on top
date: constrained to square on start and to "more information" baseline
more information: constrained to date on start, "a subtitle" on top, and parent on bottom
and, let me take questions from the others, and I'll try to get back to you in a bit
Tad: back to you! do you have another question?
Kai H.
I guess using the three dots as a height giving element is good in case one of the lines will go invisible or gone.
ok
Mark M.
Tad: if you have another question, go ahead! Also, is this the ticket you filed on the Uri permission count? https://issuetracker.google.com/issues/149315521
4:45 PM
Mark M.
Tad: if you come back to the chat, and you have another question, chime in!
meanwhile... Jan: back to you! do you have another question?
OK, Tad and Jan, if you swing back to the chat later, and have questions, let me know!
until then... Kai: it's back to you!
Kai H.
Weee
I actually have no questions as of now, I think.
I'll have to play around with your suggestion
Just wondering if I should really use "the buttons" as the height giving element
Mark M.
what are "the buttons"? the triangle/speech bubble/star?
Kai H.
Oh wait, we have figured that out alreay. Taller one of: lines of text/three dots.
Mark M.
right
Kai H.
sry, "buttons" == "three dots".
4:50 PM
Tad F.
has left the room
Jan
has left the room
Kai H.
Huh. Strange that they left at the same time.
Mark M.
yeah, that was a little odd -- I'm assuming a coincidence
you will need to work out what to do when "Some more information" is longer than what you are showing
Kai H.
ellipsized :D
Mark M.
ah, well, that's simple enough
if you needed it to wrap, and have the start end of the second line be under the date, then you would need the date and the "Some more information" to be a single TextView, using spans for formatting
Kai H.
I hope your solution works. I don't like barriers too much, I think they make it harder to understand what is happening.
And they kinda break the mapping of XML to visible element in the gui editor.
Mark M.
barriers are great when they are needed, but I don't think that you need them here
4:55 PM
Kai H.
Ok
Now I learn ConstraintLayout, just for it to be replaced by Compose soon ;-)
The circle of programming
And RxJava to eventually use Coroutines
Mark M.
Compose has its own ConstraintLayout, based on the original
Kai H.
And Java to eventually use Kotlin
Oh ok. Good to know
Mark M.
roughly speaking, using ConstraintLayout in Compose is a bit like using ConstraintSet to configure a ConstraintLayout dynamically in Java/Kotlin
just with a bit more of a DSL syntax, IIRC
Kai H.
So much to learn :)
5:00 PM
Mark M.
anyway, that's a wrap for today's chat
Kai H.
Have a good weekend.
Mark M.
next one is Tuesday in the 7:30pm US Eastern time slot
you too!
Kai H.
has left the room
Mark M.
turned off guest access

Thursday, June 4

 

Office Hours

People in this transcript

  • Jan
  • Kai Hatje
  • Mark Murphy
  • Tad Frysinger

Files in this transcript