mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-30 22:34:02 +01:00 
			
		
		
		
	Add actions and click effects to detailled bottom sheet buttons
This commit is contained in:
		
							parent
							
								
									a70d627aae
								
							
						
					
					
						commit
						a7f2b95965
					
				
					 11 changed files with 105 additions and 14 deletions
				
			
		|  | @ -358,13 +358,6 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp | |||
|         bundle.putString("CurLatLng", gsonCurLatLng); | ||||
| 
 | ||||
|         lockNearbyView(true); | ||||
|         // Begin the transaction | ||||
|         // Begin the transaction | ||||
|         /*if (viewMode.isMap()) { | ||||
|             setMapFragment(); | ||||
|         } else { | ||||
|             setListFragment(); | ||||
|         }*/ | ||||
|         setMapFragment(); | ||||
|         setListFragment(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,5 +1,6 @@ | |||
| package fr.free.nrw.commons.nearby; | ||||
| 
 | ||||
| import android.content.Intent; | ||||
| import android.graphics.Color; | ||||
| import android.net.Uri; | ||||
| import android.os.Bundle; | ||||
|  | @ -15,7 +16,9 @@ import android.view.View; | |||
| import android.view.ViewGroup; | ||||
| import android.view.animation.Animation; | ||||
| import android.view.animation.AnimationUtils; | ||||
| import android.widget.Button; | ||||
| import android.widget.ImageView; | ||||
| import android.widget.LinearLayout; | ||||
| import android.widget.TextView; | ||||
| 
 | ||||
| import com.google.gson.Gson; | ||||
|  | @ -36,10 +39,12 @@ import java.lang.reflect.Type; | |||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| 
 | ||||
| import butterknife.BindView; | ||||
| import fr.free.nrw.commons.R; | ||||
| import fr.free.nrw.commons.utils.UriDeserializer; | ||||
| 
 | ||||
| public class NearbyMapFragment extends android.support.v4.app.Fragment { | ||||
| 
 | ||||
|     private MapView mapView; | ||||
|     private List<NearbyBaseMarker> baseMarkerOptions; | ||||
|     private fr.free.nrw.commons.location.LatLng curLatLng; | ||||
|  | @ -48,6 +53,9 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment { | |||
|     private View moreInfo; | ||||
|     private BottomSheetBehavior bottomSheetListBehavior; | ||||
|     private BottomSheetBehavior bottomSheetDetailsBehavior; | ||||
|     private LinearLayout wikipediaButton; | ||||
|     private LinearLayout wikidataButton; | ||||
|     private LinearLayout directionsButton; | ||||
|     private FloatingActionButton fabList; | ||||
|     private FloatingActionButton fabPlus; | ||||
|     private FloatingActionButton fabCamera; | ||||
|  | @ -58,7 +66,6 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment { | |||
|     private TextView distance; | ||||
|     private ImageView icon; | ||||
| 
 | ||||
| 
 | ||||
|     private boolean isFabOpen=false; | ||||
|     private Animation rotate_backward; | ||||
|     private Animation fab_close; | ||||
|  | @ -158,6 +165,11 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment { | |||
|         title = getActivity().findViewById(R.id.title); | ||||
|         distance = getActivity().findViewById(R.id.category); | ||||
|         icon = getActivity().findViewById(R.id.icon); | ||||
| 
 | ||||
|         wikidataButton = getActivity().findViewById(R.id.wikidataButton); | ||||
|         wikipediaButton = getActivity().findViewById(R.id.wikipediaButton); | ||||
|         directionsButton = getActivity().findViewById(R.id.directionsButton); | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     private void setListeners() { | ||||
|  | @ -238,6 +250,7 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment { | |||
|                     bottomSheetListBehavior.setState(BottomSheetBehavior.STATE_HIDDEN); | ||||
|                     bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); | ||||
|                     //NearbyInfoDialog.showYourself(getActivity(), place); | ||||
| 
 | ||||
|                 } | ||||
|                 return false; | ||||
|             }); | ||||
|  | @ -337,13 +350,51 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment { | |||
|     } | ||||
| 
 | ||||
|     private void passInfoToSheet(Place place) { | ||||
|         //TODO set correct icon here | ||||
|         wikipediaButton.setEnabled( | ||||
|                 !(place.siteLinks == null || Uri.EMPTY.equals(place.siteLinks.getWikipediaLink()))); | ||||
|         wikipediaButton.setOnClickListener(new View.OnClickListener() { | ||||
|             @Override | ||||
|             public void onClick(View view) { | ||||
|                 openWebView(place.siteLinks.getWikipediaLink()); | ||||
|             } | ||||
|         }); | ||||
| 
 | ||||
|         wikidataButton.setEnabled( | ||||
|                 !(place.siteLinks == null || Uri.EMPTY.equals(place.siteLinks.getWikidataLink()))); | ||||
|         wikidataButton.setOnClickListener(new View.OnClickListener() { | ||||
|             @Override | ||||
|             public void onClick(View view) { | ||||
|                 openWebView(place.siteLinks.getWikidataLink()); | ||||
|             } | ||||
|         }); | ||||
| 
 | ||||
|         directionsButton.setOnClickListener(new View.OnClickListener() { | ||||
|             @Override | ||||
|             public void onClick(View view) { | ||||
|                 LatLng location = new LatLng(place.location.getLatitude() | ||||
|                         , place.location.getLongitude(), 0); | ||||
|                 //Open map app at given position | ||||
|                 Uri gmmIntentUri = Uri.parse( | ||||
|                         "geo:0,0?q=" + location.getLatitude() + "," + location.getLongitude()); | ||||
|                 Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); | ||||
| 
 | ||||
|                 if (mapIntent.resolveActivity(getActivity().getPackageManager()) != null) { | ||||
|                     startActivity(mapIntent); | ||||
|                 } | ||||
|             } | ||||
|         }); | ||||
| 
 | ||||
|         icon.setImageResource(place.getDescription().getIcon()); | ||||
|         description.setText(place.getDescription().getText()); | ||||
|         title.setText(place.name.toString()); | ||||
|         distance.setText(place.distance.toString()); | ||||
|     } | ||||
| 
 | ||||
|     private void openWebView(Uri link) { | ||||
|         Intent browserIntent = new Intent(Intent.ACTION_VIEW, link); | ||||
|         startActivity(browserIntent); | ||||
|     } | ||||
| 
 | ||||
|     private void animateFAB(boolean isFabOpen) { | ||||
| 
 | ||||
|         if (isFabOpen) { | ||||
|  | @ -368,7 +419,7 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment { | |||
|     } | ||||
| 
 | ||||
|     private void closeFabs(boolean isFabOpen){ | ||||
|         if(isFabOpen){ | ||||
|         if (isFabOpen) { | ||||
|             fabPlus.startAnimation(rotate_backward); | ||||
|             fabCamera.startAnimation(fab_close); | ||||
|             fabGallery.startAnimation(fab_close); | ||||
|  |  | |||
|  | @ -30,6 +30,9 @@ class PlaceRenderer extends Renderer<Place> { | |||
|     @BindView(R.id.distance) TextView distance; | ||||
|     @BindView(R.id.icon) ImageView icon; | ||||
|     @BindView(R.id.buttonLayout) LinearLayout buttonLayout; | ||||
|     @BindView(R.id.wikidataButton) LinearLayout wikidataButton; | ||||
|     @BindView(R.id.wikipediaButton) LinearLayout wikipediaButton; | ||||
|     @BindView(R.id.directionsButton) LinearLayout directionsButton; | ||||
| 
 | ||||
|     private View view; | ||||
|     private static ArrayList<LinearLayout> openedItems; | ||||
|  |  | |||
							
								
								
									
										8
									
								
								app/src/main/res/color/button_color_selector.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								app/src/main/res/color/button_color_selector.xml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,8 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||||
|     <item | ||||
|         android:state_enabled="false" | ||||
|         android:color="@color/disabled_button_text_color_light" /> | ||||
|     <item | ||||
|         android:color="@color/status_bar_blue" /> | ||||
| </selector> | ||||
							
								
								
									
										8
									
								
								app/src/main/res/color/text_color_selector.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								app/src/main/res/color/text_color_selector.xml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,8 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||||
|     <item | ||||
|         android:state_enabled="false" | ||||
|         android:color="@color/disabled_button_text_color_light" /> | ||||
|     <item | ||||
|         android:color="@color/enabled_button_text_color_light" /> | ||||
| </selector> | ||||
|  | @ -0,0 +1,11 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||||
|     <item | ||||
|         android:state_pressed="true" | ||||
|         android:drawable="@color/pressed_button_background_light" /> | ||||
|     <item | ||||
|         android:state_focused="true" | ||||
|         android:drawable="@color/focused_button_background_light" /> | ||||
|     <item | ||||
|         android:drawable="@android:color/transparent" /> | ||||
| </selector> | ||||
|  | @ -3,7 +3,7 @@ | |||
|         android:height="24dp" | ||||
|         android:viewportWidth="24.0" | ||||
|         android:viewportHeight="24.0" | ||||
|         android:tint="@color/status_bar_blue" | ||||
|         android:tint="@color/button_color_selector" | ||||
|     > | ||||
|     <path | ||||
|         android:fillColor="#FF000000" | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ | |||
|     android:viewportWidth="102.1415" | ||||
|     android:width="24dp" | ||||
|     xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     android:tint="@color/status_bar_blue" | ||||
|     android:tint="@color/button_color_selector" | ||||
|     > | ||||
|     <path android:fillColor="#990000" android:pathData="m0.83,77.62 l3.71,0 0,-61.79 -3.71,0 0,61.79zM8.24,77.62 L19.36,77.62 19.36,15.84 8.24,15.84 8.24,77.62zM23.07,15.84 L23.07,77.62 34.19,77.62 34.19,15.84 23.07,15.84z"/> | ||||
|     <path android:fillColor="#339966" android:pathData="m89.8,77.62 l3.7,0 0,-61.79 -3.7,0 0,61.79zM97.21,15.84 L97.21,77.62 100.92,77.62 100.92,15.84 97.21,15.84zM37.9,77.62 L41.6,77.62 41.6,15.84 37.9,15.84 37.9,77.62zM45.31,15.84 L45.31,77.62 49.02,77.62 49.02,15.84 45.32,15.84z"/> | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ | |||
|     android:viewportWidth="141.092" | ||||
|     android:width="24dp" | ||||
|     xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     android:tint="@color/status_bar_blue" | ||||
|     android:tint="@color/button_color_selector" | ||||
|     > | ||||
|     <path android:fillAlpha="1" android:fillColor="#000000" | ||||
|         android:pathData="M91.5,116.05 L73.43,73.49c-7.16,14.05 -15.09,28.64 -21.88,42.54 -0.04,0.07 -3.28,0.03 -3.28,-0.01C37.9,91.8 27.14,67.75 16.72,43.56 14.3,37.65 5.83,28.14 0.04,28.19 0.04,27.5 0.01,25.97 0,25.04L35.71,25.03l-0.02,3.11c-4.19,0.2 -11.44,2.87 -9.57,7.5 5.04,10.87 22.86,52.97 27.67,63.66 3.36,-6.58 12.75,-24.12 16.61,-31.53 -3.03,-6.22 -13.04,-29.43 -16.04,-35.27 -2.26,-3.81 -7.94,-4.28 -12.32,-4.34 0,-0.98 0.05,-1.73 0.03,-3.07l31.4,0.1 0,2.85c-4.25,0.12 -8.28,1.7 -6.45,5.76 4.22,8.77 6.69,15.01 10.57,23.11 1.24,-2.37 7.58,-15.39 10.61,-22.27 1.83,-4.57 -0.9,-6.28 -8.55,-6.49 0.1,-0.75 0.03,-2.26 0.1,-2.98 9.76,-0.04 24.5,-0.07 27.11,-0.11l0.01,2.97c-4.98,0.19 -10.14,2.85 -12.83,6.97l-13.06,27.08c1.43,3.59 13.99,31.47 15.31,34.56L123.29,34.34c-1.92,-5.05 -8.05,-6.17 -10.44,-6.23 0.02,-0.8 0.02,-2.03 0.03,-3.05l28.18,0.21 0.04,0.14 -0.05,2.68c-6.18,0.19 -10.01,3.49 -12.29,8.91 -5.62,12.68 -22.78,52.86 -34.24,79.05 -0.01,0.01 -3,-0 -3.01,-0.01z" | ||||
|  |  | |||
|  | @ -63,17 +63,21 @@ | |||
|             android:layout_weight="1" | ||||
|             android:padding="16dp" | ||||
|             android:clickable="true" | ||||
|             android:background="@drawable/button_background_selector" | ||||
|             android:orientation="vertical" | ||||
|             > | ||||
|             <ImageView | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:layout_gravity="center_horizontal" | ||||
|                 android:duplicateParentState="true" | ||||
|                 app:srcCompat="@drawable/ic_directions_black_24dp" /> | ||||
|             <TextView | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:paddingTop="8dp" | ||||
|                 android:duplicateParentState="true" | ||||
|                 android:textColor="@color/text_color_selector" | ||||
|                 android:layout_gravity="center_horizontal" | ||||
|                 android:text="@string/nearby_directions" | ||||
|                 /> | ||||
|  | @ -85,17 +89,21 @@ | |||
|             android:layout_weight="1" | ||||
|             android:padding="16dp" | ||||
|             android:clickable="true" | ||||
|             android:background="@drawable/button_background_selector" | ||||
|             android:orientation="vertical" | ||||
|             > | ||||
|             <ImageView | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:layout_gravity="center_horizontal" | ||||
|                 android:duplicateParentState="true" | ||||
|                 app:srcCompat="@drawable/ic_wikidata_logo_24dp" /> | ||||
|             <TextView | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:paddingTop="8dp" | ||||
|                 android:duplicateParentState="true" | ||||
|                 android:textColor="@color/text_color_selector" | ||||
|                 android:layout_gravity="center_horizontal" | ||||
|                 android:text="@string/nearby_wikidata" | ||||
|                 /> | ||||
|  | @ -108,18 +116,22 @@ | |||
|             android:layout_weight="1" | ||||
|             android:padding="16dp" | ||||
|             android:clickable="true" | ||||
|             android:background="@drawable/button_background_selector" | ||||
|             android:orientation="vertical" | ||||
|             > | ||||
|             <ImageView | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:layout_gravity="center_horizontal" | ||||
|                 android:duplicateParentState="true" | ||||
|                 app:srcCompat="@drawable/ic_wikipedia_logo_24dp" | ||||
|                 /> | ||||
|             <TextView | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:paddingTop="8dp" | ||||
|                 android:duplicateParentState="true" | ||||
|                 android:textColor="@color/text_color_selector" | ||||
|                 android:layout_gravity="center_horizontal" | ||||
|                 android:text="@string/nearby_wikipedia" | ||||
| 
 | ||||
|  |  | |||
|  | @ -31,4 +31,9 @@ | |||
|     <color name="upload_overlay_background_dark">#77000000</color> | ||||
|     <color name="upload_overlay_background_light">#44000000</color> | ||||
| 
 | ||||
|     <color name="pressed_button_background_light">#64999999</color> | ||||
|     <color name="focused_button_background_light">#32999999</color> | ||||
|     <color name="disabled_button_text_color_light">#48000000</color> | ||||
|     <color name="enabled_button_text_color_light">#B0000000</color> | ||||
| 
 | ||||
| </resources> | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 neslihanturan
						neslihanturan