mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-14 08:01:23 +00:00
Added share images button
This commit is contained in:
parent
43fc86ff6b
commit
a5f5f451cd
2 changed files with 68 additions and 3 deletions
|
@ -484,6 +484,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
private Button btnCalendarMaybe;
|
||||
private ContentLoadingProgressBar pbCalendarWait;
|
||||
|
||||
private ImageButton ibShareImages;
|
||||
private RecyclerView rvImage;
|
||||
|
||||
private Group grpAddresses;
|
||||
|
@ -861,6 +862,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
ibSeenBottom = vsBody.findViewById(R.id.ibSeenBottom);
|
||||
flow = vsBody.findViewById(R.id.flow);
|
||||
|
||||
ibShareImages = vsBody.findViewById(R.id.ibShareImages);
|
||||
rvImage = vsBody.findViewById(R.id.rvImage);
|
||||
rvImage.setHasFixedSize(false);
|
||||
StaggeredGridLayoutManager sglm =
|
||||
|
@ -993,6 +995,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
btnCalendarAccept.setOnLongClickListener(this);
|
||||
btnCalendarDecline.setOnLongClickListener(this);
|
||||
btnCalendarMaybe.setOnLongClickListener(this);
|
||||
|
||||
ibShareImages.setOnClickListener(this);
|
||||
}
|
||||
|
||||
if (accessibility) {
|
||||
|
@ -1091,6 +1095,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
btnCalendarAccept.setOnLongClickListener(null);
|
||||
btnCalendarDecline.setOnLongClickListener(null);
|
||||
btnCalendarMaybe.setOnLongClickListener(null);
|
||||
|
||||
ibShareImages.setOnClickListener(null);
|
||||
}
|
||||
|
||||
if (accessibility)
|
||||
|
@ -3390,6 +3396,51 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
}.execute(context, owner, args, "message:participation");
|
||||
}
|
||||
|
||||
private void onShareImages(TupleMessageEx message) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("id", message.id);
|
||||
|
||||
new SimpleTask<ArrayList<Uri>>() {
|
||||
@Override
|
||||
protected ArrayList<Uri> onExecute(Context context, Bundle args) {
|
||||
long id = args.getLong("id");
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
List<EntityAttachment> attachments = db.attachment().getAttachments(id);
|
||||
if (attachments == null)
|
||||
return null;
|
||||
|
||||
ArrayList<Uri> result = new ArrayList<>();
|
||||
for (EntityAttachment attachment : attachments)
|
||||
if (attachment.isAttachment() && attachment.isImage()) {
|
||||
File file = attachment.getFile(context);
|
||||
Uri uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID, file);
|
||||
result.add(uri);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, ArrayList<Uri> uris) {
|
||||
if (uris == null)
|
||||
return;
|
||||
|
||||
final Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
|
||||
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
|
||||
intent.setType("image/*");
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
context.startActivity(Intent.createChooser(intent, context.getString(R.string.app_name)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
|
||||
}
|
||||
}.execute(context, owner, args, "attachments:share");
|
||||
}
|
||||
|
||||
private boolean isOutgoing(TupleMessageEx message) {
|
||||
if (EntityFolder.isOutgoing(message.folderType))
|
||||
return true;
|
||||
|
@ -3562,6 +3613,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
onMenuSetImportance(message, importance);
|
||||
} else if (id == R.id.btnCalendarAccept || id == R.id.btnCalendarDecline || id == R.id.btnCalendarMaybe || id == R.id.ibCalendar) {
|
||||
onActionCalendar(message, view.getId(), false);
|
||||
} else if (id == R.id.ibShareImages) {
|
||||
onShareImages(message);
|
||||
} else {
|
||||
onToggleMessage(message);
|
||||
}
|
||||
|
|
|
@ -14,18 +14,30 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<eu.faircode.email.FixedImageButton
|
||||
android:id="@+id/ibShareImages"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/title_share"
|
||||
android:padding="6dp"
|
||||
android:scaleType="fitCenter"
|
||||
android:tooltipText="@string/title_save_all"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/vSeparatorImages"
|
||||
app:srcCompat="@drawable/twotone_share_24" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rvImage"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="3dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/vSeparatorImages" />
|
||||
app:layout_constraintTop_toBottomOf="@id/ibShareImages" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/grpImages"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:constraint_referenced_ids="vSeparatorImages,rvImage" />
|
||||
app:constraint_referenced_ids="vSeparatorImages,ibShareImages,rvImage" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
Loading…
Add table
Reference in a new issue