A simple 'Slide to Unlock' Material widget for Android, written in Kotlin 📱🎨🦄

Overview

Slide To Act

CircleCI Download Android Weekly License Twitter Awesome Kotlin Badge

A simple Slide to Unlock Material widget for Android, written in Kotlin 🇰.

sample-slidetoact gif

Getting Started 👣

Slide To Act is distributed through JCenter. To use it you need to add the following Gradle dependency to your android app gradle file (NOT the root file):

dependencies {
   implementation "com.ncorti:slidetoact:0.9.0"
}

Or you can download the .AAR artifact directly from Bintray.

Example 🚸

After setting up the Gradle dependency, you can use SlideToActView widgets inside your XML Layout files

<com.ncorti.slidetoact.SlideToActView
    android:id="@+id/example"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:text="Example" />

And bind them inside your Java/Kotlin code:

SlideToActView sta = (SlideToActView) findViewById(R.id.example);

Features 🎨

  • 100% Vectorial, no .png or other assets provided.
  • Fancy animations! 🦄
  • API >= 14 compatible (since v0.2.0)
  • Easy to integrate (just a gradle compile line).
  • Integrated with your app theme 🖼 .
  • Works out of the box, no customization needed.
  • Written in Kotlin (but you don't need Kotlin to use it)!
  • UX Friendly 🐣 , button will bump to complete if it's over the 80% of the slider (see the following gif).

ux_friendly gif

Attributes

By the default, every SlideToActView widget fits to your app using the colorAccent and the colorBackground parameters from your theme. You can customize your SlideToActView using the following custom attributes.

<com.ncorti.slidetoact.SlideToActView
    android:id="@+id/example_gray_on_green"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:elevation="6dp"
    app:area_margin="4dp"
    app:animation_duration="250"
    app:outer_color="@color/green"
    app:inner_color="@color/grey"
    app:border_radius="2dp"
    app:text="Testing all the custom attributes"
    app:text_size="12sp"
    app:slider_height="80dp"
    app:slider_locked="false" />

area_margin

Use the area_marging attribute to control the margin of the inner circular button from the outside area. If not set, this attribute defaults to 8dp.

area_margin_1 area_margin_2

You can also use a negative value to have the inner circular button bigger than the slider. To achieve this effect you also need to set android:clipChildren="false" on the parent layout, like:

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:clipChildren="false">

    <com.ncorti.slidetoact.SlideToActView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:area_margin="-8dp"/>

to obtain this behavior:

area_margin_3

icon_margin

The attribute icon_margin let you control the margin of the icon inside the circular button. This makes the icon bigger because can take up more space in the button.

This is especially useful when you want to make the height of the slider smaller (see slider_height). In this case, if you don't adjust the icon_margin the image can be too much tiny. By default, the icon_margin is set to 16dp.

In next image you can see how it looks like:

icon_margin icon_margin

inner_color & outer_color

Use the outer_color attribute to control the color of the external area and the color of the arrow icon. If not set, this attribute defaults to colorAccent from your theme.

Use the inner_color attribute to control the color of the inner circular button, the color of the tick icon and the color of the text. If not set, this attribute defaults to colorBackground from your theme.

color_1 color_2

border_radius

Use the border_radius attribute to control the radius of the inner circular button and of the external area. A border_radius set to 0dp will result in a square slider. If not set, this attribute will render your slider as a circle (default behavior).

border_radius_1 border_radius_2

text, text_size, text_style, text_appearance

Use the text attribute to control the text of your slider. If not set, this attribute defaults to SlideToActView.

Use the text_size attribute to control the size of the text of your slider. A text_size set to 0sp will result in hiding the text. If not set, this attribute defaults to 16sp.

Use the text_style attribute to control the style of your text. Accepted values are normal, bold and italic.

Use the text_appearance attribute to provide an Android TextAppearance style to fully customize your Text. Please use this attribute if you want to use a custom font or set the text to be all caps.

slider_text slider_text_appearance

slider_height

Use the slider_height attribute to control the desired height of the widget. If not set, the widget will try to render with 72dp of height.

slider_height_1 slider_height_2

slider_locked

Use the slider_locked attribute to lock the slider (this is a boolean attribute). When a slider is locked, will always bump the button to the beginning (default is false).

locked_slider gif

You can also toggle this attribute programmatically with the provided setter.

SlideToActView sta = (SlideToActView) findViewById(R.id.slider);
sta.setLocked(true);

animation_duration

Use the animation_duration attribute to set the duration of the complete and reset animation (in milliseconds).

You can also set animation duration programmatically with the provided setter.

val sta = (SlideToActView) findViewById(R.id.slider);
sta.animDuration = 600

slider_reversed

Use the slider_reversed attribute to reverse the slider (this is a boolean attribute). When a slider is reversed, the cursor will appear on the right and will progress to the left. (default is false).

reversed_slider gif

You can also toggle this attribute programmatically with the provided setter.

SlideToActView sta = (SlideToActView) findViewById(R.id.slider);
sta.setReversed(true);

slider_icon

You can set a custom icon by setting the slider_iconattribute to a drawable resource.

custom_icon

app:slider_icon="@drawable/custom_icon"

You can also set a custom icon programmatically with the provided setter.

SlideToActView sta = findViewById(R.id.slider);
sta.setSliderIcon(R.drawable.custom_icon);

You can also disable the rotation by setting the rotate_icon attribute to false.

complete_icon

You can set a custom complete icon by setting the complete_iconattribute to a drawable resource.

custom_complete_iconcon

app:complete_icon="@drawable/slidetoact_ic_check"

You can also set a custom complete icon programmatically with the provided setter.

SlideToActView sta = findViewById(R.id.slider);
sta.setCompleteIcon(R.drawable.custom_complete_animated);

slider_icon_color

You can set a custom color for the icon by setting the slider_icon_color attribute.

custom_icon

This attribute defaults to the outer_color if set. If outer_color is not set, this attribute defaults to colorAccent from your theme.

bump_vibration

You can make the device vibrate when the cursor "bumps" to the end of the sliding path by setting the period of vibration through bump_vibration attribute in your layout XML (default is 0)

app:bump_vibration="50"

Note that the period of vibration is in milliseconds

You can achieve the same programmatically using the setter:

SlideToActView sta = (SlideToActView) findViewById(R.id.slider);
sta.setBumpVibration(50);

In order for this feature to work, you need have the permission android.permission.VIBRATE in your AndroidManifest.xml

<uses-permission android:name="android.permission.VIBRATE"/>

android:elevation

Use the android:elevation attribute to set the elevation of the widget. The widgets will take care of providing the proper ViewOutlineProvider during the whole animation (a.k.a. The shadow will be drawn properly).

elevation_1 elevation_2

Event callbacks

You can use the OnSlideCompleteListener and the OnSlideResetListener to simply interact with the widget. If you need to perform operations during animations, you can provide an OnSlideToActAnimationEventListener. With the latter, you will be notified of every animation start/stop.

You can try the Event Callbacks in the Demo app to better understand where every callback is called.

event_log

Demo 📲

Wonna see the widget in action? Just give a try to the Example App, it's inside the example folder.

Otherwise, you can just download the APK from a CircleCI build, and try it on a real device/emulator.

example_app gif

Building/Testing ⚙️

CircleCI CircleCI

This projects is built with Circle CI. The CI environment takes care of building the library .AAR, the example app and to run the Espresso tests. Artifacts are exposed at the end of every build (both the .AAR and the .APK of the example app).

TravisCI Build Status

TravisCI builds are also running but they are considered Legacy. I'm probably going to dismiss it soon or later.

Building locally

Before building, make sure you have the following updated components from the Android SDK:

  • tools
  • platform-tools
  • build-tools-25.0.3
  • android-25
  • extra-android-support
  • extra-android-m2repository
  • extra-google-m2repository

Then just clone the repo locally and build the .AAR with the following command:

git clone [email protected]:cortinico/slidetoact.git
cd slidetoact/
./gradlew slidetoact:assemble

The assembled .AAR will be inside the slidetoact/build/outputs/aar folder.

Testing

Once you're able to build successfully, you can run Espresso tests locally with the following command.

./gradlew clean build connectedCheck 

Make sure your tests are all green locally before submitting PRs.

Contributing 🤝

Looking for contributors! Don't be shy. 😁 Feel free to open issues/pull requests to help me improve this project.

  • When reporting a new Issue, make sure to attach Screenshots, Videos or GIFs of the problem you are reporting.
  • When submitting a new PR, make sure tests are all green. Write new tests if necessary.

Honorable mentions 🎖

License 📄

This project is licensed under the MIT License - see the License file for details

Comments
  • Possibility to configure of animation duration

    Possibility to configure of animation duration

    Description

    add the possibility for the setting of the animation duration

    Related PRs/Issues

    https://github.com/cortinico/slidetoact/issues/82

    Todos

    • [X] Tests
    • [X] Documentation
    opened by jershell 16
  • Crash com.ncorti.slidetoact.SlideToActView.parseVectorDrawableCompat

    Crash com.ncorti.slidetoact.SlideToActView.parseVectorDrawableCompat

    What kind of issue is this?

    • [ ] UI Bug. Please provide a Screenshot/Video/GIF of what's the problem. If you need help to record a video you can follow this guide

    • [X] Functional Bug. Please describe the scenario of the bug. Furthermore, please spend the time to write a failing test.

    • [ ] Feature Request. Start by telling what's problem you’re trying to solve. A Pull request is welcome as well.

    Details

    In case of bug report, please don't forget to include also:

    • Library Version: 0.8.0
    • Android Version: Android 6(23) - xhdpi

    Thanks for taking the time to create and to maintain this library! We are currently using it in our App and are seeing a few crashes for some users.

    I was able to reproduce it in the example project using a new image resource, I tested with multiple vectors and they all seem to produce the crash. None of the included vectors seems to cause any crashes though.

    To reproduce the crash you can take a look at my fork: https://github.com/jonandersen/slidetoact Setup a new simulator targeting Api 23 for with a screen size of xhdpi (The nexus 4 is what I used)

    Thanks!

        java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ncorti.slidetoact.example/com.ncorti.slidetoact.example.MainActivity}: android.view.InflateException: Binary XML file line #21: Binary XML file line #21: Error inflating class com.ncorti.slidetoact.SlideToActView
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
            at android.app.ActivityThread.-wrap11(ActivityThread.java)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:148)
            at android.app.ActivityThread.main(ActivityThread.java:5417)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
         Caused by: android.view.InflateException: Binary XML file line #21: Binary XML file line #21: Error inflating class com.ncorti.slidetoact.SlideToActView
            at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
            at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
            at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
            at com.ncorti.slidetoact.example.MainActivity.onCreate(MainActivity.java:20)
            at android.app.Activity.performCreate(Activity.java:6237)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
            at android.app.ActivityThread.-wrap11(ActivityThread.java) 
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
            at android.os.Handler.dispatchMessage(Handler.java:102) 
            at android.os.Looper.loop(Looper.java:148) 
            at android.app.ActivityThread.main(ActivityThread.java:5417) 
            at java.lang.reflect.Method.invoke(Native Method) 
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
         Caused by: android.view.InflateException: Binary XML file line #21: Error inflating class com.ncorti.slidetoact.SlideToActView
            at android.view.LayoutInflater.createView(LayoutInflater.java:645)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
            at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
            at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555) 
            at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161) 
            at com.ncorti.slidetoact.example.MainActivity.onCreate(MainActivity.java:20) 
            at android.app.Activity.performCreate(Activity.java:6237) 
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
            at android.app.ActivityThread.-wrap11(ActivityThread.java) 
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
            at android.os.Handler.dispatchMessage(Handler.java:102) 
            at android.os.Looper.loop(Looper.java:148) 
            at android.app.ActivityThread.main(ActivityThread.java:5417) 
            at java.lang.reflect.Method.invoke(Native Method) 
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
         Caused by: java.lang.reflect.InvocationTargetException
            at java.lang.reflect.Constructor.newInstance(Native Method)
            at android.view.LayoutInflater.createView(LayoutInflater.java:619)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) 
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:838) 
            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
            at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
            at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
            at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
            at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555) 
            at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161) 
            at com.ncorti.slidetoact.example.MainActivity.onCreate(MainActivity.java:20) 
            at android.app.Activity.performCreate(Activity.java:6237) 
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
            at android.app.ActivityThread.-wrap11(ActivityThread.java) 
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
            at android.os.Handler.dispatchMessage(Handler.java:102) 
            at android.os.Looper.loop(Looper.java:148) 
            at android.app.ActivityThread.main(ActivityThread.java:5417) 
            at java.lang.reflect.Method.invoke(Native Method) 
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
         Caused by: android.content.res.Resources$NotFoundException: File res/drawable-xhdpi-v4/ic_arrow_right.png from xml type xml resource ID #0x7f07006e
            at android.content.res.Resources.loadXmlResourceParser(Resources.java:2821)
            at android.content.res.Resources.loadXmlResourceParser(Resources.java:2776)
            at android.content.res.Resources.getXml(Resources.java:1214)
            at com.ncorti.slidetoact.SlideToActView.parseVectorDrawableCompat(SlideToActView.kt:414)
            at com.ncorti.slidetoact.SlideToActView.setSliderIcon(SlideToActView.kt:149)
            at com.ncorti.slidetoact.SlideToActView.<init>(SlideToActView.kt:344)
            at com.ncorti.slidetoact.SlideToActView.<init>(SlideToActView.kt:49)
            at com.ncorti.slidetoact.SlideToActView.<init>(SlideToActView.kt)
            at java.lang.reflect.Constructor.newInstance(Native Method) 
            at android.view.LayoutInflater.createView(LayoutInflater.java:619) 
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) 
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:838) 
            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
            at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
            at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
            at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
            at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555) 
            at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161) 
            at com.ncorti.slidetoact.example.MainActivity.onCreate(MainActivity.java:20) 
            at android.app.Activity.performCreate(Activity.java:6237) 
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
            at android.app.ActivityThread.-wrap11(ActivityThread.java) 
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
            at android.os.Handler.dispatchMessage(Handler.java:102) 
            at android.os.Looper.loop(Looper.java:148) 
            at android.app.ActivityThread.main(ActivityThread.java:5417) 
            at java.lang.reflect.Method.invoke(Native Method) 
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
         Caused by: java.io.FileNotFoundException: Corrupt XML binary file
            at android.content.res.AssetManager.openXmlAssetNative(Native Method)
            at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:485)
            at android.content.res.Resources.loadXmlResourceParser(Resources.java:2803)
            at android.content.res.Resources.loadXmlResourceParser(Resources.java:2776) 
            at android.content.res.Resources.getXml(Resources.java:1214) 
            at com.ncorti.slidetoact.SlideToActView.parseVectorDrawableCompat(SlideToActView.kt:414) 
            at com.ncorti.slidetoact.SlideToActView.setSliderIcon(SlideToActView.kt:149) 
            at com.ncorti.slidetoact.SlideToActView.<init>(SlideToActView.kt:344) 
            at com.ncorti.slidetoact.SlideToActView.<init>(SlideToActView.kt:49) 
            at com.ncorti.slidetoact.SlideToActView.<init>(SlideToActView.kt) 
            at java.lang.reflect.Constructor.newInstance(Native Method) 
            at android.view.LayoutInflater.createView(LayoutInflater.java:619) 
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) 
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:838) 
            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
            at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
            at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
            at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
            at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555) 
            at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161) 
            at com.ncorti.slidetoact.example.MainActivity.onCreate(MainActivity.java:20) 
            at android.app.Activity.performCreate(Activity.java:6237) 
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
            at android.app.ActivityThread.-wrap11(ActivityThread.java) 
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
            at android.os.Handler.dispatchMessage(Handler.java:102) 
            at android.os.Looper.loop(Looper.java:148) 
            at android.app.ActivityThread.main(ActivityThread.java:5417) 
            at java.lang.reflect.Method.invoke(Native Method) 
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
    
    bug 
    opened by jonandersen 8
  • Increase size of inner circle making it bigger than outer circle

    Increase size of inner circle making it bigger than outer circle

    Nice library with nice animation

    What kind of issue is this?

    • [ ] Feature Request. Is it possible to increase the size (diameter) of the inner circle without increasing the size of outer circle such that the inner circle becomes bigger than outer circle?
    help wanted good first issue 
    opened by itabdullah1 8
  • Caused by: android.content.res.Resources$NotFoundException: File res/drawable-xxhdpi-v4/*.png from xml type xml resource ID #

    Caused by: android.content.res.Resources$NotFoundException: File res/drawable-xxhdpi-v4/*.png from xml type xml resource ID #

    I am trying to apply custom icon for the slider but getting following crash. The resource is available in drawable folder.

    Caused by: android.content.res.Resources$NotFoundException: File res/drawable-xxhdpi-v4/pointing_hand.png from xml type xml resource ID #0x7f0700ab
            at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1243)
            at android.content.res.Resources.loadXmlResourceParser(Resources.java:2172)
            at android.content.res.Resources.getXml(Resources.java:1221)
            at com.ncorti.slidetoact.SlideToActView.parseVectorDrawableCompat(SlideToActView.kt:296)
    2019-11-04 13:30:53.979 com.** E/AndroidRuntime:     at com.ncorti.slidetoact.SlideToActView.<init>(SlideToActView.kt:271)
            at com.ncorti.slidetoact.SlideToActView.<init>(SlideToActView.kt:40)
            at com.ncorti.slidetoact.SlideToActView.<init>(Unknown Source:6)
            	... 40 more
         Caused by: java.io.FileNotFoundException: Corrupt XML binary file
            at android.content.res.AssetManager.nativeOpenXmlAsset(Native Method)
            at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:1009)
            at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1227)
            	... 46 more
    

    My xml:

            <com.ncorti.slidetoact.SlideToActView
                android:id="@+id/btn_swipe"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/home_screen"
                android:layout_margin="30dp"
                app:area_margin="0dp"
                app:elevation="8dp"
                app:slider_icon="@drawable/arrow_right"
                app:inner_color="@color/colorAccent"
                app:outer_color="@color/colorPrimary"
                app:slider_height="64dp"
                app:slider_locked="false"
                app:rotate_icon="true"
                app:text="SWIPE TO REFLECT"
                app:text_color="@android:color/white"
                app:text_size="16sp"
                app:text_style="bold" />
    

    Tesing device:

    Samsung A30 - Android version: Pie 9

    Library Version:

    implementation 'com.ncorti:slidetoact:0.7.0'

    Full stacktrace:

    2019-11-04 13:47:16.887 com.** E/AndroidRuntime: FATAL EXCEPTION: main
        Process: com.***, PID: 27796
        android.view.InflateException: Binary XML file line #41: Binary XML file line #41: Error inflating class com.ncorti.slidetoact.SlideToActView
        Caused by: android.view.InflateException: Binary XML file line #41: Error inflating class com.ncorti.slidetoact.SlideToActView
        Caused by: java.lang.reflect.InvocationTargetException
            at java.lang.reflect.Constructor.newInstance0(Native Method)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
            at android.view.LayoutInflater.createView(LayoutInflater.java:686)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:829)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:769)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:902)
            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:863)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:905)
            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:863)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:554)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:461)
            at com.**.general.HomeFragment.onCreateView(HomeFragment.java:49)
            at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2600)
            at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:881)
            at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
            at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
            at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:439)
            at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2079)
            at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1869)
            at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1824)
            at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
            at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2663)
            at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManagerImpl.java:2613)
            at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:246)
            at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:542)
            at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:201)
            at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1395)
            at android.app.Activity.performStart(Activity.java:7348)
            at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3147)
            at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:180)
            at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:165)
            at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:142)
            at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1957)
            at android.os.Handler.dispatchMessage(Handler.java:106)
            at android.os.Looper.loop(Looper.java:214)
            at android.app.ActivityThread.main(ActivityThread.java:7099)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
         Caused by: android.content.res.Resources$NotFoundException: File res/drawable-xxhdpi-v4/arrow_right.png from xml type xml resource ID #0x7f07005e
            at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1243)
            at android.content.res.Resources.loadXmlResourceParser(Resources.java:2172)
            at android.content.res.Resources.getXml(Resources.java:1221)
            at com.ncorti.slidetoact.SlideToActView.parseVectorDrawableCompat(SlideToActView.kt:332)
    2019-11-04 13:47:16.888 com.** E/AndroidRuntime:     at com.ncorti.slidetoact.SlideToActView.<init>(SlideToActView.kt:306)
            at com.ncorti.slidetoact.SlideToActView.<init>(SlideToActView.kt:39)
            at com.ncorti.slidetoact.SlideToActView.<init>(Unknown Source:6)
            	... 40 more
         Caused by: java.io.FileNotFoundException: Corrupt XML binary file
            at android.content.res.AssetManager.nativeOpenXmlAsset(Native Method)
            at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:1009)
            at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1227)
            	... 46 more
    
    

    Gradle:

    compileSdkVersion 29
        defaultConfig {
            applicationId "com.***.**"
            minSdkVersion 17
            targetSdkVersion 29
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
            vectorDrawables.useSupportLibrary = true
        }
    

    Please let me know if you need more details. Thanks for your support.

    information needed 
    opened by itabdullah 8
  • Render Problem in android studio 3.3.1

    Render Problem in android studio 3.3.1

    i add this lib to my project and get render problem :

    java.lang.ClassCastException: android.graphics.drawable.BitmapDrawable cannot be cast to 
    android.graphics.drawable.VectorDrawable   at 
    android.graphics.drawable.AnimatedVectorDrawable.inflate(
    AnimatedVectorDrawable.java:546)   at 
    android.graphics.drawable.DrawableInflater.inflateFromXmlForDensity(
    DrawableInflater.java:142)   at 
    android.graphics.drawable.Drawable.createFromXmlInnerForDensity(Drawable.java:1332)   at 
    android.graphics.drawable.Drawable.createFromXmlForDensity(Drawable.java:1291)   at 
    android.graphics.drawable.Drawable.createFromXml(Drawable.java:1266)   at 
    com.android.layoutlib.bridge.impl.ResourceHelper.getDrawable(ResourceHelper.java:338) 
      at android.content.res.Resources_Delegate.getDrawable(Resources_Delegate.java:186) 
      at android.content.res.Resources.getDrawable(Resources.java:827)   at 
    com.ncorti.slidetoact.SlideToActView.<init>(SlideToActView.kt:227)   at 
    com.ncorti.slidetoact.SlideToActView.<init>(SlideToActView.kt:37)   at 
    com.ncorti.slidetoact.SlideToActView.<init>(SlideToActView.kt:-1)   at 
    java.lang.reflect.Constructor.newInstance(Constructor.java:423)   at 
    android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)   at 
    android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:863)   at 
    android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)   at 
    android.view.LayoutInflater.rInflate(LayoutInflater.java:837)   at 
    android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)   at 
    android.view.LayoutInflater.inflate(LayoutInflater.java:515)   at 
    android.view.LayoutInflater.inflate(LayoutInflater.java:394)
    
    information needed 
    opened by mrb0098 8
  • New feature: vibrate device on bump

    New feature: vibrate device on bump

    Description

    These changes make the device vibrate if the cursor "bumps" to the end of it's path (outer rect). bumpVibration property can be used to set the vibration period, if set to zero or negative will not even try to vibrate (which is actually default). This property is bound to XML attribute bump_vibration.

    Todos

    • [x] Documentation
    opened by quanta-kt 7
  • Add ability to disable icon rotation and complete animation

    Add ability to disable icon rotation and complete animation

    • rotate_icon to enable or disable icon rotation while sliding
    • animate_complete to enable or disable animation when slide is complete

    Status

    READY

    Description

    Add the ability to disable icon rotation, and the ability to disable the animation that occurs when slide is completed.

    Related PRs/Issues

    N.A

    Todos

    • [ ] Tests
    • [✓] Documentation
    • [ ] Screenshots

    Feedback Reviews

    @cortinico

    dont-merge 
    opened by sgcodigo 7
  • Add text rotation

    Add text rotation

    Description

    Add the ability to rotate the inner text.

    Related PRs/Issues

    #3 Slide from right to left

    Comments

    I've added a use case in the text/style example app.

    opened by adrienrx 6
  • Upgrade targetSdkVersion to 29

    Upgrade targetSdkVersion to 29

    Upgraded the targetSdkVersion to 29

    Appearantly, the library doesn't violates any API change. The warning on line 284 of the SlideToActView class turned into an error which was fixed by a simple null check.

    opened by quanta-kt 5
  • How to implement onSlideCompleteListener event callback ?

    How to implement onSlideCompleteListener event callback ?

    I wasn't able to capture on slide events of the plugin. I am using the latest version 'com.ncorti:slidetoact:0.7.0'

    val slideToConfirm = rootView.findViewById<SlideToActView>(R.id.frag_payment_slide_to_confirm)
    
    slideToConfirm.onSlideCompleteListener
    

    I am using the above interface but I can't seem to capture the events. I wasn't able to implement .setOnSlideCompleteListener. I am implementing the slider inside a Fragment.

    compileSdkVersion 29 buildToolsVersion "29.0.2" kotlin_version = '1.3.50' gradleVersion = '3.4.2'

    information needed 
    opened by mariaangelamagtoto 5
  • feature request: Attribute to change arrow icon DP

    feature request: Attribute to change arrow icon DP

    What kind of issue is this?

    • [ ] UI Bug. Please provide a Screenshot/Video/GIF of what's the problem. If you need help to record a video you can follow this guide

    • [ ] Functional Bug. Please describe the scenario of the bug. Furthermore, please spend the time to write a failing test.

    • [x] Feature Request. Start by telling what's problem you’re trying to solve. A Pull request is welcome as well.

    Details

    I would like a attribute to manually set the DP for the icon arrow. this would be awesome for lower value slider_height like 40dp. c54711d1-4ad0-466d-95b2-33a1f6f75343 png

    enhancement information needed 
    opened by druby-luke 5
  • 0.10.0 version changed the look of my button

    0.10.0 version changed the look of my button

    Before I had implementation 'com.ncorti:slidetoact:0.9.0' and the button looked like this

    image

    I upgraded to 'com.ncorti:slidetoact:0.10.0' and now it looks like this

    image

    What has been changed? :)

    <style name="Theme.MyApp.SlideButton" parent="">
        <item name="android:layout_width">0dp</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="area_margin">0dp</item>
        <item name="border_radius">8dp</item>
        <item name="inner_color">@color/white</item>
        <item name="outer_color">@color/colorSlideButtonOuterColor</item>
        <item name="rotate_icon">false</item>
        <item name="slider_height">48dp</item>
        <item name="slider_icon">@drawable/ic_slide_arrow</item>
        <item name="slider_icon_color">@color/colorSlideButtonIconColor</item>
        <item name="text">Accept</item>
        <item name="text_appearance">@style/Theme.MyApp.TextAppearance.SlideButton</item>
        <item name="text_size">16sp</item>
        <item name="animation_duration">0</item>
    </style>
    
    <style name="Theme.MyApp.TextAppearance.SlideButton" parent="Widget.AppCompat.TextView">
        <item name="android:fontFamily">@font/inter_medium_500</item>
        <item name="android:textSize">16sp</item>
        <item name="android:textColor">@color/colorTextOnLight</item>
    </style>
    
    opened by anonym24 1
  • Possibility to fill slider while dragging

    Possibility to fill slider while dragging

    Is there already a way to have the area from the slider fill in color when I'm already over it? So that I do not only draw a circle from left to right but build up a bar?

    If that doesn't exist yet, I'm happy to provide input for a new feature!

    I tried to visualize my idea with my best photoshop skills!

    elevation_1

    opened by fabitb 1
  • how to set text align to be show center (excluding the slider_icon area)

    how to set text align to be show center (excluding the slider_icon area)

    What kind of issue is this?

    What kind of issue is this?

    The text is centered relative to the track area(including the slider_icon). But it is not visible because it is centrally located(in my view). I want to text be centered in the track area excluding the slider_icon area. It asks if there is no attribute to set this. help.

    Details

    area_margin_3

    opened by sykim-ivy 1
  • Dependency Dashboard

    Dependency Dashboard

    This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

    This repository currently has no open or pending branches.

    Detected dependencies

    github-actions
    .github/workflows/gradle-wrapper-validation.yml
    • actions/checkout v3
    • gradle/wrapper-validation-action v1
    .github/workflows/pre-merge.yml
    • actions/checkout v3
    • actions/setup-java v3
    • gradle/gradle-build-action v2
    • actions/upload-artifact v3
    • actions/upload-artifact v3
    .github/workflows/publish-release.yml
    • actions/checkout v3
    • actions/setup-java v3
    • actions/upload-artifact v3
    .github/workflows/publish-snapshot.yml
    • actions/checkout v3
    • actions/setup-java v3
    • actions/upload-artifact v3
    gradle
    gradle.properties
    settings.gradle.kts
    build.gradle.kts
    • com.android.application 7.3.1
    • com.android.library 7.3.1
    • org.jlleitschuh.gradle.ktlint 11.0.0
    • org.jetbrains.kotlin.android 1.8.0
    example/build.gradle.kts
    • androidx.appcompat:appcompat 1.5.1
    • com.google.android.material:material 1.7.0
    • junit:junit 4.13.2
    • androidx.test.espresso:espresso-core 3.5.0
    • androidx.test:rules 1.5.0
    • androidx.test.ext:junit 1.1.4
    slidetoact/build.gradle.kts
    • androidx.appcompat:appcompat 1.5.1
    gradle-wrapper
    gradle/wrapper/gradle-wrapper.properties
    • gradle 7.6

    • [ ] Check this box to trigger a request for Renovate to run again on this repository
    opened by renovate[bot] 0
  • Add data binding support for

    Add data binding support for "complete_icon" and "slider_icon" attributes

    Description

    complete_icon and slider_icon attributes are @DrawableRes Intvariables. To be set up via Data binding they should also support the Drawable type.

    Related PRs/Issues

    #156

    Todos

    • [x] Tests - no tests
    • [x] Documentation - example added
    • [x] Screenshots - no screenshots
    enhancement 
    opened by nataliialapshyna-dna 0
Releases(v0.10.0)
Owner
Nicola Corti
Maintainer of Detekt, Chucker, AppIntro 🐧 - Host @ thebakery.dev 🎙 - He/Him 🏳️‍🌈 【ツ】
Nicola Corti
Android calendar library provides easy to use widget with events

Kotlin-AgendaCalendarView Kotlin-AgendaCalendarView based on AgendaCalendarView Kotlin-AgendaCalendarView is a awesome calendar widget with a list of

Ognev Zair 88 Nov 21, 2022
RoomJetpackCompose is an app written in Kotlin and shows a simple solution to perform CRUD operations in the Room database using Kotlin Flow in clean architecture.

RoomJetpackCompose is an app written in Kotlin and shows a simple solution to perform CRUD operations in the Room database using Kotlin Flow in clean architecture.

Alex 27 Jan 1, 2023
GBooks - A simple android app written in Kotlin to read books from the Google Book Api

G-Books A simple android app written in Kotlin to read books from the Google Boo

Google Developer Student Clubs - Baba Banda Singh Bahadur Engineering College 10 Nov 7, 2022
Android To-Do MVVM Architecture App written in Kotlin.(ViewModel, ROOM, Livedata, Coroutines)

MVVM-To-Do-App A To-Do application written in kotlin using Android Architectural components What's new? Room + Coroutines - Upgraded Room to v2.1. Roo

Naveen T P 77 Dec 8, 2022
🍼Debug Bottle is an Android runtime debug / develop tools written using kotlin language.

???? 中文 / ???? 日本語 / ???? English ?? Debug Bottle An Android debug / develop tools written using Kotlin language. All the features in Debug bottle are

Yuriel Arlencloyn 846 Nov 14, 2022
Android AsyncTask wrapper library, written in Kotlin

KillerTask This is a Kotlin Android library to create async background tasks. Inspired by TinyTask, but more beautiful and easy to use for Kotlin Andr

Inaka 26 Oct 3, 2022
Advancement Utils for Android Developer written in Kotlin

RichUtils About Version: 2.0.0 :: Dreaming Bird (夢魅鳥, Yumemidori) :: Release Note (Eng) : https://blog.uzuki.live/richutils-2-0-0-dreaming-bird-releas

WindSekirun (wind.seo) 169 Nov 13, 2022
📚 Sample Android Components Architecture on a modular word focused on the scalability, testability and maintainability written in Kotlin, following best practices using Jetpack.

Android Components Architecture in a Modular Word Android Components Architecture in a Modular Word is a sample project that presents modern, 2020 app

Madalin Valceleanu 2.3k Jan 4, 2023
🚀 Sample Android Clean Architecture on JetRorty App focused on the scalability, testability and maintainability written in Kotlin, following best practices using Jetpack with Compose.

Android Clean Architecture in Rorty is a sample project that presents modern, approach to Android application development using Kotlin and latest tech-stack.

Mr.Sanchez 114 Dec 26, 2022
Sample Android Clean Architecture on App focused on written in Kotlin, following best practices using Jetpack with Compose.

Rick And Morty Jetpack Compose Sample App Table of Contents About the Project Architecture Features Environment Setup Contact About The Project This S

Mert Toptas 132 Jan 2, 2023
An extension of EditText with pin style written in Kotlin

pin-edittext An extension of EditText with pin style Usage Include PinCodeEditText in your layout XML <com.oakkub.android.PinEditText android:layo

Metas Kerdwat 15 May 28, 2021
A lightweight cache library written in Kotlin

[NEW] Released to Maven Central: 'com.github.yundom:kache:1.x.x' Kache A runtime in-memory cache. Installation Put this in your build.gradle implemen

Dennis 22 Nov 19, 2022
Mobile client for official Nextcloud News App written as Kotlin Multiplatform Project

Newsout Android and iOS mobile client for Nextcloud news App. The Android client is already available to download in the Play Store. F-Droid and Apple

Simon Schubert 118 Oct 3, 2022
Spigot-Plugin message providing system written in Kotlin

teller Spigot-Plugin message providing system written in Kotlin Usage Create an instance of PropertiesMessageProvider using the Constructor with an in

Luca Zieserl 2 Jan 16, 2022
A furry-themed assembly language and interpreter written in Kotlin.

A furry-themed assembly language and interpreter written in Kotlin. Inspired by Furcode, the Synacor challenge, and JVM bytecode. I spent multiple hou

Maow 9 Nov 22, 2021
A Chip-8 emulator written in Kotlin

A Chip-8 emulator written in Kotlin

Cedric Beust 87 Dec 27, 2022
A fast, lightweight, entity component system library written in Kotlin.

Fleks A fast, lightweight, entity component system library written in Kotlin. Motivation When developing my hobby games using LibGDX, I always used As

Simon 66 Dec 28, 2022
Sample Code for fake Kotlin library written in Java

Jatlin このリポジトリは ブログ記事 のためのサンプルコードです。詳細は記事をご覧ください。 プロジェクト構成 :java-lib にKotlinに偽装したJavaファイルが含まれます。 :kotlin-lib は :java-lib をビルドしたJARファイルをKotlinから読み込んで実行

Takaki Hoshikawa 3 Dec 10, 2021
Slime World Format implementation written in Kotlin with Zstd for bukkit.

Slime Korld Easily create many slime worlds with the Slime Korld. What is Slime Korld? Slime Korld is a bukkit library written in Kotlin to make minec

Luiz Otávio 11 Nov 15, 2022