Added folder sync state

pull/146/head
M66B 6 years ago
parent 3df4ba3a8d
commit 75d4dc2a9d

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);
}
if ("connected".equals(folder.state))
ivState.setImageResource(R.drawable.baseline_cloud_24);
else if ("connecting".equals(folder.state))
ivState.setImageResource(R.drawable.baseline_cloud_queue_24);
else if ("closing".equals(folder.state))
ivState.setImageResource(R.drawable.baseline_close_24);
else if ("syncing".equals(folder.state))
ivState.setImageResource(R.drawable.baseline_compare_arrows_24);
else if ("downloading".equals(folder.state))
ivState.setImageResource(R.drawable.baseline_cloud_download_24);
else
ivState.setImageResource(R.drawable.baseline_cloud_off_24);
ivState.setVisibility(folder.synchronize || folder.state != null ? View.VISIBLE : View.INVISIBLE);
if (folder.sync_state == null) {
if ("connected".equals(folder.state))
ivState.setImageResource(R.drawable.baseline_cloud_24);
else if ("connecting".equals(folder.state))
ivState.setImageResource(R.drawable.baseline_cloud_queue_24);
else if ("closing".equals(folder.state))
ivState.setImageResource(R.drawable.baseline_close_24);
else if (folder.state == null)
ivState.setImageResource(R.drawable.baseline_cloud_off_24);
else
ivState.setImageResource(android.R.drawable.stat_sys_warning);
} else {
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);
if (folder.unseen > 0)

@ -46,7 +46,7 @@ import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 14,
version = 15,
entities = {
EntityIdentity.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");
}
})
.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();
}

@ -118,6 +118,9 @@ public interface DaoFolder {
@Query("UPDATE folder SET state = :state WHERE id = :id")
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")
int setFolderError(long id, String error);

@ -79,6 +79,7 @@ public class EntityFolder implements Serializable {
public Boolean unified = false;
public String[] keywords;
public String state;
public String sync_state;
public String error;
static final String INBOX = "Inbox";
@ -162,6 +163,7 @@ public class EntityFolder implements Serializable {
this.hide == other.hide &&
this.unified == other.unified &&
(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)));
} else
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);
db.folder().setFolderState(folder.id, "syncing");
db.folder().setFolderSyncState(folder.id, "syncing");
// Get reference times
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);
@ -2031,7 +2031,7 @@ public class ServiceSynchronize extends LifecycleService {
} finally {
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();
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);
db.folder().setFolderError(outbox.id, null);
} catch (Throwable ex) {
@ -2471,7 +2471,7 @@ public class ServiceSynchronize extends LifecycleService {
reportError(null, outbox.name, ex);
db.folder().setFolderError(outbox.id, Helper.formatThrowable(ex));
} finally {
db.folder().setFolderState(outbox.id, null);
db.folder().setFolderSyncState(outbox.id, null);
wl.release();
EntityLog.log(ServiceSynchronize.this, "Outbox wake lock=" + wl.isHeld());
}
@ -2484,6 +2484,7 @@ public class ServiceSynchronize extends LifecycleService {
}
};
handler.sendEmptyMessage(1);
db.folder().setFolderState(outbox.id, "connected");
}
// Start monitoring accounts

Loading…
Cancel
Save