mirror of https://github.com/M66B/FairEmail.git
Added notes color
This commit is contained in:
parent
a7ec00e6ea
commit
4497fb060c
File diff suppressed because it is too large
Load Diff
|
@ -216,6 +216,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
private int colorAccent;
|
||||
private int textColorPrimary;
|
||||
private int textColorSecondary;
|
||||
private int textColorTertiary;
|
||||
private int textColorLink;
|
||||
private int colorUnread;
|
||||
private int colorRead;
|
||||
|
@ -1146,6 +1147,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
tvPreview.setVisibility(preview && !TextUtils.isEmpty(message.preview) ? View.VISIBLE : View.GONE);
|
||||
|
||||
tvNotes.setText(message.notes);
|
||||
tvNotes.setTextColor(message.notes_color == null ? textColorTertiary : message.notes_color);
|
||||
tvNotes.setVisibility(TextUtils.isEmpty(message.notes) ? View.GONE : View.VISIBLE);
|
||||
|
||||
// Error / warning
|
||||
|
@ -4639,6 +4641,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
Bundle args = new Bundle();
|
||||
args.putLong("id", message.id);
|
||||
args.putString("notes", message.notes);
|
||||
args.putInt("color", message.notes_color == null ? Color.TRANSPARENT : message.notes_color);
|
||||
|
||||
FragmentDialogNotes fragment = new FragmentDialogNotes();
|
||||
fragment.setArguments(args);
|
||||
|
@ -5331,6 +5334,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
this.colorAccent = Helper.resolveColor(context, R.attr.colorAccent);
|
||||
this.textColorPrimary = Helper.resolveColor(context, android.R.attr.textColorPrimary);
|
||||
this.textColorSecondary = Helper.resolveColor(context, android.R.attr.textColorSecondary);
|
||||
this.textColorTertiary = Helper.resolveColor(context, android.R.attr.textColorTertiary);
|
||||
this.textColorLink = Helper.resolveColor(context, android.R.attr.textColorLink);
|
||||
|
||||
boolean highlight_unread = prefs.getBoolean("highlight_unread", true);
|
||||
|
@ -5573,9 +5577,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
same = false;
|
||||
log("preview changed", next.id);
|
||||
}
|
||||
if (!Objects.equals(prev.notes, next.notes)) {
|
||||
if (!Objects.equals(prev.notes, next.notes) ||
|
||||
!Objects.equals(prev.notes_color, next.notes_color)) {
|
||||
same = false;
|
||||
log("notes changed", next.id);
|
||||
log("notes/color changed", next.id);
|
||||
}
|
||||
if (!Objects.equals(prev.sent, next.sent)) {
|
||||
same = false;
|
||||
|
@ -6377,22 +6382,49 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
}
|
||||
|
||||
public static class FragmentDialogNotes extends FragmentDialogBase {
|
||||
private ViewButtonColor btnColor;
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
final long id = getArguments().getLong("id");
|
||||
final String notes = getArguments().getString("notes");
|
||||
final Bundle args = getArguments();
|
||||
final long id = args.getLong("id");
|
||||
final String notes = args.getString("notes");
|
||||
final Integer color = args.getInt("color");
|
||||
|
||||
final Context context = getContext();
|
||||
final InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.dialog_notes, null);
|
||||
final EditText etNotes = view.findViewById(R.id.etNotes);
|
||||
etNotes.setText(notes);
|
||||
etNotes.selectAll();
|
||||
btnColor = view.findViewById(R.id.btnColor);
|
||||
|
||||
etNotes.setText(notes);
|
||||
btnColor.setColor(color);
|
||||
|
||||
|
||||
etNotes.selectAll();
|
||||
etNotes.requestFocus();
|
||||
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
|
||||
if (imm != null)
|
||||
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
|
||||
|
||||
btnColor.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (imm != null)
|
||||
imm.hideSoftInputFromWindow(etNotes.getWindowToken(), 0);
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("color", btnColor.getColor());
|
||||
args.putString("title", getString(R.string.title_color));
|
||||
args.putBoolean("reset", true);
|
||||
|
||||
FragmentDialogColor fragment = new FragmentDialogColor();
|
||||
fragment.setArguments(args);
|
||||
fragment.setTargetFragment(FragmentDialogNotes.this, 1);
|
||||
fragment.show(getParentFragmentManager(), "identity:color");
|
||||
}
|
||||
});
|
||||
|
||||
return new AlertDialog.Builder(context)
|
||||
.setView(view)
|
||||
|
@ -6402,16 +6434,21 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
Bundle args = new Bundle();
|
||||
args.putLong("id", id);
|
||||
args.putString("notes", etNotes.getText().toString());
|
||||
args.putInt("color", btnColor.getColor());
|
||||
|
||||
new SimpleTask<Void>() {
|
||||
@Override
|
||||
protected Void onExecute(Context context, Bundle args) {
|
||||
long id = args.getLong("id");
|
||||
String notes = args.getString("notes");
|
||||
Integer color = args.getInt("color");
|
||||
|
||||
if ("".equals(notes.trim()))
|
||||
notes = null;
|
||||
|
||||
if (color == Color.TRANSPARENT)
|
||||
color = null;
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
try {
|
||||
db.beginTransaction();
|
||||
|
@ -6420,7 +6457,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
if (message == null)
|
||||
return null;
|
||||
|
||||
db.message().setMessageNotes(message.id, notes);
|
||||
db.message().setMessageNotes(message.id, notes, color);
|
||||
|
||||
if (TextUtils.isEmpty(message.msgid))
|
||||
return null;
|
||||
|
@ -6430,7 +6467,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
return null;
|
||||
|
||||
for (EntityMessage m : messages)
|
||||
db.message().setMessageNotes(m.id, notes);
|
||||
db.message().setMessageNotes(m.id, notes, color);
|
||||
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
|
@ -6450,6 +6487,16 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
if (resultCode == RESULT_OK && data != null) {
|
||||
Bundle args = data.getBundleExtra("args");
|
||||
btnColor.setColor(args.getInt("color"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class FragmentDialogKeywordManage extends FragmentDialogBase {
|
||||
|
@ -6519,7 +6566,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
etKeyword.setText(null);
|
||||
|
||||
etKeyword.requestFocus();
|
||||
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
|
||||
if (imm != null)
|
||||
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
|
||||
|
||||
return new AlertDialog.Builder(context)
|
||||
.setView(view)
|
||||
|
|
|
@ -3051,6 +3051,7 @@ class Core {
|
|||
// - messages in archive have same id as original
|
||||
Integer color = null;
|
||||
String notes = null;
|
||||
Integer notes_color = null;
|
||||
if (message == null) {
|
||||
String msgid = helper.getMessageID();
|
||||
Log.i(folder.name + " searching for " + msgid);
|
||||
|
@ -3093,8 +3094,10 @@ class Core {
|
|||
|
||||
if (dup.flagged && dup.color != null)
|
||||
color = dup.color;
|
||||
if (dup.notes != null)
|
||||
if (dup.notes != null) {
|
||||
notes = dup.notes;
|
||||
notes_color = dup.notes_color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3164,6 +3167,7 @@ class Core {
|
|||
message.ui_encrypt = message.encrypt;
|
||||
message.received = received;
|
||||
message.notes = notes;
|
||||
message.notes_color = notes_color;
|
||||
message.sent = sent;
|
||||
message.seen = seen;
|
||||
message.answered = answered;
|
||||
|
|
|
@ -65,7 +65,7 @@ import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_PASSWORD;
|
|||
// https://developer.android.com/topic/libraries/architecture/room.html
|
||||
|
||||
@Database(
|
||||
version = 192,
|
||||
version = 193,
|
||||
entities = {
|
||||
EntityIdentity.class,
|
||||
EntityAccount.class,
|
||||
|
@ -1974,6 +1974,13 @@ public abstract class DB extends RoomDatabase {
|
|||
Log.i("DB migration from version " + startVersion + " to " + endVersion);
|
||||
db.execSQL("ALTER TABLE `folder` ADD COLUMN `modseq` INTEGER");
|
||||
}
|
||||
})
|
||||
.addMigrations(new Migration(192, 193) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase db) {
|
||||
Log.i("DB migration from version " + startVersion + " to " + endVersion);
|
||||
db.execSQL("ALTER TABLE `message` ADD COLUMN `notes_color` INTEGER");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -732,8 +732,11 @@ 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 notes = :notes, notes_color = :color" +
|
||||
" WHERE id = :id" +
|
||||
" AND NOT (notes IS :notes AND notes_color IS :color)")
|
||||
int setMessageNotes(long id, String notes, Integer color);
|
||||
|
||||
@Query("UPDATE message" +
|
||||
" SET size = :size, total = :total" +
|
||||
|
|
|
@ -175,6 +175,7 @@ public class EntityMessage implements Serializable {
|
|||
public Boolean verified = false;
|
||||
public String preview;
|
||||
public String notes;
|
||||
public Integer notes_color;
|
||||
@NonNull
|
||||
public Boolean signature = true;
|
||||
public Long sent; // compose = null
|
||||
|
@ -534,6 +535,7 @@ public class EntityMessage implements Serializable {
|
|||
this.verified == other.verified &&
|
||||
Objects.equals(this.preview, other.preview) &&
|
||||
Objects.equals(this.notes, other.notes) &&
|
||||
Objects.equals(this.notes_color, other.notes_color) &&
|
||||
this.signature.equals(other.signature) &&
|
||||
Objects.equals(this.sent, other.sent) &&
|
||||
this.received.equals(other.received) &&
|
||||
|
|
|
@ -320,10 +320,10 @@ public class FragmentBase extends Fragment {
|
|||
super.onDetach();
|
||||
|
||||
try {
|
||||
InputMethodManager im = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
View focused = getActivity().getCurrentFocus();
|
||||
if (focused != null)
|
||||
im.hideSoftInputFromWindow(focused.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
|
||||
if (imm != null && focused != null)
|
||||
imm.hideSoftInputFromWindow(focused.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
|
||||
} catch (Throwable ex) {
|
||||
Log.w(ex);
|
||||
/*
|
||||
|
|
|
@ -280,7 +280,8 @@ public class FragmentDialogSearch extends FragmentDialogBase {
|
|||
}
|
||||
|
||||
etQuery.requestFocus();
|
||||
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
|
||||
if (imm != null)
|
||||
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
|
||||
|
||||
final AlertDialog dialog = new AlertDialog.Builder(context)
|
||||
.setView(dview)
|
||||
|
|
|
@ -1,33 +1,60 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<eu.faircode.email.ScrollViewEx 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">
|
||||
android:padding="24dp"
|
||||
android:scrollbarStyle="outsideOverlay">
|
||||
|
||||
<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" />
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<eu.faircode.email.EditTextPlain
|
||||
android:id="@+id/etNotes"
|
||||
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">
|
||||
<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" />
|
||||
|
||||
<requestFocus />
|
||||
</eu.faircode.email.EditTextPlain>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<eu.faircode.email.EditTextPlain
|
||||
android:id="@+id/etNotes"
|
||||
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>
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvColor"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_color"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/etNotes" />
|
||||
|
||||
<eu.faircode.email.ViewButtonColor
|
||||
android:id="@+id/btnColor"
|
||||
style="?android:attr/buttonStyleSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:paddingHorizontal="6dp"
|
||||
android:text="@string/title_select"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvColor" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</eu.faircode.email.ScrollViewEx>
|
Loading…
Reference in New Issue