Show when folder is executing operations

pull/156/head
M66B 6 years ago
parent c00eac14f4
commit a70a517c9f

File diff suppressed because it is too large Load Diff

@ -201,7 +201,9 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
vwColor.setVisibility(account < 0 ? View.VISIBLE : View.GONE); vwColor.setVisibility(account < 0 ? View.VISIBLE : View.GONE);
if (folder.sync_state == null || "requested".equals(folder.sync_state)) { if (folder.sync_state == null || "requested".equals(folder.sync_state)) {
if ("waiting".equals(folder.state)) if (folder.executing > 0)
ivState.setImageResource(R.drawable.baseline_list_24);
else if ("waiting".equals(folder.state))
ivState.setImageResource(R.drawable.baseline_hourglass_empty_24); ivState.setImageResource(R.drawable.baseline_hourglass_empty_24);
else if ("connected".equals(folder.state)) else if ("connected".equals(folder.state))
ivState.setImageResource(R.drawable.baseline_cloud_24); ivState.setImageResource(R.drawable.baseline_cloud_24);

@ -85,6 +85,8 @@ public class AdapterNavFolder extends RecyclerView.Adapter<AdapterNavFolder.View
ivItem.setImageResource(R.drawable.baseline_compare_arrows_24); ivItem.setImageResource(R.drawable.baseline_compare_arrows_24);
else if ("downloading".equals(folder.sync_state)) else if ("downloading".equals(folder.sync_state))
ivItem.setImageResource(R.drawable.baseline_cloud_download_24); ivItem.setImageResource(R.drawable.baseline_cloud_download_24);
else if (folder.executing > 0)
ivItem.setImageResource(R.drawable.baseline_list_24);
else else
ivItem.setImageResource("connected".equals(folder.state) ivItem.setImageResource("connected".equals(folder.state)
? R.drawable.baseline_folder_24 ? R.drawable.baseline_folder_24
@ -206,7 +208,8 @@ public class AdapterNavFolder extends RecyclerView.Adapter<AdapterNavFolder.View
Objects.equals(f1.state, f2.state) && Objects.equals(f1.state, f2.state) &&
Objects.equals(f1.sync_state, f2.sync_state) && Objects.equals(f1.sync_state, f2.sync_state) &&
f1.unseen == f2.unseen && f1.unseen == f2.unseen &&
f1.operations == f2.operations); f1.operations == f2.operations &&
f1.executing == f2.executing);
} }
} }

@ -51,7 +51,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 = 81, version = 82,
entities = { entities = {
EntityIdentity.class, EntityIdentity.class,
EntityAccount.class, EntityAccount.class,
@ -816,6 +816,14 @@ public abstract class DB extends RoomDatabase {
db.execSQL("ALTER TABLE `operation` ADD COLUMN `state` TEXT"); db.execSQL("ALTER TABLE `operation` ADD COLUMN `state` TEXT");
} }
}) })
.addMigrations(new Migration(81, 82) {
@Override
public void migrate(SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("CREATE INDEX `index_operation_account` ON `operation` (`account`)");
db.execSQL("CREATE INDEX `index_operation_state` ON `operation` (`state`)");
}
})
.build(); .build();
} }

@ -63,6 +63,7 @@ public interface DaoFolder {
", COUNT(message.id) AS messages" + ", COUNT(message.id) AS messages" +
", SUM(CASE WHEN message.content = 1 THEN 1 ELSE 0 END) AS content" + ", SUM(CASE WHEN message.content = 1 THEN 1 ELSE 0 END) AS content" +
", SUM(CASE WHEN message.ui_seen = 0 THEN 1 ELSE 0 END) AS unseen" + ", SUM(CASE WHEN message.ui_seen = 0 THEN 1 ELSE 0 END) AS unseen" +
", (SELECT COUNT(operation.id) FROM operation WHERE operation.folder = folder.id AND operation.state = 'executing') AS executing" +
", (SELECT COUNT(child.id) FROM folder child WHERE child.parent = folder.id) AS childs" + ", (SELECT COUNT(child.id) FROM folder child WHERE child.parent = folder.id) AS childs" +
" FROM folder" + " FROM folder" +
" LEFT JOIN account ON account.id = folder.account" + " LEFT JOIN account ON account.id = folder.account" +
@ -80,6 +81,7 @@ public interface DaoFolder {
", COUNT(message.id) AS messages" + ", COUNT(message.id) AS messages" +
", SUM(CASE WHEN message.content = 1 THEN 1 ELSE 0 END) AS content" + ", SUM(CASE WHEN message.content = 1 THEN 1 ELSE 0 END) AS content" +
", SUM(CASE WHEN message.ui_seen = 0 THEN 1 ELSE 0 END) AS unseen" + ", SUM(CASE WHEN message.ui_seen = 0 THEN 1 ELSE 0 END) AS unseen" +
", (SELECT COUNT(operation.id) FROM operation WHERE operation.folder = folder.id AND operation.state = 'executing') AS executing" +
", (SELECT COUNT(child.id) FROM folder child WHERE child.parent = folder.id) AS childs" + ", (SELECT COUNT(child.id) FROM folder child WHERE child.parent = folder.id) AS childs" +
" FROM folder" + " FROM folder" +
" JOIN account ON account.id = folder.account" + " JOIN account ON account.id = folder.account" +
@ -92,7 +94,8 @@ public interface DaoFolder {
@Query("SELECT folder.*" + @Query("SELECT folder.*" +
", account.`order` AS accountOrder, account.name AS accountName, account.color AS accountColor" + ", account.`order` AS accountOrder, account.name AS accountName, account.color AS accountColor" +
", SUM(CASE WHEN message.ui_seen = 0 THEN 1 ELSE 0 END) AS unseen" + ", SUM(CASE WHEN message.ui_seen = 0 THEN 1 ELSE 0 END) AS unseen" +
", (SELECT COUNT(*) FROM operation WHERE operation.folder = folder.id) AS operations" + ", (SELECT COUNT(operation.id) FROM operation WHERE operation.folder = folder.id) AS operations" +
", (SELECT COUNT(operation.id) FROM operation WHERE operation.folder = folder.id AND operation.state = 'executing') AS executing" +
" FROM folder" + " FROM folder" +
" LEFT JOIN account ON account.id = folder.account" + " LEFT JOIN account ON account.id = folder.account" +
" LEFT JOIN message ON message.folder = folder.id AND NOT message.ui_hide" + " LEFT JOIN message ON message.folder = folder.id AND NOT message.ui_hide" +
@ -118,6 +121,7 @@ public interface DaoFolder {
", COUNT(message.id) AS messages" + ", COUNT(message.id) AS messages" +
", SUM(CASE WHEN message.content = 1 THEN 1 ELSE 0 END) AS content" + ", SUM(CASE WHEN message.content = 1 THEN 1 ELSE 0 END) AS content" +
", SUM(CASE WHEN message.ui_seen = 0 THEN 1 ELSE 0 END) AS unseen" + ", SUM(CASE WHEN message.ui_seen = 0 THEN 1 ELSE 0 END) AS unseen" +
", (SELECT COUNT(operation.id) FROM operation WHERE operation.folder = folder.id AND operation.state = 'executing') AS executing" +
", (SELECT COUNT(child.id) FROM folder child WHERE child.parent = folder.id) AS childs" + ", (SELECT COUNT(child.id) FROM folder child WHERE child.parent = folder.id) AS childs" +
" FROM folder" + " FROM folder" +
" LEFT JOIN account ON account.id = folder.account" + " LEFT JOIN account ON account.id = folder.account" +

@ -47,9 +47,11 @@ import static androidx.room.ForeignKey.CASCADE;
@ForeignKey(childColumns = "message", entity = EntityMessage.class, parentColumns = "id", onDelete = CASCADE) @ForeignKey(childColumns = "message", entity = EntityMessage.class, parentColumns = "id", onDelete = CASCADE)
}, },
indices = { indices = {
@Index(value = {"account"}),
@Index(value = {"folder"}), @Index(value = {"folder"}),
@Index(value = {"message"}), @Index(value = {"message"}),
@Index(value = {"name"}) @Index(value = {"name"}),
@Index(value = {"state"})
} }
) )
public class EntityOperation { public class EntityOperation {

@ -35,6 +35,7 @@ public class TupleFolderEx extends EntityFolder implements Serializable {
public int messages; public int messages;
public int content; public int content;
public int unseen; public int unseen;
public int executing;
public int childs; public int childs;
@Override @Override
@ -48,6 +49,7 @@ public class TupleFolderEx extends EntityFolder implements Serializable {
this.messages == other.messages && this.messages == other.messages &&
this.content == other.content && this.content == other.content &&
this.unseen == other.unseen && this.unseen == other.unseen &&
this.executing == other.executing &&
this.childs == other.childs); this.childs == other.childs);
} else } else
return false; return false;

@ -32,6 +32,7 @@ public class TupleFolderNav extends EntityFolder implements Serializable {
public Integer accountColor; public Integer accountColor;
public int unseen; public int unseen;
public int operations; public int operations;
public int executing;
@Override @Override
Comparator getComparator(final Context context) { Comparator getComparator(final Context context) {

@ -946,6 +946,28 @@
app:layout_constraintStart_toEndOf="@id/ivConnected" app:layout_constraintStart_toEndOf="@id/ivConnected"
app:layout_constraintTop_toTopOf="@id/ivConnected" /> app:layout_constraintTop_toTopOf="@id/ivConnected" />
<ImageView
android:id="@+id/ivExecuting"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginTop="24dp"
android:contentDescription="@string/title_legend_executing"
android:src="@drawable/baseline_list_24"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ivConnected" />
<TextView
android:id="@+id/tvExecuting"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="18dp"
android:text="@string/title_legend_executing"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintBottom_toBottomOf="@id/ivExecuting"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/ivExecuting"
app:layout_constraintTop_toTopOf="@id/ivExecuting" />
<ImageView <ImageView
android:id="@+id/ivSynchronizing" android:id="@+id/ivSynchronizing"
android:layout_width="24dp" android:layout_width="24dp"
@ -954,7 +976,7 @@
android:contentDescription="@string/title_legend_synchronizing" android:contentDescription="@string/title_legend_synchronizing"
android:src="@drawable/baseline_compare_arrows_24" android:src="@drawable/baseline_compare_arrows_24"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ivConnected" /> app:layout_constraintTop_toBottomOf="@id/ivExecuting" />
<TextView <TextView
android:id="@+id/tvSynchronizing" android:id="@+id/tvSynchronizing"

@ -597,6 +597,7 @@
<string name="title_legend_connecting">Connecting</string> <string name="title_legend_connecting">Connecting</string>
<string name="title_legend_connected">Connected</string> <string name="title_legend_connected">Connected</string>
<string name="title_legend_synchronizing">Synchronizing</string> <string name="title_legend_synchronizing">Synchronizing</string>
<string name="title_legend_executing">Executing operations</string>
<string name="title_legend_downloading">Downloading</string> <string name="title_legend_downloading">Downloading</string>
<string name="title_legend_closing">Closing</string> <string name="title_legend_closing">Closing</string>
<string name="title_legend_waiting">Waiting for next synchronization</string> <string name="title_legend_waiting">Waiting for next synchronization</string>

Loading…
Cancel
Save