Apr 4 | 9:50 AM |
Mark M. | has entered the room |
Apr 4 | 9:55 AM |
Mark M. | turned on guest access |
Apr 4 | 10:00 AM |
Sebastiano P. | has entered the room |
Mark M. |
hello, Sebastiano!
|
Sebastiano P. |
Hello Mark
|
Mark M. |
how can I help you today?
|
Sebastiano P. |
I'm having a couple of issues, quite different from each other, to be honest
|
Mark M. |
go ahead with your first one
|
Sebastiano P. |
the first one is related to an app i'm developing for a custom ROM for a product i'm working on
|
Sebastiano P. |
the idea is having some sort of pre-configuration being restored on the device at each boot
|
Sebastiano P. |
because the device is going to run on public displays for people to try it
|
Sebastiano P. |
and it's going to be an unattended station
|
Sebastiano P. |
so I had the idea of getting one device configured the way we want them to be, kind of preparing a "pre-baked image"
|
Sebastiano P. |
i then got a tarball of the /data partition of the device
|
Sebastiano P. |
what i need now to do is have an app with a
BOOT_COMPLETED receiver, that extracts that tarball back to /data,
overwriting any other existing data
|
Apr 4 | 10:05 AM |
Sebastiano P. |
it's mostly done, but as you can imagine, the main
issue here is represented by the fact that one needs root access to
write on /data
|
Mark M. |
hence, this should not be an Android SDK app function
|
Mark M. |
this should be something you do in an init script or something
|
Mark M. |
that runs as part of your custom ROM during the boot cycle
|
Sebastiano P. |
being in complete control of the device (my company manifactures it) i have no problem signing the app with the platform key
|
Sebastiano P. |
that's true
|
Sebastiano P. |
i guess that's what i will have to do then... guess i was too focused on getting this to work to look at the bigger picture
|
Sebastiano P. |
anyhow, i'm left with this curiosity to satisfy
|
Sebastiano P. |
shouldn't apps that are signed with the platform key be able to perform actions as root?
|
Mark M. |
no
|
Mark M. |
signatures have nothing to do with superuser privileges
|
Sebastiano P. |
i have a device with its su binary in place (the standard AOSP one)
|
Sebastiano P. |
no i mean i know signing does not provide su privileges per se
|
Mark M. |
I am not aware that being signed with the firmware signing key somehow enables you to run su
|
Mark M. |
then again, I have zero experience with running Android apps as rot
|
Mark M. |
er, root
|
Sebastiano P. |
i understand
|
Sebastiano P. |
yeah, got that :)
|
Apr 4 | 10:10 AM |
Sebastiano P. |
i guess i will have to ask some root guru such as chainsdd or koush about that, hoping they take the time to reply
|
Mark M. |
XDA's forums would seem to be a likely spot to ask
|
Sebastiano P. |
thanks for the scripting suggestion -- in fact it should be just as easy as invoking tar itself
|
Sebastiano P. |
yeah
|
Mark M. |
make sure you do so before any processes start using files on /data
|
Sebastiano P. |
so I can now move on to my second issue here
|
Sebastiano P. |
yes, i'm going to add it to the init script
|
Sebastiano P. |
as i was saying, i'm going to move to my second issue, which is completely unrelated to the first one
|
Mark M. |
go right ahead -- nobody else is here :-)
|
Sebastiano P. |
i'm developing an app (which is going to be open sourced as soon as it's beta-quality) and i'm using my own extended ImageView
|
Sebastiano P. |
to be precise, i'm using ImageViewNext, which is open-sourced as well
|
Sebastiano P. |
because it provides two key factors i need in this case
|
Sebastiano P. |
which are automatic caching of the images in byte[] form
|
Apr 4 | 10:15 AM |
Sebastiano P. |
and showing animated gifs (thus the byte[] caching: the underlying Movie object needs the byte array, not a Drawable)
|
Sebastiano P. |
so, long story short, i had some issues because i was missing some code to implement the adjustViewBounds behaviour
|
Sebastiano P. |
i have overridden the onMeasure method to take into account the gif size when relying on the Movie
|
Sebastiano P. |
luckily, i haven't changed anything of how the underlying ImageView works when using Drawables
|
Sebastiano P. |
so just copy-pasting the onMeasure method and
adding a branch to an "if" for handling the Movie did work, with very
few adjustments to cope with some data being private to ImageView
|
Sebastiano P. |
now i have this issue
|
Sebastiano P. |
when previewing the layout in my IDE, everything works just fine
|
Sebastiano P. |
when running on a device, i get the same behaviour i would get if adjustViewBounds was set to false
|
Sebastiano P. |
i had a debug session to determine if it was my code having bugs (unlikely, since it's basically the ImageView's own)
|
Sebastiano P. |
and i saw that it's working perfectly
|
Apr 4 | 10:20 AM |
Sebastiano P. |
it's just being called a few times, alternatively with good and bad measureSpecs
|
Sebastiano P. |
meaning, i have an image that is wide and short
|
Sebastiano P. |
it's wider than my screen is, at least in portrait
|
Sebastiano P. |
so i use the fitCenter scaling mode
|
Sebastiano P. |
this gets the image itself to the right size
|
Sebastiano P. |
so I expect to have an MEASURESPEC_EXACTLY for the width dimension, and an AT_MOST or UNSPECIFIED measure spec for the height
|
Sebastiano P. |
which i in fact get for odd layout passes
|
Sebastiano P. |
but then i get an EXACTLY measure spec on even passes, i don't know why
|
Mark M. |
is there anything interesting in the call stacks,
such as even passes being triggered by something different than the odd
passes?
|
Sebastiano P. |
with the height size set to the full image height (280 px instead of the expected 125 or so that i determine when measuring)
|
Sebastiano P. |
not that I can see
|
Sebastiano P. |
if you want I can reproduce it and copy-paste them here
|
Mark M. |
that's worth a shot
|
Sebastiano P. |
ok
|
Mark M. |
I am *far* from expert on custom Views like this
|
Mark M. |
you have done more work in this area than I have
|
Sebastiano P. |
i'm launching the debugger right now
|
Mark M. |
but, maybe I'll get lucky and see something :)
|
Apr 4 | 10:25 AM |
Sebastiano P. |
yeah but you know maybe a fresh pair of eyes can see what i can't
|
Sebastiano P. |
i've been cracking my head on this for a couple of days now, so i might be a bit biased regarding what to look at :D
|
Sebastiano P. |
ok
|
Sebastiano P. |
first calling
|
Sebastiano P. |
View paste
(31 more lines)
|
Sebastiano P. |
oh one sec
|
Sebastiano P. |
this might be the wrong imageview
|
Sebastiano P. |
i'm getting EXACTLY on both dimensions on the first pass
|
Carlos | has entered the room |
Mark M. |
hello, Carlos!
|
Carlos |
Hi Mark
|
Sebastiano P. |
Hi
|
Sebastiano P. |
ok this is the correct first pass
|
Sebastiano P. |
View paste
(31 more lines)
|
Sebastiano P. |
seems pretty much the same thou
|
Sebastiano P. | |
Sebastiano P. |
next on, second pass
|
Sebastiano P. |
here i have widthSpecMode = 1073741824 and heightSpecMode = 1073741824 (which is EXACTLY)
|
Apr 4 | 10:30 AM |
Sebastiano P. |
View paste
(31 more lines)
|
Mark M. |
(Carlos: I will be with you shortly, once I get through this question from Sebastiano)
|
Mark M. |
your second trace is slightly different
|
Mark M. |
onMeasure() stems from measureChild() on
RelativeLayout, versus measureChildHorizontal() on RelativeLayout in
your first call stack
|
Sebastiano P. |
third pass: widthSpecMode = 1073741824 and heightSpecMode = 0 (which is UNSPECIFIED)
|
Sebastiano P. |
that's true
|
Sebastiano P. |
on the third pass i get the same stack trace as in the first one
|
Sebastiano P. |
View paste
(13 more lines)
|
Mark M. |
so, I'd look at the source for RelativeLayout and
determine under what conditions it calls measureChild() instead of
measureChildHorizontal()
|
Mark M. |
and see what that tells you
|
Mark M. |
let me take a question from Carlos, and I will be back with you shortly
|
Sebastiano P. |
yes
|
Mark M. |
Carlos: do you have a question?
|
Carlos |
yes
|
Carlos |
View paste
|
Sebastiano P. |
i'm looking at relativelayout in the meantime
|
Carlos |
Regarding notifications...
|
Carlos |
When the AlarmManager kicks in, I sent a notification and create a pendingIntent that will start the DetailsActivity
|
Apr 4 | 10:35 AM |
Carlos |
The problem I'm seeing is that once the user
presses done in the action bar, the Detail Activity calls finish (like
in normal operation), but the intent results from it are not handled by
the MainActivity
|
Mark M. |
MainActivity did not call startActivityForResult()
in this code path, from what you have described -- DetailsActivity was
started directly from the PendingIntent
|
Carlos |
Yes, that's correct
|
Carlos |
how I achieve the "regular app operation" within the context of clicking on a notification
|
Mark M. |
given your current reliance on startActivityForResult(), I do not know if that is possible
|
Carlos |
MainActivity is the one that updates the
ListFragment so I'm not getting my updated data saved to my database or
the Adapter updated.
|
Mark M. |
certainly, I have no idea how I would accomplish it
|
Mark M. |
while continuing to use startActivityForResult()
|
Mark M. |
however, if you switch to some other communications mechanism between the activities, you might get it to work
|
Mark M. |
for example, you might try using a PendingIntent that is created by TaskStackBuilder
|
Mark M. |
so that exiting the DetailsActivity will return to the MainActivity
|
Carlos |
Any suggestions on what to use instead of Intents?
I thought that was the recommended way, so I was surprised to find this
bug just for pending intent
|
Mark M. |
you will also need to figure out some other way for MainActivity to find out about the updated data
|
Carlos |
Just to clarify, when the action bar button is
press in the detail activity the app returns to the main activity, is
just that main activity is started without receiving the intent data
from Details Activity. Is as if the MainActivity was started from the
Launcher as is just waiting for user input.
|
Apr 4 | 10:40 AM |
Mark M. |
again, that is because MainActivity did not call startActivityForResult() on DetailsActivity
|
Mark M. |
startActivityForResult() is a very fragile mechanism
|
Carlos |
So your suggestion is to use TaskStackBuilder for both regular app navigation as well as for my notification purpose. correct?
|
Mark M. |
not necessarily -- I do not know enough about your app for that
|
Jose L. | has entered the room |
Mark M. |
however, if you are expecting BACK from
DetailsActivity to return you to MainActivity, from a PendingIntent,
TaskStackBuilder is probably your best option
|
Carlos |
Hmmm. I'm just wondering how this has been done
before fragments was available since TaskStackBuilder compatibility
library was not available in the pre-fragment era.
|
Mark M. |
BACK would simply return you to wherever you were before the notification was clicked
|
Mark M. |
which, IMHO, is what it should be doing even today, but Google thinks otherwise
|
Carlos |
Yeah, right now I'm not concern about the back
button. Is mostly about making sure than when the user presses the
notification and does edits in the detail framgment that those edits get
properly reflected in the MainActivity.
|
Sebastiano P. |
(i'm back)
|
Mark M. |
all I can suggest is that you find some solution
other than startActivityForResult(), which is really designed mostly for
simple scenarios like ACTION_PICK Intents
|
Jose L. |
Hi there guys
|
Mark M. |
for example, you might consider using Otto's event bus, particularly with @Producer
|
Carlos |
ok Mark. Thanks for your feedback. I'll work on this some more and file a SO question if I'm still stuck. Thanks!
|
Sebastiano P. |
hi Jose
|
Mark M. |
OK
|
Apr 4 | 10:45 AM |
Mark M. |
Jose: since the others have had a chance to ask a question already -- do you have a question?
|
Jose L. |
not really, just wanted to see if I could learn something
|
Mark M. |
OK
|
Mark M. |
Sebastiano: back to you -- find anything interesting?
|
Mark M. |
OK, if anyone has a question, feel free to chime in
|
Sebastiano P. |
i found that RelativeLayout calls
measureChildHorizontal from its onMeasure() to measure all children
orizontally in a for cycle, and then calls measureChild() in another for
cycle to measure them vertically
|
Mark M. |
that's interesting
|
Mark M. |
any idea why it is passing along different specs?
|
Sebastiano P. |
sorry i'm a bit slow but i've got a phone call going on as well :D
|
Mark M. |
ah, no worries
|
Mark M. |
just get rid of RelativeLayout from your sample, then :-)
|
Sebastiano P. |
it's absurd, because the RelativeLayout gets the
params before calling each measureChild*(), directly from the child:
LayoutParams params = (LayoutParams) child.getLayoutParams();
|
Apr 4 | 10:50 AM |
Carlos | has left the room |
Sebastiano P. |
View paste
|
Sebastiano P. |
:D
|
Sebastiano P. |
in the RelativeLayout code
|
Mark M. |
yeah, there a quite a few comments like that floating around the AOSP code
|
Sebastiano P. |
that's not really reassuring thou :)
|
Sebastiano P. |
i'm not sure i can get rid of the RelativeLayout thou
|
Mark M. |
that was just a joke
|
Sebastiano P. |
without having to use an awful lot of layouts :D
|
Sebastiano P. |
i'm copy-pasting my layout here
|
Sebastiano P. |
View paste
(95 more lines)
|
Sebastiano P. |
please consider it's still a WIP
|
Sebastiano P. |
but as you can see there's no way I can get rid of that RelativeLayout
|
Sebastiano P. |
(I'm implementing sort of a Cards UI, even if I designed way before Google launched Now)
|
Apr 4 | 10:55 AM |
Mark M. |
well, trying to make sense of the RelativeLayout
two-pass measure process is about as far as I am going to be able to
narrow it down for you
|
Sebastiano P. |
this is a mockup of what i'm trying to achieve here: https://www.dropbox.com/s/b0u21rord37qz0d/05a-n...
|
Mark M. |
with luck, that will at least help accelerate your finding a solution
|
Sebastiano P. |
I guess I could try and ask someone in the Android team, keeping my fingers crossed for an answer
|
Mark M. |
nice UI, though you might consider adding a profanity filter on your mockups :-)
|
Sebastiano P. |
OR, try to implement that with some other layout, maybe a TableLayout
|
Jose L. |
I'm sorry I got here too late but I don't know what's the problem, can you sumarize it real quick for me?
|
Sebastiano P. |
Mark Murphy, that's the actual episode title I'm afraid :D
|
Mark M. |
Jose: it is probably a bit difficult to summarize
easily, but you will be able to read the whole chat transcript once the
chat is over
|
Sebastiano P. |
(great show, by the way)
|
Mark M. |
Jose: all the chat transcripts are published on http://commonsware.com/office-hours/ shortly after the chat ends
|
Sebastiano P. |
Jose, I'm having an issue with the RelativeLayout
|
Sebastiano P. |
it's doing its job of laying out the children in multiple passes
|
Sebastiano P. |
one horizontal and one vertical
|
Sebastiano P. |
for each child
|
Sebastiano P. |
the issue is that in the vertical pass it's giving me the wrong LayoutParameters
|
Sebastiano P. |
because i'd expect, given how the layout is laid
out, to have the freedom to resize my extended ImageView instance for
the banner as much as I want on the vertical axis
|
Apr 4 | 11:00 AM |
Mark M. |
that's a wrap for today's chat
|
Mark M. |
the transcript will be posted to http://commonsware.com/office-hours/ shortly
|
Sebastiano P. |
but when measuring the vertical size of the child, the RelativeLayout calls my ImageViewNext (http://github.com/frapontillo/imageviewex) saying it to be precisely X pixels
|
Sebastiano P. |
ok
|
Sebastiano P. |
thanks mark
|
Mark M. |
the next chat is Tuesday at 4pm Eastern
|
Mark M. |
have a pleasant day!
|
Jose L. |
thanks!
|
Jose L. |
you to
|
Jose L. |
too
|
Sebastiano P. |
especially for the first solution
|
Sebastiano P. |
bye
|
Sebastiano P. | has left the room |
Jose L. | has left the room |
Mark M. | turned off guest access |