Feb 8 | 9:55 AM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Feb 8 | 10:00 AM |
Oliver | has entered the room |
Mark M. |
hello, Oliver!
|
Mark M. |
how can I help you today?
|
Oliver |
Hey Mark...just a quick question
|
Oliver |
I have you all to myself ;)
|
Oliver |
thanks for the time
|
Oliver |
so the question
|
Oliver |
In an app similar to MyTracks
|
Oliver |
we are loading 'tracks' or paths over the map
|
Oliver |
great
|
Oliver |
in our old app we just dumped the database...and had content observers
|
Oliver |
it worked...
|
Oliver |
now...I am liking loaders quite a lot
|
Oliver |
_but_ I cannot think of a good way to use loaders in this instance
|
Oliver |
because I am essentially needing a loader with give me everything since
|
Oliver |
that leaves me with some options
|
Oliver |
bulk load from a loader...then observe / or get changes from a service
|
Oliver |
are you following me so far?
|
Mark M. |
not exactly
|
Mark M. |
"we just dumped the database" -- what does this phrase mean?
|
Mark M. |
and, why are you bothering with Loaders, given that you have working code?
|
Oliver |
SELECT * FROM POINTS WHERE session = x
|
Oliver |
that sort of thing
|
Mark M. |
so, "dump" == "query"?
|
Oliver |
then SELECT * FROM POINTS WHERE session = X and ID > somevalue
|
Oliver |
yup
|
Feb 8 | 10:05 AM |
Oliver |
sorry...being sloppy
|
Feb 8 | 10:05 AM |
Mark M. |
how are you "dumping" presently, if you are not using a Loader?
|
Oliver |
actually it is fairly old code...so a managedCursor query
|
Mark M. |
yeah, that's not ideal
|
Mark M. |
so, why would there be a difference in using a Loader to replace your existing code, beyond the actual query itself?
|
Mark M. |
never mind
|
Mark M. |
stupid question
|
Oliver |
I think the point is we need change only updates
|
Oliver |
cos the map already has the track plotted so far
|
Mark M. |
OK
|
Mark M. |
to me, this indicates that a Loader probably is not a good choice
|
Mark M. |
replace your managedQuery() with using query() on a ContentResolver in an AsyncTask, to get it off the main application thread
|
Mark M. |
and stick with the rest of your existing logic
|
Mark M. |
Loader is designed to keep reloading your original
Cursor, which it sounds like is not what you need, and therefore adds
unnecessary overhead
|
Oliver |
sure...and if possible save the loaded data in saveInstanceState?
|
Feb 8 | 10:10 AM |
Oliver |
for screen rotation etc.
|
Mark M. |
my guess is that your data is too big for that
|
Oliver |
I could have out[data, lastIdLoaded]
|
Oliver |
erm...not sure on size limitations...maybe 10,000 points...
|
Oliver |
x,y values
|
Mark M. |
that's a bit big
|
Mark M. |
use a retained fragment or onRetainNonConfigurationInstance() for data of that size
|
Mark M. |
the Bundle used in onSaveInstanceState() can live for a while and cross process boundaries
|
Kadrov N. | has entered the room |
Mark M. |
hello, Kadrov!
|
Kadrov N. |
Hi
|
Mark M. |
Oliver: let me take a question from Kadrov, and I will be back with you shortly
|
Oliver |
Thanks Mark...I'll let Kardov chip in.
|
Mark M. |
Kadrov: do you have a question?
|
Oliver |
np
|
Kadrov N. |
Yes.
|
Kadrov N. |
I'm trying to find legal way to get default selection color for buttons. Do you know one?
|
Mark M. |
no, because it's not a color
|
Mark M. |
it's a nine-patch PNG file that is part of a StateListDrawable
|
Mark M. |
at least, by default
|
Mark M. |
different devices may have done different things with the default device theme
|
Feb 8 | 10:15 AM |
Mark M. |
what are you trying to achieve?
|
Kadrov N. |
I have application that should work on 2.2+ and
4.0+. At first case I use default lights theme and on second Holo.Light.
But I have several custom controls and what to have same selection
color for them as for default controls!
|
Kadrov N. |
So, what's the best way to do it?
|
Mark M. |
again, there is no "selection color", but rather an image that is used in the selected state as a background
|
Mark M. |
if you cannot use the existing background images, you cannot sync with the device's default theme
|
Mark M. |
hence, if you want consistency, set your own
StateListDrawable for all widgets (e.g., buttons), so you control what
it looks like everywhere within your app
|
Kadrov N. |
ok, how to use this background image in my custom Selector?
|
Mark M. |
there may be a way to achieve that via having a
style refer to a value from another style, but that's beyond my
style-handling expertise
|
Mark M. |
I apologize for not being able to help much on this issue
|
Feb 8 | 10:20 AM |
Kadrov N. |
ok. So another way is setting my own StateListDrawable for all widgets. How to do it?
|
Feb 8 | 10:20 AM |
Mark M. |
copy the stock Android one from the SDK, and modify to suit
|
Mark M. |
btn_default.xml is the background for a Button, for example
|
Mark M. |
it will look something like this (pulled from android-10):
|
Mark M. |
View paste
(1 more line)
|
Mark M. |
the images referred to in the <item> elements are nine-patch PNGs, which are available in various densities
|
Mark M. |
you would need to change whatever you want for however you wanted to use it
|
Mark M. |
let me take a question from Oliver, and I will be back with you shortly
|
Mark M. |
Oliver: do you have another question?
|
Kadrov N. |
hm... so, I have to copy style xml-s for all
controls that I use in my app localy to my APK and then modify colors.
Am I correct?
|
Mark M. |
Kadrov: not so much style XML but the background image resources, which you would then refer to from your own style XML
|
Feb 8 | 10:25 AM |
Mark M. |
for the Holo theme, this sort of customization can be somewhat automated using the Android Holo Theme Generator
|
Mark M. | |
Mark M. |
I am not aware of an equivalent for pre-Holo themes
|
Mark M. |
Oilver: do you have another question?
|
Oliver |
Hi Mark, I think I am good. I have looked at
MyTracks for an hour or so...and they really go to town. I will look at
retaining the fragment data and do as you suggest. I think it will
turn out to be quite simple.
|
Feb 8 | 10:30 AM |
Mark M. |
OK
|
Mark M. |
Kadrov: if you have another question, go ahead
|
Kadrov N. |
thanks for your help, Mark! I have no another question
|
Oliver |
ok Mark...one small question...you will have to forgive me for fuzziness.
|
Oliver |
The question is regarding a search activity
|
Oliver |
say you have a list of items
|
Oliver |
and you want to search through them
|
Oliver |
_is_ the recommendation to have a dedicated search activity
|
Oliver |
(actually I aliased the list activity)
|
Oliver |
(therefore reused code)
|
Mark M. |
you do not need a dedicated search results activity
|
Mark M. |
however, the activity should make it obvious to the user what they are viewing
|
Mark M. |
for example, you might indicate the list scope in the action bar title ("Search Results for: ...")
|
Feb 8 | 10:35 AM |
Oliver |
thanks Mark...so are you thinking of _not_ overlaying the activities?
|
Oliver |
state 1) list everything
|
Oliver |
state 2) commence search (typing in action bar)
|
Oliver |
user presses enter...
|
Oliver |
new activity launched _or_ list is just filtered?
|
Mark M. |
either is appropriate
|
Oliver |
ok...and if an activity is launched
|
Oliver |
and the user presses a search icon again
|
Oliver |
should the previous search activity be on the back stack?
|
Oliver |
list all > search a > search b etc.?
|
Oliver |
or list all > search
|
Mark M. |
AFAIK, that's more or less up to you
|
Oliver |
right...that sounds great
|
Mark M. |
if you think that past search results will be important to the user, offering a back stack might be a good idea
|
Mark M. |
but that's going to be fairly app-specific, I would imagine
|
Mark M. |
and it'
|
Mark M. |
(never mind last partial comment)
|
Feb 8 | 10:40 AM |
Oliver |
super...I think I'll leave it there...I'll try and make your next office hours with some further questions.
|
Oliver |
really appreciate your time
|
Mark M. |
happy to help!
|
Mark M. |
Kadrov: if you have additional questions, go ahead
|
Oliver | has left the room |
Feb 8 | 10:45 AM |
Kadrov N. |
Mark, do you know any services for providing normal (well secure) trial period for android applications?
|
Mark M. |
no -- I do not pay much attention to licensing engines
|
Mark M. |
I think the preferred pattern today is the free app with in-app purchases to unlock additional features or content
|
Kadrov N. |
I'm thinking about this schem: free application
that will work during 14 days and after this period it'll ask user to
buy full lifetime license (throw in-app purchase) or uninstall
application.
|
Kadrov N. |
Do you think it is ok?
|
Mark M. |
I am not aware of time-limited apps being particularly popular
|
Mark M. |
you might consider doing a search of the Play Store for "14 days" and the like, and see what sort of comments they get
|
Feb 8 | 10:50 AM |
Kadrov N. |
good idea!
|
Mark M. |
from a technical standpoint, so long as you are not worried about rooted device users, it should be fairly simple to set up
|
Kadrov N. |
only on problem. secure of trial period
|
Kadrov N. |
I mean that user cud just uninstall and install again application after end of trial period!
|
Kadrov N. |
how to protect this simple scenario?
|
Mark M. |
correct
|
Mark M. |
personally, I wouldn't use a trial period
|
Mark M. |
beyond that, you would need to store some device identifier on your server and check for matches
|
Mark M. |
however, there is no great device identifier
|
Feb 8 | 10:55 AM |
Mark M. | |
Kadrov N. |
yes, that's the way i thinking about...
|
Kadrov N. |
so, you prefer free application with unlock of some futures by in-app purchases?
|
Mark M. |
I think that works better for all parties, personally
|
Oliver | has entered the room |
Oliver | has left the room |
Feb 8 | 11:00 AM |
Kadrov N. |
and actually easier to implement then time limited application... you do not need server and so on...
|
Mark M. |
correct
|
Mark M. |
the key is having enough free-forever features to entice the user into trying the app and eventually upgrading
|
Mark M. |
and that is a wrap for today's office hours chat
|
Mark M. |
the transcript will be posted at http://commonsware.com/office-hours/ shortly
|
Mark M. |
the next chat is Tuesday at 7:30pm Eastern Time
|
Mark M. |
have a pleasant day!
|
Kadrov N. |
Ok, Mark. Thanks for your advise and your help!
|
Kadrov N. |
by
|
Kadrov N. | has left the room |
Mark M. | turned off guest access |