Skip to content

Commit

Permalink
#189 Fix view multiple attachments (click on preview)
Browse files Browse the repository at this point in the history
  • Loading branch information
yvolk committed Oct 19, 2019
1 parent e4eb1a7 commit 9e3b283
Show file tree
Hide file tree
Showing 8 changed files with 207 additions and 77 deletions.
Expand Up @@ -23,6 +23,7 @@
import org.andstatus.app.data.DownloadData;
import org.andstatus.app.data.MyContentType;
import org.andstatus.app.data.NoteForAnyAccount;
import org.andstatus.app.net.http.ConnectionException;
import org.andstatus.app.service.CommandData;
import org.andstatus.app.service.CommandEnum;
import org.andstatus.app.service.CommandExecutionContext;
Expand Down Expand Up @@ -273,9 +274,23 @@ public void reblog() throws IOException {
@Test
public void tootWithVideoAttachment() throws IOException {
mock.addResponse(org.andstatus.app.tests.R.raw.mastodon_video);
assertOneTootWithVideo("263975",
"https://mastodon.social/media_proxy/11640109/original",
"https://mastodon.social/media_proxy/11640109/small");
}


@Test
public void originalTootWithVideoAttachment() throws IOException {
mock.addResponse(org.andstatus.app.tests.R.raw.mastodon_video_original);
assertOneTootWithVideo("10496",
"https://mastodont.cat/system/media_attachments/files/000/684/914/original/7424effb937d991c.mp4?1550739268",
"https://mastodont.cat/system/media_attachments/files/000/684/914/small/7424effb937d991c.png?1550739268");
}

private void assertOneTootWithVideo(String actorOid, String videoUri, String previewUri) throws ConnectionException {
List<AActivity> timeline = mock.connection.getTimeline(Connection.ApiRoutineEnum.ACTOR_TIMELINE,
TimelinePosition.EMPTY, TimelinePosition.EMPTY, 20, Actor.fromOid(mock.getData().getOrigin(), "263975"));
TimelinePosition.EMPTY, TimelinePosition.EMPTY, 20, Actor.fromOid(mock.getData().getOrigin(), actorOid));
assertNotNull("timeline returned", timeline);
assertEquals("Number of items in the Timeline", 1, timeline.size());

Expand All @@ -285,11 +300,11 @@ public void tootWithVideoAttachment() throws IOException {
assertEquals("Media attachments " + note.attachments, 2, note.attachments.size());
Attachment video = note.attachments.list.get(0);
assertEquals("Content type", MyContentType.VIDEO, video.contentType);
assertEquals("Media URI", UriUtils.fromString("https://files.mastodon.social/media_attachments/files/011/640/109/original/2e846bfc7de88f79.mp4"),
assertEquals("Media URI", UriUtils.fromString(videoUri),
video.getUri());
Attachment preview = note.attachments.list.get(1);
assertEquals("Content type", MyContentType.IMAGE, preview.contentType);
assertEquals("Media URI", UriUtils.fromString("https://files.mastodon.social/media_attachments/files/011/640/109/small/2e846bfc7de88f79.png"),
assertEquals("Media URI", UriUtils.fromString(previewUri),
preview.getUri());
assertEquals("Preview of", preview.previewOf, video);

Expand All @@ -313,10 +328,10 @@ public void tootWithVideoAttachment() throws IOException {
NoteForAnyAccount nfa = new NoteForAnyAccount(MyContextHolder.get(),
activity.getId(), activity.getNote().noteId);
assertEquals(preview.uri, nfa.downloads.getFirstForTimeline().getUri());
assertEquals(MyContentType.IMAGE , nfa.downloads.getFirstForTimeline().getContentType());
assertEquals(MyContentType.IMAGE, nfa.downloads.getFirstForTimeline().getContentType());
assertEquals(dVideo.getDownloadId(), nfa.downloads.getFirstForTimeline().getPreviewOfDownloadId());
assertEquals(video.uri, nfa.downloads.getFirstToShare().getUri());
assertEquals(MyContentType.VIDEO , nfa.downloads.getFirstToShare().getContentType());
assertEquals(MyContentType.VIDEO, nfa.downloads.getFirstToShare().getContentType());
}

}
53 changes: 31 additions & 22 deletions app/src/androidTest/res/raw/mastodon_video.json
@@ -1,5 +1,6 @@
[
{
"//comment": "Downloaded from https://mastodon.social/api/v1/statuses/101629250444919927",
"id": "101629250444919927",
"created_at": "2019-02-21T08:54:44.000Z",
"in_reply_to_id": null,
Expand All @@ -8,15 +9,15 @@
"spoiler_text": "",
"visibility": "public",
"language": "ca",
"uri": "https:\/\/mastodont.cat\/users\/kim\/statuses\/101629249723336744",
"content": "<p>Ja estan aquí <a href=\"https:\/\/mastodont.cat\/tags\/vaga21f\" class=\"mention hashtag\" rel=\"nofollow noopener\" target=\"_blank\">#<span>vaga21f<\/span><\/a><\/p>",
"url": "https:\/\/mastodont.cat\/@kim\/101629249723336744",
"uri": "https://mastodont.cat/users/kim/statuses/101629249723336744",
"url": "https://mastodont.cat/@kim/101629249723336744",
"replies_count": 2,
"reblogs_count": 2,
"favourites_count": 0,
"favourited": false,
"reblogged": false,
"muted": false,
"content": "\u003cp\u003eJa estan aquí \u003ca href=\"https://mastodont.cat/tags/vaga21f\" class=\"mention hashtag\" rel=\"nofollow noopener\" target=\"_blank\"\u003e#\u003cspan\u003evaga21f\u003c/span\u003e\u003c/a\u003e\u003c/p\u003e",
"reblog": null,
"account": {
"id": "263975",
Expand All @@ -26,20 +27,26 @@
"locked": false,
"bot": false,
"created_at": "2017-12-19T08:55:21.303Z",
"note": "<p>Gnu\/Linux · ♥ dels gats · Privacitat, programari i cultura lliure · <a href=\"https:\/\/mastodont.cat\/tags\/faircoop\" class=\"mention hashtag\" rel=\"nofollow noopener\" target=\"_blank\">#<span>Faircoop<\/span><\/a><br>Creador de surtdelcercle.cat, webetica.cat i masto.cat<br><a href=\"https:\/\/mastodont.cat\/tags\/nobot\" class=\"mention hashtag\" rel=\"nofollow noopener\" target=\"_blank\">#<span>nobot<\/span><\/a><\/p>",
"url": "https:\/\/mastodont.cat\/@kim",
"avatar": "https:\/\/files.mastodon.social\/accounts\/avatars\/000\/263\/975\/original\/bcb9abc1648df9e2.jpeg",
"avatar_static": "https:\/\/files.mastodon.social\/accounts\/avatars\/000\/263\/975\/original\/bcb9abc1648df9e2.jpeg",
"header": "https:\/\/files.mastodon.social\/accounts\/headers\/000\/263\/975\/original\/b75016d68f953519.jpeg",
"header_static": "https:\/\/files.mastodon.social\/accounts\/headers\/000\/263\/975\/original\/b75016d68f953519.jpeg",
"followers_count": 545,
"following_count": 516,
"statuses_count": 7891,
"note": "\u003cp\u003eGnu/Linux · ♥ dels gats · Privacitat, programari i cultura lliure\u003cbr\u003e\u003ca href=\"https://mastodont.cat/tags/nobot\" class=\"mention hashtag\" rel=\"nofollow noopener\" target=\"_blank\"\u003e#\u003cspan\u003enobot\u003c/span\u003e\u003c/a\u003e\u003c/p\u003e",
"url": "https://mastodont.cat/@kim",
"avatar": "https://files.mastodon.social/accounts/avatars/000/263/975/original/bcb9abc1648df9e2.jpeg",
"avatar_static": "https://files.mastodon.social/accounts/avatars/000/263/975/original/bcb9abc1648df9e2.jpeg",
"header": "https://files.mastodon.social/accounts/headers/000/263/975/original/b75016d68f953519.jpeg",
"header_static": "https://files.mastodon.social/accounts/headers/000/263/975/original/b75016d68f953519.jpeg",
"followers_count": 557,
"following_count": 456,
"statuses_count": 9201,
"last_status_at": "2019-10-19T16:54:03.490Z",
"emojis": [],
"fields": [
{
"name": "xmpp",
"value": "kim@suchat.org",
"name": "blog",
"value": "\u003ca href=\"http://jr5kf3grd2rei4tv.onion.ws\" rel=\"nofollow noopener\" target=\"_blank\"\u003e\u003cspan class=\"invisible\"\u003ehttp://\u003c/span\u003e\u003cspan class=\"\"\u003ejr5kf3grd2rei4tv.onion.ws\u003c/span\u003e\u003cspan class=\"invisible\"\u003e\u003c/span\u003e\u003c/a\u003e",
"verified_at": null
},
{
"name": "cats",
"value": "dat://837050f69d945cd483540dbb388b1b8de950e3ca469291e36c4a21a52d3cdc86/",
"verified_at": null
}
]
Expand All @@ -48,9 +55,9 @@
{
"id": "11640109",
"type": "video",
"url": "https:\/\/files.mastodon.social\/media_attachments\/files\/011\/640\/109\/original\/2e846bfc7de88f79.mp4",
"preview_url": "https:\/\/files.mastodon.social\/media_attachments\/files\/011\/640\/109\/small\/2e846bfc7de88f79.png",
"remote_url": "https:\/\/mastodont.cat\/system\/media_attachments\/files\/000\/684\/914\/original\/7424effb937d991c.mp4",
"url": "https://mastodon.social/media_proxy/11640109/original",
"preview_url": "https://mastodon.social/media_proxy/11640109/small",
"remote_url": "https://mastodont.cat/system/media_attachments/files/000/684/914/original/7424effb937d991c.mp4",
"text_url": null,
"meta": {
"length": "0:00:08.43",
Expand All @@ -60,13 +67,13 @@
"width": 1920,
"height": 1080,
"aspect": 1.7777777777777777,
"audio_encode": "aac (LC) (mp4a \/ 0x6134706D)",
"audio_encode": "aac (LC) (mp4a / 0x6134706D)",
"audio_bitrate": "48000 Hz",
"audio_channels": "stereo",
"original": {
"width": 1920,
"height": 1080,
"frame_rate": "7500000\/251551",
"frame_rate": "7500000/251551",
"duration": 8.427,
"bitrate": 20603587
},
Expand All @@ -77,17 +84,19 @@
"aspect": 1.7777777777777777
}
},
"description": null
"description": null,
"blurhash": null
}
],
"mentions": [],
"tags": [
{
"name": "vaga21f",
"url": "https:\/\/mastodon.social\/tags\/vaga21f"
"url": "https://mastodon.social/tags/vaga21f"
}
],
"emojis": [],
"card": null
"card": null,
"poll": null
}
]
102 changes: 102 additions & 0 deletions app/src/androidTest/res/raw/mastodon_video_original.json
@@ -0,0 +1,102 @@
[
{
"//comment": "Downloaded from https://mastodont.cat/api/v1/statuses/101629249723336744",
"id": "101629249723336744",
"created_at": "2019-02-21T08:54:44.114Z",
"in_reply_to_id": null,
"in_reply_to_account_id": null,
"sensitive": false,
"spoiler_text": "",
"visibility": "public",
"language": "ca",
"uri": "https://mastodont.cat/users/kim/statuses/101629249723336744",
"url": "https://mastodont.cat/@kim/101629249723336744",
"replies_count": 2,
"reblogs_count": 2,
"favourites_count": 1,
"content": "\u003cp\u003eJa estan aquí \u003ca href=\"https://mastodont.cat/tags/vaga21f\" class=\"mention hashtag\" rel=\"tag\"\u003e#\u003cspan\u003evaga21f\u003c/span\u003e\u003c/a\u003e\u003c/p\u003e",
"reblog": null,
"application": {
"name": "Mastalab",
"website": "https://mastalab.app"
},
"account": {
"id": "10496",
"username": "kim",
"acct": "kim",
"display_name": "Kim",
"locked": false,
"bot": false,
"created_at": "2017-12-19T08:37:45.939Z",
"note": "\u003cp\u003eGnu/Linux · ♥ dels gats · Privacitat, programari i cultura lliure\u003cbr /\u003e\u003ca href=\"https://mastodont.cat/tags/nobot\" class=\"mention hashtag\" rel=\"tag\"\u003e#\u003cspan\u003enobot\u003c/span\u003e\u003c/a\u003e\u003c/p\u003e",
"url": "https://mastodont.cat/@kim",
"avatar": "https://mastodont.cat/system/accounts/avatars/000/010/496/original/fb53a9c30eb13f2f.jpg?1535281972",
"avatar_static": "https://mastodont.cat/system/accounts/avatars/000/010/496/original/fb53a9c30eb13f2f.jpg?1535281972",
"header": "https://mastodont.cat/system/accounts/headers/000/010/496/original/5ff0b94c82511576.jpg?1538642464",
"header_static": "https://mastodont.cat/system/accounts/headers/000/010/496/original/5ff0b94c82511576.jpg?1538642464",
"followers_count": 557,
"following_count": 456,
"statuses_count": 9198,
"emojis": [],
"fields": [
{
"name": "blog",
"value": "\u003ca href=\"http://jr5kf3grd2rei4tv.onion.ws\" rel=\"me nofollow noopener\" target=\"_blank\"\u003e\u003cspan class=\"invisible\"\u003ehttp://\u003c/span\u003e\u003cspan class=\"\"\u003ejr5kf3grd2rei4tv.onion.ws\u003c/span\u003e\u003cspan class=\"invisible\"\u003e\u003c/span\u003e\u003c/a\u003e",
"verified_at": null
},
{
"name": "cats",
"value": "dat://837050f69d945cd483540dbb388b1b8de950e3ca469291e36c4a21a52d3cdc86/",
"verified_at": null
}
]
},
"media_attachments": [
{
"id": "684914",
"type": "video",
"url": "https://mastodont.cat/system/media_attachments/files/000/684/914/original/7424effb937d991c.mp4?1550739268",
"preview_url": "https://mastodont.cat/system/media_attachments/files/000/684/914/small/7424effb937d991c.png?1550739268",
"remote_url": null,
"text_url": "https://mastodont.cat/media/QXH0qU6_yYaEtEqhUpc",
"meta": {
"length": "0:00:08.43",
"duration": 8.43,
"fps": 29,
"size": "1920x1080",
"width": 1920,
"height": 1080,
"aspect": 1.7777777777777777,
"audio_encode": "aac (LC) (mp4a / 0x6134706D)",
"audio_bitrate": "48000 Hz",
"audio_channels": "stereo",
"original": {
"width": 1920,
"height": 1080,
"frame_rate": "7500000/251551",
"duration": 8.427,
"bitrate": 20603587
},
"small": {
"width": 400,
"height": 225,
"size": "400x225",
"aspect": 1.7777777777777777
}
},
"description": null,
"blurhash": null
}
],
"mentions": [],
"tags": [
{
"name": "vaga21f",
"url": "https://mastodont.cat/tags/vaga21f"
}
],
"emojis": [],
"card": null,
"poll": null
}
]

0 comments on commit 9e3b283

Please sign in to comment.