Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

several UI improvements for dialogs, video messages, and the previewer activity #2583

Merged
merged 7 commits into from
Sep 17, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,10 @@ public void onSuccess(String savedMediaPath) {
} else {
// else download it
final String downloadId = mediasCache.downloadMedia(this,
mSession.getHomeServerConfig(), mediaInfo.mMediaUrl, mediaInfo.mMimeType, mediaInfo.mEncryptedFileInfo);
mSession.getHomeServerConfig(),
mediaInfo.mMediaUrl,
mediaInfo.mMimeType,
mediaInfo.mEncryptedFileInfo);

if (null != downloadId) {
mediasCache.addDownloadListener(downloadId, new MXMediaDownloadListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ private void downloadVideo(final View view, final int position, boolean force) {
final VideoView videoView = view.findViewById(R.id.media_slider_video_view);
final ImageView thumbView = view.findViewById(R.id.media_slider_video_thumbnail);
final PieFractionView pieFractionView = view.findViewById(R.id.media_slider_pie_view);
final ImageView playCircleView = view.findViewById(R.id.media_slider_video_play);
final View downloadFailedView = view.findViewById(R.id.media_download_failed);

final SlidableMediaInfo mediaInfo = mMediasMessagesList.get(position);
Expand Down Expand Up @@ -249,20 +250,21 @@ public void onSuccess(File file) {

if (null != downloadId) {
pieFractionView.setVisibility(View.VISIBLE);
playCircleView.setVisibility(View.GONE);
pieFractionView.setFraction(mMediasCache.getProgressValueForDownloadId(downloadId));
pieFractionView.setTag(downloadId);

mMediasCache.addDownloadListener(downloadId, new MXMediaDownloadListener() {

@Override
public void onDownloadError(String downloadId, JsonElement jsonElement) {
MatrixError error = JsonUtils.toMatrixError(jsonElement);
pieFractionView.setVisibility(View.GONE);
downloadFailedView.setVisibility(View.VISIBLE);

MatrixError error = JsonUtils.toMatrixError(jsonElement);
if ((null != error) && error.isSupportedErrorCode()) {
Toast.makeText(mContext, error.getLocalizedMessage(), Toast.LENGTH_LONG).show();
}

downloadFailedView.setVisibility(View.VISIBLE);
}

@Override
Expand All @@ -276,9 +278,9 @@ public void onDownloadProgress(String aDownloadId, DownloadStats stats) {
public void onDownloadComplete(String aDownloadId) {
if (aDownloadId.equals(pieFractionView.getTag())) {
pieFractionView.setVisibility(View.GONE);

// check if the media has been downloaded
if (mMediasCache.isMediaCached(loadingUri, mediaInfo.mMimeType)) {
playCircleView.setVisibility(View.VISIBLE);
mMediasCache.createTmpDecryptedMediaFile(loadingUri, mediaInfo.mMimeType, mediaInfo.mEncryptedFileInfo,
new SimpleApiCallback<File>() {
@Override
Expand Down Expand Up @@ -345,14 +347,12 @@ private void downloadHighResImage(final View view, final int position) {
public void onDownloadError(String aDownloadId, JsonElement jsonElement) {
if (aDownloadId.equals(downloadId)) {
pieFractionView.setVisibility(View.GONE);
downloadFailedView.setVisibility(View.VISIBLE);

MatrixError error = JsonUtils.toMatrixError(jsonElement);

if (null != error) {
Toast.makeText(mContext, error.getLocalizedMessage(), Toast.LENGTH_LONG).show();
}

downloadFailedView.setVisibility(View.VISIBLE);
}
}

Expand All @@ -367,7 +367,6 @@ public void onDownloadProgress(String aDownloadId, DownloadStats stats) {
public void onDownloadComplete(String aDownloadId) {
if (aDownloadId.equals(downloadId)) {
pieFractionView.setVisibility(View.GONE);

if (mMediasCache.isMediaCached(loadingUri, imageInfo.mMimeType)) {
mMediasCache.createTmpDecryptedMediaFile(loadingUri, imageInfo.mMimeType, imageInfo.mEncryptedFileInfo,
new SimpleApiCallback<File>() {
Expand Down
33 changes: 10 additions & 23 deletions vector/src/main/java/im/vector/adapters/VectorMessagesAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -1430,43 +1430,30 @@ private View getImageVideoView(int type, final int position, View convertView, V
Event event = row.getEvent();
Message message = null;

int waterMarkResourceId = -1;

boolean videoContent = false;
if (type == ROW_TYPE_IMAGE) {

ImageMessage imageMessage = JsonUtils.toImageMessage(event.getContent());

if ("image/gif".equals(imageMessage.getMimeType())) {
waterMarkResourceId = R.drawable.filetype_gif;
if (imageMessage.getMimeType().equals("image/gif")) {
videoContent = true;
}
message = imageMessage;

} else if (type == ROW_TYPE_VIDEO) {

videoContent = true;
message = JsonUtils.toVideoMessage(event.getContent());
waterMarkResourceId = R.drawable.filetype_video;

} else if (type == ROW_TYPE_STICKER) {

StickerMessage stickerMessage = JsonUtils.toStickerMessage(event.getContent());
message = stickerMessage;
}

// display a type watermark
final ImageView imageTypeView = convertView.findViewById(R.id.messagesAdapter_image_type);

if (null == imageTypeView) {
// display a play icon for video content
final ImageView playCircleView = convertView.findViewById(R.id.messagesAdapter_play_circle);
playCircleView.setVisibility(View.GONE);
if (null == playCircleView) {
Log.e(LOG_TAG, "getImageVideoView : invalid layout");
return convertView;
}

imageTypeView.setBackgroundColor(Color.TRANSPARENT);

if (waterMarkResourceId > 0) {
imageTypeView.setImageBitmap(BitmapFactory.decodeResource(getContext().getResources(), waterMarkResourceId));
imageTypeView.setVisibility(View.VISIBLE);
} else {
imageTypeView.setVisibility(View.GONE);
if (videoContent) {
playCircleView.setVisibility(View.VISIBLE);
}

if (null != message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="4dp"
android:autoLink="none"
tools:text="A filename here" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@
android:adjustViewBounds="true"
android:scaleType="center" />

<!-- the media type -->
<!-- the play icon -->
<ImageView
android:id="@+id/messagesAdapter_image_type"
android:id="@+id/messagesAdapter_play_circle"
android:layout_width="@dimen/chat_avatar_size"
android:layout_height="@dimen/chat_avatar_size"
android:layout_alignLeft="@+id/messagesAdapter_image"
android:layout_margin="10dp"
android:src="@drawable/filetype_image" />
android:layout_centerInParent="true"
android:layout_gravity="center"
android:src="@drawable/ic_material_play_circle" />

<!-- the upload fails -->
<ImageView
Expand Down
8 changes: 4 additions & 4 deletions vector/src/main/res/layout/adapter_vector_medias_viewer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@

<ImageView
android:id="@+id/media_slider_video_play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:src="@drawable/ic_material_play_circle" />
</RelativeLayout>

<im.vector.view.PieFractionView
android:id="@+id/media_slider_pie_view"
android:layout_width="160dp"
android:layout_height="160dp"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:alpha="0.4" />
Expand Down
1 change: 1 addition & 0 deletions vector/src/main/res/layout/dialog_base_edit_text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
android:paddingStart="?dialogPreferredPadding"
android:paddingRight="?dialogPreferredPadding"
android:paddingEnd="?dialogPreferredPadding"
android:paddingTop="12dp"
android:orientation="vertical">

<EditText
Expand Down
2 changes: 1 addition & 1 deletion vector/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@
<string name="rejoin">Rejoin</string>
<string name="forget_room">Forget room</string>

<!-- Miscelaneous image descriptions for accessibility -->
<!-- Miscellaneous image descriptions for accessibility -->
<string name="receipt_avatar">Receipt avatar</string>
<string name="notice_avatar">Notice avatar</string>
<string name="avatar">Avatar</string>
Expand Down