Skip to content

Commit 2ac38a1

Browse files
committed
Inıt search layouts on Nearby parent
1 parent 929c92d commit 2ac38a1

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

app/src/main/java/fr/free/nrw/commons/bookmarks/locations/BookmarkLocationsDao.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ Place fromCursor(Cursor cursor) {
156156
cursor.getString(cursor.getColumnIndex(Table.COLUMN_DESCRIPTION)),
157157
location,
158158
cursor.getString(cursor.getColumnIndex(Table.COLUMN_CATEGORY)),
159-
builder.build()
159+
builder.build(),
160+
null
160161
);
161162
}
162163

app/src/main/java/fr/free/nrw/commons/nearby/Label.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public enum Label {
4242
TEMPLE("Q44539", R.drawable.round_icon_church),
4343
UNKNOWN("?", R.drawable.round_icon_unknown);
4444

45-
private static final Map<String, Label> TEXT_TO_DESCRIPTION
45+
public static final Map<String, Label> TEXT_TO_DESCRIPTION
4646
= new HashMap<>(Label.values().length);
4747

4848
static {

app/src/main/java/fr/free/nrw/commons/nearby/fragments/NearbyParentFragment.java

+45
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,21 @@
88
import android.content.IntentFilter;
99
import android.content.res.Configuration;
1010
import android.os.Bundle;
11+
import android.util.Log;
1112
import android.view.Gravity;
1213
import android.view.LayoutInflater;
1314
import android.view.View;
1415
import android.view.ViewGroup;
1516
import android.view.animation.Animation;
1617
import android.view.animation.AnimationUtils;
18+
import android.widget.ArrayAdapter;
1719
import android.widget.Button;
1820
import android.widget.FrameLayout;
1921
import android.widget.ImageView;
2022
import android.widget.LinearLayout;
23+
import android.widget.ListView;
2124
import android.widget.ProgressBar;
25+
import android.widget.SearchView;
2226
import android.widget.TextView;
2327
import android.widget.Toast;
2428

@@ -28,8 +32,11 @@
2832
import androidx.fragment.app.FragmentTransaction;
2933

3034
import com.google.android.material.bottomsheet.BottomSheetBehavior;
35+
import com.google.android.material.chip.Chip;
3136
import com.google.android.material.floatingactionbutton.FloatingActionButton;
3237
import com.google.android.material.snackbar.Snackbar;
38+
import com.jakewharton.rxbinding2.view.RxView;
39+
import com.jakewharton.rxbinding2.widget.RxSearchView;
3340
import com.mapbox.mapboxsdk.Mapbox;
3441
import com.mapbox.mapboxsdk.annotations.Marker;
3542
import com.mapbox.mapboxsdk.camera.CameraPosition;
@@ -39,6 +46,9 @@
3946
import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
4047
import com.mapbox.mapboxsdk.maps.Style;
4148

49+
import java.util.ArrayList;
50+
import java.util.concurrent.TimeUnit;
51+
4252
import javax.inject.Inject;
4353
import javax.inject.Named;
4454

@@ -54,12 +64,14 @@
5464
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
5565
import fr.free.nrw.commons.kvstore.JsonKvStore;
5666
import fr.free.nrw.commons.location.LocationServiceManager;
67+
import fr.free.nrw.commons.nearby.Label;
5768
import fr.free.nrw.commons.nearby.NearbyController;
5869
import fr.free.nrw.commons.nearby.NearbyMarker;
5970
import fr.free.nrw.commons.nearby.Place;
6071
import fr.free.nrw.commons.nearby.contract.NearbyParentFragmentContract;
6172
import fr.free.nrw.commons.nearby.presenter.NearbyParentFragmentPresenter;
6273
import fr.free.nrw.commons.utils.FragmentUtils;
74+
import fr.free.nrw.commons.utils.LayoutUtils;
6375
import fr.free.nrw.commons.utils.NearbyFABUtils;
6476
import fr.free.nrw.commons.utils.NetworkUtils;
6577
import fr.free.nrw.commons.utils.PermissionUtils;
@@ -73,6 +85,7 @@
7385
import static fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType.LOCATION_SIGNIFICANTLY_CHANGED;
7486
import static fr.free.nrw.commons.contributions.MainActivity.CONTRIBUTIONS_TAB_POSITION;
7587
import static fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType.MAP_UPDATED;
88+
import static fr.free.nrw.commons.nearby.Label.TEXT_TO_DESCRIPTION;
7689
import static fr.free.nrw.commons.wikidata.WikidataConstants.PLACE_OBJECT;
7790

7891

@@ -106,6 +119,17 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
106119
@BindView(R.id.container_sheet) FrameLayout frameLayout;
107120
@BindView(R.id.loading_nearby_list) ConstraintLayout loadingNearbyLayout;
108121

122+
@BindView(R.id.choice_chip_exists)
123+
Chip chipExists;
124+
@BindView(R.id.choice_chip_needs_photo)
125+
Chip chipNeedsPhoto;
126+
@BindView(R.id.search_view)
127+
SearchView searchView;
128+
@BindView(R.id.search_list_view)
129+
ListView searchListView;
130+
@BindView(R.id.nearby_filter_list_layout)
131+
LinearLayout nearbyFilterListLayout;
132+
109133
@Inject LocationServiceManager locationManager;
110134
@Inject NearbyController nearbyController;
111135
@Inject @Named("default_preferences") JsonKvStore applicationKvStore;
@@ -156,6 +180,7 @@ public void onResume() {
156180
super.onResume();
157181
nearbyMapFragment = getNearbyMapFragment();
158182
nearbyListFragment = getListFragment();
183+
initNearbyFilter();
159184
}
160185

161186

@@ -178,6 +203,26 @@ private void initBottomSheets() {
178203
bottomSheetDetails.setVisibility(View.VISIBLE);
179204
}
180205

206+
public void initNearbyFilter() {
207+
208+
ArrayList<String> stringArrayList = new ArrayList<>();
209+
for(Label label : TEXT_TO_DESCRIPTION.values())
210+
stringArrayList.add(label.toString());
211+
212+
ArrayAdapter adapter = new ArrayAdapter<>(getContext(),android.R.layout.simple_list_item_1,stringArrayList);
213+
searchListView.setAdapter(adapter);
214+
LayoutUtils.setLayoutHeightAllignedToWidth(1, nearbyFilterListLayout);
215+
216+
compositeDisposable.add(RxSearchView.queryTextChanges(searchView)
217+
.takeUntil(RxView.detaches(searchView))
218+
.debounce(500, TimeUnit.MILLISECONDS)
219+
.observeOn(AndroidSchedulers.mainThread())
220+
.subscribe( query -> {
221+
Log.d("deneme4","query:"+query);
222+
}
223+
));
224+
}
225+
181226
/**
182227
* Defines how bottom sheets will act on click
183228
*/

0 commit comments

Comments
 (0)