mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-30 22:34:02 +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) { | ||||
|                     extractor.fill(media); | ||||
| 
 | ||||
|                     setTextFields(media); | ||||
|                     setOnClickListeners(media); | ||||
|                     } else { | ||||
|                     // Set text of desc, license, and categories | ||||
|                     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(); | ||||
|                 } else { | ||||
|                     Timber.d("Failed to load photo details."); | ||||
|                 } | ||||
|             } | ||||
|  | @ -251,41 +265,6 @@ public class MediaDetailFragment extends Fragment { | |||
|         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() { | ||||
|         categoryContainer.removeAllViews(); | ||||
|         // @fixme add the category items | ||||
|  | @ -371,33 +350,4 @@ public class MediaDetailFragment extends Fragment { | |||
|         } | ||||
|         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); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Mikel
						Mikel