mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-28 02:37:16 +00:00
Star from message item
This commit is contained in:
parent
b2e1336a3a
commit
74a991e4e4
3 changed files with 56 additions and 43 deletions
|
@ -254,6 +254,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
|
||||
private void wire() {
|
||||
itemView.setOnClickListener(this);
|
||||
ivFlagged.setOnClickListener(this);
|
||||
ivExpanderAddress.setOnClickListener(this);
|
||||
ivAddContact.setOnClickListener(this);
|
||||
btnHtml.setOnClickListener(this);
|
||||
|
@ -264,6 +265,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
|
||||
private void unwire() {
|
||||
itemView.setOnClickListener(null);
|
||||
ivFlagged.setOnClickListener(null);
|
||||
ivExpanderAddress.setOnClickListener(null);
|
||||
ivAddContact.setOnClickListener(null);
|
||||
btnHtml.setOnClickListener(null);
|
||||
|
@ -362,9 +364,12 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
ivExpander.setVisibility(View.GONE);
|
||||
|
||||
if (viewType == ViewType.THREAD)
|
||||
ivFlagged.setVisibility(message.unflagged == 1 ? View.GONE : View.VISIBLE);
|
||||
ivFlagged.setImageResource(message.unflagged == 1
|
||||
? R.drawable.baseline_star_border_24 : R.drawable.baseline_star_24);
|
||||
else
|
||||
ivFlagged.setVisibility(message.count - message.unflagged > 0 ? View.VISIBLE : View.GONE);
|
||||
ivFlagged.setImageResource(message.count - message.unflagged > 0
|
||||
? R.drawable.baseline_star_24 : R.drawable.baseline_star_border_24);
|
||||
ivFlagged.setVisibility(View.VISIBLE);
|
||||
|
||||
tvFrom.setText(MessageHelper.getFormattedAddresses(outgoing ? message.to : message.from, !compact));
|
||||
tvSize.setText(message.size == null ? null : Helper.humanReadableByteCount(message.size, true));
|
||||
|
@ -551,7 +556,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
|
||||
TupleMessageEx message = differ.getItem(pos);
|
||||
|
||||
if (view.getId() == R.id.ivAddContact)
|
||||
if (view.getId() == R.id.ivFlagged)
|
||||
onToggleFlag(message);
|
||||
else if (view.getId() == R.id.ivAddContact)
|
||||
onAddContact(message);
|
||||
else if (viewType == ViewType.THREAD) {
|
||||
if (view.getId() == R.id.ivExpanderAddress)
|
||||
|
@ -1130,11 +1137,15 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
}.load(context, owner, args);
|
||||
}
|
||||
|
||||
private void onFlag(ActionData data) {
|
||||
private void onToggleFlag(ActionData data) {
|
||||
onToggleFlag(data.message);
|
||||
}
|
||||
|
||||
private void onToggleFlag(TupleMessageEx message) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("id", data.message.id);
|
||||
args.putBoolean("flagged", !data.message.ui_flagged);
|
||||
Log.i(Helper.TAG, "Set message id=" + data.message.id + " flagged=" + !data.message.ui_flagged);
|
||||
args.putLong("id", message.id);
|
||||
args.putBoolean("flagged", !message.ui_flagged);
|
||||
Log.i(Helper.TAG, "Set message id=" + message.id + " flagged=" + !message.ui_flagged);
|
||||
|
||||
new SimpleTask<Void>() {
|
||||
@Override
|
||||
|
@ -1372,7 +1383,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
onUnseen(data);
|
||||
return true;
|
||||
case R.id.menu_flag:
|
||||
onFlag(data);
|
||||
onToggleFlag(data);
|
||||
return true;
|
||||
case R.id.menu_show_headers:
|
||||
onShowHeaders(data);
|
||||
|
@ -1455,7 +1466,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
List<EntityFolder> folders = db.folder().getFolders(message.account);
|
||||
List<EntityFolder> targets = new ArrayList<>();
|
||||
for (EntityFolder folder : folders)
|
||||
if (!folder.hide && !folder.id.equals(message.folder))
|
||||
if (!folder.hide &&
|
||||
!folder.id.equals(message.folder) &&
|
||||
!EntityFolder.ARCHIVE.equals(folder.type) &&
|
||||
!EntityFolder.TRASH.equals(folder.type) &&
|
||||
!EntityFolder.JUNK.equals(folder.type))
|
||||
targets.add(folder);
|
||||
|
||||
EntityFolder.sort(targets);
|
||||
|
|
|
@ -48,18 +48,6 @@
|
|||
app:layout_constraintStart_toEndOf="@+id/ivExpander"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivFlagged"
|
||||
android:layout_width="21dp"
|
||||
android:layout_height="21dp"
|
||||
android:layout_marginStart="6dp"
|
||||
android:src="@drawable/baseline_star_24"
|
||||
android:tint="?attr/colorUnread"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tvFrom"
|
||||
app:layout_constraintStart_toEndOf="@id/paddingStart"
|
||||
app:layout_constraintTop_toTopOf="@+id/tvFrom" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivAvatar"
|
||||
android:layout_width="0dp"
|
||||
|
@ -68,7 +56,7 @@
|
|||
android:src="@drawable/baseline_person_24"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/tvFrom"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintStart_toEndOf="@id/ivFlagged"
|
||||
app:layout_constraintStart_toEndOf="@id/paddingStart"
|
||||
app:layout_constraintTop_toTopOf="@+id/tvFrom" />
|
||||
|
||||
<TextView
|
||||
|
@ -101,12 +89,12 @@
|
|||
android:id="@+id/tvTime"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:maxLines="1"
|
||||
android:text="Time"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tvFrom"
|
||||
app:layout_constraintEnd_toStartOf="@+id/paddingEnd"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ivFlagged"
|
||||
app:layout_constraintTop_toTopOf="@id/tvFrom" />
|
||||
|
||||
<ImageView
|
||||
|
@ -171,12 +159,23 @@
|
|||
android:id="@+id/ivThread"
|
||||
android:layout_width="15dp"
|
||||
android:layout_height="15dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:src="@drawable/baseline_message_24"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tvSubject"
|
||||
app:layout_constraintEnd_toStartOf="@+id/paddingEnd"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ivFlagged"
|
||||
app:layout_constraintTop_toTopOf="@id/tvSubject" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivFlagged"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:src="@drawable/baseline_star_24"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tvSubject"
|
||||
app:layout_constraintEnd_toEndOf="@id/paddingEnd"
|
||||
app:layout_constraintTop_toTopOf="@+id/tvFrom" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvPreview"
|
||||
android:layout_width="0dp"
|
||||
|
|
|
@ -46,18 +46,6 @@
|
|||
app:layout_constraintStart_toEndOf="@+id/ivExpander"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivFlagged"
|
||||
android:layout_width="21dp"
|
||||
android:layout_height="21dp"
|
||||
android:layout_marginStart="6dp"
|
||||
android:src="@drawable/baseline_star_24"
|
||||
android:tint="?attr/colorUnread"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tvFrom"
|
||||
app:layout_constraintStart_toEndOf="@id/paddingStart"
|
||||
app:layout_constraintTop_toTopOf="@+id/tvFrom" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivAvatar"
|
||||
android:layout_width="0dp"
|
||||
|
@ -66,7 +54,7 @@
|
|||
android:src="@drawable/baseline_person_24"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/tvFrom"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintStart_toEndOf="@id/ivFlagged"
|
||||
app:layout_constraintStart_toEndOf="@id/paddingStart"
|
||||
app:layout_constraintTop_toTopOf="@+id/tvFrom" />
|
||||
|
||||
<TextView
|
||||
|
@ -86,7 +74,7 @@
|
|||
android:id="@+id/tvSize"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:maxLines="1"
|
||||
android:text="123 KB"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
|
@ -103,7 +91,7 @@
|
|||
android:text="Time"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tvFrom"
|
||||
app:layout_constraintEnd_toStartOf="@+id/paddingEnd"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ivFlagged"
|
||||
app:layout_constraintTop_toTopOf="@id/tvFrom" />
|
||||
|
||||
<ImageView
|
||||
|
@ -168,12 +156,23 @@
|
|||
android:id="@+id/ivThread"
|
||||
android:layout_width="15dp"
|
||||
android:layout_height="15dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:src="@drawable/baseline_message_24"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tvSubject"
|
||||
app:layout_constraintEnd_toStartOf="@+id/paddingEnd"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ivFlagged"
|
||||
app:layout_constraintTop_toTopOf="@id/tvSubject" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivFlagged"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:src="@drawable/baseline_star_24"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tvSubject"
|
||||
app:layout_constraintEnd_toEndOf="@id/paddingEnd"
|
||||
app:layout_constraintTop_toTopOf="@+id/tvFrom" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvPreview"
|
||||
android:layout_width="0dp"
|
||||
|
|
Loading…
Reference in a new issue