Jul 2 | 7:20 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Jul 2 | 7:25 PM |
marekdef | has entered the room |
Mark M. |
hello, maredef!
|
Mark M. |
how can I help you today?
|
marekdef |
Hi Mark
|
marekdef |
I have my custom keyboard and a non-editable EditText ...
|
marekdef |
Is custom view and it seems we need some standard behavior(s)
|
marekdef |
one is autoSizeTextType
|
marekdef |
other is blinking cursor
|
marekdef |
so I wrote a TextWatcher
|
marekdef |
that measures text
|
marekdef |
and if is too big
|
Jul 2 | 7:30 PM |
marekdef |
1. modifies content.textScaleX
|
marekdef |
(content is EditText)
|
marekdef |
or 2. modifies textSize so it will fit
|
marekdef |
it works fine
|
marekdef |
until rotation
|
marekdef |
the view has Id
|
marekdef |
so it restores fine
|
marekdef |
I see the text in LayoutInspector
|
marekdef |
what happens is that autoscaler is calculating available space
|
marekdef |
and for rotation is 0
|
marekdef |
something like content.length
|
marekdef |
I am adding this textwatcher in a constructor of custom view
|
Mark M. |
your saved instance state will not yet be applied by the time your constructor is called
|
Jul 2 | 7:35 PM |
marekdef |
yes I think it happens later
|
marekdef |
avaialble space is calculated in textwatcher
|
marekdef |
so is fired after someones sets the text on this new instance
|
Mark M. |
you may need to override your custom view's onRestoreInstanceState(), chain to the superclass, and then update your text scale at that point (as you should have the text by then)
|
marekdef |
I think it would be to early
|
marekdef |
content.width is zero apparently
|
marekdef |
and since textwatcher is called, someone is saving
|
marekdef |
*some is restoring state
|
Jul 2 | 7:40 PM |
marekdef |
so. the problem is not that the text is empty or something
|
Mark M. |
then perhaps use ViewTreeObserver.OnGlobalLayoutListener to find out when the custom view has been laid out, and at that point both register your TextWatcher and handle any text that you have at the time
|
Mark M. |
because once the view has been laid out, you should have its size to use for your text-length analysis
|
marekdef |
ok will try it out
|
Jul 2 | 7:50 PM |
marekdef |
seems to work!
|
Mark M. |
great!
|
marekdef |
seem the token is still mine :)
|
marekdef |
recently we released multiple apk
|
marekdef |
one for api level 16-21 and 22+
|
marekdef |
this 22+ was already in a market
|
marekdef |
so I just added the apk for old devices
|
marekdef |
and i am not sure if is related
|
Jul 2 | 7:55 PM |
marekdef |
but go receiving and error like this
|
marekdef |
android.os.BadParcelableException
|
marekdef |
I don't see the message
|
marekdef |
is only Android 10
|
marekdef |
Parcel.java:3059
|
marekdef |
I am using androidxref for source
|
marekdef |
it does not have android 10 yet
|
Mark M. | |
Mark M. |
except that line 3059 is blank
|
marekdef |
thx
|
Mark M. |
since device manufacturers change Android, line numbers do not always line up with official AOSP sources
|
Mark M. |
I try to go more by method names from the stack trace, as those usually are consistent
|
marekdef |
Samsung, Nokia, OnePlus
|
marekdef |
android.os.Parcel.readParcelableCreator
|
marekdef |
if (creator == null) {
|
marekdef |
only this throws this Bad...
|
Jul 2 | 8:00 PM |
Mark M. |
what is the error message on the exception?
|
marekdef |
I dont' see it
|
Mark M. |
that's a problem
|
Mark M. |
where are you getting the stack trace from?
|
marekdef |
google play
|
marekdef |
console, Android Vitals
|
Mark M. |
ah, OK, I and my consulting clients have always used something else, so I do not have direct experience with the one in the Play Console
|
Mark M. |
but without that message, it will be difficult to determine what is going wrong
|
Mark M. |
do you have any custom Parcelable classes?
|
marekdef |
yes @Parcelize
|
marekdef |
quite a lot I think
|
Mark M. |
are you putting any of those as extras on an Intent being wrapped in a PendingIntent?
|
Mark M. |
such as for a notification, or for AlarmManager?
|
marekdef |
yes notification
|
Mark M. |
that is risky
|
Mark M. | |
marekdef |
btw the stacktrace does not contain anhything from our aopp
|
marekdef |
app
|
Jul 2 | 8:05 PM |
Mark M. |
you may want to consider the "convert the Parcelable to a byte[]" approach that I mention at the end of that blog post
|
marekdef |
ok will read that
|
Mark M. |
in that Android 10 source, this problem would result in a BadParcelableException (among all those other cases)
|
marekdef |
the thing is
|
marekdef |
the app is pretty long on the market
|
marekdef |
this never happen before
|
marekdef |
and the recent release was re-release
|
Mark M. |
perhaps Android 10 is unpacking the Parcel in scenarios where it was not doing it before
|
Mark M. |
this is just one area where I know that we can get this exception in seemingly-safe code
|
Mark M. |
I have more on this problem in *The Busy Coder's Guide*: https://wares.commonsware.com/app/internal/book...
|
marekdef |
ok thanks for pointers
|
Mark M. |
I had to apply this for my current customer's project, for this problem, earlier this year
|
Mark M. |
so, it might not be the source of your crash, but it is worth trying
|
marekdef |
will just post a stacktrace
|
marekdef |
View paste
(6 more lines)
|
Jul 2 | 8:10 PM |
marekdef |
maybe it gives more clue
|
marekdef |
if not I am happy with the links
|
marekdef |
will have to digest it
|
Mark M. |
the crash is coming from https://cs.android.com/android/platform/superpr...
|
Mark M. |
unpacking a Bundle just for hashCode() seems excessive, but, I did not write this :-)
|
Mark M. |
but this code should be running in your process, and the PendingIntent problem that I cited is a case where the crash really is in another process and triggers a crash in our own process through some IPC mechanism
|
marekdef |
ok thanks
|
Mark M. |
LaunchActivityItem is tied into launching an activity (not surprising)
|
Mark M. |
so, I would be worried a bit more about Intent extras for this case
|
Mark M. |
but I do not know why you are not getting the detailed error message for the exception
|
Jul 2 | 8:15 PM |
Mark M. |
and that is really what you need to find out what is going on
|
marekdef |
I am not sure either
|
marekdef |
I think play console don't gather messages
|
marekdef |
none of the exceptions have them
|
Mark M. |
that sucks
|
marekdef |
ok another thing
|
Mark M. |
longer-term, you might want to consider using something else for crash logging (Crashlytics, your own hosted backend using ACRA as the collector, etc.)
|
marekdef |
yes would like to have crashlytics
|
marekdef |
ACRA would be an option too
|
marekdef |
one thing about designer/developer cooperation
|
marekdef |
we support lot of devices
|
marekdef |
16+
|
marekdef |
the designs are usually for tall slim phones
|
Jul 2 | 8:20 PM |
marekdef |
the question is what would be the best way to tackle that
|
Mark M. |
tackle what, exactly?
|
marekdef |
excuse me
|
marekdef |
tackle design for smaller phones
|
marekdef |
1. expect each screen also for smaller devices
|
marekdef |
convince designers to have small phone by default
|
marekdef |
or expect sample screens for smaller phones
|
Mark M. |
ideally, designers design around the smallest screen that your firm is willing to support -- usually it is easier to expand a small design than it is to shrink a large design
|
Mark M. |
since that did not happen here, the simplest thing to do is to get a smaller device, test the app, take screenshots of where things are not fitting, and ask for updated designs that can take the smaller screen into account
|
Mark M. |
some of your screens will be fine, and others will require some adjustment
|
Jul 2 | 8:25 PM |
marekdef |
ok
|
marekdef |
what I do is I create emulator that has size exactly as in zeplin/figma
|
marekdef |
mdpi
|
marekdef |
then I can compare screenshot and export
|
Mark M. |
I have it a bit easier, in that I have *lots* of hardware, acquired over the years
|
Mark M. |
somebody might grumble that the emulator is not "real", so I try to test with hardware where I can
|
marekdef |
ok thanks for the chat
|
Mark M. |
happy to help!
|
marekdef |
good night
|
Jul 2 | 8:30 PM |
marekdef |
I am watching Jupiter and Saturn btw
|
marekdef |
one at a time ofc
|
Mark M. |
enjoy the planet-watching!
|
Mark M. |
and, have a pleasant evening!
|
marekdef | has left the room |
Mark M. | turned off guest access |