mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-04 11:54:10 +01:00
Show number of messages on server
This commit is contained in:
1540
app/schemas/eu.faircode.email.DB/52.json
Normal file
1540
app/schemas/eu.faircode.email.DB/52.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -168,7 +168,17 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
||||
tvName.setTypeface(null, folder.unseen > 0 ? Typeface.BOLD : Typeface.NORMAL);
|
||||
tvName.setTextColor(folder.unseen > 0 ? colorUnread : textColorSecondary);
|
||||
|
||||
tvMessages.setText(String.format("%d/%d", folder.content, folder.messages));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(folder.content);
|
||||
sb.append('/');
|
||||
sb.append(folder.messages);
|
||||
sb.append('/');
|
||||
if (folder.total == null)
|
||||
sb.append('?');
|
||||
else
|
||||
sb.append(folder.total);
|
||||
tvMessages.setText(sb.toString());
|
||||
|
||||
ivMessages.setImageResource(folder.download || EntityFolder.OUTBOX.equals(folder.type)
|
||||
? R.drawable.baseline_mail_24 : R.drawable.baseline_mail_outline_24);
|
||||
|
||||
|
||||
@@ -1005,6 +1005,9 @@ class Core {
|
||||
}
|
||||
}
|
||||
|
||||
int count = ifolder.getMessageCount();
|
||||
db.folder().setFolderTotal(folder.id, count < 0 ? null : count);
|
||||
|
||||
if (download) {
|
||||
db.folder().setFolderSyncState(folder.id, "downloading");
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory;
|
||||
// https://developer.android.com/topic/libraries/architecture/room.html
|
||||
|
||||
@Database(
|
||||
version = 51,
|
||||
version = 52,
|
||||
entities = {
|
||||
EntityIdentity.class,
|
||||
EntityAccount.class,
|
||||
@@ -553,6 +553,13 @@ public abstract class DB extends RoomDatabase {
|
||||
db.execSQL("DELETE FROM operation WHERE name = '" + EntityOperation.WAIT + "'");
|
||||
}
|
||||
})
|
||||
.addMigrations(new Migration(51, 52) {
|
||||
@Override
|
||||
public void migrate(SupportSQLiteDatabase db) {
|
||||
Log.i("DB migration from version " + startVersion + " to " + endVersion);
|
||||
db.execSQL("ALTER TABLE `folder` ADD COLUMN `total` INTEGER");
|
||||
}
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -143,6 +143,9 @@ public interface DaoFolder {
|
||||
@Query("UPDATE folder SET sync_state = :state WHERE id = :id")
|
||||
int setFolderSyncState(long id, String state);
|
||||
|
||||
@Query("UPDATE folder SET total = :total WHERE id = :id")
|
||||
int setFolderTotal(long id, Integer total);
|
||||
|
||||
@Query("UPDATE folder SET error = :error WHERE id = :id")
|
||||
int setFolderError(long id, String error);
|
||||
|
||||
|
||||
@@ -86,6 +86,8 @@ public class EntityFolder implements Serializable {
|
||||
public Boolean unified = false;
|
||||
@NonNull
|
||||
public Boolean notify = false;
|
||||
|
||||
public Integer total; // messages on server
|
||||
public String[] keywords;
|
||||
|
||||
@NonNull
|
||||
@@ -255,6 +257,7 @@ public class EntityFolder implements Serializable {
|
||||
this.hide == other.hide &&
|
||||
this.unified == other.unified &&
|
||||
this.notify == other.notify &&
|
||||
Objects.equals(this.total, other.total) &&
|
||||
Helper.equal(this.keywords, other.keywords) &&
|
||||
Objects.equals(this.tbd, other.tbd) &&
|
||||
Objects.equals(this.state, other.state) &&
|
||||
|
||||
@@ -637,6 +637,9 @@ public class ServiceSynchronize extends LifecycleService {
|
||||
db.folder().setFolderState(folder.id, "connected");
|
||||
db.folder().setFolderError(folder.id, null);
|
||||
|
||||
int count = ifolder.getMessageCount();
|
||||
db.folder().setFolderTotal(folder.id, count < 0 ? null : count);
|
||||
|
||||
Log.i(account.name + " folder " + folder.name + " flags=" + ifolder.getPermanentFlags());
|
||||
|
||||
// Listen for new and deleted messages
|
||||
@@ -691,6 +694,9 @@ public class ServiceSynchronize extends LifecycleService {
|
||||
Log.e(folder.name, ex);
|
||||
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex, true));
|
||||
}
|
||||
|
||||
int count = ifolder.getMessageCount();
|
||||
db.folder().setFolderTotal(folder.id, count < 0 ? null : count);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(folder.name, ex);
|
||||
Core.reportError(ServiceSynchronize.this, account, folder, ex);
|
||||
@@ -716,6 +722,9 @@ public class ServiceSynchronize extends LifecycleService {
|
||||
} catch (MessageRemovedException ex) {
|
||||
Log.w(folder.name, ex);
|
||||
}
|
||||
|
||||
int count = ifolder.getMessageCount();
|
||||
db.folder().setFolderTotal(folder.id, count < 0 ? null : count);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(folder.name, ex);
|
||||
Core.reportError(ServiceSynchronize.this, account, folder, ex);
|
||||
|
||||
@@ -509,7 +509,7 @@
|
||||
<string name="title_legend_stop">Stop processing rules</string>
|
||||
|
||||
<string name="title_legend_sync_keep">Number of days to synchronize / to keep messages</string>
|
||||
<string name="title_legend_download_fetch">Number of message bodies downloaded / headers fetched</string>
|
||||
<string name="title_legend_download_fetch">Number of message bodies downloaded / headers fetched / on server</string>
|
||||
|
||||
<string name="title_legend_metered">Connection is metered</string>
|
||||
<string name="title_legend_unmetered">Connection is unmetered</string>
|
||||
|
||||
Reference in New Issue
Block a user