Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

com.github.st235:swipetoactionlayout

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

com.github.st235:swipetoactionlayout

Another one swipe gesture menu.

  • 1.1.4
  • Source
  • Maven
  • Socket score

Version published
Maintainers
1
Source

SwipeToActionLayout

Min Android Sdk Maven Central

SwipeToActionLayout is a layout which helps to implement swipe to reveal behaviour. It is really easy to setup and maintain.

First of all, you need to download it, don't you? 🙂

Download from ...

Important: library was migrated from JCenter to MavenCentral

It means that it may be necessary to add mavenCentral repository to your repositories list

allprojects {
    repositories {
        // your repositories

        mavenCentral()
    }
}
  • Maven
<dependency>
  <groupId>com.github.st235</groupId>
  <artifactId>swipetoactionlayout</artifactId>
  <version>X.X</version>
  <type>pom</type>
</dependency>
  • Gradle
implementation 'com.github.st235:swipetoactionlayout:X.X'
  • Ivy
<dependency org='com.github.st235' name='swipetoactionlayout' rev='X.X'>
  <artifact name='swipetoactionlayout' ext='pom' ></artifact>
</dependency>

P.S.: The latest code version is mentioned at the version badge at the top of this page.

Usage

After you have downloaded the library, you need to integrate it. You should declare layout at your xml.

<github.com.st235.lib_swipetoactionlayout.SwipeToActionLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:sal_gravity="right"
    app:sal_isFullActionSupported="false"
    app:sal_items="@menu/swipe_to_action_menu"
    app:sal_shouldVibrateOnQuickAction="false">

    ... draggable child ...

</github.com.st235.lib_swipetoactionlayout.SwipeToActionLayout>

Xml declaration supports the following attributes:

propertytypedescription
sal_gravityenumgravity of your action menu. could be without rtl support, ie left or right, and with rtl support, ie start and end
sal_isFullActionSupportedbooleanallows you to add support of quick action, which will be revealed on full swipe
sal_shouldVibrateOnQuickActionbooleanwhen quick action will be applied view can perform haptic feedback. set this flag as true if you want to support it.
sal_itemsreferencereference to your xml menu file

If you decided to use xml-declared menu then you should create menu file by the next rules:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@+id/call"
        android:icon="@drawable/ic_call_black_18dp"
        android:background="@drawable/action_background"
        android:iconTint="@color/iconTint"/>

    <item
        android:id="@+id/email"
        android:icon="@drawable/ic_email_black_18dp"
        android:background="@drawable/action_background"
        android:iconTint="@color/iconTint" />

    <item
        android:id="@+id/delete"
        android:icon="@drawable/ic_delete_black_18dp"
        android:background="@drawable/action_background"
        android:iconTint="@color/colorAccent" />
</menu>

An item supports the following attributes:

propertytypedescription
ididan id of your action
titletexta supporting text, will be shown under icon
iconreferencea reference to drawable
titleTextColorcolora color of your title
backgroundreferencea reference to your background resource
iconTintcolortint to your icon, allows to change color of it

PS: all these properties are start with android prefix, for example android:background

Is is also possible to apply actions programmatically

        swipeToActionLayout.actions =
                listOf(
                        SwipeAction(0xFFFBDAEE.toInt(), R.drawable.baseline_call_24, getString(R.string.action_call), Color.BLACK, Color.BLACK),
                        SwipeAction(0xFFFFF7A4.toInt(), R.drawable.baseline_email_24, getString(R.string.action_email), Color.BLACK, Color.BLACK),
                        SwipeAction(0xFFC0E7F6.toInt(), R.drawable.baseline_duo_24, getString(R.string.action_duo), Color.BLACK, Color.BLACK)
                )

To listen lifecycle callbacks from SwipeToActionLayout you should implement SwipeMenuListener


swipeToActionLayout.menuListener = MenuListener()

private inner class MenuListener: SwipeMenuListener {

        override fun onClosed(view: View) {
            // empty on purpose
        }

        override fun onOpened(view: View) {
            // empty on purpose
        }

        override fun onFullyOpened(view: View, quickAction: SwipeAction) {
            // empty on purpose
        }

     override fun onActionClicked(view: View, action: SwipeAction) {
         Toast.makeText(this@MainActivity, "On clicked on: ${action.text}", Toast.LENGTH_SHORT).show()
         swipeToActionLayout.close()
     }
 }

And that is it. Enjoy it!

License

MIT License

Copyright (c) 2019 Alexander Dadukin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

FAQs

Package last updated on 01 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc