Jun 25 | 3:55 PM |
Mark M. | has entered the room |
Jun 25 | 3:55 PM |
Mark M. | turned on guest access |
Shay | has entered the room |
Mark M. |
hello, Shay!
|
Mark M. |
how can I help you today?
|
Shay |
Hi Mark, Good afternoon (I think)
|
Mark M. |
(though I must say
|
Mark M. |
rhyming is not normally my way)
|
Shay |
hehe
|
Jun 25 | 4:00 PM |
Shay |
So, I haven't yet read everything about Navigation component, but I'm trying to understand something more related to the concept
|
Shay |
I have been away from Android dev for quite some time now, and I remember doing some Fragment transactions and stuff like that (ViewPage et al)
|
Mark M. |
those are still there if you want them
|
Shay |
From my understanding, Navigation architecture component is not to be used for a whole app, right? For example, if some Activities have different theme styles, is is possible to still use them with one navigation?
|
Mark M. |
themes should not impact the Navigation component
|
Mark M. |
it does not care what your themes are for any given activity
|
Shay |
I see. So, If I have a navigation component, I should separate it from activities that, for example are using a theme with no ActionBar?
|
Mark M. |
the Navigation component may not handle all patterns (e.g., your aforementioned ViewPager), but if your UI fits within its supported patterns, you could use it for the whole app
|
Mark M. |
the Navigation component itself won't care about that theme, but your integration code with the Navigation component will
|
Mark M. |
just skip trying to tie Navigation into the action bar on that activity
|
Jun 25 | 4:05 PM |
Shay |
In my case it's a splash screen. I thought of using one Navigation for splash screen and login screen, and then set destination to the "Main" activity if user is logged in
|
Jun 25 | 4:05 PM |
Shay |
Does that sound plausible?
|
Mark M. |
IIRC, that is the recommended pattern: have a dedicated nav graph for that sort of onboarding, which then leads to a nav graph for the "main" section of the app
|
Mark M. |
however, if you wanted to skip Navigation for the onboarding and only jump into it when you started the main activity, that is reasonable
|
Shay |
Nice, that's what I thought
|
Shay |
Right, skipping navigation for first activity sounds good too
|
Shay |
One other thing I was wondering, do fragments inside navigation are saved in memory or created anew every time you go to a "destination"? Do you have an idea about it?
|
Mark M. |
IIRC, they are created anew
|
Shay |
hmm
|
Mark M. |
they definitely are not just hidden and shown again, and I do not think they are detached and later re-attached
|
Shay |
Well, that could be a problem
|
Shay |
It sounds a bit silly to do that
|
Mark M. |
from a memory management standpoint, their approach makes sense
|
Mark M. |
from a CPU usage standpoint, less so
|
Jun 25 | 4:10 PM |
Shay |
It's like if you use Whatsapp and every time you go back to a chat the whole screen is reloaded
|
Shay |
It also sounds like bad UX
|
Mark M. |
it might be reloaded, for all we know -- if the chat data is already in memory, you are not necessarily going to know if they are a new set of views or not
|
Mark M. |
part of the Navigation component is an assumption that you're doing other things in terms of app architecture: ViewModel, repository pattern, etc.
|
Mark M. |
so that the fragment is only a manager of views
|
Shay |
ah I see
|
Shay |
so basically letting the ViewModel/LiveData handle in-memory "remembering" stuff
|
Shay |
I am probably not using correct terminology...
|
Mark M. |
that, plus perhaps caching at the repository level, if appropriate and practical
|
Mark M. |
for the level of a chat, that was fine :-)
|
Shay |
Well, it HAS been around two years since I've worked with Android, so I might forgive myself
|
Mark M. |
yeah, and those were two kinda busy years, in terms of how Android apps get developed
|
Shay |
Yes, this is why I asked general questions only. I like knowing more than being fed how to do every samll step
|
Jun 25 | 4:15 PM |
Shay |
I also need to read the Jetpack book thouroughly
|
Mark M. |
there will be portions of that you can skim through, as it is a replacement for the core chapters of *The Busy Coder's Guide to Android Development*
|
Mark M. |
other portions, such as the Navigation component, are likely to be new to you
|
Shay |
Yes, exactly. I was happy when I saw Navigation, as it reminded me of iOS/macOS storyboard
|
Jun 25 | 4:35 PM |
Mark M. |
BTW, if you have another question, go right ahead
|
Shay |
Well, to be honest, if I ask now it would be more like teaching instead of giving the right direction
|
Shay |
I would ask more about Navigation, but as I said, I am no well versed enough in the new way
|
Mark M. |
um, OK
|
Mark M. |
no problem
|
Shay |
Something else though, small thing. I am trying to create a theme for the ActionBar
|
Shay |
Everything is working, besides giving the text a different colour than the default white
|
Jun 25 | 4:40 PM |
Shay |
(i.e. I have my gradient background and stuff)
|
Jun 25 | 4:40 PM |
Shay |
I have a theme for the App, referencing a theme for TextAppearance, but android:textColor is not working for some reason
|
Mark M. |
first, are you using AppCompatActivity or something else?
|
Shay |
Yes, AppCompat, based on androidx.appCompat
|
Mark M. |
OK, and you are using the default action bar, not a Toolbar that you constructed?
|
Shay |
The default, but it has a custom actionBarStyle
|
Mark M. |
and, in there, are you setting titleTextStyle and android:titleTextStyle?
|
Shay |
no, I set that inside the AppTheme
|
Shay |
I should explain myself better
|
Shay |
At the moment, I am talking about the OverFlowMenu text color
|
Shay |
sorry for misleading you
|
Mark M. |
oh, sorry, I thought you meant the title
|
Shay |
No, it was my bad :)
|
Jun 25 | 4:45 PM |
Mark M. |
try actionMenuTextColor and android:actionMenuTextColor
|
Shay |
will do. I did put the code here: https://paste.ubuntu.com/p/WTScYQTvXb/
|
Shay |
It'll probably be more clear like this
|
Shay |
"actionMenuTextColor and android:actionMenuTextColor" this didn't do the trick unfortunately
|
Mark M. |
parent="android:style/TextAppearance.Holo.Widget.ActionBar.Title" worries me, as I doubt that you want a reference to Holo there
|
Mark M. |
and, to be clear, you are saying that this theme is not working either?
|
Shay |
Yes, the theme is not working
|
Mark M. |
OK, then, off the top of my head (and with a bit of light searching), I don't have an answer for you, sorry
|
Mark M. |
other than my Holo note, which probably is not the source of your difficulty
|
Mark M. |
frankly, all of this is just a mess at this point
|
Jun 25 | 4:50 PM |
Mark M. |
(not your code, referring to styling the action bar)
|
Shay |
That's fine. I have combed stackoverflow, and it seems I am using the "right" solution :)
|
Mark M. |
you might consider using a Toolbar
|
Shay |
Yes, I will consider a Toolbar.
|
Shay |
And the Actionbar styling is a mess indeed
|
Shay |
Tbh, it seems as if all of android styling is a mess
|
Mark M. |
yes
|
Mark M. |
and, in two years, Jetpack Compose is going to replace all of this, and we will have new and exciting under-documented stuff to work with
|
Shay |
so true
|
Shay |
Only reason I don't do iOS dev is the need to buy an iPhone, and the pesky yearly 99$
|
Mark M. |
if you have an international market, Android is a wee bit larger -- in the US, I think it's close to a 50/50 split with iOS
|
Shay |
I think going into the international market is always better. For example, my country is small, so local market makes no sense
|
Shay |
but the price of getting "inside" for android is much cheaper
|
Shay |
and with iOS, some things like camera, you Must have a real device
|
Jun 25 | 4:55 PM |
Mark M. |
well, I wouldn't trust the Android emulator for camera stuff either -- *way* too many hardware-specific issues
|
Mark M. |
which is why it will be interesting to see how Google's CameraX fares
|
Shay |
I won't trust it either tbh, but an Android device cost much less than an iPhone, even an old one (and an old iPhone will not support the user-wanted features, in any case)
|
Mark M. |
agreed, though at least with iPhone, there are only so many models you need to worry about
|
Mark M. |
I wrote two CameraX-ish equivalents, and gave up on both, after concluding I wasn't sure if I would run out of device budget or patience first
|
Jun 25 | 5:00 PM |
Shay |
sounds right
|
Mark M. |
and, that's a wrap for today's chat
|
Mark M. |
the transcript will go up on https://commonsware.com/office-hours/ shortly
|
Shay |
Nice
|
Mark M. |
the next chat is Thursday at 9am US Eastern
|
Mark M. |
have a pleasant evening!
|
Shay |
Hope you'll have a great evening, I am going to sleep (12AM here :) )
|
Shay | has left the room |
Mark M. | turned off guest access |