mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Enhancement-Show Icon Labels When Long Pressed (#5492)
* Enhancement-Show Icon Labels when Long Pressed * Tests Added
This commit is contained in:
parent
a8545abff2
commit
8bafee3801
5 changed files with 67 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
@ -39,7 +44,10 @@ 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(
|
||||
|
|
@ -47,7 +55,9 @@ fun placeAdapterDelegate(
|
|||
)
|
||||
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
|
||||
|
|
@ -74,6 +84,7 @@ fun placeAdapterDelegate(
|
|||
R.drawable.ic_round_star_border_24px
|
||||
)
|
||||
}
|
||||
nearbyButtonLayout.directionsButton.setOnLongClickListener{onDirectionsLongPressed()}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -1905,21 +1905,41 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
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());
|
||||
|
||||
|
|
|
|||
|
|
@ -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 }
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -99,4 +104,4 @@ class CommonPlaceClickActionsUnitTest {
|
|||
method.invoke(commonPlaceClickActions)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue