Take threading into account for account unread count

pull/147/head
M66B 6 years ago
parent bb9708f17f
commit 1cb75e8720

@ -48,9 +48,9 @@ public class ActivityMain extends AppCompatActivity implements FragmentManager.O
if (prefs.getBoolean("eula", false)) {
super.onCreate(savedInstanceState);
DB.getInstance(this).account().liveAccounts(true).observe(this, new Observer<List<TupleAccountEx>>() {
DB.getInstance(this).account().liveAccounts(true).observe(this, new Observer<List<EntityAccount>>() {
@Override
public void onChanged(@Nullable List<TupleAccountEx> accounts) {
public void onChanged(@Nullable List<EntityAccount> accounts) {
if (accounts == null || accounts.size() == 0)
startActivity(new Intent(ActivityMain.this, ActivitySetup.class));
else {

@ -65,9 +65,9 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On
fragmentTransaction.commit();
}
DB.getInstance(this).account().liveAccounts(true).observe(this, new Observer<List<TupleAccountEx>>() {
DB.getInstance(this).account().liveAccounts(true).observe(this, new Observer<List<EntityAccount>>() {
@Override
public void onChanged(List<TupleAccountEx> accounts) {
public void onChanged(List<EntityAccount> accounts) {
hasAccount = (accounts != null && accounts.size() > 0);
}
});

@ -104,6 +104,7 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager;
public class ActivityView extends ActivityBilling implements FragmentManager.OnBackStackChangedListener {
private boolean unified;
private boolean threading;
private View view;
private DrawerLayout drawerLayout;
@ -145,6 +146,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
unified = prefs.getBoolean("unified", true);
threading = prefs.getBoolean("threading", true);
view = LayoutInflater.from(this).inflate(R.layout.activity_view, null);
setContentView(view);
@ -248,7 +250,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
getSupportFragmentManager().addOnBackStackChangedListener(this);
DB.getInstance(this).account().liveAccounts(true).observe(this, new Observer<List<TupleAccountEx>>() {
DB.getInstance(this).account().liveAccounts(true, threading).observe(this, new Observer<List<TupleAccountEx>>() {
@Override
public void onChanged(@Nullable List<TupleAccountEx> accounts) {
if (accounts == null)

@ -41,18 +41,22 @@ public interface DaoAccount {
@Query("SELECT * FROM account")
LiveData<List<EntityAccount>> liveAccounts();
@Query("SELECT * FROM account WHERE synchronize = :synchronize")
LiveData<List<EntityAccount>> liveAccounts(boolean synchronize);
@Query("SELECT *" +
", (SELECT COUNT(message.id)" +
", (SELECT COUNT(DISTINCT CASE WHEN :threading THEN message.thread ELSE message.id END)" +
" FROM message" +
" JOIN folder ON folder.id = message.folder" +
" WHERE message.account = account.id" +
" AND folder.type <> '" + EntityFolder.ARCHIVE + "'" +
" AND folder.type <> '" + EntityFolder.TRASH + "'" +
" AND folder.type <> '" + EntityFolder.DRAFTS + "'" +
" AND folder.type <> '" + EntityFolder.OUTBOX + "'" +
" AND NOT ui_seen) AS unseen" +
" FROM account" +
" WHERE synchronize = :synchronize")
LiveData<List<TupleAccountEx>> liveAccounts(boolean synchronize);
LiveData<List<TupleAccountEx>> liveAccounts(boolean synchronize, boolean threading);
@Query("SELECT * FROM account WHERE id = :id")
EntityAccount getAccount(long id);

@ -1366,11 +1366,11 @@ public class FragmentCompose extends FragmentEx {
final DB db = DB.getInstance(getContext());
db.account().liveAccounts(true).observe(getViewLifecycleOwner(), new Observer<List<TupleAccountEx>>() {
db.account().liveAccounts(true).observe(getViewLifecycleOwner(), new Observer<List<EntityAccount>>() {
private LiveData<List<EntityIdentity>> liveIdentities = null;
@Override
public void onChanged(List<TupleAccountEx> accounts) {
public void onChanged(List<EntityAccount> accounts) {
if (accounts == null)
accounts = new ArrayList<>();
@ -1780,11 +1780,11 @@ public class FragmentCompose extends FragmentEx {
EntityAccount account;
}
public class AccountAdapter extends ArrayAdapter<TupleAccountEx> {
public class AccountAdapter extends ArrayAdapter<EntityAccount> {
private Context context;
private List<TupleAccountEx> accounts;
private List<EntityAccount> accounts;
AccountAdapter(@NonNull Context context, List<TupleAccountEx> accounts) {
AccountAdapter(@NonNull Context context, List<EntityAccount> accounts) {
super(context, 0, accounts);
this.context = context;
this.accounts = accounts;

@ -354,13 +354,13 @@ public class FragmentSetup extends FragmentEx {
final DB db = DB.getInstance(getContext());
db.account().liveAccounts(true).observe(getViewLifecycleOwner(), new Observer<List<TupleAccountEx>>() {
db.account().liveAccounts(true).observe(getViewLifecycleOwner(), new Observer<List<EntityAccount>>() {
private boolean done = false;
private LiveData<EntityFolder> livePrimaryDrafts = null;
private LiveData<EntityFolder> livePrimaryArchive = null;
@Override
public void onChanged(@Nullable List<TupleAccountEx> accounts) {
public void onChanged(@Nullable List<EntityAccount> accounts) {
done = (accounts != null && accounts.size() > 0);
btnIdentity.setEnabled(done);

Loading…
Cancel
Save