1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-27 02:07:12 +00:00

Added button delete replied/forwarded message text

This commit is contained in:
M66B 2019-09-09 17:37:22 +02:00
parent 01195e448d
commit 3590be3e33
4 changed files with 99 additions and 9 deletions

View file

@ -177,6 +177,7 @@ public class FragmentCompose extends FragmentBase {
private CheckBox cbSignature;
private TextView tvReference;
private ImageButton ibCloseRefHint;
private ImageButton ibReferenceDelete;
private ImageButton ibReferenceEdit;
private ImageButton ibReferenceImages;
private BottomNavigationView edit_bar;
@ -226,12 +227,13 @@ public class FragmentCompose extends FragmentBase {
private static final int REQUEST_ENCRYPT = 8;
private static final int REQUEST_COLOR = 9;
private static final int REQUEST_SEND_AFTER = 10;
private static final int REQUEST_REF_EDIT = 11;
private static final int REQUEST_CONTACT_GROUP = 12;
private static final int REQUEST_ANSWER = 13;
private static final int REQUEST_LINK = 14;
private static final int REQUEST_DISCARD = 15;
private static final int REQUEST_SEND = 16;
private static final int REQUEST_REF_DELETE = 11;
private static final int REQUEST_REF_EDIT = 12;
private static final int REQUEST_CONTACT_GROUP = 13;
private static final int REQUEST_ANSWER = 14;
private static final int REQUEST_LINK = 15;
private static final int REQUEST_DISCARD = 16;
private static final int REQUEST_SEND = 17;
@Override
public void onCreate(Bundle savedInstanceState) {
@ -271,6 +273,7 @@ public class FragmentCompose extends FragmentBase {
cbSignature = view.findViewById(R.id.cbSignature);
tvReference = view.findViewById(R.id.tvReference);
ibCloseRefHint = view.findViewById(R.id.ibCloseRefHint);
ibReferenceDelete = view.findViewById(R.id.ibReferenceDelete);
ibReferenceEdit = view.findViewById(R.id.ibReferenceEdit);
ibReferenceImages = view.findViewById(R.id.ibReferenceImages);
edit_bar = view.findViewById(R.id.edit_bar);
@ -392,6 +395,13 @@ public class FragmentCompose extends FragmentBase {
}
});
ibReferenceDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onReferenceDelete();
}
});
ibReferenceEdit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -479,6 +489,7 @@ public class FragmentCompose extends FragmentBase {
grpBody.setVisibility(View.GONE);
grpSignature.setVisibility(View.GONE);
grpReferenceHint.setVisibility(View.GONE);
ibReferenceDelete.setVisibility(View.GONE);
ibReferenceEdit.setVisibility(View.GONE);
ibReferenceImages.setVisibility(View.GONE);
tvReference.setVisibility(View.GONE);
@ -581,6 +592,67 @@ public class FragmentCompose extends FragmentBase {
return view;
}
private void onReferenceDelete() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
if (prefs.getBoolean("delete_ref_confirmed", false)) {
onReferenceDeleteConfirmed();
return;
}
Bundle args = new Bundle();
args.putString("question", getString(R.string.title_ask_delete_ref));
args.putString("notagain", "delete_ref_confirmed");
FragmentDialogAsk fragment = new FragmentDialogAsk();
fragment.setArguments(args);
fragment.setTargetFragment(this, REQUEST_REF_DELETE);
fragment.show(getFragmentManager(), "compose:refdelete");
}
private void onReferenceDeleteConfirmed() {
Bundle args = new Bundle();
args.putLong("id", working);
new SimpleTask<EntityMessage>() {
@Override
protected void onPreExecute(Bundle args) {
ibReferenceDelete.setEnabled(false);
ibReferenceEdit.setEnabled(false);
}
@Override
protected void onPostExecute(Bundle args) {
ibReferenceDelete.setEnabled(true);
ibReferenceEdit.setEnabled(true);
}
@Override
protected EntityMessage onExecute(Context context, Bundle args) throws Throwable {
long id = args.getLong("id");
DB db = DB.getInstance(context);
EntityMessage draft = db.message().getMessage(id);
if (draft != null) {
File refFile = draft.getRefFile(context);
refFile.delete();
}
return draft;
}
@Override
protected void onExecuted(Bundle args, EntityMessage draft) {
if (draft != null)
showDraft(draft);
}
@Override
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getFragmentManager(), ex);
}
}.execute(FragmentCompose.this, args, "compose:refdelete");
}
private void onReferenceEdit() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
if (prefs.getBoolean("edit_ref_confirmed", false)) {
@ -606,11 +678,13 @@ public class FragmentCompose extends FragmentBase {
new SimpleTask<EntityMessage>() {
@Override
protected void onPreExecute(Bundle args) {
ibReferenceDelete.setEnabled(false);
ibReferenceEdit.setEnabled(false);
}
@Override
protected void onPostExecute(Bundle args) {
ibReferenceDelete.setEnabled(true);
ibReferenceEdit.setEnabled(true);
}
@ -1184,6 +1258,10 @@ public class FragmentCompose extends FragmentBase {
onSendAfter(args.getLong("time"));
}
break;
case REQUEST_REF_DELETE:
if (resultCode == RESULT_OK)
onReferenceDeleteConfirmed();
break;
case REQUEST_REF_EDIT:
if (resultCode == RESULT_OK)
onReferenceEditConfirmed();
@ -3052,6 +3130,7 @@ public class FragmentCompose extends FragmentBase {
tvReference.setText(text[1]);
tvReference.setVisibility(text[1] == null ? View.GONE : View.VISIBLE);
grpReferenceHint.setVisibility(text[1] == null || !ref_hint ? View.GONE : View.VISIBLE);
ibReferenceDelete.setVisibility(text[1] == null ? View.GONE : View.VISIBLE);
ibReferenceEdit.setVisibility(text[1] == null ? View.GONE : View.VISIBLE);
ibReferenceImages.setVisibility(ref_has_images && !show_images ? View.VISIBLE : View.GONE);

View file

@ -69,7 +69,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
};
private final static String[] RESET_QUESTIONS = new String[]{
"welcome", "show_html_confirmed", "print_html_confirmed", "edit_ref_confirmed", "crash_reports_asked"
"welcome", "show_html_confirmed", "print_html_confirmed", "delete_ref_confirmed", "edit_ref_confirmed", "crash_reports_asked"
};
@Override

View file

@ -313,10 +313,20 @@
android:text="@string/title_no_format"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toStartOf="@+id/ibReferenceEdit"
app:layout_constraintEnd_toStartOf="@+id/ibReferenceDelete"
app:layout_constraintStart_toEndOf="@id/ibCloseRefHint"
app:layout_constraintTop_toBottomOf="@id/vSeparatorSignature" />
<ImageButton
android:id="@+id/ibReferenceDelete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="6dp"
android:contentDescription="@string/title_legend_edit"
app:layout_constraintEnd_toStartOf="@+id/ibReferenceEdit"
app:layout_constraintTop_toBottomOf="@id/vSeparatorSignature"
app:srcCompat="@drawable/baseline_delete_24" />
<ImageButton
android:id="@+id/ibReferenceEdit"
android:layout_width="wrap_content"
@ -342,7 +352,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="bottom"
app:constraint_referenced_ids="ibCloseRefHint,tvReferenceHint,ibReferenceEdit,ibReferenceImages" />
app:constraint_referenced_ids="ibCloseRefHint,tvReferenceHint,ibReferenceDelete,ibReferenceEdit,ibReferenceImages" />
<TextView
android:id="@+id/tvReference"

View file

@ -531,6 +531,7 @@
<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_image">Showing images can leak privacy sensitive information</string>
<string name="title_ask_delete_ref">Delete replied/forwarded message text? This cannot be undone.</string>
<string name="title_ask_edit_ref">Edit reformatted replied/forwarded message text?</string>
<string name="title_ask_sync_all">Synchronize all messages in %1$s?</string>
<string name="title_ask_delete_local">Delete local messages? Messages will remain on the remote server.</string>