Removed toggle chips and changed pin's color

This commit is contained in:
Kanahia 2024-06-02 09:42:03 +05:30
parent ac3a2d6f49
commit c56a16e38e
15 changed files with 45 additions and 228 deletions

View file

@ -52,7 +52,7 @@ import timber.log.Timber;
@Module
@SuppressWarnings({"WeakerAccess", "unused"})
public class NetworkingModule {
private static final String WIKIDATA_SPARQL_QUERY_URL = "https://query.wikidata.org/sparql";
private static final String WIKIDATA_SPARQL_QUERY_URL = "https://query.wikidata.org/bigdata/namespace/wdq/sparql";
private static final String TOOLS_FORGE_URL = "https://tools.wmflabs.org/commons-android-app/tool-commons-android-app";
public static final long OK_HTTP_CACHE_SIZE = 10 * 1024 * 1024;

View file

@ -76,8 +76,7 @@ public interface NearbyParentFragmentContract {
void filterOutAllMarkers();
void filterMarkersByLabels(List<Label> selectedLabels, boolean existsSelected,
boolean needPhotoSelected, boolean wlmSelected, boolean filterForPlaceState,
void filterMarkersByLabels(List<Label> selectedLabels, boolean filterForPlaceState,
boolean filterForAllNoneType);
LatLng getCameraTarget();

View file

@ -491,7 +491,6 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
});
binding.tvLearnMore.setOnClickListener(v -> onLearnMoreClicked());
binding.nearbyFilter.ivToggleChips.setOnClickListener(v -> onToggleChipsClicked());
if (!locationPermissionsHelper.checkLocationPermission(getActivity())) {
askForLocationPermission();
@ -675,7 +674,6 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
addActionToTitle();
if (!Utils.isMonumentsEnabled(new Date())) {
NearbyFilterState.setWlmSelected(false);
binding.nearbyFilter.chipView.choiceChipWlm.setVisibility(View.GONE);
}
}
@ -751,7 +749,6 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
((NearbyFilterSearchRecyclerViewAdapter) binding.nearbyFilterList.searchListView.getAdapter()).getFilter()
.filter(query.toString());
}));
initFilterChips();
}
@Override
@ -767,121 +764,12 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
@Override
public void setFilterState() {
binding.nearbyFilter.chipView.choiceChipNeedsPhoto.setChecked(
NearbyFilterState.getInstance().isNeedPhotoSelected());
binding.nearbyFilter.chipView.choiceChipExists.setChecked(
NearbyFilterState.getInstance().isExistsSelected());
binding.nearbyFilter.chipView.choiceChipWlm.setChecked(
NearbyFilterState.getInstance().isWlmSelected());
if (NearbyController.currentLocation != null) {
presenter.filterByMarkerType(nearbyFilterSearchRecyclerViewAdapter.selectedLabels,
binding.nearbyFilterList.checkboxTriStates.getState(), true, false);
}
}
private void initFilterChips() {
binding.nearbyFilter.chipView.choiceChipNeedsPhoto.setOnCheckedChangeListener(
(buttonView, isChecked) -> {
if (NearbyController.currentLocation != null) {
binding.nearbyFilterList.checkboxTriStates.setState(CheckBoxTriStates.CHECKED);
NearbyFilterState.setNeedPhotoSelected(isChecked);
presenter.filterByMarkerType(
nearbyFilterSearchRecyclerViewAdapter.selectedLabels,
binding.nearbyFilterList.checkboxTriStates.getState(), true, true);
updatePlaceList(binding.nearbyFilter.chipView.choiceChipNeedsPhoto.isChecked(),
binding.nearbyFilter.chipView.choiceChipExists.isChecked(),
binding.nearbyFilter.chipView.choiceChipWlm.isChecked());
} else {
binding.nearbyFilter.chipView.choiceChipNeedsPhoto.setChecked(!isChecked);
}
});
binding.nearbyFilter.chipView.choiceChipExists.setOnCheckedChangeListener(
(buttonView, isChecked) -> {
if (NearbyController.currentLocation != null) {
binding.nearbyFilterList.checkboxTriStates.setState(CheckBoxTriStates.CHECKED);
NearbyFilterState.setExistsSelected(isChecked);
presenter.filterByMarkerType(
nearbyFilterSearchRecyclerViewAdapter.selectedLabels,
binding.nearbyFilterList.checkboxTriStates.getState(), true, true);
updatePlaceList(binding.nearbyFilter.chipView.choiceChipNeedsPhoto.isChecked(),
binding.nearbyFilter.chipView.choiceChipExists.isChecked(),
binding.nearbyFilter.chipView.choiceChipWlm.isChecked());
} else {
binding.nearbyFilter.chipView.choiceChipExists.setChecked(!isChecked);
}
});
binding.nearbyFilter.chipView.choiceChipWlm.setOnCheckedChangeListener(
(buttonView, isChecked) -> {
if (NearbyController.currentLocation != null) {
binding.nearbyFilterList.checkboxTriStates.setState(CheckBoxTriStates.CHECKED);
NearbyFilterState.setWlmSelected(isChecked);
presenter.filterByMarkerType(
nearbyFilterSearchRecyclerViewAdapter.selectedLabels,
binding.nearbyFilterList.checkboxTriStates.getState(), true, true);
updatePlaceList(binding.nearbyFilter.chipView.choiceChipNeedsPhoto.isChecked(),
binding.nearbyFilter.chipView.choiceChipExists.isChecked(),
binding.nearbyFilter.chipView.choiceChipWlm.isChecked());
} else {
binding.nearbyFilter.chipView.choiceChipWlm.setChecked(!isChecked);
}
});
}
/**
* Updates Nearby place list according to available chip states
*
* @param needsPhoto is chipNeedsPhoto checked
* @param exists is chipExists checked
* @param isWlm is chipWlm checked
*/
private void updatePlaceList(final boolean needsPhoto, final boolean exists,
final boolean isWlm) {
final List<Place> updatedPlaces = new ArrayList<>();
if (needsPhoto) {
for (final Place place :
places) {
if (place.pic.trim().isEmpty() && !updatedPlaces.contains(place)) {
updatedPlaces.add(place);
}
}
} else {
updatedPlaces.addAll(places);
}
if (exists) {
for (final Iterator<Place> placeIterator = updatedPlaces.iterator();
placeIterator.hasNext(); ) {
final Place place = placeIterator.next();
if (!place.exists) {
placeIterator.remove();
}
}
}
if (!isWlm) {
for (final Place place :
places) {
if (place.isMonument() && updatedPlaces.contains(place)) {
updatedPlaces.remove(place);
}
}
} else {
for (final Place place :
places) {
if (place.isMonument() && !updatedPlaces.contains(place)) {
updatedPlaces.add(place);
}
}
}
adapter.setItems(updatedPlaces);
binding.bottomSheetNearby.noResultsMessage.setVisibility(
updatedPlaces.isEmpty() ? View.VISIBLE : View.GONE);
}
/**
* Defines how bottom sheets will act on click
*/
@ -1811,18 +1699,16 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
* Filters markers based on selectedLabels and chips
*
* @param selectedLabels label list that user clicked
* @param displayExists chip for displaying only existing places
* @param displayNeedsPhoto chip for displaying only places need photos
* @param filterForPlaceState true if we filter places for place state
* @param filterForAllNoneType true if we filter places with all none button
*/
@Override
public void filterMarkersByLabels(final List<Label> selectedLabels,
final boolean displayExists,
final boolean displayNeedsPhoto,
final boolean displayWlm,
final boolean filterForPlaceState,
final boolean filterForAllNoneType) {
final boolean displayExists = false;
final boolean displayNeedsPhoto= false;
final boolean displayWlm = false;
// Remove the previous markers before updating them
clearAllMarkers();
for (final MarkerPlaceGroup markerPlaceGroup : NearbyController.markerLabelList) {
@ -1931,15 +1817,16 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
return (isBookmarked ?
R.drawable.ic_custom_map_marker_green_bookmarked :
R.drawable.ic_custom_map_marker_green);
} else if (!place.exists || (place.name
== "")) { // Means that the topic of the Wikidata item does not exist in the real world anymore, for instance it is a past event, or a place that was destroyed
} else if (!place.exists) { // Means that the topic of the Wikidata item does not exist in the real world anymore, for instance it is a past event, or a place that was destroyed
return (R.drawable.ic_clear_black_24dp);
}else if (place.name == "") {
return (isBookmarked ?
R.drawable.ic_custom_map_marker_grey_bookmarked :
R.drawable.ic_custom_map_marker_grey);
R.drawable.ic_custom_map_marker_grey_bookmarked :
R.drawable.ic_custom_map_marker_grey);
} else {
return (isBookmarked ?
R.drawable.ic_custom_map_marker_blue_bookmarked :
R.drawable.ic_custom_map_marker);
R.drawable.ic_custom_map_marker_red);
}
}
@ -2257,7 +2144,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
Timber.d("Gallery button tapped. Place: %s", selectedPlace.toString());
storeSharedPrefs(selectedPlace);
controller.initiateGalleryPick(getActivity(),
binding.nearbyFilter.chipView.choiceChipWlm.isChecked());
false);
}
});
@ -2490,13 +2377,4 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
startActivity(intent);
}
public void onToggleChipsClicked() {
if (binding.nearbyFilter.chipView.getRoot().getVisibility() == View.VISIBLE) {
binding.nearbyFilter.chipView.getRoot().setVisibility(View.GONE);
} else {
binding.nearbyFilter.chipView.getRoot().setVisibility(View.VISIBLE);
}
binding.nearbyFilter.ivToggleChips.setRotation(
binding.nearbyFilter.ivToggleChips.getRotation() + 180);
}
}

View file

@ -281,18 +281,12 @@ public class NearbyParentFragmentPresenter
case CHECKED:
// Despite showing all labels NearbyFilterState still should be applied
nearbyParentFragmentView.filterMarkersByLabels(selectedLabels,
NearbyFilterState.getInstance().isExistsSelected(),
NearbyFilterState.getInstance().isNeedPhotoSelected(),
NearbyFilterState.getInstance().isWlmSelected(),
filterForPlaceState, false);
nearbyParentFragmentView.setRecyclerViewAdapterAllSelected();
break;
}
} else {
nearbyParentFragmentView.filterMarkersByLabels(selectedLabels,
NearbyFilterState.getInstance().isExistsSelected(),
NearbyFilterState.getInstance().isNeedPhotoSelected(),
NearbyFilterState.getInstance().isWlmSelected(),
filterForPlaceState, false);
}
}

View file

@ -10,7 +10,7 @@
android:strokeWidth="1" />
<path
android:fillAlpha="1"
android:fillColor="#f84d4d"
android:fillColor="#000000"
android:pathData="M11.575,11.62C10.689,11.462 9.902,10.759 9.625,9.878 9.553,9.65 9.535,9.499 9.538,9.14c0.004,-0.397 0.019,-0.492 0.13,-0.787 0.236,-0.631 0.646,-1.099 1.212,-1.382 0.386,-0.193 0.709,-0.272 1.116,-0.272 0.676,0 1.263,0.247 1.744,0.734 0.355,0.359 0.541,0.682 0.657,1.136 0.327,1.278 -0.442,2.611 -1.723,2.987 -0.282,0.083 -0.817,0.114 -1.099,0.063z"
android:strokeWidth="1" />
<path

View file

@ -16,14 +16,14 @@
<path
android:pathData="M11.617,21.707C10.518,20.424 9.338,18.864 8.395,17.449 6.524,14.641 5.455,12.305 5.102,10.255 5.014,9.744 5.006,8.628 5.088,8.137 5.348,6.561 6.043,5.221 7.158,4.148 9.148,2.231 12.016,1.668 14.593,2.688c2.043,0.809 3.607,2.581 4.162,4.719 0.174,0.67 0.204,0.933 0.203,1.761 -0.001,0.81 -0.035,1.098 -0.22,1.857 -0.614,2.524 -2.571,5.977 -5.383,9.501 -0.645,0.809 -1.321,1.61 -1.358,1.61 -0.008,0 -0.179,-0.193 -0.381,-0.428zM12.617,11.603c0.783,-0.188 1.457,-0.795 1.738,-1.564 0.516,-1.415 -0.317,-2.962 -1.783,-3.312 -0.216,-0.052 -0.317,-0.059 -0.661,-0.047 -0.354,0.012 -0.441,0.025 -0.682,0.104 -0.673,0.221 -1.205,0.695 -1.506,1.344 -0.176,0.38 -0.218,0.584 -0.217,1.054 0.001,0.324 0.014,0.452 0.064,0.635 0.266,0.97 1.077,1.689 2.079,1.844 0.243,0.038 0.68,0.012 0.968,-0.057z"
android:strokeWidth="1"
android:fillColor="#006699"
android:fillColor="#f84d4d"
android:strokeColor="#003b59"
android:fillAlpha="1"/>
<path
android:pathData="M17.9025,7.0798 L14.1612,6.7552 12.7003,3.3154c-0.2628,-0.6261 -1.1595,-0.6261 -1.4223,0L9.817,6.7629 6.0835,7.0798C5.4032,7.134 5.125,7.9842 5.6429,8.4326l2.8369,2.4581 -0.8503,3.6485c-0.1546,0.6648 0.5643,1.1904 1.1518,0.8348l3.2079,-1.9325 3.2079,1.9402c0.5875,0.3556 1.3064,-0.1701 1.1518,-0.8348L15.4985,10.8907 18.3354,8.4326C18.8533,7.9842 18.5827,7.134 17.9025,7.0798Z"
android:strokeAlpha="1"
android:strokeWidth="1"
android:fillColor="#f84d4d"
android:fillColor="#006699"
android:fillAlpha="1"
android:strokeColor="#003b59"/>
</vector>

View file

@ -23,7 +23,7 @@
android:pathData="M17.9025,7.0798 L14.1612,6.7552 12.7003,3.3154c-0.2628,-0.6261 -1.1595,-0.6261 -1.4223,0L9.817,6.7629 6.0835,7.0798C5.4032,7.134 5.125,7.9842 5.6429,8.4326l2.8369,2.4581 -0.8503,3.6485c-0.1546,0.6648 0.5643,1.1904 1.1518,0.8348l3.2079,-1.9325 3.2079,1.9402c0.5875,0.3556 1.3064,-0.1701 1.1518,-0.8348L15.4985,10.8907 18.3354,8.4326C18.8533,7.9842 18.5827,7.134 17.9025,7.0798Z"
android:strokeAlpha="1"
android:strokeWidth="1"
android:fillColor="#f84d4d"
android:fillColor="#006699"
android:fillAlpha="1"
android:strokeColor="#003b59"/>
</vector>

View file

@ -23,7 +23,7 @@
android:pathData="M17.9025,7.0798 L14.1612,6.7552 12.7003,3.3154c-0.2628,-0.6261 -1.1595,-0.6261 -1.4223,0L9.817,6.7629 6.0835,7.0798C5.4032,7.134 5.125,7.9842 5.6429,8.4326l2.8369,2.4581 -0.8503,3.6485c-0.1546,0.6648 0.5643,1.1904 1.1518,0.8348l3.2079,-1.9325 3.2079,1.9402c0.5875,0.3556 1.3064,-0.1701 1.1518,-0.8348L15.4985,10.8907 18.3354,8.4326C18.8533,7.9842 18.5827,7.134 17.9025,7.0798Z"
android:strokeAlpha="1"
android:strokeWidth="1"
android:fillColor="#f84d4d"
android:fillColor="#006699"
android:fillAlpha="1"
android:strokeColor="#003b59"/>
</vector>

View file

@ -10,7 +10,7 @@
android:strokeWidth="1" />
<path
android:fillAlpha="1"
android:fillColor="#f84d4d"
android:fillColor="#000000"
android:pathData="M11.575,11.62C10.689,11.462 9.902,10.759 9.625,9.878 9.553,9.65 9.535,9.499 9.538,9.14c0.004,-0.397 0.019,-0.492 0.13,-0.787 0.236,-0.631 0.646,-1.099 1.212,-1.382 0.386,-0.193 0.709,-0.272 1.116,-0.272 0.676,0 1.263,0.247 1.744,0.734 0.355,0.359 0.541,0.682 0.657,1.136 0.327,1.278 -0.442,2.611 -1.723,2.987 -0.282,0.083 -0.817,0.114 -1.099,0.063z"
android:strokeWidth="1" />
<path

View file

@ -23,7 +23,7 @@
android:pathData="M17.9025,7.0798 L14.1612,6.7552 12.7003,3.3154c-0.2628,-0.6261 -1.1595,-0.6261 -1.4223,0L9.817,6.7629 6.0835,7.0798C5.4032,7.134 5.125,7.9842 5.6429,8.4326l2.8369,2.4581 -0.8503,3.6485c-0.1546,0.6648 0.5643,1.1904 1.1518,0.8348l3.2079,-1.9325 3.2079,1.9402c0.5875,0.3556 1.3064,-0.1701 1.1518,-0.8348L15.4985,10.8907 18.3354,8.4326C18.8533,7.9842 18.5827,7.134 17.9025,7.0798Z"
android:strokeAlpha="1"
android:strokeWidth="1"
android:fillColor="#f84d4d"
android:fillColor="#006699"
android:fillAlpha="1"
android:strokeColor="#003b59"/>
</vector>

View file

@ -0,0 +1,23 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="@dimen/half_standard_height"
android:height="28dp"
android:viewportWidth="24.0"
android:viewportHeight="28.0">
<path
android:fillAlpha="0.1"
android:fillColor="#000000"
android:pathData="M6.072,22.223a6.031,3.672 0,1 0,12.062 0a6.031,3.672 0,1 0,-12.062 0z"
android:strokeWidth="1" />
<path
android:fillAlpha="1"
android:fillColor="#000000"
android:pathData="M11.575,11.62C10.689,11.462 9.902,10.759 9.625,9.878 9.553,9.65 9.535,9.499 9.538,9.14c0.004,-0.397 0.019,-0.492 0.13,-0.787 0.236,-0.631 0.646,-1.099 1.212,-1.382 0.386,-0.193 0.709,-0.272 1.116,-0.272 0.676,0 1.263,0.247 1.744,0.734 0.355,0.359 0.541,0.682 0.657,1.136 0.327,1.278 -0.442,2.611 -1.723,2.987 -0.282,0.083 -0.817,0.114 -1.099,0.063z"
android:strokeWidth="1" />
<path
android:fillAlpha="1"
android:fillColor="#f84d4d"
android:pathData="M11.617,21.707C10.518,20.424 9.338,18.864 8.395,17.449 6.524,14.641 5.455,12.305 5.102,10.255 5.014,9.744 5.006,8.628 5.088,8.137 5.348,6.561 6.043,5.221 7.158,4.148 9.148,2.231 12.016,1.668 14.593,2.688c2.043,0.809 3.607,2.581 4.162,4.719 0.174,0.67 0.204,0.933 0.203,1.761 -0.001,0.81 -0.035,1.098 -0.22,1.857 -0.614,2.524 -2.571,5.977 -5.383,9.501 -0.645,0.809 -1.321,1.61 -1.358,1.61 -0.008,0 -0.179,-0.193 -0.381,-0.428zM12.617,11.603c0.783,-0.188 1.457,-0.795 1.738,-1.564 0.516,-1.415 -0.317,-2.962 -1.783,-3.312 -0.216,-0.052 -0.317,-0.059 -0.661,-0.047 -0.354,0.012 -0.441,0.025 -0.682,0.104 -0.673,0.221 -1.205,0.695 -1.506,1.344 -0.176,0.38 -0.218,0.584 -0.217,1.054 0.001,0.324 0.014,0.452 0.064,0.635 0.266,0.97 1.077,1.689 2.079,1.844 0.243,0.038 0.68,0.012 0.968,-0.057z"
android:strokeAlpha="1"
android:strokeColor="#003b59"
android:strokeWidth="1" />
</vector>

View file

@ -1,50 +0,0 @@
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_gravity="center_vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingStart="@dimen/filter_padding"
android:text="@string/place_state"
android:textColor="@color/white"/>
<com.google.android.material.chip.ChipGroup
android:id="@+id/choice_chip_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/filter_padding"
android:theme="@style/Theme.MaterialComponents.Light"
app:singleSelection="false">
<com.google.android.material.chip.Chip
android:id="@+id/choice_chip_exists"
style="@style/Widget.MaterialComponents.Chip.Filter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:chipBackgroundColor="@color/bg_chip_state"
android:text="@string/place_state_exists"/>
<com.google.android.material.chip.Chip
android:id="@+id/choice_chip_needs_photo"
style="@style/Widget.MaterialComponents.Chip.Filter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:chipBackgroundColor="@color/bg_chip_state"
android:text="@string/place_state_needs_photo"/>
<com.google.android.material.chip.Chip
android:id="@+id/choice_chip_wlm"
style="@style/Widget.MaterialComponents.Chip.Filter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:chipBackgroundColor="@color/bg_chip_state"
android:text="@string/place_state_wlm"/>
</com.google.android.material.chip.ChipGroup>
</LinearLayout>

View file

@ -18,7 +18,8 @@
<include
android:id="@+id/nearby_filter"
layout="@layout/nearby_filter_all_items" />
layout="@layout/nearby_filter_all_items"
android:visibility="visible" />
<RelativeLayout
android:id="@+id/rl_container_wlm_month_message"

View file

@ -1,38 +1,16 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/status_bar_blue">
<include
android:id="@+id/chip_view"
layout="@layout/filter_chip_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toStartOf="@+id/iv_toggle_chips"
android:background="@color/deleteRed"
android:contentDescription="@string/nearby_filter_state" />
<include
android:id="@+id/search_view_layout"
layout="@layout/filter_search_view_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/chip_view"
android:layout_toStartOf="@+id/iv_toggle_chips"
android:contentDescription="@string/nearby_filter_search" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_toggle_chips"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:contentDescription="@string/nearby_filter_toggle"
android:padding="12dp"
android:scaleType="centerCrop"
android:tint="@color/white"
app:srcCompat="@drawable/arrow_up" />
</RelativeLayout>

View file

@ -263,9 +263,6 @@ class NearbyParentFragmentPresenterTest {
verify(nearbyParentFragmentView).filterMarkersByLabels(
ArgumentMatchers.anyList(),
ArgumentMatchers.anyBoolean(),
ArgumentMatchers.anyBoolean(),
ArgumentMatchers.anyBoolean(),
ArgumentMatchers.anyBoolean(),
ArgumentMatchers.anyBoolean()
);
verify(nearbyParentFragmentView).setRecyclerViewAdapterAllSelected()
@ -281,9 +278,6 @@ class NearbyParentFragmentPresenterTest {
verify(nearbyParentFragmentView).filterMarkersByLabels(
any(),
anyBoolean(),
anyBoolean(),
anyBoolean(),
anyBoolean(),
anyBoolean()
);
verifyNoMoreInteractions(nearbyParentFragmentView)