Revert "Fixes #2337 - Show captions of image in media details (conflicts fixed) (#2933)" (#2934)

This reverts commit 3c9b7ba7a8.
This commit is contained in:
Ashish Kumar 2019-05-01 16:10:43 +05:30 committed by GitHub
parent 3c9b7ba7a8
commit c8a58bfc2e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 6 additions and 137 deletions

View file

@ -47,7 +47,6 @@ public class Media implements Parcelable {
protected String filename;
protected String description; // monolingual description on input...
protected String discussion;
protected String caption;
protected long dataLength;
protected Date dateCreated;
protected @Nullable Date dateUploaded;
@ -241,22 +240,6 @@ public class Media implements Parcelable {
return imageUrl;
}
/**
* Sets the Caption of the file.
* @param caption
*/
public void setCaption(String caption) {
this.caption = caption;
}
/**
* Gets the file Caption as a string.
* @return file Caption as a string
*/
public String getCaption() {
return caption;
}
/**
* Gets the name of the file.
* @return file name as a string

View file

@ -1,9 +1,5 @@
package fr.free.nrw.commons;
import android.util.Log;
import java.io.IOException;
import javax.inject.Inject;
import javax.inject.Singleton;
@ -24,18 +20,16 @@ public class MediaDataExtractor {
private final MediaWikiApi mediaWikiApi;
private final OkHttpJsonApiClient okHttpJsonApiClient;
@Inject
public MediaDataExtractor(MediaWikiApi mwApi,
OkHttpJsonApiClient okHttpJsonApiClient) {
this.okHttpJsonApiClient = okHttpJsonApiClient;
this.mediaWikiApi = mwApi;
}
/**
* Simplified method to extract all details required to show media details.
* It fetches media object, deletion status, talk page and caption for the filename
* It fetches media object, deletion status and talk page for the filename
* @param filename for which the details are to be fetched
* @return full Media object with all details including deletion status and talk page
*/
@ -43,11 +37,8 @@ public class MediaDataExtractor {
Single<Media> mediaSingle = getMediaFromFileName(filename);
Single<Boolean> pageExistsSingle = mediaWikiApi.pageExists("Commons:Deletion_requests/" + filename);
Single<String> discussionSingle = getDiscussion(filename);
Single<String> captionSingle = getCaption(filename);
return Single.zip(mediaSingle, pageExistsSingle, discussionSingle, captionSingle, (media, deletionStatus, discussion, caption) -> {
return Single.zip(mediaSingle, pageExistsSingle, discussionSingle, (media, deletionStatus, discussion) -> {
media.setDiscussion(discussion);
media.setCaption(caption);
if (deletionStatus) {
media.setRequestedDeletion();
}
@ -77,19 +68,5 @@ public class MediaDataExtractor {
Timber.e(throwable, "Error occurred while fetching discussion");
return "";
});
}
/**
* Fetch caption from the MediaWiki API
* @param filename the filename we will return the caption for
* @return a single with caption string (an empty string if no caption)
*/
private Single<String> getCaption(String filename) {
return mediaWikiApi.fetchCaptionByFilename(filename)
.onErrorReturn(throwable -> {
Timber.e(throwable, "Error occurred while fetching caption");
return "";
});
}
}

View file

@ -101,8 +101,6 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
SimpleDraweeView image;
@BindView(R.id.mediaDetailSpacer)
MediaDetailSpacer spacer;
@BindView(R.id.mediaDetailCaption)
TextView mediaCaption;
@BindView(R.id.mediaDetailTitle)
TextView title;
@BindView(R.id.mediaDetailDesc)
@ -317,7 +315,6 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
coordinates.setText(prettyCoordinates(media));
uploadedDate.setText(prettyUploadedDate(media));
mediaDiscussion.setText(prettyDiscussion(media));
mediaCaption.setText(prettyCaption(media));
categoryNames.clear();
categoryNames.addAll(media.getCategories());
@ -519,16 +516,6 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
return desc;
}
}
private String prettyCaption(Media media) {
String caption = media.getCaption().trim();
if (caption.equals("")) {
return getString(R.string.detail_caption_empty);
} else {
return caption;
}
}
private String prettyDiscussion(Media media) {
String disc = media.getDiscussion().trim();
if (disc.equals("")) {

View file

@ -3,7 +3,6 @@ package fr.free.nrw.commons.mwapi;
import android.content.Context;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
import com.google.gson.Gson;
@ -304,26 +303,6 @@ public class ApacheHttpClientMediaWikiApi implements MediaWikiApi {
.getString("/api/flow-parsoid-utils/@content"));
}
/**
* fetches the Caption of the file with a given name.
* @param filename title of the file
* @return a single with media caption
*/
@Override
public Single<String> fetchCaptionByFilename(String filename) {
return Single.fromCallable(() -> {
CustomApiResult apiResult = api.action("wbgetentities")
.param("sites", "commonswiki")
.param("titles", filename)
.param("props", "labels")
.param("format", "xml")
.param("languages", Locale.getDefault().getLanguage())
.param("languagefallback", "1")
.get();
return apiResult.getString("/api/entities/entity/labels/label/@value");
});
}
@Override
@NonNull
public Single<MediaResult> fetchMediaByFilename(String filename) {

View file

@ -66,8 +66,6 @@ public interface MediaWikiApi {
Single<String> parseWikicode(String source);
Single<String> fetchCaptionByFilename(String filename);
@NonNull
Single<MediaResult> fetchMediaByFilename(String filename);

View file

@ -52,34 +52,6 @@
android:orientation="vertical"
android:padding="@dimen/standard_gap">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/subBackground"
android:orientation="vertical"
android:padding="@dimen/standard_gap">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/tiny_gap"
android:text="@string/media_detail_caption"
android:textColor="@android:color/white"
android:textSize="@dimen/normal_text"
android:textStyle="bold" />
<TextView
android:id="@+id/mediaDetailCaption"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:background="?attr/subBackground"
android:padding="@dimen/small_gap"
android:textColor="@android:color/white"
android:textSize="@dimen/description_text_size"
tools:text="Captions of the media" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"

View file

@ -160,7 +160,6 @@
<string name="detail_panel_cats_none">None selected</string>
<string name="detail_description_empty">No description</string>
<string name="detail_discussion_empty">No discussion</string>
<string name="detail_caption_empty">No caption</string>
<string name="detail_license_empty">Unknown license</string>
<string name="menu_refresh">Refresh</string>
<string name="storage_permission_title">Requesting Storage Permission</string>
@ -174,7 +173,6 @@
<string name="upload_image_duplicate">This file already exists on Commons. Are you sure you want to proceed?</string>
<string name="yes">Yes</string>
<string name="no">No</string>
<string name="media_detail_caption">Caption</string>
<string name="media_detail_title">Title</string>
<string name="media_detail_description">Description</string>
<string name="media_detail_discussion">Discussion</string>