Jul 9 | 8:25 AM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Kai H. | has entered the room |
Mark M. |
hello, Kai!
|
Mark M. |
how can I help you today?
|
Kai H. |
Hi there
|
Kai H. |
Do you happen to know how to "globally" change the Font/Typeface of DialogFragments?
|
Mark M. |
have them use a theme that changes the font/typeface
|
Kai H. |
How would I do that?
|
Mark M. |
call setStyle() on the DialogFragment, passing the theme resource ID as a parameter
|
Mark M. |
do that in onCreate(), before you're asked to inflate any layouts
|
Jul 9 | 8:30 AM |
Mark M. |
alternatively, don't worry about at the level of the DialogFragment, but instead deal with it at the level of the individual widgets, pointing them to an appropriate textAppearance or style
|
Kai H. |
You mean like a TextView?
|
Mark M. |
yes (or Button or other things that extend from it)
|
Kai H. |
TextViews in general pick up the font and color I have set in my theme. It's Dialogs that give me a hard time.
|
Mark M. |
well, a dialog does not have a font, as a dialog does not have text -- widgets inside the dialog have fonts and text
|
Kai H. |
Some pieces of DialogFragment seems to not pick up those changes.
|
Kai H. |
As far as I can see those Widgets inside the Dialog don't pick up what they should.
|
Kai H. |
But tbh I am quite confused about themes and styling. It seems to be quite the pile
|
Mark M. |
it is a mess
|
Kai H. |
of things one needs to know in Order to do it properly
|
Jul 9 | 8:35 AM |
Mark M. |
warning: it looks like 37 Signals is having Campfire problems: https://www.basecampstatus.com/
|
Mark M. |
so, we may have some chat interruptions, since this is a Campfire chat room
|
Mark M. |
getting back to your problem, push comes to shove, control it at the individual widget level
|
Kai H. |
Like setting a custom font and fontcolor for all TextViews? And that will be picked up by a DialogFragment?
|
Kai H. |
Or rather the TextViews inside it.
|
Mark M. |
yes, either by android:textAppearance or style attributes on the <TextView> element
|
Jul 9 | 8:40 AM |
Mark M. | |
Mohd A. | has entered the room |
Mohd A. |
Hi.
|
Kai H. |
Hello
|
Mark M. |
Kai: let me take a question from Mohd, and I will come back to you in a bit
|
Mark M. |
Mohd: hi! how can I help you today?
|
Mohd A. |
Yeah Mark, I need some projects or libraries suggestion to showcase on Github.
|
Mark M. |
um, I don't know if I can really help with that -- create something that you think that you will use enough to be willing to maintain over time, I guess
|
Mohd A. |
Okay..No issues.
|
Jul 9 | 8:45 AM |
Mark M. |
if this is to try to impress recruiters, I can tell you that I am looking more at general programming techniques and the overall presentation of the project, rather than what problem the project is trying to solve
|
Mark M. |
so, for example, a well-done README is well worth the time to write, as it is the first thing that a reviewer will see
|
Mark M. |
and it shows your communication skills, in ways that pure code cannot
|
Mark M. |
but, in terms of what the project should do... ¯\_(ツ)_/¯
|
Mohd A. |
Good suggestion. Thanks.
|
Mark M. |
let me take another question from Kai, and I will switch back to you shortly
|
Mark M. |
Kai: back to you! do you have another question?
|
Kai H. |
Not right now. I am just baffled at the complexity of something as seeminly simple as "change the font and font color for the whole app"
|
Jul 9 | 8:50 AM |
marekdef | has entered the room |
Mark M. |
well, bear in mind that fonts were not a first-class resource until Android 8.0
|
Mark M. |
prior to that, we were using libraries like Calligraphy
|
Kai H. |
And trying to understand why a particular Dialog in our App doesn't pick up the font in the "Title" (if it is the real title, that is).
|
Mark M. |
if you are using onCreateDialog() and AlertDialog.Builder, you are probably picking up a system theme
|
Mark M. |
(BTW, hello marekdef -- I will be with you shortly!)
|
Kai H. |
It is the "alertTitle" apparently.
|
Kai H. |
A system theme that is not the Theme I have set, you mean?
|
Kai H. |
It does pick up my color though.
|
Mark M. |
yes, I mean Theme.Material
|
Mark M. |
(or some variation on that)
|
Mark M. |
but, like you said, it's a mess, and on my client projects, we typically just hammer on things until they behave
|
Kai H. |
I run out of places to hammer on ;-)
|
Mark M. |
(and on my own projects, I just don't change the font, because life's too short)
|
Kai H. |
Or rather ideas on how to hammer and where to hammer.
|
Kai H. |
But I'll try the ones you suggested.
|
Mark M. |
if it is your widget: use textAppearance or style
|
Mark M. |
if it is not your widget: that's likely to be a problem
|
Kai H. |
I think it's the "built in" Dialog-thing.
|
Kai H. |
Even though I could probably replace it. If I understand how our Dialog classes are made up. There is like 15 of them, with 3 base classes.
|
Jul 9 | 8:55 AM |
Mark M. |
if you want complete control over the look, do not use AlertDialog.Builder and onCreateDialog() -- use onCreateView() and inflate your own layout that you control
|
Mark M. |
let me take questions from the others, and I will come back to you in a while
|
Mark M. |
marekdef: hi! how can I help you today?
|
marekdef |
Hi!
|
marekdef |
let's say we have some product catalogue with pictures
|
marekdef |
in the designs some have dp(s)
|
marekdef |
some are full screen width
|
marekdef |
and now there is idea to conserve space to request images according to device density and resoltion
|
marekdef |
so if the device is small it will request for smaller picture
|
Mark M. |
by "request images", do you mean downloading them from a Web service or other online source?
|
marekdef |
yes they are dynamic
|
marekdef |
some url(s)
|
marekdef |
probably fetched with glide
|
marekdef |
I just wonder if it really makes sense
|
Mark M. |
I can tell you that I have not done much of that sort of thing
|
marekdef |
assuming we care about offline first
|
marekdef |
and we fetch those only once
|
Mark M. |
I have used different requests for different image sizes, but that was for cases where there were clearly different roles (thumbnail versus full size)
|
Jul 9 | 9:00 AM |
Mohd A. | has left the room |
marekdef |
I tend to think that downloading biggest image
|
marekdef |
and scaling it down for the views would really be no different
|
Mark M. |
the difference would be in bandwidth and storage, mostly
|
marekdef |
but there is another argument that scaling images drains the battery
|
marekdef |
but I think that code to download images would become more complex
|
Mark M. |
while scaling images may consume more CPU time, that's really not a thing that I would worry about
|
Mark M. |
by which, I mean that there are lots of other things that I would worry about first from a battery consumption standpoint
|
marekdef |
allright
|
Mark M. |
and, depending on your use case, you might elect to only scale once (and persist the scaled image), rather than scale on each read
|
Mark M. |
so, for a thumbnail-versus-full-size situation, having separate URLs for that is reasonable, as the resolution difference may be massive, and you may want better server-side scaling algorithms
|
Mark M. |
but for smaller differences in size, I agree that it seems unlikely to be worth the engineering effort
|
Jul 9 | 9:05 AM |
Mark M. |
however, your server team may have other arguments, such as server bandwidth
|
marekdef |
well in fact this is server team initiative
|
marekdef |
but as I said, once downloaded I hope glide is aware of cache headers on the server
|
marekdef |
and will not download images twice
|
Mark M. |
I am uncertain whether Glide does that or it relies on the underlying HTTP client (such as OkHttp)
|
marekdef |
yes, maybe there
|
Mark M. |
but, one way or another, you should be able to get HTTP caching working, if the server is setting the appropriate headers
|
marekdef |
yes I think they do
|
Mark M. |
let me quick check in with Kai, and I will return to you in a bit
|
Mark M. |
Kai: back to you! do you have another question?
|
Kai H. |
Nah, still trying to figure out my "special case"
|
Jul 9 | 9:10 AM |
Mark M. |
OK, if you come up with another question, let me know so I can come back to you
|
Jul 9 | 9:10 AM |
Mark M. |
in the meantime...
|
Mark M. |
marekdef: back to you!
|
marekdef |
oh :)
|
marekdef |
very random questions then
|
marekdef |
I have custom view
|
marekdef |
it needs two constructors as far I am aware
|
marekdef |
I have private method that initilizes the view
|
marekdef |
called in each constructor
|
marekdef |
I would like to keep it under the constructor so is easy to glimpse there
|
marekdef |
what the method is doing
|
marekdef |
but there are some purist around :)
|
marekdef |
that say "private method must be at the end of the file"!
|
marekdef |
ofc you can browse in studio the private method
|
marekdef |
and hit return ctrl, alt <- (AFAIR) to go back to the constructor
|
marekdef |
but I prefer visible distance
|
marekdef |
I guess that's a question of preferences
|
marekdef |
or believes
|
marekdef |
beliefs
|
Mark M. |
yeah, I can't tell you what coding style to use
|
marekdef |
sure
|
marekdef |
related question, you have attrs, styles, dimens files
|
Jul 9 | 9:15 AM |
marekdef |
for custom view I create custom_view.xml I put all attrs styles dimens related to that custom view
|
marekdef |
but I wonder should I create cust_view_attrs.xml, custom_view_styles.xml ...
|
marekdef |
or put everything in global files
|
Mark M. |
I try to minimize the use of custom views
|
Mark M. |
historically, my client projects that have used them just have attrs.xml for the project, not one per custom view
|
Mark M. |
but, your approach seems reasonable
|
marekdef |
I am getting to the same conclusion, using custom views is very expensive
|
Mark M. |
I just find them to be a pain to maintain
|
marekdef |
like they always behave bit differently than system views
|
marekdef |
and they lack features
|
marekdef |
that you would expect by just looking at them as system views
|
Jul 9 | 9:30 AM |
Mark M. |
OK, that's a wrap for today's chat
|
Mark M. |
next chat is Saturday at 4pm US Eastern
|
marekdef |
thank you
|
Mark M. |
have a pleasant day!
|
Kai H. | has left the room |
marekdef | has left the room |
Mark M. | turned off guest access |