mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Remove Clickable behaviour of License and Coordinates
This commit is contained in:
parent
7edfe34a3e
commit
2ce7a464ca
2 changed files with 17 additions and 68 deletions
|
|
@ -216,9 +216,23 @@ public class MediaDetailFragment extends Fragment {
|
||||||
if (success) {
|
if (success) {
|
||||||
extractor.fill(media);
|
extractor.fill(media);
|
||||||
|
|
||||||
setTextFields(media);
|
// Set text of desc, license, and categories
|
||||||
setOnClickListeners(media);
|
desc.setText(prettyDescription(media));
|
||||||
} else {
|
license.setText(prettyLicense(media));
|
||||||
|
coordinates.setText(prettyCoordinates(media));
|
||||||
|
uploadedDate.setText(prettyUploadedDate(media));
|
||||||
|
|
||||||
|
categoryNames.clear();
|
||||||
|
categoryNames.addAll(media.getCategories());
|
||||||
|
|
||||||
|
categoriesLoaded = true;
|
||||||
|
categoriesPresent = (categoryNames.size() > 0);
|
||||||
|
if (!categoriesPresent) {
|
||||||
|
// Stick in a filler element.
|
||||||
|
categoryNames.add(getString(R.string.detail_panel_cats_none));
|
||||||
|
}
|
||||||
|
rebuildCatList();
|
||||||
|
} else {
|
||||||
Timber.d("Failed to load photo details.");
|
Timber.d("Failed to load photo details.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -251,41 +265,6 @@ public class MediaDetailFragment extends Fragment {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setTextFields(Media media) {
|
|
||||||
desc.setText(prettyDescription(media));
|
|
||||||
license.setText(prettyLicense(media));
|
|
||||||
coordinates.setText(prettyCoordinates(media));
|
|
||||||
uploadedDate.setText(prettyUploadedDate(media));
|
|
||||||
|
|
||||||
categoryNames.clear();
|
|
||||||
categoryNames.addAll(media.getCategories());
|
|
||||||
|
|
||||||
categoriesLoaded = true;
|
|
||||||
categoriesPresent = (categoryNames.size() > 0);
|
|
||||||
if (!categoriesPresent) {
|
|
||||||
// Stick in a filler element.
|
|
||||||
categoryNames.add(getString(R.string.detail_panel_cats_none));
|
|
||||||
}
|
|
||||||
rebuildCatList();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setOnClickListeners(final Media media) {
|
|
||||||
license.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
openWebBrowser(licenseLink(media));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (media.getCoordinates() != null) {
|
|
||||||
coordinates.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
openMap(media.getCoordinates());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void rebuildCatList() {
|
private void rebuildCatList() {
|
||||||
categoryContainer.removeAllViews();
|
categoryContainer.removeAllViews();
|
||||||
// @fixme add the category items
|
// @fixme add the category items
|
||||||
|
|
@ -371,33 +350,4 @@ public class MediaDetailFragment extends Fragment {
|
||||||
}
|
}
|
||||||
return media.getCoordinates().getPrettyCoordinateString();
|
return media.getCoordinates().getPrettyCoordinateString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private @Nullable String licenseLink(Media media) {
|
|
||||||
String licenseKey = media.getLicense();
|
|
||||||
if (licenseKey == null || licenseKey.equals("")) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
License licenseObj = licenseList.get(licenseKey);
|
|
||||||
if (licenseObj == null) {
|
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return licenseObj.getUrl(Locale.getDefault().getLanguage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void openWebBrowser(String url) {
|
|
||||||
Intent browser = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
|
||||||
startActivity(browser);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void openMap(LatLng coordinates) {
|
|
||||||
//Open map app at given position
|
|
||||||
Uri gmmIntentUri = Uri.parse(
|
|
||||||
"geo:0,0?q=" + coordinates.getLatitude() + "," + coordinates.getLatitude());
|
|
||||||
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
|
|
||||||
|
|
||||||
if (mapIntent.resolveActivity(getActivity().getPackageManager()) != null) {
|
|
||||||
startActivity(mapIntent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,6 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="start"
|
android:layout_gravity="start"
|
||||||
android:background="?attr/subBackground"
|
android:background="?attr/subBackground"
|
||||||
android:foreground="?attr/selectableItemBackground"
|
|
||||||
android:text="@string/media_detail_license"
|
android:text="@string/media_detail_license"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue