mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 13:53:54 +01:00
Integrate API for displaying featured images (#1456)
* Integrate API for displaying featured images * Add pagination and refactor code so that it can be reused for category images * Add license info to the images * Fix author view * Remove unused values * Fix minor issues with featured images * Fix null license url issue * Remove some log lines * Fix back navigation issue * fix tests * fix test inits * Gracefully handling various error situations * Added java docs
This commit is contained in:
parent
96eae8c0a6
commit
9845a6265d
26 changed files with 953 additions and 309 deletions
|
|
@ -45,6 +45,7 @@ import fr.free.nrw.commons.mwapi.MediaWikiApi;
|
|||
import fr.free.nrw.commons.ui.widget.CompatTextView;
|
||||
import timber.log.Timber;
|
||||
|
||||
import static android.view.View.*;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
|
||||
public class MediaDetailFragment extends CommonsDaggerSupportFragment {
|
||||
|
|
@ -154,9 +155,9 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
|
|||
authorLayout = (LinearLayout) view.findViewById(R.id.authorLinearLayout);
|
||||
|
||||
if (isFeaturedMedia){
|
||||
authorLayout.setVisibility(View.VISIBLE);
|
||||
authorLayout.setVisibility(VISIBLE);
|
||||
} else {
|
||||
authorLayout.setVisibility(View.GONE);
|
||||
authorLayout.setVisibility(GONE);
|
||||
}
|
||||
|
||||
licenseList = new LicenseList(getActivity());
|
||||
|
|
@ -306,6 +307,12 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
|
|||
}
|
||||
rebuildCatList();
|
||||
|
||||
if(media.getCreator() == null || media.getCreator().equals("")) {
|
||||
authorLayout.setVisibility(GONE);
|
||||
} else {
|
||||
author.setText(media.getCreator());
|
||||
}
|
||||
|
||||
checkDeletion(media);
|
||||
}
|
||||
|
||||
|
|
@ -313,13 +320,17 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
|
|||
if (licenseLink(media) != null) {
|
||||
license.setOnClickListener(v -> openWebBrowser(licenseLink(media)));
|
||||
} else {
|
||||
Toast toast = Toast.makeText(getContext(), getString(R.string.null_url), Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
if(isFeaturedMedia) {
|
||||
Timber.d("Unable to fetch license URL for %s", media.getLicense());
|
||||
} else {
|
||||
Toast toast = Toast.makeText(getContext(), getString(R.string.null_url), Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
if (media.getCoordinates() != null) {
|
||||
coordinates.setOnClickListener(v -> openMap(media.getCoordinates()));
|
||||
}
|
||||
if (delete.getVisibility() == View.VISIBLE) {
|
||||
if (delete.getVisibility() == VISIBLE) {
|
||||
enableDeleteButton(true);
|
||||
|
||||
delete.setOnClickListener(v -> {
|
||||
|
|
@ -369,7 +380,7 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
|
|||
d.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
|
||||
});
|
||||
}
|
||||
if (nominatedforDeletion.getVisibility() == View.VISIBLE){
|
||||
if (nominatedforDeletion.getVisibility() == VISIBLE){
|
||||
seeMore.setOnClickListener(v -> {
|
||||
openWebBrowser(media.getFilePageTitle().getMobileUri().toString());
|
||||
});
|
||||
|
|
@ -476,12 +487,12 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
|
|||
|
||||
private void checkDeletion(Media media){
|
||||
if (media.getRequestedDeletion()){
|
||||
delete.setVisibility(View.GONE);
|
||||
nominatedforDeletion.setVisibility(View.VISIBLE);
|
||||
delete.setVisibility(GONE);
|
||||
nominatedforDeletion.setVisibility(VISIBLE);
|
||||
}
|
||||
else{
|
||||
delete.setVisibility(View.VISIBLE);
|
||||
nominatedforDeletion.setVisibility(View.GONE);
|
||||
delete.setVisibility(VISIBLE);
|
||||
nominatedforDeletion.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue