Added displaying and sending sensitivity

pull/194/merge
M66B 3 years ago
parent 0834873524
commit ae36359805

@ -340,6 +340,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private ImageButton ibVerified;
private ImageButton ibAuth;
private ImageButton ibPriority;
private ImageButton ibSensitivity;
private ImageView ivImportance;
private ImageView ivSigned;
private ImageView ivEncrypted;
@ -648,6 +649,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibVerified = itemView.findViewById(R.id.ibVerified);
ibAuth = itemView.findViewById(R.id.ibAuth);
ibPriority = itemView.findViewById(R.id.ibPriority);
ibSensitivity = itemView.findViewById(R.id.ibSensitivity);
ivImportance = itemView.findViewById(R.id.ivImportance);
ivSigned = itemView.findViewById(R.id.ivSigned);
ivEncrypted = itemView.findViewById(R.id.ivEncrypted);
@ -911,6 +913,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibVerified.setOnClickListener(this);
ibAuth.setOnClickListener(this);
ibPriority.setOnClickListener(this);
ibSensitivity.setOnClickListener(this);
ibSnoozed.setOnClickListener(this);
ibFlagged.setOnClickListener(this);
if (viewType == ViewType.THREAD) {
@ -1014,6 +1017,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibVerified.setOnClickListener(null);
ibAuth.setOnClickListener(null);
ibPriority.setOnClickListener(null);
ibSensitivity.setOnClickListener(null);
ibSnoozed.setOnClickListener(null);
ibFlagged.setOnClickListener(null);
if (viewType == ViewType.THREAD) {
@ -1156,6 +1160,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibVerified.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
ibAuth.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
ibPriority.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
ibSensitivity.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
ivImportance.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
ivSigned.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
ivEncrypted.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
@ -1243,6 +1248,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} else
ibPriority.setVisibility(View.GONE);
ibSensitivity.setImageLevel(message.sensitivity == null ? 0 : message.sensitivity);
ibSensitivity.setVisibility(message.sensitivity == null ? View.GONE : View.VISIBLE);
if (EntityMessage.PRIORITIY_HIGH.equals(message.ui_importance)) {
ivImportance.setImageLevel(message.ui_importance);
ivImportance.setVisibility(View.VISIBLE);
@ -3503,6 +3511,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
onShowAuth(message);
else if (id == R.id.ibPriority)
onShowPriority(message);
else if (id == R.id.ibSensitivity)
onShowSensitivity(message);
else if (id == R.id.ibSnoozed)
onShowSnoozed(message);
else if (id == R.id.ibFlagged)
@ -3974,6 +3984,18 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ToastEx.makeText(context, R.string.title_legend_priority_low, Toast.LENGTH_LONG).show();
}
private void onShowSensitivity(TupleMessageEx message) {
int resid = -1;
if (EntityMessage.SENSITIVITY_PERSONAL.equals(message.sensitivity))
resid = R.string.title_legend_sensitivity_personal;
else if (EntityMessage.SENSITIVITY_PRIVATE.equals(message.sensitivity))
resid = R.string.title_legend_sensitivity_private;
else if (EntityMessage.SENSITIVITY_CONFIDENTIAL.equals(message.sensitivity))
resid = R.string.title_legend_sensitivity_confidential;
if (resid > 0)
ToastEx.makeText(context, resid, Toast.LENGTH_LONG).show();
}
private void onShowSnoozed(TupleMessageEx message) {
if (message.ui_snoozed != null && message.ui_snoozed != Long.MAX_VALUE) {
DateFormat DTF = Helper.getDateTimeInstance(context, SimpleDateFormat.MEDIUM, SimpleDateFormat.SHORT);

@ -677,6 +677,9 @@ public interface DaoMessage {
@Query("UPDATE message SET priority = :priority WHERE id = :id AND NOT (priority IS :priority)")
int setMessagePriority(long id, Integer priority);
@Query("UPDATE message SET sensitivity = :sensitivity WHERE id = :id AND NOT (sensitivity IS :sensitivity)")
int setMessageSensitivity(long id, Integer sensitivity);
@Query("UPDATE message SET importance = :importance WHERE id = :id AND NOT (importance IS :importance)")
int setMessageImportance(long id, Integer importance);

@ -6959,6 +6959,7 @@ public class FragmentCompose extends FragmentBase {
final Spinner spEncrypt = dview.findViewById(R.id.spEncrypt);
final ImageButton ibEncryption = dview.findViewById(R.id.ibEncryption);
final Spinner spPriority = dview.findViewById(R.id.spPriority);
final Spinner spSensitivity = dview.findViewById(R.id.spSensitivity);
final TextView tvSendAt = dview.findViewById(R.id.tvSendAt);
final ImageButton ibSendAt = dview.findViewById(R.id.ibSendAt);
final CheckBox cbArchive = dview.findViewById(R.id.cbArchive);
@ -7007,6 +7008,8 @@ public class FragmentCompose extends FragmentBase {
spEncrypt.setSelection(0);
spPriority.setTag(1);
spPriority.setSelection(1);
spSensitivity.setTag(0);
spSensitivity.setSelection(0);
tvSendAt.setText(null);
cbArchive.setEnabled(false);
cbNotAgain.setChecked(!send_dialog);
@ -7219,6 +7222,47 @@ public class FragmentCompose extends FragmentBase {
}
});
spSensitivity.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
int last = (int) spSensitivity.getTag();
if (last != position) {
spSensitivity.setTag(position);
setSensitivity(position);
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
spSensitivity.setTag(0);
setSensitivity(0);
}
private void setSensitivity(int sensitivity) {
Bundle args = new Bundle();
args.putLong("id", id);
args.putInt("sensitivity", sensitivity);
new SimpleTask<Void>() {
@Override
protected Void onExecute(Context context, Bundle args) {
long id = args.getLong("id");
int sensitivity = args.getInt("sensitivity");
DB db = DB.getInstance(context);
db.message().setMessageSensitivity(id, sensitivity < 1 ? null : sensitivity);
return null;
}
@Override
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(getParentFragmentManager(), ex);
}
}.setExecutor(executor).execute(FragmentDialogSend.this, args, "compose:sensitivity");
}
});
ibSendAt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@ -7289,6 +7333,10 @@ public class FragmentCompose extends FragmentBase {
spPriority.setTag(priority);
spPriority.setSelection(priority);
int sensitivity = (draft.sensitivity == null ? 0 : draft.sensitivity);
spSensitivity.setTag(sensitivity);
spSensitivity.setSelection(sensitivity);
if (draft.ui_snoozed == null) {
if (send_delayed == 0)
tvSendAt.setText(getString(R.string.title_now));

@ -283,6 +283,14 @@ public class MessageHelper {
imessage.addHeader("X-MSMail-Priority", "High");
}
// Sensitivity
if (EntityMessage.SENSITIVITY_PERSONAL.equals(message.sensitivity))
imessage.addHeader("Sensitivity", "Personal");
else if (EntityMessage.SENSITIVITY_PRIVATE.equals(message.sensitivity))
imessage.addHeader("Sensitivity", "Private");
else if (EntityMessage.SENSITIVITY_CONFIDENTIAL.equals(message.sensitivity))
imessage.addHeader("Sensitivity", "Company-Confidential");
// References
if (message.references != null) {
// https://tools.ietf.org/html/rfc5322#section-2.1.1

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/twotone_person_24"
android:maxLevel="1" />
<item
android:drawable="@drawable/twotone_people_24"
android:maxLevel="2" />
<item
android:drawable="@drawable/twotone_business_24"
android:maxLevel="3" />
</level-list>

@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M12,11h2v2h-2v2h2v2h-2v2h8L20,9h-8v2zM16,11h2v2h-2v-2zM16,15h2v2h-2v-2z"
android:strokeAlpha="0.3"
android:fillAlpha="0.3"/>
<path
android:fillColor="@android:color/white"
android:pathData="M16,15h2v2h-2zM16,11h2v2h-2zM22,7L12,7L12,3L2,3v18h20L22,7zM6,19L4,19v-2h2v2zM6,15L4,15v-2h2v2zM6,11L4,11L4,9h2v2zM6,7L4,7L4,5h2v2zM10,19L8,19v-2h2v2zM10,15L8,15v-2h2v2zM10,11L8,11L8,9h2v2zM10,7L8,7L8,5h2v2zM20,19h-8v-2h2v-2h-2v-2h2v-2h-2L12,9h8v10z"/>
</vector>

@ -391,6 +391,29 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvPriority" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvSensitivity"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginEnd="12dp"
android:text="@string/title_send_sensitivity"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintEnd_toStartOf="@id/ibEncryption"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spPriority" />
<Spinner
android:id="@+id/spSensitivity"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:layout_marginEnd="12dp"
android:entries="@array/sensitivityNames"
app:layout_constraintEnd_toStartOf="@id/ibEncryption"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSensitivity" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvSendTitle"
android:layout_width="0dp"
@ -401,7 +424,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintEnd_toStartOf="@+id/ibSendAt"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/spPriority" />
app:layout_constraintTop_toBottomOf="@+id/spSensitivity" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvSendAt"

@ -176,6 +176,78 @@
app:layout_constraintStart_toEndOf="@id/ivLowPriority"
app:layout_constraintTop_toBottomOf="@id/tvHighPriority" />
<eu.faircode.email.FixedImageView
android:id="@+id/ivPersonalSensitivity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/title_legend_sensitivity_personal"
android:padding="12dp"
app:layout_constraintBottom_toBottomOf="@+id/tvPersonalSensitivity"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/tvPersonalSensitivity"
app:srcCompat="@drawable/twotone_person_24"
app:tint="?attr/colorAccent" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvPersonalSensitivity"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:minHeight="48dp"
android:text="@string/title_legend_sensitivity_personal"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/ivPersonalSensitivity"
app:layout_constraintTop_toBottomOf="@id/tvLowPriority" />
<eu.faircode.email.FixedImageView
android:id="@+id/ivPrivateSensitivity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/title_legend_sensitivity_private"
android:padding="12dp"
app:layout_constraintBottom_toBottomOf="@+id/tvPrivateSensitivity"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/tvPrivateSensitivity"
app:srcCompat="@drawable/twotone_people_24"
app:tint="?attr/colorAccent" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvPrivateSensitivity"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:minHeight="48dp"
android:text="@string/title_legend_sensitivity_private"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/ivPrivateSensitivity"
app:layout_constraintTop_toBottomOf="@id/tvPersonalSensitivity" />
<eu.faircode.email.FixedImageView
android:id="@+id/ivConfidentialSensitivity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/title_legend_sensitivity_confidential"
android:padding="12dp"
app:layout_constraintBottom_toBottomOf="@+id/tvConfidentialSensitivity"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/tvConfidentialSensitivity"
app:srcCompat="@drawable/twotone_business_24"
app:tint="?attr/colorAccent" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvConfidentialSensitivity"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:minHeight="48dp"
android:text="@string/title_legend_sensitivity_confidential"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/ivConfidentialSensitivity"
app:layout_constraintTop_toBottomOf="@id/tvPrivateSensitivity" />
<eu.faircode.email.FixedImageView
android:id="@+id/ivHighImportance"
android:layout_width="wrap_content"
@ -197,7 +269,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/ivHighImportance"
app:layout_constraintTop_toBottomOf="@id/tvLowPriority" />
app:layout_constraintTop_toBottomOf="@id/tvConfidentialSensitivity" />
<eu.faircode.email.FixedImageView
android:id="@+id/ivLowImportance"

@ -94,13 +94,25 @@
app:srcCompat="@drawable/priority"
app:tint="?attr/colorAccent" />
<eu.faircode.email.FixedImageButton
android:id="@+id/ibSensitivity"
android:layout_width="21dp"
android:layout_height="21dp"
android:layout_marginStart="6dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
app:layout_constraintBottom_toBottomOf="@+id/tvFrom"
app:layout_constraintStart_toEndOf="@id/ibPriority"
app:layout_constraintTop_toTopOf="@+id/tvFrom"
app:srcCompat="@drawable/sensitivity"
app:tint="?attr/colorAccent" />
<eu.faircode.email.FixedImageView
android:id="@+id/ivImportance"
android:layout_width="21dp"
android:layout_height="21dp"
android:layout_marginStart="6dp"
app:layout_constraintBottom_toBottomOf="@+id/tvFrom"
app:layout_constraintStart_toEndOf="@id/ibPriority"
app:layout_constraintStart_toEndOf="@id/ibSensitivity"
app:layout_constraintTop_toTopOf="@+id/tvFrom"
app:srcCompat="@drawable/importance"
app:tint="?attr/colorAccent" />

@ -93,13 +93,25 @@
app:srcCompat="@drawable/priority"
app:tint="?attr/colorAccent" />
<eu.faircode.email.FixedImageButton
android:id="@+id/ibSensitivity"
android:layout_width="21dp"
android:layout_height="21dp"
android:layout_marginStart="6dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
app:layout_constraintBottom_toBottomOf="@+id/tvFrom"
app:layout_constraintStart_toEndOf="@id/ibPriority"
app:layout_constraintTop_toTopOf="@+id/tvFrom"
app:srcCompat="@drawable/sensitivity"
app:tint="?attr/colorAccent" />
<eu.faircode.email.FixedImageView
android:id="@+id/ivImportance"
android:layout_width="21dp"
android:layout_height="21dp"
android:layout_marginStart="6dp"
app:layout_constraintBottom_toBottomOf="@+id/tvFrom"
app:layout_constraintStart_toEndOf="@id/ibPriority"
app:layout_constraintStart_toEndOf="@id/ibSensitivity"
app:layout_constraintTop_toTopOf="@+id/tvFrom"
app:srcCompat="@drawable/importance"
app:tint="?attr/colorAccent" />

@ -1249,6 +1249,7 @@
<string name="title_send_auto_archive">Archive replied message</string>
<string name="title_send_encryption">Encryption</string>
<string name="title_send_priority">Priority</string>
<string name="title_send_sensitivity">Sensitivity</string>
<string name="title_no_server">No server found at \'%1$s\'</string>
<string name="title_style">Style</string>
@ -1606,6 +1607,9 @@
<string name="title_legend_draft">Has draft</string>
<string name="title_legend_priority">Has high priority</string>
<string name="title_legend_priority_low">Has low priority</string>
<string name="title_legend_sensitivity_personal">Is personal</string>
<string name="title_legend_sensitivity_private">Is private</string>
<string name="title_legend_sensitivity_confidential">Is confidential</string>
<string name="title_legend_importance">Is important</string>
<string name="title_legend_importance_low">Is not important</string>
<string name="title_legend_signed">Is signed</string>

Loading…
Cancel
Save