Jun 25 | 8:25 AM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
marekdef | has entered the room |
Mark M. |
hello, markedef!
|
Mark M. |
how can I help you today?
|
marekdef |
Hi Mark
|
marekdef |
on the last chat you mentioned accessibility is important
|
marekdef |
I was wondering how can I test if the app is accessible
|
Mark M. |
turn on Talkback and try using it with your eyes closed :-)
|
Mark M. |
(though I'm not completely joking there...)
|
Mark M. | |
Kai H. | has entered the room |
marekdef |
because if you remember I have my custom keyboard and a custom TextField that displays a price
|
Mark M. |
among other things, Google has an app ("Accessibility Scanner") that can help identify accessibility issues
|
Jun 25 | 8:30 AM |
Mark M. |
(BTW, hello Kai -- I will be with you shortly!)
|
Kai H. |
Hello everythone
|
Mark M. |
marekdef: yes, and I was concerned about accessibility with respect to the custom keyboard
|
marekdef |
I think the keyboard is accessible beceause is built on top of TextFields but my custom price tag is FrameLayout with EditText covered by another FrameLayout
|
marekdef |
just wanted to check if blind person could read the price
|
Leora | has entered the room |
Mark M. |
my guess is they will not
|
Mark M. |
but I have not had to do that sort of thing very recently, so I am not completely certain
|
Mark M. |
(BTW, hello Leora -- I will be with you shortly!)
|
marekdef |
allright will check the scanner app
|
Mark M. |
so, turn on Talkback and see if you get announcements from your EditText
|
Leora |
hi Mark! sure thing
|
Mark M. |
also, set up a Bluetooth keyboard and make sure that you support text input, both in terms of numbers and in terms of arrow keys for navigation
|
Mark M. |
if you can get both of those working, you should be in decent shape
|
Mark M. |
also, I think there are firms out there that help with accessibility testing, if your firm is interested in getting specific professional input on your... ummm... custom specific professional form of input :-)
|
Mark M. |
let me take questions from the others, and I will come back to you a bit later
|
Mark M. |
Kai: you were next, so... how can I help you today?
|
marekdef |
sure
|
Jun 25 | 8:35 AM |
Kai H. |
I was wondering how to implement different layouts for different screens sizes properly, especially given a ListItem with ConstraintLayout
|
Mark M. |
that's a little abstract... in general, you decide at what size you want to switch strategies, and then set up a layout resource directory for that size
|
Kai H. | |
Kai H. |
Given this listitem
|
Kai H. |
I want it to have both the highlight bar and the "action buttons" (dots on the right) in one screen width, only the action buttons in another and neither highlight bar nor action buttions in a third.
|
Mark M. |
you have two choices: handle that with layout resource directories, or handle that in code
|
Mark M. |
with layout resource directories, you would have res/layout/, res/layout-swXXXdp/, and res/layout-swYYYdp/
|
Kai H. |
I did make three variants with w420dp, w420dp-large and layout
|
Mark M. |
I strongly recommend changing w420dp-large to something else, based purely on a dimension
|
Kai H. |
So that is still the proper approach? Just have three layout variants?
|
Mark M. |
that is one possibility
|
Mark M. |
the other is to mark those widgets as having visibility of View.GONE by one means or another
|
Kai H. |
Thing is that I had it that way but for some reason I didn't get the results I was looking for. Also, we have a two-pane view for tablets which still works with -large and I wanted it to adhere to that
|
Jun 25 | 8:40 AM |
Mark M. |
I really don't recommend using -large anymore
|
Mark M. |
that's a 2011 sort of thing
|
Mark M. |
and you are even more at the mercy of device manufacturers than usual if you use it
|
Mark M. |
use w420dp and another wNNNdp, for some other value of NNN
|
Kai H. |
I kinda needed to as I needed the listitem to change at the same time as two-pane would come up, which is coupled to -large atm. When refactoring I could change that.
|
Mark M. |
tactically, if you want to use it, go ahead -- it's just something that would worry me
|
Kai H. |
It worries me too, but at the time being, I kinda had to do it that way.
|
Mark M. |
in general, I can't really help with "I didn't get the results I was looking for", as I don't know enough details
|
Kai H. |
Short of taking the time to find out how the app should look on different devices and refactor large
|
Kai H. |
But I think that answers my question. I wanted to know if I was going in the proper direction.
|
Mark M. |
your revisions are minor enough that I would consider having just one layout and either use integer resources to change visibility of those widgets or change their visibility in code
|
Mark M. |
but, three layouts is certainly reasonable, particularly if you anticipate more substantial changes down the road
|
Mark M. |
let me take questions from the others, and I will return to you in a bit
|
Kai H. |
How readable would that be?
|
Mark M. |
Leora: your turn! how can I help you today?
|
Kai H. |
I haven't thought about integer resources so far, but sounds like an interesting approach.
|
Leora |
Having some trouble converting my code from java to kotlin
|
Jun 25 | 8:45 AM |
Leora |
specifically, I have a lib module and an app module
|
Leora |
interface INav in lib, singleton class Nav that implements INav, and class NavA from app that extends Nav
|
Leora |
I get the correct Nav class when I initialize some stuff using custom Application classes
|
Leora |
In java it worked great! even when i had a function called from the singleton Nav class, it was directed to the overridden function in NavA class. perfect
|
Leora |
in kotlin, I made the singleton class using object Nav
|
Leora |
but the function called from the Nav object calls it's own function, instead of redirecting to the overriden function in NavA
|
Leora |
phew that's it
|
Jun 25 | 8:50 AM |
Mark M. |
I'm surprised that NavA can exist -- I didn't think you could subclass an object
|
Leora |
hahaha
|
Leora |
object NavigationST : INavigation by Navigation{}
|
Leora |
:)
|
Mark M. |
but, isn't Navigation itself an object?
|
Leora |
yup
|
Leora |
i thought that's how i get a singleton class in kotlin...?
|
Mark M. |
yes, but I guess I had not realized it could be used this way
|
Leora |
is my pattern messed up?
|
Mark M. |
you said that it is not working, so ¯\_(ツ)_/¯
|
Leora |
how can i define a navigation base class and override some methods of it depending which app subclasses it?
|
Mark M. |
well, on the whole, I would try to minimize the use of the Kotlin object keyword
|
Mark M. |
ideally, you would be using dependency inversion (Dagger, Koin, etc.)
|
Leora |
i should be using?
|
Mark M. |
personally, I use Koin, as it is very easy to set up -- I use it in quite a few of my books
|
Mark M. |
but, let's skip that for now and say that you still need to use object
|
Leora |
which book? I downloaded all of them
|
Leora |
ok
|
Jun 25 | 8:55 AM |
Mark M. |
my intro to DI is in *Elements of Android Jetpack*, I use it in *Exploring Android* in the back third of the book, and many of samples in the other *Elements* books use it
|
Leora |
ok i'll check it out
|
Mark M. |
anyway, you might consider having your base implementation be a regular class, and use objects for leaves of your hierarchy, rather than trying to use one object as a property delegate for another
|
Mark M. |
it is possible that there is a way to get that to work, but I have never tried it, and it makes my stomach queasy
|
Leora |
interesting...until you said queasy
|
Mark M. |
the "queasy" was with reference to the property delegate approach
|
Leora |
i'm sorry, which is that?
|
Mark M. |
I would see if the library can have the base class implementing the interface, and different modules can create subclasses of that as singleton objects as needed
|
Mark M. |
object NavigationST : INavigation by Navigation{} // by is the keyword to set up a property delegate
|
Leora |
ooooh
|
Jun 25 | 9:00 AM |
Mark M. |
if Navigation is an object, you now have an object whose implementation is backed by another object
|
Leora |
how would the subclass define itself? object NavigationST : Navigation()
|
Leora |
?
|
Mark M. |
(I so wish this chat supported Markdown for backticks-as-code)
|
Mark M. |
let's suppose that in this revised approach, you still have INavigation, and Navigation is a base class, not an object
|
Mark M. |
then yes, object NavigationST : Navigation()
|
Leora |
ok, thanks Mark, I'll try it :)
|
Mark M. |
let me take questions from the others, and I should be able to get back to you before the chat ends
|
Mark M. |
marekdef: back to you! do you have another question?
|
Mark M. |
marekdef: do you have another question?
|
Jun 25 | 9:05 AM |
Mark M. |
marekdef: if you come up with another question, let me know
|
Jun 25 | 9:05 AM |
Mark M. |
in the meantime...
|
Mark M. |
Kai: back to you! do you have another question?
|
Kai H. |
Yes. I want the background of a listitem to look a certain way after it had been clicked. I am quite confused after trying to find out how to do it.
|
Mark M. |
I think the typical approach is to use a StateListDrawable for the background, where you have different background for normal an activated
|
Kai H. |
I tried that with checked, but it never got activated.
|
Mark M. |
checked AFAIK is only really there for CompoundButton
|
Mark M. |
activated as a state exists for all views
|
Mark M. |
and it is not used by the framework itself for anything, so our uses of it will not conflict with something else
|
Mark M. |
so, if you use the activated state, you should have better luck
|
Kai H. |
I didn't know that. We used "pressed" and "activated" at a lot of points
|
Mark M. |
pressed as a state should get triggered while the user is sending touch events to the view
|
Kai H. |
A listitem is "activated" after a long press or a press on the "action button" in our app.
|
Kai H. |
If you would short press it or press the action button again, its state goes back to... dunno :D
|
Mark M. |
let's go back to "I want the background of a listitem to look a certain way after it had been clicked"
|
Mark M. |
is this a transient thing (i.e., it reverts to normal after 500ms), or a permanent thing?
|
Mark M. |
and, if it is a permanent thing, doesn't this conflict with the long-press thing?
|
Kai H. |
Permanent
|
Kai H. |
It denotes the item that has been selected last
|
Jun 25 | 9:10 AM |
Mark M. |
and that is something different than the long-click?
|
Kai H. |
The long press brings up action mode (and you can actually press other items and add them to the selection after having pressed one with long-click).
|
Kai H. |
If you short-click it, you just choose it, but don't invoke action mode.
|
Mark M. |
your graphic designer and I are not going to get along
|
Mark M. |
at most, I would do one or the other of those
|
Kai H. |
And it gets a highlight bar atm, but the graphic desiners want another background too
|
Kai H. |
So would I, after having understood what they want.
|
Mark M. |
you'll probably just have to manage that yourself in code
|
Mark M. |
keep track of which one is "selected" and manually swap the backgrounds
|
Kai H. |
I just wanted to clear up my confusion on how to do the selection thing properly on the technical side.
|
Mark M. |
basically, "activated" gives us one application-level UI state that we can leverage, but only one
|
Mark M. |
you're using that for something else
|
Mark M. |
so, this "last selected" state is going to have to be manually tracked
|
Kai H. |
I think that is what I wanted to know.
|
Kai H. |
I guess the usualy states for a normal app would be state_pressed, state_activated and none?
|
Mark M. |
yes, though most of those have framework uses (e.g., the framework switches between normal and pressed)
|
Kai H. |
pressed on clicking something, activated after it has been clicked and none otherwise?
|
Mark M. |
activated is there for application use, and so you can decide if/when a view is activated or not
|
Mark M. |
in your case, you are using that for something else, and I do not recall there being another application-centric state
|
Mark M. |
everything else (pressed, disabled, etc.) are used by the system
|
Mark M. |
and will have ramifications beyond the background
|
Kai H. |
It's good that the framework "uses" the pressed state, as it is something you get automatically.
|
Jun 25 | 9:15 AM |
Mark M. |
yes, and the original vision was that *all* states would be framework-managed
|
Mark M. |
activated was an afterthought, added in API Level 11
|
Mark M. |
and I'm grateful for it
|
Kai H. |
But you could always change the colors for the states?
|
Mark M. |
sure
|
Kai H. |
And "activated" you can actually "grab" as an event, is that what was added in API Level 11?
|
Mark M. |
it's not an event
|
Mark M. |
it's a state that you set yourself, via setActivated()
|
Mark M. |
it's just not one that anything in the framework should be using and setting automatically
|
Mark M. |
and it's not one that the framework will react to, other than for your own purposes (e.g., StateListDrawable)
|
Kai H. |
So before API Level 11 there where not states that could be set by oneself
|
Mark M. |
you could set something like disabled, but then that has other impacts, such as disabling user input
|
Kai H. |
And they added that to give a generic and controllable state besides the framework used ones
|
Mark M. |
correct
|
Kai H. |
I see
|
Mark M. |
let me take questions from the others, and I might be able to get back to you before the chat ends
|
Mark M. |
Leora: back to you! do you have another question?
|
Leora |
yes, but also to say your suggestion of changing the base Nav to class and NavA to object worked!!!
|
Mark M. |
oh, cool
|
Leora |
it's now pointing to the correct methods
|
Leora |
totally cool thanks!
|
Mark M. |
you're welcom!
|
Leora |
quick question but looks like a bug
|
Mark M. |
er, welcome!
|
Leora |
registerForActivityResult is suddenly showing up 'unrecognized'
|
Jun 25 | 9:20 AM |
Leora |
red, error
|
Leora | |
Leora |
but the code compiles and runs fine
|
Leora |
any idea?
|
Mark M. |
since that stuff is still in alpha IIRC, are you sure that both modules are using that alpha version of androidx.activity or androidx.fragment
|
Leora |
i had it in the library module as api and not implementation
|
Leora |
that usualyy takes care of the imports of the app module
|
Mark M. |
agreed, that sounds fine
|
Leora |
but after the error i added the dependencies to the app gradle as well
|
Leora |
error persists [insert eye roll here]
|
Kai H. |
If I have something like this, I first click on the elephant in the top right to sync gradle. If that didn't work I restart the IDE
|
Mark M. |
hmmm... there's always Build > Clean Project, and running a Gradle dependency report to confirm you are using the alpha
|
Leora |
did all, even invalidate caches/restart
|
Mark M. |
but, given that this is compiling, it might just be an IDE bug
|
Jun 25 | 9:25 AM |
Mark M. |
what version of Android Studio are you using?
|
Leora |
ok probably
|
Leora |
ahhh maybe cause i DARED to try the beta 4.1
|
Leora |
i felt i could handle it hahaha
|
Mark M. |
it's not you, it's the beta
|
Leora |
thats what they all say :)
|
Leora |
btw i only need the androidx.activity OR androidx.fargment?
|
Leora |
not both?
|
Mark M. |
AFAIK, you need whichever one(s) you are using -- so, if you are calling registerForActivityResult() in an activity, you need androidx.activity
|
Leora |
ok thanks
|
Mark M. |
this is just based off of a quick skim of the docs -- I haven't played with these APIs yet
|
Leora |
and thanks Kai for the suggestion - love your name!
|
Leora |
ok, i've been feelin bleeding edge
|
Mark M. |
if anyone has any last questions, fire away!
|
Leora |
Thanks so much Mark, a pleasure as always
|
Kai H. |
None for 1 minute :D
|
Kai H. |
What is the airspeed of an unladen swallow? ;-)
|
Leora |
hahaha
|
Jun 25 | 9:30 AM |
Mark M. |
is that an African or European swallow?
|
Kai H. |
*sproing*
|
Kai H. |
aaaaahhhhh....
|
Mark M. |
but, alas, that's a wrap for today's chat
|
Mark M. |
the next one is Saturday at 4pm US Eastern
|
marekdef |
thank you all
|
Kai H. |
Have a good time everyone
|
Mark M. |
have a pleasant day, and stay healthy!
|
marekdef | has left the room |
Kai H. | has left the room |
Leora | has left the room |
Mark M. | turned off guest access |