Browse Source

Show conversations by thread ID

main
M66B 6 years ago
parent
commit
8901221548
6 changed files with 31 additions and 40 deletions
  1. +9
    -3
      app/src/main/java/eu/faircode/email/ActivityView.java
  2. +1
    -0
      app/src/main/java/eu/faircode/email/AdapterFolder.java
  3. +2
    -1
      app/src/main/java/eu/faircode/email/AdapterMessage.java
  4. +4
    -4
      app/src/main/java/eu/faircode/email/DaoMessage.java
  5. +13
    -31
      app/src/main/java/eu/faircode/email/FragmentMessages.java
  6. +2
    -1
      app/src/main/java/eu/faircode/email/ServiceSynchronize.java

+ 9
- 3
app/src/main/java/eu/faircode/email/ActivityView.java View File

@ -302,7 +302,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
setIntent(intent); setIntent(intent);
getSupportFragmentManager().popBackStack("unified", 0); getSupportFragmentManager().popBackStack("unified", 0);
intent.putExtra("id", Long.parseLong(action.split(":")[1]));
intent.putExtra("thread", action.split(":", 2)[1]);
onViewThread(intent); onViewThread(intent);
} }
} }
@ -752,8 +752,13 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
}; };
private void onViewMessages(Intent intent) { private void onViewMessages(Intent intent) {
Bundle args = new Bundle();
args.putLong("account", intent.getLongExtra("account", -1));
args.putLong("folder", intent.getLongExtra("folder", -1));
FragmentMessages fragment = new FragmentMessages(); FragmentMessages fragment = new FragmentMessages();
fragment.setArguments(intent.getExtras());
fragment.setArguments(args);
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("messages"); fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("messages");
fragmentTransaction.commit(); fragmentTransaction.commit();
@ -761,7 +766,8 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
private void onViewThread(Intent intent) { private void onViewThread(Intent intent) {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("thread", intent.getLongExtra("id", -1));
args.putLong("account", intent.getLongExtra("account", -1));
args.putString("thread", intent.getStringExtra("thread"));
FragmentMessages fragment = new FragmentMessages(); FragmentMessages fragment = new FragmentMessages();
fragment.setArguments(args); fragment.setArguments(args);


+ 1
- 0
app/src/main/java/eu/faircode/email/AdapterFolder.java View File

@ -156,6 +156,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context); LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast( lbm.sendBroadcast(
new Intent(ActivityView.ACTION_VIEW_MESSAGES) new Intent(ActivityView.ACTION_VIEW_MESSAGES)
.putExtra("account", folder.account)
.putExtra("folder", folder.id)); .putExtra("folder", folder.id));
} }


+ 2
- 1
app/src/main/java/eu/faircode/email/AdapterMessage.java View File

@ -472,7 +472,8 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context); LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast( lbm.sendBroadcast(
new Intent(ActivityView.ACTION_VIEW_THREAD) new Intent(ActivityView.ACTION_VIEW_THREAD)
.putExtra("id", message.id));
.putExtra("account", message.account)
.putExtra("thread", message.thread));
} }
} }
} }


+ 4
- 4
app/src/main/java/eu/faircode/email/DaoMessage.java View File

@ -103,15 +103,15 @@ public interface DaoMessage {
" FROM message" + " FROM message" +
" JOIN account ON account.id = message.account" + " JOIN account ON account.id = message.account" +
" JOIN folder ON folder.id = message.folder" + " JOIN folder ON folder.id = message.folder" +
" WHERE (NOT message.ui_hide OR :debug)" +
" AND message.account = (SELECT m1.account FROM message m1 WHERE m1.id = :msgid)" +
" AND message.thread = (SELECT m2.thread FROM message m2 WHERE m2.id = :msgid)" +
" WHERE message.account = :account" +
" AND message.thread = :thread" +
" AND (NOT message.ui_hide OR :debug)" +
" ORDER BY CASE" + " ORDER BY CASE" +
" WHEN 'unread' = :sort THEN NOT message.ui_seen" + " WHEN 'unread' = :sort THEN NOT message.ui_seen" +
" WHEN 'starred' = :sort THEN message.ui_flagged" + " WHEN 'starred' = :sort THEN message.ui_flagged" +
" ELSE 0" + " ELSE 0" +
" END DESC, message.received DESC, message.sent DESC") " END DESC, message.received DESC, message.sent DESC")
DataSource.Factory<Integer, TupleMessageEx> pagedThread(long msgid, String sort, boolean debug);
DataSource.Factory<Integer, TupleMessageEx> pagedThread(long account, String thread, String sort, boolean debug);
@Query("SELECT *" + @Query("SELECT *" +
" FROM message" + " FROM message" +


+ 13
- 31
app/src/main/java/eu/faircode/email/FragmentMessages.java View File

@ -76,7 +76,8 @@ public class FragmentMessages extends FragmentEx {
private FloatingActionButton fab; private FloatingActionButton fab;
private long folder = -1; private long folder = -1;
private long thread = -1;
private long account = -1;
private String thread = null;
private String search = null; private String search = null;
private long primary = -1; private long primary = -1;
@ -106,8 +107,9 @@ public class FragmentMessages extends FragmentEx {
// Get arguments // Get arguments
Bundle args = getArguments(); Bundle args = getArguments();
if (args != null) { if (args != null) {
account = args.getLong("account", -1);
folder = args.getLong("folder", -1); folder = args.getLong("folder", -1);
thread = args.getLong("thread", -1); // message ID
thread = args.getString("thread");
search = args.getString("search"); search = args.getString("search");
} }
} }
@ -166,7 +168,7 @@ public class FragmentMessages extends FragmentEx {
rvMessage.setLayoutManager(llm); rvMessage.setLayoutManager(llm);
if (TextUtils.isEmpty(search)) if (TextUtils.isEmpty(search))
if (thread < 0)
if (thread == null)
if (folder < 0) if (folder < 0)
viewType = AdapterMessage.ViewType.UNIFIED; viewType = AdapterMessage.ViewType.UNIFIED;
else else
@ -531,38 +533,18 @@ public class FragmentMessages extends FragmentEx {
// Compose FAB // Compose FAB
if (viewType != AdapterMessage.ViewType.THREAD) { if (viewType != AdapterMessage.ViewType.THREAD) {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("folder", folder);
args.putLong("thread", thread);
args.putLong("account", account);
new SimpleTask<Long>() { new SimpleTask<Long>() {
@Override @Override
protected Long onLoad(Context context, Bundle args) { protected Long onLoad(Context context, Bundle args) {
long fid = args.getLong("folder", -1);
long thread = args.getLong("thread", -1); // message ID
long account = args.getLong("account", -1);
DB db = DB.getInstance(context);
Long account = null;
if (thread < 0) {
if (folder >= 0) {
EntityFolder folder = db.folder().getFolder(fid);
if (folder != null)
account = folder.account;
}
} else {
EntityMessage threaded = db.message().getMessage(thread);
if (threaded != null)
account = threaded.account;
}
if (account == null) {
// outbox
EntityFolder primary = db.folder().getPrimaryDrafts();
if (primary != null)
account = primary.account;
}
return account;
if (account < 0) {
EntityFolder primary = DB.getInstance(context).folder().getPrimaryDrafts();
return (primary == null ? null : primary.account);
} else
return account;
} }
@Override @Override
@ -751,7 +733,7 @@ public class FragmentMessages extends FragmentEx {
break; break;
case THREAD: case THREAD:
messages = new LivePagedListBuilder<>(db.message().pagedThread(thread, sort, debug), LOCAL_PAGE_SIZE).build();
messages = new LivePagedListBuilder<>(db.message().pagedThread(account, thread, sort, debug), LOCAL_PAGE_SIZE).build();
break; break;
} }
} else { } else {


+ 2
- 1
app/src/main/java/eu/faircode/email/ServiceSynchronize.java View File

@ -409,8 +409,9 @@ public class ServiceSynchronize extends LifecycleService {
args.putLong("id", message.id); args.putLong("id", message.id);
Intent thread = new Intent(this, ActivityView.class); Intent thread = new Intent(this, ActivityView.class);
thread.setAction("thread:" + message.id);
thread.setAction("thread:" + message.thread);
thread.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); thread.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
thread.putExtra("account", message.account);
PendingIntent piContent = PendingIntent.getActivity( PendingIntent piContent = PendingIntent.getActivity(
this, ActivityView.REQUEST_THREAD, thread, PendingIntent.FLAG_UPDATE_CURRENT); this, ActivityView.REQUEST_THREAD, thread, PendingIntent.FLAG_UPDATE_CURRENT);


Loading…
Cancel
Save