mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Merge branch 'main' into adb/issue-4082
This commit is contained in:
@@ -65,6 +65,7 @@ public class RelayListAdapter extends RecyclerView.Adapter<RelayListAdapter.Rela
|
||||
|
||||
public static class RelayViewHolder extends RecyclerView.ViewHolder {
|
||||
private final TextView titleText;
|
||||
private final TextView subtitleText;
|
||||
private final ImageView mainIndicator;
|
||||
private final ImageView editButton;
|
||||
private final ImageView deleteButton;
|
||||
@@ -72,14 +73,17 @@ public class RelayListAdapter extends RecyclerView.Adapter<RelayListAdapter.Rela
|
||||
public RelayViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
titleText = itemView.findViewById(R.id.title);
|
||||
subtitleText = itemView.findViewById(R.id.subtitle);
|
||||
mainIndicator = itemView.findViewById(R.id.main_indicator);
|
||||
editButton = itemView.findViewById(R.id.edit_button);
|
||||
deleteButton = itemView.findViewById(R.id.delete_button);
|
||||
}
|
||||
|
||||
public void bind(EnteredLoginParam relay, boolean isMain, OnRelayClickListener listener) {
|
||||
titleText.setText(relay.addr);
|
||||
mainIndicator.setVisibility(isMain ? View.VISIBLE : View.GONE);
|
||||
String[] parts = relay.addr.split("@");
|
||||
titleText.setText(parts.length == 2? parts[1] : parts[0]);
|
||||
subtitleText.setText(parts.length == 2? parts[0] : "");
|
||||
mainIndicator.setVisibility(isMain ? View.VISIBLE : View.INVISIBLE);
|
||||
deleteButton.setVisibility(isMain ? View.GONE : View.VISIBLE);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
|
||||
@@ -152,13 +152,32 @@ public class SaveAttachmentTask extends ProgressDialogAsyncTask<SaveAttachmentTa
|
||||
return StorageUtil.getVideoUri();
|
||||
} else if (contentType.startsWith("audio/")) {
|
||||
return StorageUtil.getAudioUri();
|
||||
} else if (contentType.startsWith("image/")) {
|
||||
} else if (isMediaStoreImageType(contentType)) {
|
||||
return StorageUtil.getImageUri();
|
||||
} else {
|
||||
return StorageUtil.getDownloadUri();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the content type is a standard image format supported by Android's MediaStore.
|
||||
* Non-standard image formats (like XCF, PSD, etc.) should be saved to Downloads instead.
|
||||
*/
|
||||
private boolean isMediaStoreImageType(@NonNull String contentType) {
|
||||
if (!contentType.startsWith("image/")) {
|
||||
return false;
|
||||
}
|
||||
return contentType.equals("image/jpeg") ||
|
||||
contentType.equals("image/jpg") ||
|
||||
contentType.equals("image/png") ||
|
||||
contentType.equals("image/gif") ||
|
||||
contentType.equals("image/webp") ||
|
||||
contentType.equals("image/bmp") ||
|
||||
contentType.equals("image/heic") ||
|
||||
contentType.equals("image/heif") ||
|
||||
contentType.equals("image/avif");
|
||||
}
|
||||
|
||||
private @Nullable File ensureExternalPath(@Nullable File path) {
|
||||
if (path != null && path.exists()) {
|
||||
return path;
|
||||
@@ -197,7 +216,7 @@ public class SaveAttachmentTask extends ProgressDialogAsyncTask<SaveAttachmentTa
|
||||
storage = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES);
|
||||
} else if (contentType.startsWith("audio/")) {
|
||||
storage = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC);
|
||||
} else if (contentType.startsWith("image/")) {
|
||||
} else if (isMediaStoreImageType(contentType)) {
|
||||
storage = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user