Show auto classified

pull/190/head
M66B 4 years ago
parent 83e888a1bd
commit 3b98e55f5d

File diff suppressed because it is too large Load Diff

@ -341,6 +341,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private TextView tvTime;
private ImageView ivType;
private ImageView ivFound;
private ImageView ivClassified;
private ImageButton ibSnoozed;
private ImageView ivAnswered;
private ImageView ivForwarded;
@ -503,6 +504,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
tvTime = itemView.findViewById(R.id.tvTime);
ivType = itemView.findViewById(R.id.ivType);
ivFound = itemView.findViewById(R.id.ivFound);
ivClassified = itemView.findViewById(R.id.ivClassified);
ibSnoozed = itemView.findViewById(R.id.ibSnoozed);
ivAnswered = itemView.findViewById(R.id.ivAnswered);
ivForwarded = itemView.findViewById(R.id.ivForwarded);
@ -940,6 +942,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
tvTime.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
ivType.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
ivFound.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
ivClassified.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
ibSnoozed.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
ivAnswered.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
ivForwarded.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
@ -1042,6 +1045,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
ivFound.setVisibility(message.ui_found && found ? View.VISIBLE : View.GONE);
ivClassified.setVisibility(message.auto_classified ? View.VISIBLE : View.GONE);
int snoozy = (message.ui_snoozed != null && message.ui_snoozed == Long.MAX_VALUE
? R.drawable.twotone_visibility_off_24

@ -64,7 +64,7 @@ import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_PASSWORD;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 182,
version = 183,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -1788,6 +1788,13 @@ public abstract class DB extends RoomDatabase {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `folder` ADD COLUMN `auto_classify` INTEGER NOT NULL DEFAULT 0");
}
})
.addMigrations(new Migration(182, 183) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `message` ADD COLUMN `auto_classified` INTEGER NOT NULL DEFAULT 0");
}
});
}

@ -186,6 +186,8 @@ public class EntityMessage implements Serializable {
@NonNull
public Boolean fts = false;
@NonNull
public Boolean auto_classified = false;
@NonNull
public Boolean ui_seen = false;
@NonNull
public Boolean ui_answered = false;

@ -167,7 +167,12 @@ public class EntityOperation {
db.message().setMessageLabels(message.id, DB.Converters.fromStringArray(message.labels));
} else if (MOVE.equals(name)) {
// Parameters:
// Parameters in:
// 0: target folder
// 1: mark seen
// 2: auto classified
// Parameters out:
// 0: target folder
// 1: mark seen
// 2: temporary message
@ -183,6 +188,13 @@ public class EntityOperation {
autoread = jargs.getBoolean(1);
autounflag = false;
}
boolean auto_classified = false;
if (jargs.opt(2) != null) {
auto_classified = jargs.getBoolean(2);
jargs.remove(2);
}
jargs.put(1, autoread);
jargs.put(3, autounflag);
@ -266,6 +278,7 @@ public class EntityOperation {
message.stored = new Date().getTime();
message.notifying = 0;
message.fts = false;
message.auto_classified = auto_classified;
if (reset_importance)
message.importance = null;
if (autoread) {

@ -110,9 +110,16 @@ public class MessageClassifier {
if (classified != null) {
EntityFolder f = db.folder().getFolderByName(account.id, classified);
if (f != null && !f.id.equals(folder.id) && f.auto_classify) {
EntityOperation.queue(context, message, EntityOperation.MOVE, f.id, false);
if (f != null && !f.id.equals(folder.id) && f.auto_classify)
try {
db.beginTransaction();
EntityOperation.queue(context, message, EntityOperation.MOVE, f.id, false, true);
message.ui_hide = true;
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
} catch (Throwable ex) {

@ -257,6 +257,28 @@
app:layout_constraintStart_toEndOf="@id/ivEncrypted"
app:layout_constraintTop_toTopOf="@id/ivEncrypted" />
<ImageView
android:id="@+id/ivClassified"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/title_legend_classified"
android:padding="12dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ivEncrypted"
app:srcCompat="@drawable/twotone_label_24" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvClassified"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center_vertical"
android:text="@string/title_legend_classified"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintBottom_toBottomOf="@id/ivClassified"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/ivClassified"
app:layout_constraintTop_toTopOf="@id/ivClassified" />
<ImageView
android:id="@+id/ivSnoozed"
android:layout_width="wrap_content"
@ -264,7 +286,7 @@
android:contentDescription="@string/title_legend_snoozed"
android:padding="12dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ivEncrypted"
app:layout_constraintTop_toBottomOf="@id/ivClassified"
app:srcCompat="@drawable/twotone_timelapse_24" />
<eu.faircode.email.FixedTextView

@ -189,6 +189,17 @@
app:layout_constraintTop_toTopOf="@+id/tvSubject"
app:srcCompat="@drawable/twotone_search_24" />
<ImageView
android:id="@+id/ivClassified"
android:layout_width="21dp"
android:layout_height="21dp"
android:layout_marginStart="6dp"
android:contentDescription="@string/title_legend_classified"
app:layout_constraintBottom_toBottomOf="@+id/tvSubject"
app:layout_constraintStart_toEndOf="@id/ivFound"
app:layout_constraintTop_toTopOf="@+id/tvSubject"
app:srcCompat="@drawable/twotone_label_24" />
<ImageButton
android:id="@+id/ibSnoozed"
android:layout_width="21dp"
@ -197,7 +208,7 @@
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_legend_snoozed"
app:layout_constraintBottom_toBottomOf="@+id/tvSubject"
app:layout_constraintStart_toEndOf="@id/ivFound"
app:layout_constraintStart_toEndOf="@id/ivClassified"
app:layout_constraintTop_toTopOf="@+id/tvSubject"
app:srcCompat="@drawable/twotone_timelapse_24" />

@ -228,6 +228,17 @@
app:layout_constraintTop_toTopOf="@+id/tvFolder"
app:srcCompat="@drawable/twotone_search_24" />
<ImageView
android:id="@+id/ivClassified"
android:layout_width="21dp"
android:layout_height="21dp"
android:layout_marginStart="6dp"
android:contentDescription="@string/title_legend_classified"
app:layout_constraintBottom_toBottomOf="@+id/tvFolder"
app:layout_constraintStart_toEndOf="@id/ivFound"
app:layout_constraintTop_toTopOf="@+id/tvFolder"
app:srcCompat="@drawable/twotone_label_24" />
<ImageButton
android:id="@+id/ibSnoozed"
android:layout_width="21dp"
@ -236,7 +247,7 @@
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_legend_snoozed"
app:layout_constraintBottom_toBottomOf="@+id/tvFolder"
app:layout_constraintStart_toEndOf="@id/ivFound"
app:layout_constraintStart_toEndOf="@id/ivClassified"
app:layout_constraintTop_toTopOf="@+id/tvFolder"
app:srcCompat="@drawable/twotone_timelapse_24" />

@ -1279,6 +1279,7 @@
<string name="title_legend_encrypted">Is encrypted</string>
<string name="title_legend_auth">Authentication failed</string>
<string name="title_legend_found">Was found</string>
<string name="title_legend_classified">Was classified</string>
<string name="title_legend_snoozed">Is snoozed</string>
<string name="title_legend_browsed">Is browsed or searched</string>
<string name="title_legend_answered">Was answered</string>

Loading…
Cancel
Save