mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-11 06:33:29 +00:00
Draft from template
This commit is contained in:
parent
3d9c78402d
commit
dd61347b95
4 changed files with 54 additions and 3 deletions
1
FAQ.md
1
FAQ.md
|
@ -950,6 +950,7 @@ but even Google's Chrome cannot handle this.
|
|||
* Did you know there is an advanced option to mark messages read when they are moved and that archiving and trashing is also moving?
|
||||
* Did you know that you can select text (or an email address) in any app on recent Android versions and let FairEmail search for it? You'll need to set a primary account and an archive folder for this to work, so FairEmail knows where to search. There will be 'FairEmail' in the menu with copy, cut, etc.
|
||||
* Did you know that FairEmail has a tablet mode? Rotate your device in landscape mode and conversation threads will be opened in a second column if there is enough screen space.
|
||||
* Did you know that you can long press a reply template to create a draft message from the template?
|
||||
|
||||
<br />
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ package eu.faircode.email;
|
|||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -34,6 +35,7 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
import androidx.recyclerview.widget.DiffUtil;
|
||||
import androidx.recyclerview.widget.ListUpdateCallback;
|
||||
|
@ -41,12 +43,15 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
|
||||
public class AdapterAnswer extends RecyclerView.Adapter<AdapterAnswer.ViewHolder> {
|
||||
private Context context;
|
||||
private LifecycleOwner owner;
|
||||
private LayoutInflater inflater;
|
||||
|
||||
private List<EntityAnswer> all = new ArrayList<>();
|
||||
private List<EntityAnswer> filtered = new ArrayList<>();
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
private EntityAccount primary = null;
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
|
||||
View itemView;
|
||||
TextView tvName;
|
||||
|
||||
|
@ -59,10 +64,12 @@ public class AdapterAnswer extends RecyclerView.Adapter<AdapterAnswer.ViewHolder
|
|||
|
||||
private void wire() {
|
||||
itemView.setOnClickListener(this);
|
||||
itemView.setOnLongClickListener(this);
|
||||
}
|
||||
|
||||
private void unwire() {
|
||||
itemView.setOnClickListener(null);
|
||||
itemView.setOnLongClickListener(null);
|
||||
}
|
||||
|
||||
private void bindTo(EntityAnswer answer) {
|
||||
|
@ -82,12 +89,48 @@ public class AdapterAnswer extends RecyclerView.Adapter<AdapterAnswer.ViewHolder
|
|||
new Intent(ActivityView.ACTION_EDIT_ANSWER)
|
||||
.putExtra("id", answer.id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
if (primary == null)
|
||||
return false;
|
||||
|
||||
int pos = getAdapterPosition();
|
||||
if (pos == RecyclerView.NO_POSITION)
|
||||
return false;
|
||||
|
||||
EntityAnswer answer = filtered.get(pos);
|
||||
|
||||
context.startActivity(new Intent(context, ActivityCompose.class)
|
||||
.putExtra("action", "new")
|
||||
.putExtra("answer", answer.id));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
AdapterAnswer(Context context) {
|
||||
AdapterAnswer(Context context, LifecycleOwner owner) {
|
||||
this.context = context;
|
||||
this.owner = owner;
|
||||
this.inflater = LayoutInflater.from(context);
|
||||
setHasStableIds(true);
|
||||
|
||||
new SimpleTask<EntityAccount>() {
|
||||
@Override
|
||||
protected EntityAccount onExecute(Context context, Bundle args) {
|
||||
return DB.getInstance(context).account().getPrimaryAccount();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, EntityAccount account) {
|
||||
primary = account;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Helper.unexpectedError(AdapterAnswer.this.context, AdapterAnswer.this.owner, ex);
|
||||
}
|
||||
}.execute(context, owner, new Bundle(), "answer:account:primary");
|
||||
}
|
||||
|
||||
public void set(@NonNull List<EntityAnswer> answers) {
|
||||
|
|
|
@ -63,7 +63,7 @@ public class FragmentAnswers extends FragmentEx {
|
|||
LinearLayoutManager llm = new LinearLayoutManager(getContext());
|
||||
rvAnswer.setLayoutManager(llm);
|
||||
|
||||
adapter = new AdapterAnswer(getContext());
|
||||
adapter = new AdapterAnswer(getContext(), getViewLifecycleOwner());
|
||||
rvAnswer.setAdapter(adapter);
|
||||
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
|
|
|
@ -1520,6 +1520,13 @@ public class FragmentCompose extends FragmentEx {
|
|||
result.draft.subject = args.getString("subject", "");
|
||||
body = args.getString("body", "");
|
||||
body = body.replaceAll("\\r?\\n", "<br />");
|
||||
|
||||
if (answer > 0) {
|
||||
String text = db.answer().getAnswer(answer).text;
|
||||
text = text.replace("$name$", "");
|
||||
text = text.replace("$email$", "");
|
||||
body = text + body;
|
||||
}
|
||||
} else {
|
||||
result.draft.thread = ref.thread;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue