Added message priority

pull/162/head
M66B 5 years ago
parent 9218aad5b4
commit c5f9d495e5

File diff suppressed because it is too large Load Diff

@ -254,6 +254,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private TextView tvSize;
private TextView tvTime;
private ImageView ivType;
private ImageView ivPriority;
private ImageView ibAuth;
private ImageView ibSnoozed;
private ImageView ivBrowsed;
@ -365,6 +366,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
tvSize = itemView.findViewById(R.id.tvSize);
tvTime = itemView.findViewById(R.id.tvTime);
ivType = itemView.findViewById(R.id.ivType);
ivPriority = itemView.findViewById(R.id.ivPriority);
ibAuth = itemView.findViewById(R.id.ibAuth);
ibSnoozed = itemView.findViewById(R.id.ibSnoozed);
ivBrowsed = itemView.findViewById(R.id.ivBrowsed);
@ -611,6 +613,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
tvSize.setText(null);
tvTime.setText(null);
ivType.setVisibility(View.GONE);
ivPriority.setVisibility(View.GONE);
ibAuth.setVisibility(View.GONE);
ibSnoozed.setVisibility(View.GONE);
ivBrowsed.setVisibility(View.GONE);
@ -677,6 +680,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
tvSize.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
tvTime.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
ivType.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
ivPriority.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
ibAuth.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
ibSnoozed.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
ivBrowsed.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
@ -763,6 +767,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
(viewType == ViewType.THREAD && EntityFolder.SENT.equals(message.folderType))
? View.VISIBLE : View.GONE);
}
ivPriority.setVisibility(EntityMessage.PRIORITIY_HIGH.equals(message.priority) ? View.VISIBLE : View.GONE);
ibAuth.setVisibility(authentication && !authenticated ? View.VISIBLE : View.GONE);
ibSnoozed.setVisibility(message.ui_snoozed == null ? View.GONE : View.VISIBLE);
ivBrowsed.setVisibility(message.ui_browsed ? View.VISIBLE : View.GONE);

@ -1424,6 +1424,7 @@ class Core {
message.inreplyto = helper.getInReplyTo();
message.deliveredto = helper.getDeliveredTo();
message.thread = helper.getThreadId(context, account.id, 0);
message.priority = helper.getPriority();
message.receipt_request = helper.getReceiptRequested();
message.receipt_to = helper.getReceiptTo();
message.dkim = MessageHelper.getAuthentication("dkim", authentication);
@ -2042,6 +2043,7 @@ class Core {
// Local address contains control or whitespace in string ``mailing list someone@example.org''
message.deliveredto = helper.getDeliveredTo();
message.thread = helper.getThreadId(context, account.id, uid);
message.priority = helper.getPriority();
message.receipt_request = helper.getReceiptRequested();
message.receipt_to = helper.getReceiptTo();
message.dkim = MessageHelper.getAuthentication("dkim", authentication);

@ -58,7 +58,7 @@ import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 104,
version = 105,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -1034,6 +1034,13 @@ public abstract class DB extends RoomDatabase {
db.execSQL("UPDATE `message` SET ui_hide = 1 WHERE ui_hide <> 0");
}
})
.addMigrations(new Migration(104, 105) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `message` ADD COLUMN `priority` INTEGER");
}
})
.build();
}

@ -364,6 +364,9 @@ public interface DaoMessage {
@Query("UPDATE message SET msgid = :msgid WHERE id = :id")
int setMessageMsgId(long id, String msgid);
@Query("UPDATE message SET priority = :priority WHERE id = :id")
int setMessagePriority(long id, Integer priority);
@Query("UPDATE message SET notifying = :notifying WHERE id = :id")
int setMessageNotifying(long id, int notifying);

@ -78,6 +78,10 @@ import static androidx.room.ForeignKey.SET_NULL;
public class EntityMessage implements Serializable {
static final String TABLE_NAME = "message";
static final Integer PRIORITIY_LOW = 0;
static final Integer PRIORITIY_NORMAL = 1;
static final Integer PRIORITIY_HIGH = 2;
@PrimaryKey(autoGenerate = true)
public Long id;
@NonNull
@ -94,6 +98,7 @@ public class EntityMessage implements Serializable {
public String deliveredto;
public String inreplyto;
public String thread; // compose = null
public Integer priority;
public Boolean receipt_request;
public Address[] receipt_to;
public Boolean dkim;

@ -3435,6 +3435,7 @@ public class FragmentCompose extends FragmentBase {
final CheckBox cbEncrypt = dview.findViewById(R.id.cbEncrypt);
final TextView tvSendAt = dview.findViewById(R.id.tvSendAt);
final ImageButton ibSendAt = dview.findViewById(R.id.ibSendAt);
final Spinner spPriority = dview.findViewById(R.id.spPriority);
final TextView tvRemindSubject = dview.findViewById(R.id.tvRemindSubject);
final TextView tvRemindAttachment = dview.findViewById(R.id.tvRemindAttachment);
final CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
@ -3443,6 +3444,8 @@ public class FragmentCompose extends FragmentBase {
tvTo.setText(null);
tvVia.setText(null);
tvSendAt.setText(null);
spPriority.setTag(1);
spPriority.setSelection(1);
tvRemindSubject.setVisibility(remind_subject ? View.VISIBLE : View.GONE);
tvRemindAttachment.setVisibility(remind_attachment ? View.VISIBLE : View.GONE);
cbNotAgain.setChecked(!send_dialog);
@ -3487,6 +3490,10 @@ public class FragmentCompose extends FragmentBase {
DateFormat D = new SimpleDateFormat("E");
tvSendAt.setText(D.format(draft.ui_snoozed) + " " + DTF.format(draft.ui_snoozed));
}
int priority = (draft.priority == null ? 1 : draft.priority);
spPriority.setTag(priority);
spPriority.setSelection(priority);
}
});
@ -3558,6 +3565,47 @@ public class FragmentCompose extends FragmentBase {
}
});
spPriority.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
int last = (int) spPriority.getTag();
if (last != position) {
spPriority.setTag(position);
setPriority(position);
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
spPriority.setTag(1);
setPriority(1);
}
private void setPriority(int priority) {
Bundle args = new Bundle();
args.putLong("id", id);
args.putInt("priority", priority);
new SimpleTask<Void>() {
@Override
protected Void onExecute(Context context, Bundle args) {
long id = args.getLong("id");
int priority = args.getInt("priority");
DB db = DB.getInstance(context);
db.message().setMessagePriority(id, priority);
return null;
}
@Override
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getFragmentManager(), ex);
}
}.execute(FragmentDialogSend.this, args, "compose:priority");
}
});
return new AlertDialog.Builder(getContext())
.setView(dview)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

@ -119,6 +119,20 @@ public class MessageHelper {
DB db = DB.getInstance(context);
MimeMessageEx imessage = new MimeMessageEx(isession, message.msgid);
if (EntityMessage.PRIORITIY_LOW.equals(message.priority)) {
// Low
imessage.addHeader("Importance", "Low");
imessage.addHeader("Priority", "Non-Urgent");
imessage.addHeader("X-Priority", "5"); // Lowest
imessage.addHeader("X-MSMail-Priority", "Low");
} else if (EntityMessage.PRIORITIY_HIGH.equals(message.priority)) {
// High
imessage.addHeader("Importance", "High");
imessage.addHeader("Priority", "Urgent");
imessage.addHeader("X-Priority", "1"); // Highest
imessage.addHeader("X-MSMail-Priority", "High");
}
if (message.references != null)
imessage.addHeader("References", message.references);
if (message.inreplyto != null)
@ -456,6 +470,43 @@ public class MessageHelper {
return (TextUtils.isEmpty(msgid) ? Long.toString(uid) : msgid);
}
Integer getPriority() throws MessagingException {
Integer priority = null;
// https://docs.microsoft.com/en-us/openspecs/exchange_server_protocols/ms-oxcmail/2bb19f1b-b35e-4966-b1cb-1afd044e83ab
String header = imessage.getHeader("Importance", null);
if (header == null)
header = imessage.getHeader("Priority", null);
if (header == null)
header = imessage.getHeader("X-Priority", null);
if (header == null)
header = imessage.getHeader("X-MSMail-Priority", null);
if ("high".equalsIgnoreCase(header) || "urgent".equalsIgnoreCase(header))
priority = EntityMessage.PRIORITIY_HIGH;
else if ("normal".equalsIgnoreCase(header) || "medium".equalsIgnoreCase(header))
priority = EntityMessage.PRIORITIY_NORMAL;
else if ("low".equalsIgnoreCase(header) || "non-urgent".equalsIgnoreCase(header))
priority = EntityMessage.PRIORITIY_LOW;
else if (header != null)
try {
priority = Integer.parseInt(header);
if (priority < 3)
priority = EntityMessage.PRIORITIY_HIGH;
else if (priority > 3)
priority = EntityMessage.PRIORITIY_LOW;
else
priority = EntityMessage.PRIORITIY_NORMAL;
} catch (NumberFormatException ex) {
Log.e("priority=" + header);
}
if (EntityMessage.PRIORITIY_NORMAL.equals(priority))
priority = null;
return priority;
}
boolean getReceiptRequested() throws MessagingException {
return (imessage.getHeader("Return-Receipt-To") != null ||
imessage.getHeader("Disposition-Notification-To") != null);

@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M12,19m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0"/>
<path
android:fillColor="@android:color/white"
android:pathData="M10,3h4v12h-4z"/>
</vector>

@ -122,6 +122,26 @@
app:layout_constraintEnd_toEndOf="parent"
app:srcCompat="@drawable/baseline_timelapse_24" />
<TextView
android:id="@+id/tvPriority"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_send_priority"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ibSendAt" />
<Spinner
android:id="@+id/spPriority"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:entries="@array/priorityNames"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvPriority" />
<TextView
android:id="@+id/tvRemindSubject"
android:layout_width="wrap_content"
@ -131,7 +151,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="?attr/colorWarning"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ibSendAt" />
app:layout_constraintTop_toBottomOf="@id/spPriority" />
<TextView
android:id="@+id/tvRemindAttachment"

@ -78,6 +78,29 @@
app:layout_constraintStart_toEndOf="@id/ivDraft"
app:layout_constraintTop_toTopOf="@id/ivDraft" />
<ImageView
android:id="@+id/ivPriority"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/title_legend_priority"
android:padding="12dp"
android:tint="@color/colorError"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ivDraft"
app:srcCompat="@drawable/baseline_priority_high_24" />
<TextView
android:id="@+id/tvPriority"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center_vertical"
android:text="@string/title_legend_priority"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintBottom_toBottomOf="@id/ivPriority"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/ivPriority"
app:layout_constraintTop_toTopOf="@id/ivPriority" />
<ImageView
android:id="@+id/ivAuth"
android:layout_width="wrap_content"
@ -86,7 +109,7 @@
android:padding="12dp"
android:tint="@color/colorError"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ivDraft"
app:layout_constraintTop_toBottomOf="@id/ivPriority"
app:srcCompat="@drawable/baseline_flag_24" />
<TextView

@ -110,6 +110,18 @@
app:layout_constraintTop_toTopOf="@+id/tvSubject"
app:srcCompat="@drawable/baseline_edit_24" />
<ImageView
android:id="@+id/ivPriority"
android:layout_width="21dp"
android:layout_height="21dp"
android:layout_marginStart="6dp"
android:contentDescription="@string/title_send_priority"
android:tint="@color/colorError"
app:layout_constraintBottom_toBottomOf="@+id/tvSubject"
app:layout_constraintStart_toEndOf="@id/ivType"
app:layout_constraintTop_toTopOf="@+id/tvSubject"
app:srcCompat="@drawable/baseline_priority_high_24" />
<ImageButton
android:id="@+id/ibAuth"
android:layout_width="21dp"
@ -119,7 +131,7 @@
android:contentDescription="@string/title_legend_auth"
android:tint="@color/colorError"
app:layout_constraintBottom_toBottomOf="@+id/tvSubject"
app:layout_constraintStart_toEndOf="@id/ivType"
app:layout_constraintStart_toEndOf="@id/ivPriority"
app:layout_constraintTop_toTopOf="@+id/tvSubject"
app:srcCompat="@drawable/baseline_flag_24" />

@ -135,6 +135,18 @@
app:layout_constraintTop_toTopOf="@+id/tvFolder"
app:srcCompat="@drawable/baseline_edit_24" />
<ImageView
android:id="@+id/ivPriority"
android:layout_width="21dp"
android:layout_height="21dp"
android:layout_marginStart="6dp"
android:contentDescription="@string/title_send_priority"
android:tint="@color/colorError"
app:layout_constraintBottom_toBottomOf="@+id/tvFolder"
app:layout_constraintStart_toEndOf="@id/ivType"
app:layout_constraintTop_toTopOf="@+id/tvFolder"
app:srcCompat="@drawable/baseline_priority_high_24" />
<ImageButton
android:id="@+id/ibAuth"
android:layout_width="21dp"
@ -144,7 +156,7 @@
android:contentDescription="@string/title_legend_auth"
android:tint="@color/colorError"
app:layout_constraintBottom_toBottomOf="@+id/tvFolder"
app:layout_constraintStart_toEndOf="@id/ivType"
app:layout_constraintStart_toEndOf="@id/ivPriority"
app:layout_constraintTop_toTopOf="@+id/tvFolder"
app:srcCompat="@drawable/baseline_flag_24" />

@ -585,6 +585,7 @@
<string name="title_send_via">Send via</string>
<string name="title_send_with_options">Send &#8230;</string>
<string name="title_send_at">Send at &#8230;</string>
<string name="title_send_priority">Priority</string>
<string name="title_no_server">No server found at \'%1$s\'</string>
<string name="title_style_bold">Bold</string>
@ -749,6 +750,7 @@
<string name="title_legend_thread">Conversation</string>
<string name="title_legend_zoom">Change text size</string>
<string name="title_legend_draft">Has draft</string>
<string name="title_legend_priority">Has high priority</string>
<string name="title_legend_auth">Authentication failed</string>
<string name="title_legend_snoozed">Is snoozed</string>
<string name="title_legend_browsed">Is browsed or searched</string>
@ -1023,6 +1025,12 @@
<item>At the end</item>
</string-array>
<string-array name="priorityNames">
<item>Low</item>
<item>Normal</item>
<item>High</item>
</string-array>
<string name="fingerprint" translatable="false">17BA15C1AF55D925F98B99CEA4375D4CDF4C174B</string>
<string name="public_key" translatable="false">MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtFbxEbzL8u5accPGgBw/XdyiSS5BBE6ZQ9ELpKyJ/OQN+kdYniCAOw3lsQ/GuJScy4Y2HobqbBgLL8GLHG+Yu2EHC9dLjA3v2Mc25vvnfn86BsrpQvz1poN2n+roTBdq09FWbtebJ8m0hDBVmtfRi7RhTKIL4No3kodLhksdnucKjcFheubebWKgpmvbmw7NwuELhaZmyhw8WTtnQ4rZPMhjY1JJZgzwNExXgD7zzg4pJPkuQlfkuRkkvBpHpi3C7VDnYjrBlLHngI4wv3wxQBVwJqlvAT9PmX8dOVnTsWWdJdLQBZVWphuqVY54kjBIovN+o8w03WjsV9QiOQq+XwIDAQAB</string>
</resources>

Loading…
Cancel
Save