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

"Remove location" button for new uploads #5262

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
e0d0e77
Added styling for "remove location" button to be shown when opening l…
paco-arana Jul 24, 2023
a1be991
Added english language strings for remove location button and popup
paco-arana Jul 24, 2023
210bf23
Merge branch 'commons-app:master' into removelocation
paco-arana Jul 24, 2023
7160d6a
Added code to display remove button whenever the edit button is prese…
paco-arana Jul 24, 2023
d96be6b
Merge remote-tracking branch 'origin/removelocation' into removelocation
paco-arana Jul 24, 2023
01f3654
Added popup to be displayed when clicking on "remove location" button…
paco-arana Jul 24, 2023
34b3013
Added contents of removeLocationFromPicture() method
paco-arana Jul 24, 2023
818fc74
Modified removeLocationFromPicture() to save and exit
paco-arana Jul 24, 2023
df90bde
Methods now set coords to null instead of 0,0.
paco-arana Jul 27, 2023
8e596c6
Merge branch 'commons-app:master' into removelocation
paco-arana Jul 27, 2023
ec0d9b6
Simplified removeLocationFromPicture()
paco-arana Jul 28, 2023
efa657b
Attempt 1: Added removeLocationButton to tests
paco-arana Jul 28, 2023
968cb49
Attempt 2: Moved loc removal to placeSelected()
paco-arana Jul 29, 2023
8b92253
Attempt 3: Testing without method.invoke()
paco-arana Jul 30, 2023
230a1d4
Attempt 4: Placing camera loc to 0,0 and using boolean to remove it e…
paco-arana Jul 30, 2023
5f9feb9
Rolling back changes to tests
paco-arana Jul 30, 2023
1e8049d
Rolling back changes to activity
paco-arana Jul 31, 2023
0f959c3
Attempt 5: Simplified method. Made Style Nullable
paco-arana Jul 31, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import fr.free.nrw.commons.Utils;
import fr.free.nrw.commons.kvstore.JsonKvStore;
import fr.free.nrw.commons.theme.BaseActivity;
import fr.free.nrw.commons.utils.DialogUtil;
import fr.free.nrw.commons.utils.SystemThemeUtils;
import javax.inject.Inject;
import javax.inject.Named;
Expand Down Expand Up @@ -106,6 +107,10 @@ public class LocationPickerActivity extends BaseActivity implements OnMapReadyCa
* modifyLocationButton : button for start editing location
*/
Button modifyLocationButton;
/**
* removeLocationButton : button for removing location metadata
*/
Button removeLocationButton;
/**
* showInMapButton : button for showing in map
*/
Expand Down Expand Up @@ -182,6 +187,7 @@ protected void onCreate(@Nullable final Bundle savedInstanceState) {
if ("UploadActivity".equals(activity)) {
placeSelectedButton.setVisibility(View.GONE);
modifyLocationButton.setVisibility(View.VISIBLE);
removeLocationButton.setVisibility(View.VISIBLE);
showInMapButton.setVisibility(View.VISIBLE);
largeToolbarText.setText(getResources().getString(R.string.image_location));
smallToolbarText.setText(getResources().
Expand Down Expand Up @@ -217,6 +223,7 @@ private void bindViews() {
markerImage = findViewById(R.id.location_picker_image_view_marker);
tvAttribution = findViewById(R.id.tv_attribution);
modifyLocationButton = findViewById(R.id.modify_location);
removeLocationButton = findViewById(R.id.remove_location);
showInMapButton = findViewById(R.id.show_in_map);
showInMapButton.setText(getResources().getString(R.string.show_in_map_app).toUpperCase());
shadow = findViewById(R.id.location_picker_image_view_shadow);
Expand Down Expand Up @@ -284,6 +291,7 @@ private void onStyleLoaded(final Style style) {
}

modifyLocationButton.setOnClickListener(v -> onClickModifyLocation());
removeLocationButton.setOnClickListener(v -> onClickRemoveLocation());
showInMapButton.setOnClickListener(v -> showInMap());
}

Expand All @@ -293,6 +301,7 @@ private void onStyleLoaded(final Style style) {
private void onClickModifyLocation() {
placeSelectedButton.setVisibility(View.VISIBLE);
modifyLocationButton.setVisibility(View.GONE);
removeLocationButton.setVisibility(View.GONE);
showInMapButton.setVisibility(View.GONE);
droppedMarkerLayer.setProperties(visibility(NONE));
markerImage.setVisibility(View.VISIBLE);
Expand All @@ -303,6 +312,47 @@ private void onClickModifyLocation() {
fabCenterOnLocation.setVisibility(View.VISIBLE);
}

/**
* Handles onclick event of removeLocationButton
*/
private void onClickRemoveLocation() {
showRemovedLocationPopup();
}

/**
* Show the popup to confirm location removal
*/
public void showRemovedLocationPopup() {
DialogUtil.showAlertDialog(this,
getString(R.string.no_location_selected),
getString(R.string.no_location_selected_warning_desc),
getString(R.string.continue_message),
getString(R.string.cancel), () -> removeLocationFromPicture(), null);
}

/**
* Method to remove the location from the picture and exit the location picker activity
*/
private void removeLocationFromPicture() {
// Set the camera position to (0, 0)
cameraPosition = new CameraPosition.Builder()
.target(new LatLng(0, 0))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work so far! As you wrote, removing location altogether is needed here. 🙂

.zoom(16)
.build();

// Save the new location (0, 0) to preferences or any other data storage
applicationKvStore.putString(LAST_LOCATION,
mapboxMap.getCameraPosition().target.getLatitude() + ","
+ mapboxMap.getCameraPosition().target.getLongitude());
applicationKvStore.putString(LAST_ZOOM, mapboxMap.getCameraPosition().zoom + "");

// Exit the location picker activity with the updated cameraPosition
final Intent returningIntent = new Intent();
returningIntent.putExtra(LocationPickerConstants.MAP_CAMERA_POSITION, cameraPosition);
setResult(AppCompatActivity.RESULT_OK, returningIntent);
finish();
}

/**
* Show the location in map app
*/
Expand Down
28 changes: 25 additions & 3 deletions app/src/main/res/layout/bottom_container_location_picker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,46 @@
app:layout_constraintStart_toStartOf="parent">

<Button
android:id="@+id/modify_location"
android:id="@+id/remove_location"
style="@style/Widget.AppCompat.Button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:backgroundTint="@color/deleteRed"
android:text="@string/remove_location"
android:textColor="@color/white"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/map_bottom_layout"
app:layout_constraintEnd_toStartOf="@+id/guideline2"
app:layout_constraintStart_toStartOf="@id/map_bottom_layout"
app:layout_constraintTop_toTopOf="@id/map_bottom_layout" />

<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.30" />

<Button
android:id="@+id/modify_location"
android:layout_width="0dp"
android:layout_height="0dp"
android:text="@string/modify_location"
android:textColor="@color/white"
android:visibility="gone"
android:layout_margin="5dp"
app:layout_constraintBottom_toBottomOf="@id/map_bottom_layout"
app:layout_constraintEnd_toStartOf="@+id/guideline3"
app:layout_constraintStart_toStartOf="@id/map_bottom_layout"
app:layout_constraintStart_toEndOf="@+id/guideline2"
app:layout_constraintTop_toTopOf="@id/map_bottom_layout" />

<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5" />
app:layout_constraintGuide_percent="0.70" />

<TextView
android:id="@+id/show_in_map"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,9 @@ Upload your first media by tapping on the add button.</string>
<string name="no_depictions_selected">No Depictions Selected</string>
<string name="no_depictions_selected_warning_desc">Images with depictions are more easily found and more likely to be used. Are you sure you want to continue without selecting depictions?</string>

<string name="no_location_selected">Removing Location</string>
<string name="no_location_selected_warning_desc">Location makes pictures more useful and findable. Do you really wish to remove location from this picture?</string>

<string name="back_button_warning">Cancel Upload</string>
<string name="back_button_warning_desc">Using the back button will cancel this upload and you will lose your progress</string>
<string name="back_button_continue">Continue Upload</string>
Expand Down Expand Up @@ -683,6 +686,7 @@ Upload your first media by tapping on the add button.</string>
<string name="select_location_location_picker">Select location</string>
<string name="show_in_map_app">Show in map app</string>
<string name="modify_location">Edit location</string>
<string name="remove_location">Remove location</string>
<string name="location_picker_image_view">The image view of the location picker</string>
<string name="location_picker_image_view_shadow">
The shadow of the image view of the location picker</string>
Expand Down
Loading