mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 05:43:55 +01:00
Add actions and click effects to detailled bottom sheet buttons
This commit is contained in:
parent
693ddef897
commit
b594c111b3
11 changed files with 105 additions and 16 deletions
|
|
@ -367,15 +367,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();
|
||||
}
|
||||
swipeLayout.setRefreshing(false);
|
||||
}*/
|
||||
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() {
|
||||
|
|
@ -240,6 +252,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;
|
||||
});
|
||||
|
|
@ -318,7 +331,7 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment {
|
|||
this.getView().clearFocus();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void hideFAB() {
|
||||
|
|
@ -339,13 +352,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) {
|
||||
|
|
@ -370,7 +421,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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue