mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-24 07:01:05 +00:00
Long press 'write' to go to drafts
This commit is contained in:
parent
67b22a8cd4
commit
5c17b32e09
3 changed files with 29 additions and 11 deletions
|
@ -56,12 +56,6 @@ public interface DaoAccount {
|
||||||
@Query("SELECT * FROM account WHERE id = :id")
|
@Query("SELECT * FROM account WHERE id = :id")
|
||||||
LiveData<EntityAccount> liveAccount(long id);
|
LiveData<EntityAccount> liveAccount(long id);
|
||||||
|
|
||||||
@Query("SELECT account.* FROM account" +
|
|
||||||
" JOIN folder ON folder.account = account.id" +
|
|
||||||
" WHERE (account.id = :id OR (:id IS NULL AND account.`primary`))" +
|
|
||||||
" AND folder.type = '" + EntityFolder.DRAFTS + "'")
|
|
||||||
LiveData<EntityAccount> liveAccountDraft(Long id);
|
|
||||||
|
|
||||||
@Query("SELECT" +
|
@Query("SELECT" +
|
||||||
" (SELECT COUNT(account.id) FROM account WHERE synchronize AND state = 'connected') AS accounts" +
|
" (SELECT COUNT(account.id) FROM account WHERE synchronize AND state = 'connected') AS accounts" +
|
||||||
", (SELECT COUNT(operation.id) FROM operation" +
|
", (SELECT COUNT(operation.id) FROM operation" +
|
||||||
|
|
|
@ -78,6 +78,12 @@ public interface DaoFolder {
|
||||||
" GROUP BY folder.id")
|
" GROUP BY folder.id")
|
||||||
LiveData<List<TupleFolderEx>> liveUnified();
|
LiveData<List<TupleFolderEx>> liveUnified();
|
||||||
|
|
||||||
|
@Query("SELECT folder.* FROM folder" +
|
||||||
|
" JOIN account ON account.id = folder.account" +
|
||||||
|
" WHERE folder.type = '" + EntityFolder.DRAFTS + "'" +
|
||||||
|
" AND (account.id = :account OR (:account IS NULL AND account.`primary`))")
|
||||||
|
LiveData<EntityFolder> liveDrafts(Long account);
|
||||||
|
|
||||||
@Query("SELECT folder.*, account.name AS accountName, account.color AS accountColor" +
|
@Query("SELECT folder.*, account.name AS accountName, account.color AS accountColor" +
|
||||||
", COUNT(message.id) AS messages" +
|
", COUNT(message.id) AS messages" +
|
||||||
", SUM(CASE WHEN message.content = 1 THEN 1 ELSE 0 END) AS content" +
|
", SUM(CASE WHEN message.content = 1 THEN 1 ELSE 0 END) AS content" +
|
||||||
|
|
|
@ -599,13 +599,31 @@ public class FragmentMessages extends FragmentEx {
|
||||||
fab.setOnClickListener(new View.OnClickListener() {
|
fab.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
EntityFolder drafts = (EntityFolder) fab.getTag();
|
||||||
|
|
||||||
startActivity(new Intent(getContext(), ActivityCompose.class)
|
startActivity(new Intent(getContext(), ActivityCompose.class)
|
||||||
.putExtra("action", "new")
|
.putExtra("action", "new")
|
||||||
.putExtra("account", (Long) fab.getTag())
|
.putExtra("account", drafts.account)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fab.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View v) {
|
||||||
|
EntityFolder drafts = (EntityFolder) fab.getTag();
|
||||||
|
|
||||||
|
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
|
||||||
|
lbm.sendBroadcast(
|
||||||
|
new Intent(ActivityView.ACTION_VIEW_MESSAGES)
|
||||||
|
.putExtra("account", drafts.account)
|
||||||
|
.putExtra("folder", drafts.id)
|
||||||
|
.putExtra("outgoing", drafts.isOutgoing()));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
fabMore.setOnClickListener(new View.OnClickListener() {
|
fabMore.setOnClickListener(new View.OnClickListener() {
|
||||||
private final int action_seen = 1;
|
private final int action_seen = 1;
|
||||||
private final int action_unseen = 2;
|
private final int action_unseen = 2;
|
||||||
|
@ -1210,13 +1228,13 @@ public class FragmentMessages extends FragmentEx {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
db.account().liveAccountDraft(account < 0 ? null : account).observe(getViewLifecycleOwner(), new Observer<EntityAccount>() {
|
db.folder().liveDrafts(account < 0 ? null : account).observe(getViewLifecycleOwner(), new Observer<EntityFolder>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(EntityAccount account) {
|
public void onChanged(EntityFolder drafts) {
|
||||||
if (account == null)
|
if (drafts == null)
|
||||||
fab.hide();
|
fab.hide();
|
||||||
else {
|
else {
|
||||||
fab.setTag(account.id);
|
fab.setTag(drafts);
|
||||||
fab.show();
|
fab.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue