Oct 5 | 7:20 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Oct 5 | 7:25 PM |
MyWay | has entered the room |
Mark M. |
hello, MyWay!
|
Mark M. |
how can I help you today?
|
MyWay |
hi Mark :)
|
MyWay |
I switched Activity to AppCompatActivity for Material Design, now I'd like to do the same for PreferenceActivity, but I see there is no AppCompatPreferenceActivity and I see you're extending Activity in your book, should I extend AppCompatActivity? What's the difference?
|
Mark M. |
in your case, use the new android.support.v14.preference.PreferenceFragment in an AppCompatActivity, I imagine
|
MyWay |
ah, I was using android.preference.PreferenceFragment
|
Mark M. |
actually, there's also android.support.v7.preference.PreferenceFragmentCompat
|
Mark M. |
I'm not sure what the role of one is versus the other
|
Oct 5 | 7:30 PM |
Mark M. |
since their docs are just copy-and-paste jobs from the original PreferenceFragment
|
Mark M. | |
MyWay |
in my case I'm on minSdk >= 14
|
Mark M. |
I still don't really know which of those two classes is the right answer
|
Mark M. |
but, I'm sure it's one of them :-)
|
MyWay |
eheh
|
MyWay |
and what about ListActivity? Should I change something?
|
Mark M. |
just use AppCompatActivity and put in your own ListView
|
Mark M. |
or ListFragment
|
Mark M. |
it's not like ListActivity had all that much to it
|
MyWay |
yeah
|
Oct 5 | 7:35 PM |
MyWay |
for DialogFragment I should do something or just apply a style?
|
Mark M. |
there is AppCompatDialogFragment
|
Mark M. |
to be honest, I haven't done much with the whole AppCompat ecosystem
|
MyWay |
ah, didn't notice it, thanks
|
MyWay |
If I understand correctly: as I'm switching PreferenceFragment (the support v14 one), I just have to move the call to addPreferencesFromResource inside onCreatePreferences instead of onCreate, because onCreatePreferences is called when onCreate is, right?
|
Mark M. |
um, I guess so
|
Mark M. |
I have never used this class
|
Mark M. |
I just know that it exists
|
MyWay |
ah
|
Mark M. |
did I mention that I haven't done much with the whole AppCompat ecosystem? :-)
|
MyWay |
yes it seems they splitted them
|
MyWay |
ahah
|
Oct 5 | 7:40 PM |
MyWay |
one last thing, after switching to AppCompatActivity I've noticed that the logo/icon isn't used anymore (they motivated it "the icon shouldn't be that important if you give it a nice look, or something like that), to me it does not seems that bad, but only if there is a navigation drawer, can I restore the old logo/icon on the actionbar?
|
Mark M. |
yeah, but you probably won't want to
|
MyWay |
or you think it's better to not restore the logo/icon?
|
Mark M. |
I tried it, and while it works, the icon does not get sized properly
|
MyWay |
ah
|
Mark M. |
then again, I haven't tried it in a year, and so it might have gotten better
|
MyWay |
didn't know, nice
|
Mark M. |
I forget the exact recipe for doing it, though
|
MyWay |
what do you think about it?
|
Mark M. |
what do I think about what?
|
MyWay |
about their motivation to not use a icon anymore
|
Mark M. |
I never understood the rationale
|
Mark M. |
(for the change, that is)
|
MyWay |
yes
|
MyWay |
I will try to restore it and see if there are sizing problems again
|
MyWay |
thank you very much as always :P
|
Mark M. |
you are very welcome
|
Oct 5 | 7:50 PM |
MyWay |
https://plus.google.com/+AndroidDevelopers/post... (So what about the preferences-v14 library? You’ll find it offers the same API as the preferences-v7 library, but built on framework Fragments and DialogFragments.)
|
MyWay |
apparently no other differences
|
Mark M. |
OK, so for AppCompat, you'll want the preferences-v7 one
|
Mark M. |
and PreferenceFragmentCompat
|
MyWay |
and apparently no more isValidFragment
|
Mark M. |
that's a PreferenceActivity thing
|
MyWay |
ah, that's why
|
Mark M. |
since there's no PreferenceActivity in the AppCompat scenario, there's no isValidFragment() to have to fuss with
|
Oct 5 | 7:55 PM |
MyWay |
before I was using onBuildHeaders to loadHeadersFromResource (load my header), but now that I'm inside AppCompatActivity how should I load it?
|
Oct 5 | 8:00 PM |
Mark M. |
according to that G+ post you linked to, there's no preference header support
|
Mark M. |
"One thing you’ll note isn’t in here is preference headers and you’d be totally right. However, that doesn’t mean a single list of preferences need to span a 10” tablet screen. Instead, your Activity can implement OnPreferenceStartFragmentCallback (http://goo.gl/IZWZBP) to handle preferences with an app:fragment attribute or OnPreferenceStartScreenCallback (http://goo.gl/CFp5Cr) to handle PreferenceScreen preferences. This allows you to construct a ‘header’ style PreferenceFragmentCompat in one pane and use those callbacks to replace a second pane without working in two separate types of XML files."
|
Oct 5 | 8:20 PM |
Bryan | has entered the room |
Bryan |
Hello
|
Mark M. |
hello, Bryan!
|
Bryan |
I have a couple questions, hopefully quick
|
Mark M. |
the chat ends soonish -- how can I help you?
|
Mark M. |
go right ahead
|
Bryan |
I am saving a file to the downloads directory
|
Bryan |
and it is not showing up
|
Bryan |
here is what I am using to get the mediascanner to see it
|
Bryan |
but it doesn't seem to work
|
Bryan |
getting it....
|
Bryan |
View paste
|
Mark M. |
is your callback being invoked?
|
Bryan |
View paste
|
Bryan |
yeah
|
Bryan |
and the file is there (if I use a 3rd party file explorer)
|
Mark M. |
but you're not seeing it on your desktop OS?
|
Bryan |
but if I go to "downloads" in my app drawer on my nexus 6
|
Bryan |
it isn't there
|
Mark M. |
oh, it's not going to show up there
|
Bryan |
i'll check on desktop (mac)
|
Mark M. |
that's only for files downloaded via DownloadManager
|
Bryan |
ok
|
Bryan |
that makes sense then
|
Bryan |
so what I am wanting to do is offer a download to csv of a "history" in my app
|
Bryan |
what is the best way to do that and get it into something "easy" for the user to find it
|
Bryan |
I was hoping to just pop it into download
|
Oct 5 | 8:25 PM |
Bryan |
I was even going to use the download manager, but it will only take http/s
|
Oct 5 | 8:25 PM |
Bryan |
it feels like a trivial exercise that is actually a lot harder than it would seem it should be
|
Mark M. |
"easy", IMHO, would be ACTION_SEND, to allow the user to share the content via their preferred mechanism
|
Bryan |
ok, that makes sense, and I could do that with a generated file?
|
Mark M. |
sure
|
Mark M. |
just write the file out first, before triggering the share option
|
Bryan |
so I could pop up a dialog with spinner while the file builds and then throw up the share intent?
|
Mark M. |
sure
|
Bryan |
ok, another quick question?
|
Bryan |
<4 min
|
Mark M. |
type quickly! :-)
|
Bryan |
we are trying to refactor a project and we are using lint
|
Bryan |
it is suggesting we take ALL strings out of the code
|
Bryan |
including log comments and json declarations, etc etc
|
Bryan |
things that don't need to be translated
|
Bryan |
lets say there are 400 of those
|
Bryan |
I don't want to have to add 400 suppressions
|
Bryan |
but want to continue to use lint
|
Bryan |
your expert opinion?
|
Mark M. |
ummm... I think you're out of luck
|
Mark M. |
perhaps isolate the strings into a Constants class somewhere and suppress the lint warnings on the class?
|
Bryan |
not what I wanted to hear, I wanted some sort of commonsware magical answer that made it easy and make sense
|
Bryan |
ooooooh, I like it!
|
Bryan |
there you go!
|
Mark M. |
I haven't tried suppressing that particular Lint warning at the class level, so it might not work
|
Bryan |
I think I will do something like that
|
Mark M. |
and then you have 400 refactorings to do
|
Bryan |
lol
|
Mark M. |
which may not be a net improvement over 400 suppressions
|
Bryan |
do you leave strings in your code?
|
Mark M. |
sure, ones akin to the ones that you describe
|
Bryan |
ok, cool
|
Bryan |
Thanks, just got in under the wire! Have a good nite
|
Oct 5 | 8:30 PM |
Mark M. |
you too!
|
Mark M. |
that's a wrap for today's chat
|
Mark M. |
the transcript will be posted to https://commonsware.com/office-hours/ shortly
|
Mark M. |
the next chat is tomorrow at 4pm US Eastern
|
MyWay | has left the room |
Bryan | has left the room |
Mark M. | turned off guest access |