/** * This class holds all meta information about a media item to be sent
*/ publicclass MediaItem implements Parcelable {
@MediaType privateint type; private Uri originalUri; // Uri of original media item before creating a local copy private Uri uri; private Orientation orientation; privateint exifRotation; privatelong durationMs; private String caption; privatelong startTimeMs; privatelong endTimeMs;
@BitmapUtil.FlipType privateint exifFlip; private String mimeType;
@FileData.RenderingType int renderingType;
@PreferenceService.ImageScale privateint imageScale; // desired image scale
@PreferenceService.VideoSize privateint videoSize; // desired video scale factor private String filename; privateboolean deleteAfterUse; privateboolean isEdited; privateboolean muted;
for (Uri uri : uris) {
mediaItems.add(getFromUri(uri, context, asFile));
}
return mediaItems;
}
@NonNull publicstatic MediaItem getFromUri(@NonNull Uri uri, @NonNull Context context, boolean asFile) {
String mimeType = FileUtil.getMimeTypeFromUri(context, uri);
Uri originalUri = uri; try { // log the number of permissions due to limit https://commonsware.com/blog/2020/06/13/count-your-saf-uri-permission-grants.html
logger.info("Number of taken persistable uri permissions {}", context.getContentResolver().getPersistedUriPermissions().size());
context.getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
} catch (Exception e) {
logger.info(e.getMessage());
uri = FileUtil.getFileUri(uri);
}
MediaItem mediaItem = new MediaItem(uri, mimeType, null);
/** * Set this flag if the file is temporary and can be deleted after use * * @param deleteAfterUse 1 to signal the file is expendable, 0 otherwise
*/ publicvoid setDeleteAfterUse(boolean deleteAfterUse) { this.deleteAfterUse = deleteAfterUse;
}
public @Nullable Uri getOriginalUri() { if (originalUri == null) { return uri;
} return originalUri;
}
/** * Set this to the original location of the file before creating a copy for persistence across activities * * @param originalUri Uri of the original media file
*/ publicvoid setOriginalUri(Uri originalUri) { this.originalUri = originalUri;
}
/** * Return true, if the picture has been edited (painted or cropped)
*/ publicboolean isEdited() { return isEdited;
}
/** * Mark this media item as edited (painted or cropped)
*/ publicvoid setEdited(boolean edited) { this.isEdited = edited;
}
/** * Return true, if the video should be sent without audio
*/ publicboolean isMuted() { return muted;
}
/** * Set flag to remove the audio before sending
*/ publicvoid setMuted(boolean muted) { this.muted = muted;
}
/** * Return true if the media item has been modified. For images this includes: crop, painted, * rotated, or flipped. For videos this includes: different start time, different end time
*/ publicboolean hasChanges() { if (type == TYPE_IMAGE) { return isEdited() || orientation.getRotation() != 0 || orientation.getFlip() != BitmapUtil.FLIP_NONE;
} elseif (type == TYPE_VIDEO || type == TYPE_VIDEO_CAM) { return needsTrimming() || muted;
} else { returnfalse;
}
}
/** * Return true if the media item will be sent as file. This is the case for files, or for images * or videos with the quality set to file.
*/ publicboolean sendAsFile() { if (type == TYPE_VIDEO || type == TYPE_VIDEO_CAM) { return getVideoSize() == PreferenceService.VIDEO_SIZE_SEND_AS_FILE;
} elseif (type == TYPE_IMAGE || type == TYPE_IMAGE_CAM) { return getImageScale() == PreferenceService.IMAGE_SCALE_SEND_AS_FILE;
} else { return type == TYPE_FILE || type == TYPE_IMAGE_ANIMATED;
}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.2 Sekunden
(vorverarbeitet am 2026-04-27)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.