Set contact info in download phase

This commit is contained in:
M66B 2018-12-07 15:23:17 +01:00
parent 1d99a40216
commit 35407bf289
5 changed files with 12 additions and 11 deletions

View File

@ -565,7 +565,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
draft.subject = context.getString(R.string.app_name) + " " + BuildConfig.VERSION_NAME + " crash log";
draft.content = true;
draft.received = new Date().getTime();
draft.getAvatar(context);
draft.setContactInfo(context);
draft.id = db.message().insertMessage(draft);
draft.write(context, body);
@ -871,7 +871,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
draft.subject = context.getString(R.string.app_name) + " " + BuildConfig.VERSION_NAME + " debug info";
draft.content = true;
draft.received = new Date().getTime();
draft.getAvatar(context);
draft.setContactInfo(context);
draft.id = db.message().insertMessage(draft);
draft.write(context, body);

View File

@ -201,7 +201,7 @@ public class EntityMessage implements Serializable {
}
}
void getAvatar(Context context) {
boolean setContactInfo(Context context) {
if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_CONTACTS)
== PackageManager.PERMISSION_GRANTED) {
this.avatar = null;
@ -234,6 +234,8 @@ public class EntityMessage implements Serializable {
if (!TextUtils.isEmpty(displayName))
((InternetAddress) this.from[i]).setPersonal(displayName);
return true;
}
} finally {
if (cursor != null)
@ -244,6 +246,8 @@ public class EntityMessage implements Serializable {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
}
}
return false;
}
static String getQuote(Context context, long id) throws IOException {

View File

@ -1202,7 +1202,7 @@ public class FragmentCompose extends FragmentEx {
result.draft.content = true;
result.draft.received = new Date().getTime();
result.draft.getAvatar(context);
result.draft.setContactInfo(context);
result.draft.id = db.message().insertMessage(result.draft);
result.draft.write(context, body == null ? "" : body);

View File

@ -215,7 +215,7 @@ public class Helper {
draft.subject = context.getString(R.string.app_name) + " " + BuildConfig.VERSION_NAME + " crash log";
draft.content = true;
draft.received = new Date().getTime();
draft.getAvatar(context);
draft.setContactInfo(context);
draft.id = db.message().insertMessage(draft);
draft.write(context, body);

View File

@ -2193,7 +2193,6 @@ public class ServiceSynchronize extends LifecycleService {
message.ui_found = false;
message.ui_ignored = false;
message.ui_browsed = browsed;
message.getAvatar(context);
message.id = db.message().insertMessage(message);
@ -2249,11 +2248,6 @@ public class ServiceSynchronize extends LifecycleService {
Log.i(Helper.TAG, folder.name + " updated id=" + message.id + " uid=" + message.uid + " unhide");
}
boolean noavatar = TextUtils.isEmpty(message.avatar);
message.getAvatar(context);
if (noavatar != TextUtils.isEmpty(message.avatar))
update = true;
if (update)
db.message().updateMessage(message);
}
@ -2287,6 +2281,9 @@ public class ServiceSynchronize extends LifecycleService {
List<EntityAttachment> attachments = db.attachment().getAttachments(message.id);
MessageHelper helper = new MessageHelper(imessage);
if (message.setContactInfo(context))
db.message().updateMessage(message);
boolean fetch = false;
if (!message.content)
if (!metered || (message.size != null && message.size < download))