forked from commons-app/apps-android-commons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add layout items for nearby filter list and filter item (cherry picked from commit b96f8a6) * Edit nearby query (cherry picked from commit 1f3c8c8) * Add filter items to nearby parent fragment xml (cherry picked from commit d0beadd) * Add icon for green marker (cherry picked from commit f65ca03) * Add layout util file to organize layout utilities (cherry picked from commit 5c57939) * Add pic parameter to nearby result item (cherry picked from commit 86007e4) * Add pic parameter to place type (cherry picked from commit 25c358b) * Add green marker styling (cherry picked from commit 929c92d) * Inıt search layouts on Nearby parent (cherry picked from commit 2ac38a1) * Style green markers at nearby controller (cherry picked from commit 3e08f39) * Edit bookmark daos to include pic to tables (cherry picked from commit 48d69ed) * TODO foc bookmark dao item but works now (cherry picked from commit f748399) * Style nearby filter area (cherry picked from commit 6267e48) * fix style of filter tab (cherry picked from commit 5f843bf) * Add nearby list adapter (cherry picked from commit 56334af) * Current status, list size is working, visibility working, filter mechanism is ready (cherry picked from commit 7d75c9c) * Filtering works (cherry picked from commit 8a13cf7) * Filter function works (cherry picked from commit 78368a2) * Fix style issues (cherry picked from commit 2204f70) * Add divider to recyclerview (cherry picked from commit c8100b5) * Hide bottom sheets accordingly (cherry picked from commit c5deba8) * Code cleanup (cherry picked from commit cf8f64f) * Add actions to chips * Fetch destroyed information from servers * Add destroyed places icon * Make chip filter functions work * Revert irrelevant changes * Revert accidentally replaced strings * Remove unneeded lines * Remove only places expalanation from trings * Do not filter if nearby places are not loaded * Add triple checkbox for add none and neutral * Make tri checkbox work * Fix travis issue * Add coments * fix search this area button locaton * Set initial place type state and recover it between each populate places
- Loading branch information
1 parent
5c6ab3b
commit b3c1184
Showing
35 changed files
with
1,265 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
195 changes: 195 additions & 0 deletions
195
app/src/main/java/fr/free/nrw/commons/nearby/CheckBoxTriStates.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
package fr.free.nrw.commons.nearby; | ||
|
||
import android.content.Context; | ||
import android.os.Parcel; | ||
import android.os.Parcelable; | ||
import android.util.AttributeSet; | ||
import android.widget.CompoundButton; | ||
|
||
import androidx.annotation.Nullable; | ||
import androidx.appcompat.widget.AppCompatCheckBox; | ||
|
||
import fr.free.nrw.commons.R; | ||
import fr.free.nrw.commons.nearby.presenter.NearbyParentFragmentPresenter; | ||
|
||
/** | ||
* Base on https://stackoverflow.com/a/40939367/3950497 answer. | ||
*/ | ||
public class CheckBoxTriStates extends AppCompatCheckBox { | ||
|
||
static public final int UNKNOWN = -1; | ||
|
||
static public final int UNCHECKED = 0; | ||
|
||
static public final int CHECKED = 1; | ||
|
||
private int state; | ||
|
||
/** | ||
* This is the listener set to the super class which is going to be evoke each | ||
* time the check state has changed. | ||
*/ | ||
private final OnCheckedChangeListener privateListener = new CompoundButton.OnCheckedChangeListener() { | ||
|
||
// checkbox status is changed from uncheck to checked. | ||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { | ||
switch (state) { | ||
case UNKNOWN: | ||
setState(UNCHECKED);; | ||
break; | ||
case UNCHECKED: | ||
setState(CHECKED); | ||
break; | ||
case CHECKED: | ||
setState(UNKNOWN); | ||
break; | ||
} | ||
} | ||
}; | ||
|
||
/** | ||
* Holds a reference to the listener set by a client, if any. | ||
*/ | ||
private OnCheckedChangeListener clientListener; | ||
|
||
/** | ||
* This flag is needed to avoid accidentally changing the current {@link #state} when | ||
* {@link #onRestoreInstanceState(Parcelable)} calls {@link #setChecked(boolean)} | ||
* evoking our {@link #privateListener} and therefore changing the real state. | ||
*/ | ||
private boolean restoring; | ||
|
||
public CheckBoxTriStates(Context context) { | ||
super(context); | ||
init(); | ||
} | ||
|
||
public CheckBoxTriStates(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
init(); | ||
} | ||
|
||
public CheckBoxTriStates(Context context, AttributeSet attrs, int defStyleAttr) { | ||
super(context, attrs, defStyleAttr); | ||
init(); | ||
} | ||
|
||
public int getState() { | ||
return state; | ||
} | ||
|
||
public void setState(int state) { | ||
if(!this.restoring && this.state != state) { | ||
this.state = state; | ||
|
||
if(this.clientListener != null) { | ||
this.clientListener.onCheckedChanged(this, this.isChecked()); | ||
} | ||
|
||
if (NearbyController.currentLocation != null) { | ||
NearbyParentFragmentPresenter.getInstance().filterByMarkerType(null, state, false, true); | ||
} | ||
updateBtn(); | ||
} | ||
} | ||
|
||
@Override | ||
public void setOnCheckedChangeListener(@Nullable OnCheckedChangeListener listener) { | ||
|
||
// we never truly set the listener to the client implementation, instead we only hold | ||
// a reference to it and evoke it when needed. | ||
if(this.privateListener != listener) { | ||
this.clientListener = listener; | ||
} | ||
|
||
// always use our implementation | ||
super.setOnCheckedChangeListener(privateListener); | ||
} | ||
|
||
@Override | ||
public Parcelable onSaveInstanceState() { | ||
Parcelable superState = super.onSaveInstanceState(); | ||
|
||
SavedState ss = new SavedState(superState); | ||
|
||
ss.state = state; | ||
|
||
return ss; | ||
} | ||
|
||
@Override | ||
public void onRestoreInstanceState(Parcelable state) { | ||
this.restoring = true; // indicates that the ui is restoring its state | ||
SavedState ss = (SavedState) state; | ||
super.onRestoreInstanceState(ss.getSuperState()); | ||
setState(ss.state); | ||
requestLayout(); | ||
this.restoring = false; | ||
} | ||
|
||
private void init() { | ||
state = UNKNOWN; | ||
updateBtn(); | ||
} | ||
|
||
public void addAction() { | ||
setOnCheckedChangeListener(this.privateListener); | ||
} | ||
|
||
private void updateBtn() { | ||
int btnDrawable = R.drawable.ic_indeterminate_check_box_black_24dp; | ||
switch (state) { | ||
case UNKNOWN: | ||
btnDrawable = R.drawable.ic_indeterminate_check_box_black_24dp; | ||
break; | ||
case UNCHECKED: | ||
btnDrawable = R.drawable.ic_check_box_outline_blank_black_24dp; | ||
break; | ||
case CHECKED: | ||
btnDrawable = R.drawable.ic_check_box_black_24dp; | ||
break; | ||
} | ||
setButtonDrawable(btnDrawable); | ||
|
||
} | ||
|
||
static class SavedState extends BaseSavedState { | ||
int state; | ||
|
||
SavedState(Parcelable superState) { | ||
super(superState); | ||
} | ||
|
||
private SavedState(Parcel in) { | ||
super(in); | ||
state = in.readInt(); | ||
} | ||
|
||
@Override | ||
public void writeToParcel(Parcel out, int flags) { | ||
super.writeToParcel(out, flags); | ||
out.writeValue(state); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "CheckboxTriState.SavedState{" | ||
+ Integer.toHexString(System.identityHashCode(this)) | ||
+ " state=" + state + "}"; | ||
} | ||
|
||
@SuppressWarnings("hiding") | ||
public static final Parcelable.Creator<SavedState> CREATOR = | ||
new Parcelable.Creator<SavedState>() { | ||
@Override | ||
public SavedState createFromParcel(Parcel in) { | ||
return new SavedState(in); | ||
} | ||
|
||
@Override | ||
public SavedState[] newArray(int size) { | ||
return new SavedState[size]; | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
app/src/main/java/fr/free/nrw/commons/nearby/MarkerPlaceGroup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package fr.free.nrw.commons.nearby; | ||
|
||
import com.mapbox.mapboxsdk.annotations.Marker; | ||
|
||
/** | ||
* This class groups visual map item Marker with the reated data of displayed place and information | ||
* of bookmark | ||
*/ | ||
public class MarkerPlaceGroup { | ||
private Marker marker; // Marker item from the map | ||
private boolean isBookmarked; // True if user bookmarked the place | ||
private Place place; // Place of the location displayed by the marker | ||
|
||
public MarkerPlaceGroup(Marker marker, boolean isBookmarked, Place place) { | ||
this.marker = marker; | ||
this.isBookmarked = isBookmarked; | ||
this.place = place; | ||
} | ||
|
||
public Marker getMarker() { | ||
return marker; | ||
} | ||
|
||
public Place getPlace() { | ||
return place; | ||
} | ||
|
||
public boolean getIsBookmarked() { | ||
return isBookmarked; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.