mirror of https://github.com/M66B/FairEmail.git
Added button to remove all attachments
This commit is contained in:
parent
aa6f72ec1d
commit
3f043372ec
|
@ -157,6 +157,10 @@ public interface DaoAttachment {
|
||||||
" WHERE id = :id")
|
" WHERE id = :id")
|
||||||
int deleteAttachment(long id);
|
int deleteAttachment(long id);
|
||||||
|
|
||||||
|
@Query("DELETE FROM attachment" +
|
||||||
|
" WHERE message = :message")
|
||||||
|
int deleteAttachments(long message);
|
||||||
|
|
||||||
@Query("DELETE FROM attachment" +
|
@Query("DELETE FROM attachment" +
|
||||||
" WHERE message = :message" +
|
" WHERE message = :message" +
|
||||||
" AND (encryption IS NULL OR encryption NOT IN (:keep))")
|
" AND (encryption IS NULL OR encryption NOT IN (:keep))")
|
||||||
|
|
|
@ -240,6 +240,7 @@ public class FragmentCompose extends FragmentBase {
|
||||||
private ImageButton ibBccAdd;
|
private ImageButton ibBccAdd;
|
||||||
private EditText etSubject;
|
private EditText etSubject;
|
||||||
private ImageButton ibCcBcc;
|
private ImageButton ibCcBcc;
|
||||||
|
private ImageButton ibRemoveAttachments;
|
||||||
private RecyclerView rvAttachment;
|
private RecyclerView rvAttachment;
|
||||||
private TextView tvNoInternetAttachments;
|
private TextView tvNoInternetAttachments;
|
||||||
private TextView tvDsn;
|
private TextView tvDsn;
|
||||||
|
@ -320,6 +321,7 @@ public class FragmentCompose extends FragmentBase {
|
||||||
private static final int REQUEST_LINK = 12;
|
private static final int REQUEST_LINK = 12;
|
||||||
private static final int REQUEST_DISCARD = 13;
|
private static final int REQUEST_DISCARD = 13;
|
||||||
private static final int REQUEST_SEND = 14;
|
private static final int REQUEST_SEND = 14;
|
||||||
|
private static final int REQUEST_REMOVE_ATTACHMENTS = 15;
|
||||||
|
|
||||||
private static ExecutorService executor = Helper.getBackgroundExecutor(1, "compose");
|
private static ExecutorService executor = Helper.getBackgroundExecutor(1, "compose");
|
||||||
|
|
||||||
|
@ -356,6 +358,7 @@ public class FragmentCompose extends FragmentBase {
|
||||||
ibBccAdd = view.findViewById(R.id.ibBccAdd);
|
ibBccAdd = view.findViewById(R.id.ibBccAdd);
|
||||||
etSubject = view.findViewById(R.id.etSubject);
|
etSubject = view.findViewById(R.id.etSubject);
|
||||||
ibCcBcc = view.findViewById(R.id.ibCcBcc);
|
ibCcBcc = view.findViewById(R.id.ibCcBcc);
|
||||||
|
ibRemoveAttachments = view.findViewById(R.id.ibRemoveAttachments);
|
||||||
rvAttachment = view.findViewById(R.id.rvAttachment);
|
rvAttachment = view.findViewById(R.id.rvAttachment);
|
||||||
tvNoInternetAttachments = view.findViewById(R.id.tvNoInternetAttachments);
|
tvNoInternetAttachments = view.findViewById(R.id.tvNoInternetAttachments);
|
||||||
tvDsn = view.findViewById(R.id.tvDsn);
|
tvDsn = view.findViewById(R.id.tvDsn);
|
||||||
|
@ -1206,6 +1209,20 @@ public class FragmentCompose extends FragmentBase {
|
||||||
|
|
||||||
grpAddresses.setVisibility(cc_bcc ? View.VISIBLE : View.GONE);
|
grpAddresses.setVisibility(cc_bcc ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
|
ibRemoveAttachments.setVisibility(View.GONE);
|
||||||
|
ibRemoveAttachments.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putString("question", getString(R.string.title_ask_delete_attachments));
|
||||||
|
|
||||||
|
FragmentDialogAsk fragment = new FragmentDialogAsk();
|
||||||
|
fragment.setArguments(args);
|
||||||
|
fragment.setTargetFragment(FragmentCompose.this, REQUEST_REMOVE_ATTACHMENTS);
|
||||||
|
fragment.show(getParentFragmentManager(), "compose:discard");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
rvAttachment.setHasFixedSize(false);
|
rvAttachment.setHasFixedSize(false);
|
||||||
LinearLayoutManager llm = new LinearLayoutManager(getContext());
|
LinearLayoutManager llm = new LinearLayoutManager(getContext());
|
||||||
rvAttachment.setLayoutManager(llm);
|
rvAttachment.setLayoutManager(llm);
|
||||||
|
@ -2543,6 +2560,10 @@ public class FragmentCompose extends FragmentBase {
|
||||||
onAction(R.id.action_send, extras, "sendnow");
|
onAction(R.id.action_send, extras, "sendnow");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case REQUEST_REMOVE_ATTACHMENTS:
|
||||||
|
if (resultCode == RESULT_OK)
|
||||||
|
onRemoveAttachments();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Log.e(ex);
|
Log.e(ex);
|
||||||
|
@ -3868,6 +3889,28 @@ public class FragmentCompose extends FragmentBase {
|
||||||
onAction(R.id.action_delete, "delete");
|
onAction(R.id.action_delete, "delete");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onRemoveAttachments() {
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putLong("id", working);
|
||||||
|
|
||||||
|
new SimpleTask<Void>() {
|
||||||
|
@Override
|
||||||
|
protected Void onExecute(Context context, Bundle args) throws Throwable {
|
||||||
|
long id = args.getLong("id");
|
||||||
|
|
||||||
|
DB db = DB.getInstance(context);
|
||||||
|
db.attachment().deleteAttachments(id);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onException(Bundle args, Throwable ex) {
|
||||||
|
Log.unexpectedError(getParentFragmentManager(), ex);
|
||||||
|
}
|
||||||
|
}.execute(FragmentCompose.this, args, "attachments:remove");
|
||||||
|
}
|
||||||
|
|
||||||
private void onExit() {
|
private void onExit() {
|
||||||
if (state == State.LOADED) {
|
if (state == State.LOADED) {
|
||||||
state = State.NONE;
|
state = State.NONE;
|
||||||
|
@ -5162,6 +5205,7 @@ public class FragmentCompose extends FragmentBase {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ibRemoveAttachments.setVisibility(attachments.size() > 2 ? View.VISIBLE : View.GONE);
|
||||||
grpAttachments.setVisibility(attachments.size() > 0 ? View.VISIBLE : View.GONE);
|
grpAttachments.setVisibility(attachments.size() > 0 ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
boolean downloading = false;
|
boolean downloading = false;
|
||||||
|
|
|
@ -240,14 +240,27 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/etSubject" />
|
app:layout_constraintTop_toBottomOf="@id/etSubject" />
|
||||||
|
|
||||||
|
<eu.faircode.email.FixedImageButton
|
||||||
|
android:id="@+id/ibRemoveAttachments"
|
||||||
|
android:layout_width="36dp"
|
||||||
|
android:layout_height="36dp"
|
||||||
|
android:layout_marginTop="6dp"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:contentDescription="@string/title_legend_delete"
|
||||||
|
android:padding="6dp"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/vSeparatorAttachments"
|
||||||
|
app:srcCompat="@drawable/twotone_delete_24" />
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/rvAttachment"
|
android:id="@+id/rvAttachment"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="6dp"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/vSeparatorAttachments" />
|
app:layout_constraintTop_toBottomOf="@+id/ibRemoveAttachments"
|
||||||
|
app:layout_goneMarginTop="6dp" />
|
||||||
|
|
||||||
<eu.faircode.email.FixedTextView
|
<eu.faircode.email.FixedTextView
|
||||||
android:id="@+id/tvNoInternetAttachments"
|
android:id="@+id/tvNoInternetAttachments"
|
||||||
|
|
|
@ -1233,6 +1233,7 @@
|
||||||
<string name="title_ask_delete_accept">I understand that permanently deleting messages is irreversible</string>
|
<string name="title_ask_delete_accept">I understand that permanently deleting messages is irreversible</string>
|
||||||
<string name="title_ask_delete_answer">Delete reply template permanently?</string>
|
<string name="title_ask_delete_answer">Delete reply template permanently?</string>
|
||||||
<string name="title_ask_delete_rule">Delete rule permanently?</string>
|
<string name="title_ask_delete_rule">Delete rule permanently?</string>
|
||||||
|
<string name="title_ask_delete_attachments">Remove all attachments?</string>
|
||||||
<string name="title_ask_discard">Discard draft?</string>
|
<string name="title_ask_discard">Discard draft?</string>
|
||||||
<string name="title_ask_show_html">Showing the original message can leak privacy sensitive information</string>
|
<string name="title_ask_show_html">Showing the original message can leak privacy sensitive information</string>
|
||||||
<string name="title_ask_show_html_remark">Displaying the original message on a dark background is not possible as it may make dark texts and images invisible</string>
|
<string name="title_ask_show_html_remark">Displaying the original message on a dark background is not possible as it may make dark texts and images invisible</string>
|
||||||
|
|
Loading…
Reference in New Issue