potential improvement for responsiveness in k9mail

Hello developers of K-9 mail,

I'm a Ph.D. student and I'm doing research related to Android apps'
responsiveness. I found there are some cases in K9 that the database
is queried, or bitmap is generated in UI thread. Does this affect the
responsiveness of the app? An optimization could be extracting these
operations into AsyncTask.

For example, in AttachmentView.java, line 174 "getPreviewIcon()"
decodes a bitmap from a stream, which is a relative long
computation. Is it better to put them into a AsyncTask, so the UI
thread won't be blocked on decoding? I attach a sample patch
here.

Also, in MessageCompose.java, "actionCompose" method at line 412
invokes "Preferences.getPreferences" which create a "Storage" and
queries database. This also lead to a potential responsiveness
issue. Thus, I tried to move it into AsyncTask.

Similarly, MessageViewFragment.java invokes
"Preferences.getPreferences" at line 272. Note that I add a null check
"if(mAccount == null)" before every use of "mAccount", because there
are data races on "mAccount" after put line 272 into AsyncTask. I also
did the same transformation for ChooseFolder.java and
AccountSetupBasics.java.

There should be some other places that can be improved. I can't report
all of them at one time. However, what do you think about these
improvements? My thought is we can improve the responsiveness if we
try to avoid the access to IO/Database, generating bitmap in UI thread.

Thanks,
Yu