Skip to content

Enhancement-Show Icon Labels When Long Pressed #5492

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -17,10 +17,15 @@ fun placeAdapterDelegate(
bookmarkLocationDao: BookmarkLocationsDao,
onItemClick: ((Place) -> Unit)? = null,
onCameraClicked: (Place, ActivityResultLauncher<Array<String>>) -> Unit,
onCameraLongPressed: () -> Boolean,
onGalleryClicked: (Place) -> Unit,
onGalleryLongPressed: () -> Boolean,
onBookmarkClicked: (Place, Boolean) -> Unit,
onBookmarkLongPressed: () -> Boolean,
onOverflowIconClicked: (Place, View) -> Unit,
onOverFlowLongPressed: () -> Boolean,
onDirectionsClicked: (Place) -> Unit,
onDirectionsLongPressed: () -> Boolean,
inAppCameraLocationPermissionLauncher: ActivityResultLauncher<Array<String>>
) = adapterDelegateViewBinding<Place, Place, ItemPlaceBinding>({ layoutInflater, parent ->
ItemPlaceBinding.inflate(layoutInflater, parent, false)
Expand All @@ -39,15 +44,20 @@ fun placeAdapterDelegate(
}
}
nearbyButtonLayout.cameraButton.setOnClickListener { onCameraClicked(item, inAppCameraLocationPermissionLauncher) }
nearbyButtonLayout.cameraButton.setOnLongClickListener { onCameraLongPressed() }

nearbyButtonLayout.galleryButton.setOnClickListener { onGalleryClicked(item) }
nearbyButtonLayout.galleryButton.setOnLongClickListener{onGalleryLongPressed()}
bookmarkButtonImage.setOnClickListener {
val isBookmarked = bookmarkLocationDao.updateBookmarkLocation(item)
bookmarkButtonImage.setImageResource(
if (isBookmarked) R.drawable.ic_round_star_filled_24px else R.drawable.ic_round_star_border_24px
)
onBookmarkClicked(item, isBookmarked)
}
bookmarkButtonImage.setOnLongClickListener{onBookmarkLongPressed()}
nearbyButtonLayout.iconOverflow.setOnClickListener { onOverflowIconClicked(item, it) }
nearbyButtonLayout.iconOverflow.setOnLongClickListener{onOverFlowLongPressed()}
nearbyButtonLayout.directionsButton.setOnClickListener { onDirectionsClicked(item) }
bind {
tvName.text = item.name
Expand All @@ -74,6 +84,7 @@ fun placeAdapterDelegate(
R.drawable.ic_round_star_border_24px
)
}
nearbyButtonLayout.directionsButton.setOnLongClickListener{onDirectionsLongPressed()}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.content.Intent
import android.net.Uri
import android.view.MenuItem
import android.view.View
import android.widget.Toast
import androidx.activity.result.ActivityResultLauncher
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.widget.PopupMenu
Expand Down Expand Up @@ -37,6 +38,30 @@ class CommonPlaceClickActions @Inject constructor(
}
}

/**
* Shows the Label for the Icon when it's long pressed
**/
fun onCameraLongPressed(): () -> Boolean = {
Toast.makeText(activity, R.string.menu_from_camera, Toast.LENGTH_SHORT).show()
true
}
fun onGalleryLongPressed(): () -> Boolean = {
Toast.makeText(activity, R.string.menu_from_gallery, Toast.LENGTH_SHORT).show()
true
}
fun onBookmarkLongPressed(): () -> Boolean = {
Toast.makeText(activity, R.string.menu_bookmark, Toast.LENGTH_SHORT).show()
true
}
fun onDirectionsLongPressed(): () -> Boolean = {
Toast.makeText(activity, R.string.nearby_directions, Toast.LENGTH_SHORT).show()
true
}
fun onOverflowLongPressed(): () -> Boolean = {
Toast.makeText(activity, R.string.more, Toast.LENGTH_SHORT).show()
true
}

fun onGalleryClicked(): (Place) -> Unit = {
if (applicationKvStore.getBoolean("login_skipped", false)) {
showLoginDialog()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1905,21 +1905,41 @@ private void passInfoToSheet(final Place place) {
updateMarker(isBookmarked, selectedPlace, locationManager.getLastLocation());
mapView.invalidate();
});
bookmarkButton.setOnLongClickListener(view -> {
Toast.makeText(getContext(), R.string.menu_bookmark, Toast.LENGTH_SHORT).show();
return true;
});

wikipediaButton.setVisibility(place.hasWikipediaLink() ? View.VISIBLE : View.GONE);
wikipediaButton.setOnClickListener(
view -> Utils.handleWebUrl(getContext(), selectedPlace.siteLinks.getWikipediaLink()));
wikipediaButton.setOnLongClickListener(view -> {
Toast.makeText(getContext(), R.string.nearby_wikipedia, Toast.LENGTH_SHORT).show();
return true;
});

wikidataButton.setVisibility(place.hasWikidataLink() ? View.VISIBLE : View.GONE);
wikidataButton.setOnClickListener(
view -> Utils.handleWebUrl(getContext(), selectedPlace.siteLinks.getWikidataLink()));
wikidataButton.setOnLongClickListener(view -> {
Toast.makeText(getContext(), R.string.nearby_wikidata, Toast.LENGTH_SHORT).show();
return true;
});

directionsButton.setOnClickListener(view -> Utils.handleGeoCoordinates(getActivity(),
selectedPlace.getLocation()));
directionsButton.setOnLongClickListener(view -> {
Toast.makeText(getContext(), R.string.nearby_directions, Toast.LENGTH_SHORT).show();
return true;
});

commonsButton.setVisibility(selectedPlace.hasCommonsLink() ? View.VISIBLE : View.GONE);
commonsButton.setOnClickListener(
view -> Utils.handleWebUrl(getContext(), selectedPlace.siteLinks.getCommonsLink()));
commonsButton.setOnLongClickListener(view -> {
Toast.makeText(getContext(), R.string.nearby_commons, Toast.LENGTH_SHORT).show();
return true;
});

icon.setImageResource(selectedPlace.getLabel().getIcon());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@ class PlaceAdapter(
bookmarkLocationsDao,
onPlaceClicked,
commonPlaceClickActions.onCameraClicked(),
commonPlaceClickActions.onCameraLongPressed(),
commonPlaceClickActions.onGalleryClicked(),
commonPlaceClickActions.onGalleryLongPressed(),
onBookmarkClicked,
commonPlaceClickActions.onBookmarkLongPressed(),
commonPlaceClickActions.onOverflowClicked(),
commonPlaceClickActions.onOverflowLongPressed(),
commonPlaceClickActions.onDirectionsClicked(),
commonPlaceClickActions.onDirectionsLongPressed(),
inAppCameraLocationPermissionLauncher
),
areItemsTheSame = {oldItem, newItem -> oldItem.wikiDataEntityId == newItem.wikiDataEntityId }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ class CommonPlaceClickActionsUnitTest {
Assert.assertNotNull(commonPlaceClickActions.onGalleryClicked())
Assert.assertNotNull(commonPlaceClickActions.onOverflowClicked())
Assert.assertNotNull(commonPlaceClickActions.onDirectionsClicked())
Assert.assertNotNull(commonPlaceClickActions.onCameraLongPressed())
Assert.assertNotNull(commonPlaceClickActions.onGalleryLongPressed())
Assert.assertNotNull(commonPlaceClickActions.onBookmarkLongPressed())
Assert.assertNotNull(commonPlaceClickActions.onDirectionsLongPressed())
Assert.assertNotNull(commonPlaceClickActions.onOverflowLongPressed())
}

@Test
Expand Down Expand Up @@ -99,4 +104,4 @@ class CommonPlaceClickActionsUnitTest {
method.invoke(commonPlaceClickActions)
}

}
}