mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-13 15:40:27 +00:00
Added folder sync state
This commit is contained in:
parent
3df4ba3a8d
commit
75d4dc2a9d
6 changed files with 1215 additions and 19 deletions
1174
app/schemas/eu.faircode.email.DB/15.json
Normal file
1174
app/schemas/eu.faircode.email.DB/15.json
Normal file
File diff suppressed because it is too large
Load diff
|
@ -123,19 +123,28 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
||||||
vwLevel.setLayoutParams(lp);
|
vwLevel.setLayoutParams(lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("connected".equals(folder.state))
|
if (folder.sync_state == null) {
|
||||||
ivState.setImageResource(R.drawable.baseline_cloud_24);
|
if ("connected".equals(folder.state))
|
||||||
else if ("connecting".equals(folder.state))
|
ivState.setImageResource(R.drawable.baseline_cloud_24);
|
||||||
ivState.setImageResource(R.drawable.baseline_cloud_queue_24);
|
else if ("connecting".equals(folder.state))
|
||||||
else if ("closing".equals(folder.state))
|
ivState.setImageResource(R.drawable.baseline_cloud_queue_24);
|
||||||
ivState.setImageResource(R.drawable.baseline_close_24);
|
else if ("closing".equals(folder.state))
|
||||||
else if ("syncing".equals(folder.state))
|
ivState.setImageResource(R.drawable.baseline_close_24);
|
||||||
ivState.setImageResource(R.drawable.baseline_compare_arrows_24);
|
else if (folder.state == null)
|
||||||
else if ("downloading".equals(folder.state))
|
ivState.setImageResource(R.drawable.baseline_cloud_off_24);
|
||||||
ivState.setImageResource(R.drawable.baseline_cloud_download_24);
|
else
|
||||||
else
|
ivState.setImageResource(android.R.drawable.stat_sys_warning);
|
||||||
ivState.setImageResource(R.drawable.baseline_cloud_off_24);
|
} else {
|
||||||
ivState.setVisibility(folder.synchronize || folder.state != null ? View.VISIBLE : View.INVISIBLE);
|
if ("syncing".equals(folder.sync_state))
|
||||||
|
ivState.setImageResource(R.drawable.baseline_compare_arrows_24);
|
||||||
|
else if ("downloading".equals(folder.sync_state))
|
||||||
|
ivState.setImageResource(R.drawable.baseline_cloud_download_24);
|
||||||
|
else
|
||||||
|
ivState.setImageResource(android.R.drawable.stat_sys_warning);
|
||||||
|
}
|
||||||
|
ivState.setVisibility(
|
||||||
|
folder.synchronize || folder.state != null || folder.sync_state != null
|
||||||
|
? View.VISIBLE : View.INVISIBLE);
|
||||||
|
|
||||||
String name = folder.getDisplayName(context);
|
String name = folder.getDisplayName(context);
|
||||||
if (folder.unseen > 0)
|
if (folder.unseen > 0)
|
||||||
|
|
|
@ -46,7 +46,7 @@ import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory;
|
||||||
// https://developer.android.com/topic/libraries/architecture/room.html
|
// https://developer.android.com/topic/libraries/architecture/room.html
|
||||||
|
|
||||||
@Database(
|
@Database(
|
||||||
version = 14,
|
version = 15,
|
||||||
entities = {
|
entities = {
|
||||||
EntityIdentity.class,
|
EntityIdentity.class,
|
||||||
EntityAccount.class,
|
EntityAccount.class,
|
||||||
|
@ -234,6 +234,13 @@ public abstract class DB extends RoomDatabase {
|
||||||
db.execSQL("ALTER TABLE `folder` ADD COLUMN `level` INTEGER NOT NULL DEFAULT 0");
|
db.execSQL("ALTER TABLE `folder` ADD COLUMN `level` INTEGER NOT NULL DEFAULT 0");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.addMigrations(new Migration(14, 15) {
|
||||||
|
@Override
|
||||||
|
public void migrate(SupportSQLiteDatabase db) {
|
||||||
|
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion);
|
||||||
|
db.execSQL("ALTER TABLE `folder` ADD COLUMN `sync_state` TEXT");
|
||||||
|
}
|
||||||
|
})
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,6 +118,9 @@ public interface DaoFolder {
|
||||||
@Query("UPDATE folder SET state = :state WHERE id = :id")
|
@Query("UPDATE folder SET state = :state WHERE id = :id")
|
||||||
int setFolderState(long id, String state);
|
int setFolderState(long id, String state);
|
||||||
|
|
||||||
|
@Query("UPDATE folder SET sync_state = :state WHERE id = :id")
|
||||||
|
int setFolderSyncState(long id, String state);
|
||||||
|
|
||||||
@Query("UPDATE folder SET error = :error WHERE id = :id")
|
@Query("UPDATE folder SET error = :error WHERE id = :id")
|
||||||
int setFolderError(long id, String error);
|
int setFolderError(long id, String error);
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,7 @@ public class EntityFolder implements Serializable {
|
||||||
public Boolean unified = false;
|
public Boolean unified = false;
|
||||||
public String[] keywords;
|
public String[] keywords;
|
||||||
public String state;
|
public String state;
|
||||||
|
public String sync_state;
|
||||||
public String error;
|
public String error;
|
||||||
|
|
||||||
static final String INBOX = "Inbox";
|
static final String INBOX = "Inbox";
|
||||||
|
@ -162,6 +163,7 @@ public class EntityFolder implements Serializable {
|
||||||
this.hide == other.hide &&
|
this.hide == other.hide &&
|
||||||
this.unified == other.unified &&
|
this.unified == other.unified &&
|
||||||
(this.state == null ? other.state == null : this.state.equals(other.state)) &&
|
(this.state == null ? other.state == null : this.state.equals(other.state)) &&
|
||||||
|
(this.sync_state == null ? other.sync_state == null : this.sync_state.equals(other.sync_state)) &&
|
||||||
(this.error == null ? other.error == null : this.error.equals(other.error)));
|
(this.error == null ? other.error == null : this.error.equals(other.error)));
|
||||||
} else
|
} else
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1857,7 +1857,7 @@ public class ServiceSynchronize extends LifecycleService {
|
||||||
|
|
||||||
Log.v(Helper.TAG, folder.name + " start sync after=" + folder.sync_days + "/" + folder.keep_days);
|
Log.v(Helper.TAG, folder.name + " start sync after=" + folder.sync_days + "/" + folder.keep_days);
|
||||||
|
|
||||||
db.folder().setFolderState(folder.id, "syncing");
|
db.folder().setFolderSyncState(folder.id, "syncing");
|
||||||
|
|
||||||
// Get reference times
|
// Get reference times
|
||||||
Calendar cal_sync = Calendar.getInstance();
|
Calendar cal_sync = Calendar.getInstance();
|
||||||
|
@ -1990,7 +1990,7 @@ public class ServiceSynchronize extends LifecycleService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
db.folder().setFolderState(folder.id, "downloading");
|
db.folder().setFolderSyncState(folder.id, "downloading");
|
||||||
|
|
||||||
//fp.add(IMAPFolder.FetchProfileItem.MESSAGE);
|
//fp.add(IMAPFolder.FetchProfileItem.MESSAGE);
|
||||||
|
|
||||||
|
@ -2031,7 +2031,7 @@ public class ServiceSynchronize extends LifecycleService {
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
Log.v(Helper.TAG, folder.name + " end sync state=" + state);
|
Log.v(Helper.TAG, folder.name + " end sync state=" + state);
|
||||||
db.folder().setFolderState(folder.id, ifolder.isOpen() ? "connected" : "disconnected");
|
db.folder().setFolderSyncState(folder.id, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2463,7 +2463,7 @@ public class ServiceSynchronize extends LifecycleService {
|
||||||
wl.acquire();
|
wl.acquire();
|
||||||
Log.i(Helper.TAG, outbox.name + " process");
|
Log.i(Helper.TAG, outbox.name + " process");
|
||||||
|
|
||||||
db.folder().setFolderState(outbox.id, "syncing");
|
db.folder().setFolderSyncState(outbox.id, "syncing");
|
||||||
processOperations(null, outbox, null, null, null, state);
|
processOperations(null, outbox, null, null, null, state);
|
||||||
db.folder().setFolderError(outbox.id, null);
|
db.folder().setFolderError(outbox.id, null);
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
|
@ -2471,7 +2471,7 @@ public class ServiceSynchronize extends LifecycleService {
|
||||||
reportError(null, outbox.name, ex);
|
reportError(null, outbox.name, ex);
|
||||||
db.folder().setFolderError(outbox.id, Helper.formatThrowable(ex));
|
db.folder().setFolderError(outbox.id, Helper.formatThrowable(ex));
|
||||||
} finally {
|
} finally {
|
||||||
db.folder().setFolderState(outbox.id, null);
|
db.folder().setFolderSyncState(outbox.id, null);
|
||||||
wl.release();
|
wl.release();
|
||||||
EntityLog.log(ServiceSynchronize.this, "Outbox wake lock=" + wl.isHeld());
|
EntityLog.log(ServiceSynchronize.this, "Outbox wake lock=" + wl.isHeld());
|
||||||
}
|
}
|
||||||
|
@ -2484,6 +2484,7 @@ public class ServiceSynchronize extends LifecycleService {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
handler.sendEmptyMessage(1);
|
handler.sendEmptyMessage(1);
|
||||||
|
db.folder().setFolderState(outbox.id, "connected");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start monitoring accounts
|
// Start monitoring accounts
|
||||||
|
|
Loading…
Add table
Reference in a new issue