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

[post list] allow for edge swiping only #721

Open
SleepyScribe opened this issue Apr 25, 2024 · 19 comments
Open

[post list] allow for edge swiping only #721

SleepyScribe opened this issue Apr 25, 2024 · 19 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@SleepyScribe
Copy link

I saw this feature used in Feeder RSS reader. Wanted to bring it up here after accidentally downvoting myself when trying to swipe down through comments.

I also get hung up on scrolling because the app will catch and try to swipe an article (an issue that plagues every app with swipe actions). An option to only allow swiping from the corresponding edges would bring a ton of quality of life.

Something like a third of the content card, so it doesn't clash with gesture navigation. This would allow for the middle third to be scrolling only.

@diegoberaldin
Copy link
Owner

Swipe actions can be disabled completely in the settings screen or you can enable actions just on one side in the "Configure swipe actions" section.

I understand what your request is, i.e. starting the swipe only if the gesture begins at a certain offset on the card, but I don't know if it possible technically. I'll look into it.

@SleepyScribe
Copy link
Author

@diegoberaldin I do enjoy the swiping feature a lot, and Raccoon has a really pleasant way of handling it as well as being very customizable. I fully understand if it's not possible and that it's a minor detail in the first place.

I'm just tossing out ideas honestly, its already a superb app.

@diegoberaldin
Copy link
Owner

diegoberaldin commented Apr 25, 2024

Thanks for your appreciation, feel free to ask for features or suggest changes! Actually swiping and scrolling are always a pain in Jetpack Compose (the UI toolkit used in this app) and I've already played quite a bit with SwipeToDismissBox.

@diegoberaldin diegoberaldin added the enhancement New feature or request label Apr 25, 2024
@diegoberaldin diegoberaldin changed the title Allow for edge swiping only. [post list] allow for edge swiping only Apr 28, 2024
@cloudlessx
Copy link

@diegoberaldin Even with all swipe actions disabled, the post list still registers swipes. You can see the post bounce slightly when you try to swipe.

The problem is that scrolling up/down is often incorrectly being recognized as swipes. This makes scrolling difficult, and it is biggest reason I don't want to use Raccoon until this is fixed.

Tested with 1.10.0-20240501-pre

@cloudlessx
Copy link

@diegoberaldin Sorry please ignore my previous comment. I just found the "Enable swipe actions" toggle, looks like the issue is resolved when I have the toggle off.

That said, I think swipe actions should only count when swiping from the edge, instead of in the middle of the screen.

@diegoberaldin diegoberaldin added the help wanted Extra attention is needed label May 3, 2024
@diegoberaldin
Copy link
Owner

Unfortunately, I've taken some time to dig into the documentation, and there is no support with standard M3 components. The only viable option would be to completely rewrite the component, reimplement the default behaviour by hand and adding this conditional check on top of it. I added the "help wanted" tag so if anyone wants to pick this and experiment, they'll be welcome.

@cloudlessx
Copy link

I have no idea if this is true (they could be hallucinating), but...

According to Gemini:

Using Modifier.swipeable:

Modifier.swipeable allows you to configure swipe behavior for your composable.
You can define a threshold value for the swipe distance using the resistance parameter.
When the swipe distance exceeds the threshold (i.e., swiping from the edge), the swipe action will be triggered.

Using GestureDetector:

GestureDetector provides a lower-level way to handle gestures.
You can track touch events and detect swipe gestures within the composable.
By checking the starting and ending positions of the swipe, you can determine if it originated from the edge.

And according to Copilot:

To implement edge swipe actions in Jetpack Compose, you can use the Modifier.pointerInput in combination with detectDragGestures. You’ll need to check the initial touch position to determine if the gesture started from the edge of the screen.
This setup allows you to detect swipes that start from the specified edge width and perform an action accordingly. Adjust the edgeWidth as needed for your UI. Remember to handle the state changes and UI updates that should occur as a result of the edge swipe within the onEdgeSwipe lambda or elsewhere in your composable function.

You can ask for specific code examples if you put your question into the prompt. You can probably try putting your code into the prompt and ask for the implementation based on your existing code as well.

@diegoberaldin
Copy link
Owner

Using pointerInput, swipeable or anchoredDraggable (the latter is used internally in SwipeToDismissBox) is what I meant by "redefining manually the behaviour" (GestureDetector applies to views, here we are in Compose so it does not apply directly).

If someone has time, I am leaving this issue open with the "help wanted" tag so who knows...

@cloudlessx
Copy link

I haven't done coding for ages but I'm really interested in taking up this challenge. I just installed Android Studio and got the following error while trying to build Raccoon:

image

Any suggestion on how to resolve this? Must be something straight forward but I've never done Android development before. And I am only familiar with Java and C#.

I am hoping to help contribute more once I get a hold of the build process.

@cloudlessx
Copy link

This warning in the "sync" tab:

prepareKotlinBuildScriptModel:
SDK processing. This version only understands SDK XML versions up to 3 but an SDK XML file of version 4 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times.

@diegoberaldin
Copy link
Owner

The error about missing symbols is due to KSP (the symbol processor) not having run and generated the XmlString class... open the Gradle panel on the right, click the button "Execute Gradle task" and run the task called :core:l10n:kspCommonMainKotlinMetadata.

gradle

This will generate the messages class. It should be done automatically but, you know, Android Studio + Gradle + Kotlin Multiplatform + Kotlin Symbol Processor in a multi-module Gradle setup. 💥

@diegoberaldin
Copy link
Owner

As for the second message, which version of Android Studio are you using? There needs to be a consistency among:

  • the Android Studio version
  • the Android Gradle Plugin version (here it is AGP 8.2.2 you can see it in gradle/libs.versions.toml)
  • Gradle version (project is set up with 8.6 in gradle/wrapper/gradle-wrapper.properties)
  • the Android SDK version, here it refers to the command line tools you can check everything in the "SDK Manager" of Android Studio, see attached screenshot
  • Gradle's JDK version which is very important too, you can check in Android Studio settings, see attached screenshot

Schermata del 2024-05-06 18-22-35
Schermata del 2024-05-06 18-24-50

I agree that (especially if you are not an Android developer) all this may seem a little intimidating, but welcome to our life.

I have written in the CONTRIBUTING.md some notes about how to set up the environment and some more in the technical manual. Just in case you need further references.

@cloudlessx
Copy link

I am using Android Studio Jellyfish, but after the initial failure, I also tried Koala.

It appears that I could execute kspCommonMainKotlinMetadata:

22:14:11: Executing 'core:l10n:kspCommonMainKotlinMetadata'...

Executing tasks: [core:l10n:kspCommonMainKotlinMetadata] in project C:\Users\chung\StudioProjects\RaccoonForLemmy
Type-safe project accessors is an incubating feature.
> Task :core:l10n:checkKotlinGradlePluginConfigurationErrors
> Task :core:l10n:generateComposeResClass UP-TO-DATE
> Task :core:l10n:transformCommonMainDependenciesMetadata UP-TO-DATE
> Task :core:l10n:kspCommonMainKotlinMetadata UP-TO-DATE

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.6/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

BUILD SUCCESSFUL in 6s
4 actionable tasks: 1 executed, 3 up-to-date

Build Analyzer results available
22:14:18: Execution finished 'core:l10n:kspCommonMainKotlinMetadata'.

But I am still getting the "unresolved reference: XmlStrings" errors.
image

I tried to much your JDK version (OpenJDK 21.0.2):
image

And the Android SDK version appears to be the same as yours:
image

According to libs.versions.toml:
android_gradle = "8.2.2"

Any other suggestion?

@diegoberaldin
Copy link
Owner

There should be several .kt files inside the build/generated/ksp/metadata/commonMain/kotlin directory, otherwise it means KSP failed to parse the XML resources and generate the Kotlin sources.

Schermata del 2024-05-07 00-35-12

I assume you are on Windows looking at the path in the logs? (I am on MacOS and Linux, never tried building on other OSes).

@cloudlessx
Copy link

@diegoberaldin I finally managed to build it. I was using Windows (no choice because of work).

Then I tried Fedora, and installed Android Studio via Flatpak. Didn't work, got the exact same issues as with Windows.

Finally I tried Ubuntu, and installed Android Studio via Snap. Got it working!

I will see if I can find a solution to this particular issue. But with a working build I will play with the code and find other things to improve.

Thanks a lot for your help.

@diegoberaldin
Copy link
Owner

I am glad that you managed to get it building but I wonder what is wrong with KSP and Lyricist now...

Everything involving the symbol processor and code generation across different modules has given me headaches (in your case it was the code in :core:l10n not seeing the code in :core:resources). If we find what the cause was it may help others too.

@MV-GH
Copy link

MV-GH commented May 7, 2024

I have the same issue (XmlStrings), With latest Android Studio Jelly Fish. Even when manually running the task, the resources don't appear in the build directory

@diegoberaldin
Copy link
Owner

@cloudlessx I discovered here an example of redefining the swipe to dismiss behaviour with the anchoredDraggable Modifier.

@diegoberaldin
Copy link
Owner

I had issues again when configuring the CI pipeline with the code generated by Lyricist's plugin, and I had to remove all messages using format specifiers.

Another quirk of KMP + multi-module setup, I guess. 🤷🏻

The lack of documentation/samples is considerable unfortunately, and this with it being one of the best libraries out there! I can not complain because it does its job greatly, but there is a little room for improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants