mirror of https://github.com/M66B/FairEmail.git
Added local notes
This commit is contained in:
parent
a2c3e9ad57
commit
6b9ac9c54f
File diff suppressed because it is too large
Load Diff
|
@ -356,6 +356,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
private ImageView ivThread;
|
||||
private TextView tvExpand;
|
||||
private TextView tvPreview;
|
||||
private TextView tvNotes;
|
||||
private TextView tvError;
|
||||
private ImageButton ibHelp;
|
||||
|
||||
|
@ -516,6 +517,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
tvKeywords = itemView.findViewById(R.id.tvKeywords);
|
||||
tvExpand = itemView.findViewById(R.id.tvExpand);
|
||||
tvPreview = itemView.findViewById(R.id.tvPreview);
|
||||
tvNotes = itemView.findViewById(R.id.tvNotes);
|
||||
tvFolder = itemView.findViewById(R.id.tvFolder);
|
||||
tvLabels = itemView.findViewById(R.id.tvLabels);
|
||||
tvCount = itemView.findViewById(R.id.tvCount);
|
||||
|
@ -922,6 +924,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
tvFolder.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize * 0.9f);
|
||||
tvLabels.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize * 0.9f);
|
||||
tvPreview.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize * 0.9f);
|
||||
tvNotes.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize * 0.9f);
|
||||
}
|
||||
|
||||
// Selected / disabled
|
||||
|
@ -960,6 +963,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
tvCount.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
|
||||
ivThread.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
|
||||
tvPreview.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
|
||||
tvNotes.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
|
||||
tvError.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
|
||||
}
|
||||
|
||||
|
@ -1127,6 +1131,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
tvPreview.setText(message.preview);
|
||||
tvPreview.setVisibility(preview && !TextUtils.isEmpty(message.preview) ? View.VISIBLE : View.GONE);
|
||||
|
||||
tvNotes.setText(message.notes);
|
||||
tvNotes.setVisibility(TextUtils.isEmpty(message.notes) ? View.GONE : View.VISIBLE);
|
||||
|
||||
// Error / warning
|
||||
String error = message.error;
|
||||
if (message.warning != null)
|
||||
|
@ -4165,6 +4172,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
case R.id.menu_resync:
|
||||
onMenuResync(message);
|
||||
return true;
|
||||
case R.id.menu_edit_notes:
|
||||
onMenuNotes(message);
|
||||
return true;
|
||||
case R.id.menu_search_in_text:
|
||||
onMenuSearch(message);
|
||||
return true;
|
||||
|
@ -4603,6 +4613,16 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
}.execute(context, owner, args, "message:resync");
|
||||
}
|
||||
|
||||
private void onMenuNotes(TupleMessageEx message) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("id", message.id);
|
||||
args.putString("notes", message.notes);
|
||||
|
||||
FragmentDialogNotes fragment = new FragmentDialogNotes();
|
||||
fragment.setArguments(args);
|
||||
fragment.show(parentFragment.getParentFragmentManager(), "edit:notes");
|
||||
}
|
||||
|
||||
private void onMenuSearch(TupleMessageEx message) {
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
View dview = inflater.inflate(R.layout.popup_search_in_text, null, false);
|
||||
|
@ -5509,6 +5529,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
same = false;
|
||||
log("preview changed", next.id);
|
||||
}
|
||||
if (!Objects.equals(prev.notes, next.notes)) {
|
||||
same = false;
|
||||
log("preview changed", next.id);
|
||||
}
|
||||
if (!Objects.equals(prev.sent, next.sent)) {
|
||||
same = false;
|
||||
log("sent changed", next.id);
|
||||
|
@ -6632,6 +6656,53 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
}
|
||||
}
|
||||
|
||||
public static class FragmentDialogNotes extends FragmentDialogBase {
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
final long id = getArguments().getLong("id");
|
||||
final String notes = getArguments().getString("notes");
|
||||
|
||||
View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_notes, null);
|
||||
final EditText etNote = view.findViewById(R.id.etNote);
|
||||
etNote.setText(notes);
|
||||
|
||||
return new AlertDialog.Builder(getContext())
|
||||
.setView(view)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("id", id);
|
||||
args.putString("notes", etNote.getText().toString());
|
||||
|
||||
new SimpleTask<Void>() {
|
||||
@Override
|
||||
protected Void onExecute(Context context, Bundle args) {
|
||||
long id = args.getLong("id");
|
||||
String notes = args.getString("notes");
|
||||
|
||||
if ("".equals(notes.trim()))
|
||||
notes = null;
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
db.message().setMessageNotes(id, notes);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Log.unexpectedError(getParentFragmentManager(), ex);
|
||||
}
|
||||
}.execute(getContext(), getActivity(), args, "message:note");
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create();
|
||||
}
|
||||
}
|
||||
|
||||
public static class FragmentDialogKeywordManage extends FragmentDialogBase {
|
||||
@NonNull
|
||||
@Override
|
||||
|
|
|
@ -64,7 +64,7 @@ import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_PASSWORD;
|
|||
// https://developer.android.com/topic/libraries/architecture/room.html
|
||||
|
||||
@Database(
|
||||
version = 184,
|
||||
version = 185,
|
||||
entities = {
|
||||
EntityIdentity.class,
|
||||
EntityAccount.class,
|
||||
|
@ -1809,6 +1809,13 @@ public abstract class DB extends RoomDatabase {
|
|||
" OR type = '" + EntityFolder.INBOX + "'" +
|
||||
" OR type = '" + EntityFolder.JUNK + "')");
|
||||
}
|
||||
})
|
||||
.addMigrations(new Migration(184, 185) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase db) {
|
||||
Log.i("DB migration from version " + startVersion + " to " + endVersion);
|
||||
db.execSQL("ALTER TABLE `message` ADD COLUMN `notes` TEXT");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -699,6 +699,9 @@ public interface DaoMessage {
|
|||
" OR NOT (warning IS :warning))")
|
||||
int setMessageContent(long id, boolean content, String language, Boolean plain_only, String preview, String warning);
|
||||
|
||||
@Query("UPDATE message SET notes = :notes WHERE id = :id AND NOT (notes IS :notes)")
|
||||
int setMessageNotes(long id, String notes);
|
||||
|
||||
@Query("UPDATE message" +
|
||||
" SET size = :size, total = :total" +
|
||||
" WHERE id = :id" +
|
||||
|
@ -790,7 +793,7 @@ public interface DaoMessage {
|
|||
" AND NOT EXISTS" +
|
||||
" (SELECT * FROM operation" +
|
||||
" WHERE operation.message = message.id" +
|
||||
" AND operation.name = '" + EntityOperation.ADD + "')"+
|
||||
" AND operation.name = '" + EntityOperation.ADD + "')" +
|
||||
" AND NOT EXISTS" +
|
||||
" (SELECT * FROM operation o" +
|
||||
" JOIN message m ON m.id = o.message" +
|
||||
|
|
|
@ -165,6 +165,7 @@ public class EntityMessage implements Serializable {
|
|||
@NonNull
|
||||
public Boolean verified = false;
|
||||
public String preview;
|
||||
public String notes;
|
||||
@NonNull
|
||||
public Boolean signature = true;
|
||||
public Long sent; // compose = null
|
||||
|
@ -510,6 +511,7 @@ public class EntityMessage implements Serializable {
|
|||
Objects.equals(this.ui_encrypt, other.ui_encrypt) &&
|
||||
this.verified == other.verified &&
|
||||
Objects.equals(this.preview, other.preview) &&
|
||||
Objects.equals(this.notes, other.notes) &&
|
||||
this.signature.equals(other.signature) &&
|
||||
Objects.equals(this.sent, other.sent) &&
|
||||
this.received.equals(other.received) &&
|
||||
|
|
|
@ -854,7 +854,6 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
Log.e(ex);
|
||||
}
|
||||
|
||||
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="24dp">
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvNotes"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:labelFor="@+id/etKeyword"
|
||||
android:text="@string/title_edit_notes"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<eu.faircode.email.EditTextPlain
|
||||
android:id="@+id/etNote"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:imeOptions="actionDone"
|
||||
android:inputType="textCapSentences|textMultiLine|textAutoCorrect"
|
||||
android:text="Notes"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvNotes">
|
||||
|
||||
<requestFocus />
|
||||
</eu.faircode.email.EditTextPlain>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -368,6 +368,19 @@
|
|||
app:layout_constraintStart_toEndOf="@id/paddingStart"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvExpand" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvNotes"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:text="Notes"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toStartOf="@+id/paddingEnd"
|
||||
app:layout_constraintStart_toEndOf="@id/paddingStart"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvPreview" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvError"
|
||||
android:layout_width="0dp"
|
||||
|
@ -382,7 +395,7 @@
|
|||
android:textIsSelectable="true"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ibHelp"
|
||||
app:layout_constraintStart_toEndOf="@id/paddingStart"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvPreview" />
|
||||
app:layout_constraintTop_toBottomOf="@id/tvNotes" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/ibHelp"
|
||||
|
|
|
@ -366,6 +366,20 @@
|
|||
app:layout_constraintStart_toEndOf="@id/paddingStart"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvExpand" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvNotes"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:text="Notes"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toStartOf="@+id/paddingEnd"
|
||||
app:layout_constraintStart_toEndOf="@id/paddingStart"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvPreview" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvError"
|
||||
android:layout_width="0dp"
|
||||
|
@ -381,7 +395,7 @@
|
|||
android:textIsSelectable="true"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ibHelp"
|
||||
app:layout_constraintStart_toEndOf="@id/paddingStart"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvPreview" />
|
||||
app:layout_constraintTop_toBottomOf="@id/tvNotes" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/ibHelp"
|
||||
|
|
|
@ -107,6 +107,10 @@
|
|||
android:id="@+id/menu_resync"
|
||||
android:title="@string/title_resync" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_edit_notes"
|
||||
android:title="@string/title_edit_notes" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_search_in_text"
|
||||
android:title="@string/title_search_in_text" />
|
||||
|
|
|
@ -850,6 +850,7 @@
|
|||
<string name="title_forward">Forward</string>
|
||||
<string name="title_new_message">New message</string>
|
||||
<string name="title_editasnew">Edit as new</string>
|
||||
<string name="title_edit_notes">Edit local notes</string>
|
||||
<string name="title_create_rule">Create rule …</string>
|
||||
<string name="title_share">Share</string>
|
||||
<string name="title_event">Add to calendar</string>
|
||||
|
|
Loading…
Reference in New Issue