Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #3303 #3322

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
caaadbf
Fixes #3303
ashishkumar468 Jan 12, 2020
bc30b13
Pass updated place list to listfragment
ashishkumar468 Jan 12, 2020
ae7fab7
Added default zoom rate to mapbox
ashishkumar468 Jan 13, 2020
70e9415
Removed NearbyListFragmet and added the ui login to handle the same i…
ashishkumar468 Jan 13, 2020
54af122
More code refactor
ashishkumar468 Jan 13, 2020
e64669e
BigFix, Fragmet visibility, register/un-register camera move based on…
ashishkumar468 Jan 13, 2020
43c5864
More code refactor
ashishkumar468 Jan 13, 2020
4e20bb5
BugFixes
ashishkumar468 Jan 15, 2020
3a0a8f5
UI Fixes
ashishkumar468 Jan 15, 2020
3e9ddff
Fix failing test case, let TestCommonsApplication extend Application …
ashishkumar468 Jan 15, 2020
5dc0d5c
start map view when nearby is visible
ashishkumar468 Jan 21, 2020
023ba00
start the map when NearbyFragmet is visible
ashishkumar468 Jan 21, 2020
c6a41c0
More bugfixes
ashishkumar468 Jan 21, 2020
a1194c2
More bugfixes (Fixes #3287)
ashishkumar468 Jan 21, 2020
c114941
BugFix, search this area should search the nearby places for the curr…
ashishkumar468 Jan 21, 2020
ef230f2
More BugFixes
ashishkumar468 Jan 21, 2020
ab8d778
resolved merge conflicts with master
ashishkumar468 Jan 22, 2020
6d5d7e5
onCameraMove should have null-check on NearbyController.latestSearchL…
ashishkumar468 Jan 27, 2020
a76861e
Resolved merge conflicts with master
ashishkumar468 Jan 27, 2020
6c95868
Search for places around last focus location
ashishkumar468 Feb 2, 2020
100657e
Handle location updates
ashishkumar468 Feb 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies {
implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'
implementation 'com.github.chrisbanes:PhotoView:2.0.0'
implementation 'com.github.pedrovgs:renderers:3.3.3'
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:7.2.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:8.6.1'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-localization-v7:0.7.0'
implementation 'com.github.deano2390:MaterialShowcaseView:1.2.0'
implementation 'com.dinuscxj:circleprogressbar:1.1.1'
Expand Down Expand Up @@ -95,6 +95,7 @@ dependencies {

//swipe_layout
implementation 'com.daimajia.swipelayout:library:1.2.0@aar'
implementation 'com.squareup.retrofit2:retrofit:2.7.1'
}

android {
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/fr/free/nrw/commons/CommonsApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.imagepipeline.core.ImagePipeline;
import com.facebook.imagepipeline.core.ImagePipelineConfig;
import com.mapbox.mapboxsdk.Mapbox;
import com.squareup.leakcanary.LeakCanary;
import com.squareup.leakcanary.RefWatcher;

Expand Down Expand Up @@ -123,6 +124,7 @@ public void onCreate() {

INSTANCE = this;
ACRA.init(this);
Mapbox.getInstance(this, getString(R.string.mapbox_commons_app_token));

ApplicationlessInjection
.getInstance(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import fr.free.nrw.commons.location.LocationServiceManager;
import fr.free.nrw.commons.nearby.NearbyNotificationCardView;
import fr.free.nrw.commons.nearby.fragments.NearbyParentFragment;
import fr.free.nrw.commons.nearby.presenter.NearbyParentFragmentPresenter;
import fr.free.nrw.commons.notification.Notification;
import fr.free.nrw.commons.notification.NotificationActivity;
import fr.free.nrw.commons.notification.NotificationController;
Expand Down Expand Up @@ -72,6 +71,7 @@ public class MainActivity extends NavigationBaseActivity implements FragmentMana

private MenuItem notificationsMenuItem;
private TextView notificationCount;
private NearbyParentFragment nearbyParentFragment;

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -181,8 +181,6 @@ public void onPageSelected(int position) {
tabLayout.getTabAt(NEARBY_TAB_POSITION).select();
isContributionsFragmentVisible = false;
updateMenuItem();
// Do all permission and GPS related tasks on tab selected, not on create
NearbyParentFragmentPresenter.getInstance().onTabSelected();
break;
default:
tabLayout.getTabAt(CONTRIBUTIONS_TAB_POSITION).select();
Expand Down Expand Up @@ -258,7 +256,9 @@ public void onBackPressed() {
}
} else if (getSupportFragmentManager().findFragmentByTag(nearbyFragmentTag) != null && !isContributionsFragmentVisible) {
// Means that nearby fragment is visible (not contributions fragment)
NearbyParentFragmentPresenter.getInstance().backButtonClicked();
if (null != nearbyParentFragment) {
nearbyParentFragment.backButtonClicked();
}
} else {
super.onBackPressed();
}
Expand Down Expand Up @@ -373,12 +373,13 @@ public Fragment getItem(int position) {
}

case 1:
NearbyParentFragment retainedNearbyFragment = getNearbyFragment(1);
if (retainedNearbyFragment != null) {
return retainedNearbyFragment;
nearbyParentFragment = getNearbyFragment(1);
if (nearbyParentFragment != null) {
return nearbyParentFragment;
} else {
// If we reach here, retainedNearbyFragment is null
return new NearbyParentFragment();
nearbyParentFragment=new NearbyParentFragment();
return nearbyParentFragment;
}
default:
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import fr.free.nrw.commons.media.MediaDetailFragment;
import fr.free.nrw.commons.media.MediaDetailPagerFragment;
import fr.free.nrw.commons.nearby.fragments.NearbyListFragment;
import fr.free.nrw.commons.nearby.fragments.NearbyMapFragment;
import fr.free.nrw.commons.nearby.fragments.NearbyParentFragment;
import fr.free.nrw.commons.review.ReviewImageFragment;
import fr.free.nrw.commons.settings.SettingsFragment;
Expand Down Expand Up @@ -59,9 +58,6 @@ public abstract class FragmentBuilderModule {
@ContributesAndroidInjector
abstract ContributionsFragment bindContributionsFragment();

@ContributesAndroidInjector
abstract NearbyMapFragment bindNearbyMapFragment();

@ContributesAndroidInjector
abstract NearbyParentFragment bindNearbyParentFragment();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatCheckBox;

import java.util.List;

import fr.free.nrw.commons.R;
import fr.free.nrw.commons.nearby.presenter.NearbyParentFragmentPresenter;

Expand All @@ -25,6 +27,16 @@ public class CheckBoxTriStates extends AppCompatCheckBox {

private int state;

private Callback callback;

public interface Callback{
void filterByMarkerType(@Nullable List<Label> selectedLabels, int state, boolean b, boolean b1);
}

public void setCallback(Callback callback) {
this.callback = callback;
}

/**
* This is the listener set to the super class which is going to be evoke each
* time the check state has changed.
Expand Down Expand Up @@ -87,7 +99,7 @@ public void setState(int state) {
}

if (NearbyController.currentLocation != null) {
NearbyParentFragmentPresenter.getInstance().filterByMarkerType(null, state, false, true);
callback.filterByMarkerType(null, state, false, true);
}
updateBtn();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,14 @@ public class NearbyFilterSearchRecyclerViewAdapter

private int state;

private Callback callback;

RecyclerView.SmoothScroller smoothScroller;

public void setCallback(Callback callback) {
this.callback = callback;
}

public NearbyFilterSearchRecyclerViewAdapter(Context context, ArrayList<Label> labels, RecyclerView recyclerView) {
this.context = context;
this.labels = labels;
Expand Down Expand Up @@ -79,15 +85,15 @@ public void onBindViewHolder(@NonNull RecyclerViewHolder holder, int position) {

holder.placeTypeLayout.setBackgroundColor(label.isSelected() ? ContextCompat.getColor(context, R.color.divider_grey) : Color.WHITE);
holder.placeTypeLayout.setOnClickListener(view -> {
NearbyParentFragmentPresenter.getInstance().setCheckboxUnknown();
callback.setCheckboxUnknown();
if (label.isSelected()) {
selectedLabels.remove(label);
} else {
selectedLabels.add(label);
}
label.setSelected(!label.isSelected());
holder.placeTypeLayout.setBackgroundColor(label.isSelected() ? ContextCompat.getColor(context, R.color.divider_grey) : Color.WHITE);
NearbyParentFragmentPresenter.getInstance().filterByMarkerType(selectedLabels, 0, false, false);
callback.filterByMarkerType(selectedLabels, 0, false, false);
});
}

Expand Down Expand Up @@ -166,4 +172,11 @@ public void setRecyclerViewAdapterNeutral() {
state = CheckBoxTriStates.UNKNOWN;
}

public interface Callback{

void setCheckboxUnknown();

void filterByMarkerType(ArrayList<Label> selectedLabels, int i, boolean b, boolean b1);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@
import fr.free.nrw.commons.contributions.ContributionController;
import fr.free.nrw.commons.di.ApplicationlessInjection;
import fr.free.nrw.commons.kvstore.JsonKvStore;
import fr.free.nrw.commons.nearby.fragments.NearbyMapFragment;
import fr.free.nrw.commons.nearby.fragments.NearbyParentFragment;
import timber.log.Timber;

import static fr.free.nrw.commons.nearby.fragments.NearbyParentFragment.TAG_RETAINED_MAP_FRAGMENT;
import static fr.free.nrw.commons.theme.NavigationBaseActivity.startActivityWithFlags;
import static fr.free.nrw.commons.wikidata.WikidataConstants.PLACE_OBJECT;

Expand Down Expand Up @@ -193,8 +191,7 @@ protected void hookListeners(View view) {
onBookmarkClick.onClick();
}
else {
((NearbyMapFragment)(fragment.getParentFragment()).getChildFragmentManager().
findFragmentByTag(TAG_RETAINED_MAP_FRAGMENT)).
((NearbyParentFragment) (fragment.getParentFragment())).
updateMarker(isBookmarked, place, null);
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package fr.free.nrw.commons.nearby.contract;

import android.content.Context;

import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.maps.MapboxMap;

Expand All @@ -9,16 +11,17 @@
import fr.free.nrw.commons.location.LatLng;
import fr.free.nrw.commons.location.LocationServiceManager;
import fr.free.nrw.commons.nearby.Label;
import fr.free.nrw.commons.nearby.NearbyBaseMarker;
import fr.free.nrw.commons.nearby.Place;
import fr.free.nrw.commons.nearby.presenter.NearbyParentFragmentPresenter;

public interface NearbyParentFragmentContract {

interface View {
void registerLocationUpdates(LocationServiceManager locationServiceManager);
boolean isNetworkConnectionEstablished();
void addNetworkBroadcastReceiver();
void listOptionMenuItemClicked();
void populatePlaces(LatLng curlatLng, LatLng searchLatLng);
void populatePlaces(LatLng curlatLng);
boolean isListBottomSheetExpanded();
void checkPermissionsAndPerformAction(Runnable runnable);
void displayLoginSkippedWarning();
Expand All @@ -29,7 +32,7 @@ interface View {
void hideBottomSheet();
void hideBottomDetailsSheet();
void displayBottomSheetWithInfo(Marker marker);
void addOnCameraMoveListener(MapboxMap.OnCameraMoveListener onCameraMoveListener);
void addOnCameraMoveListener();
void addSearchThisAreaButtonAction();
void setSearchThisAreaButtonVisibility(boolean isVisible);
void setProgressBarVisibility(boolean isVisible);
Expand All @@ -44,26 +47,49 @@ interface View {
void setFilterState();
void disableFABRecenter();
void enableFABRecenter();
void addCurrentLocationMarker(LatLng curLatLng);

void updateMapToTrackPosition(LatLng curLatLng);

Context getContext();

void updateMapMarkers(List<NearbyBaseMarker> nearbyBaseMarkers, Marker selectedMarker);

void filterOutAllMarkers();

void displayAllMarkers();

void filterMarkersByLabels(List<Label> selectedLabels, boolean existsSelected, boolean needPhotoSelected, boolean filterForPlaceState, boolean filterForAllNoneType);

LatLng getCameraTarget();

void centerMapToPlace(Place placeToCenter);

void updateListFragment(List<Place> placeList);

LatLng getLastLocation();
}

interface NearbyListView {
void updateListFragment(List<Place> placeList);
}

interface UserActions {
void onTabSelected();
void checkForPermission();
void updateMapAndList(LocationServiceManager.LocationChangeType locationChangeType, LatLng cameraTarget);
void updateMapAndList(LocationServiceManager.LocationChangeType locationChangeType);
void lockUnlockNearby(boolean isNearbyLocked);

void attachView(View view);

void detachView();

void setActionListeners(JsonKvStore applicationKvStore);
void backButtonClicked();
MapboxMap.OnCameraMoveListener onCameraMove(MapboxMap mapboxMap);
void onCameraMove(com.mapbox.mapboxsdk.geometry.LatLng latLng);
void filterByMarkerType(List<Label> selectedLabels, int state, boolean filterForPlaceState, boolean filterForAllNoneType);

void updateMapMarkersToController(List<NearbyBaseMarker> nearbyBaseMarkers);

void searchViewGainedFocus();
void setCheckboxUnknown();
}

interface ViewsAreReadyCallback {
void nearbyFragmentsAreReady();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public class NearbyListFragment extends CommonsDaggerSupportFragment implements
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(true);
}

@Override
Expand Down
Loading