mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-03 03:19:24 +01:00
Added operation state
This commit is contained in:
1759
app/schemas/eu.faircode.email.DB/81.json
Normal file
1759
app/schemas/eu.faircode.email.DB/81.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -26,6 +26,7 @@ import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -53,6 +54,7 @@ public class AdapterOperation extends RecyclerView.Adapter<AdapterOperation.View
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
|
||||
private View view;
|
||||
private ImageView ivState;
|
||||
private TextView tvFolder;
|
||||
private TextView tvOperation;
|
||||
private TextView tvTime;
|
||||
@@ -62,6 +64,7 @@ public class AdapterOperation extends RecyclerView.Adapter<AdapterOperation.View
|
||||
super(itemView);
|
||||
|
||||
view = itemView.findViewById(R.id.clItem);
|
||||
ivState = itemView.findViewById(R.id.ivState);
|
||||
tvFolder = itemView.findViewById(R.id.tvFolder);
|
||||
tvOperation = itemView.findViewById(R.id.tvOperation);
|
||||
tvTime = itemView.findViewById(R.id.tvTime);
|
||||
@@ -96,6 +99,7 @@ public class AdapterOperation extends RecyclerView.Adapter<AdapterOperation.View
|
||||
String folderName =
|
||||
(operation.accountName == null ? "" : operation.accountName + "/") + operation.folderName;
|
||||
|
||||
ivState.setVisibility(operation.state == null ? View.INVISIBLE : View.VISIBLE);
|
||||
tvFolder.setText(folderName);
|
||||
tvOperation.setText(sb.toString());
|
||||
tvTime.setText(Helper.getRelativeTimeSpanString(context, operation.created));
|
||||
|
||||
@@ -180,6 +180,8 @@ class Core {
|
||||
|
||||
// Operations should use database transaction when needed
|
||||
|
||||
db.operation().setOperationState(op.id, "executing");
|
||||
|
||||
switch (op.name) {
|
||||
case EntityOperation.SEEN:
|
||||
onSeen(context, jargs, folder, message, (IMAPFolder) ifolder);
|
||||
@@ -307,6 +309,8 @@ class Core {
|
||||
}
|
||||
|
||||
throw ex;
|
||||
} finally {
|
||||
db.operation().setOperationState(op.id, null);
|
||||
}
|
||||
} finally {
|
||||
Log.i(folder.name + " end op=" + op.id + "/" + op.name);
|
||||
|
||||
@@ -51,7 +51,7 @@ import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory;
|
||||
// https://developer.android.com/topic/libraries/architecture/room.html
|
||||
|
||||
@Database(
|
||||
version = 80,
|
||||
version = 81,
|
||||
entities = {
|
||||
EntityIdentity.class,
|
||||
EntityAccount.class,
|
||||
@@ -809,6 +809,13 @@ public abstract class DB extends RoomDatabase {
|
||||
db.execSQL("CREATE INDEX `index_attachment_message_cid` ON `attachment` (`message`, `cid`)");
|
||||
}
|
||||
})
|
||||
.addMigrations(new Migration(80, 81) {
|
||||
@Override
|
||||
public void migrate(SupportSQLiteDatabase db) {
|
||||
Log.i("DB migration from version " + startVersion + " to " + endVersion);
|
||||
db.execSQL("ALTER TABLE `operation` ADD COLUMN `state` TEXT");
|
||||
}
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -93,6 +93,9 @@ public interface DaoOperation {
|
||||
" AND message = :message")
|
||||
int getOperationCount(long folder, long message);
|
||||
|
||||
@Query("UPDATE operation SET state = :state WHERE id = :id")
|
||||
int setOperationState(long id, String state);
|
||||
|
||||
@Query("UPDATE operation SET error = :error WHERE id = :id")
|
||||
int setOperationError(long id, String error);
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ public class EntityOperation {
|
||||
public String args;
|
||||
@NonNull
|
||||
public Long created;
|
||||
public String state;
|
||||
public String error;
|
||||
|
||||
static final String ADD = "add";
|
||||
@@ -285,6 +286,7 @@ public class EntityOperation {
|
||||
this.name.equals(other.name) &&
|
||||
this.args.equals(other.args) &&
|
||||
this.created.equals(other.created) &&
|
||||
Objects.equals(this.state, other.state) &&
|
||||
Objects.equals(this.error, other.error));
|
||||
} else
|
||||
return false;
|
||||
|
||||
@@ -14,59 +14,69 @@
|
||||
android:paddingEnd="6dp"
|
||||
android:paddingBottom="3dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivState"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/title_legend_synchronizing"
|
||||
android:src="@drawable/baseline_compare_arrows_24"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvFolder"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
android:ellipsize="middle"
|
||||
android:gravity="center_vertical"
|
||||
android:singleLine="true"
|
||||
android:text="Folder"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintWidth_default="percent"
|
||||
app:layout_constraintWidth_percent=".40" />
|
||||
app:layout_constraintBottom_toBottomOf="@id/ivState"
|
||||
app:layout_constraintStart_toEndOf="@id/ivState"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvOperation"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:ellipsize="end"
|
||||
android:paddingStart="6dp"
|
||||
android:gravity="center_vertical"
|
||||
android:singleLine="true"
|
||||
android:text="Name"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintBottom_toBottomOf="@id/ivState"
|
||||
app:layout_constraintEnd_toStartOf="@+id/tvTime"
|
||||
app:layout_constraintStart_toEndOf="@id/tvFolder"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintWidth_default="percent"
|
||||
app:layout_constraintWidth_percent=".40" />
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvTime"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="start"
|
||||
android:gravity="end"
|
||||
android:paddingStart="6dp"
|
||||
android:gravity="center_vertical"
|
||||
android:singleLine="true"
|
||||
android:text="Time"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintBottom_toBottomOf="@id/ivState"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintWidth_default="percent"
|
||||
app:layout_constraintWidth_percent=".20" />
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvError"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
android:text="error"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textColor="?attr/colorWarning"
|
||||
android:textIsSelectable="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/ivState"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvFolder" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</FrameLayout>
|
||||
Reference in New Issue
Block a user