All Projects → aritraroy → Patternlockview

aritraroy / Patternlockview

Licence: apache-2.0
An easy-to-use, customizable and Material Design ready Pattern Lock view for Android

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Patternlockview

Vuebase
Building Vuebase : a Firebase-like theme : https://vuebase-theme.firebaseapp.com built with Vue and Vuetify (https://vuetifyjs.com)
Stars: ✭ 227 (-91.44%)
Mutual labels:  material-design
Motion Shapeofview
Explain how to use MotionLayout with ShapeOfView
Stars: ✭ 236 (-91.1%)
Mutual labels:  material-design
Material Design Nav Drawer
Sample app showcasing the Navigation Drawer according Material Design guidelines. Check out the article to further explanation.
Stars: ✭ 238 (-91.03%)
Mutual labels:  material-design
Pokemonapp
Pokemon App with animations and beautiful UI
Stars: ✭ 228 (-91.41%)
Mutual labels:  material-design
Vue Material Kit
Vue Material Kit - Open Source Material Design UI Kit
Stars: ✭ 231 (-91.29%)
Mutual labels:  material-design
Alyle Ui
Minimal Design, a set of components for Angular 9+
Stars: ✭ 234 (-91.18%)
Mutual labels:  material-design
Numberslidingpicker
Android Number Picker with gestures
Stars: ✭ 225 (-91.52%)
Mutual labels:  material-design
Materialbanner
A library that provides an implementation of the banner widget from the Material design.
Stars: ✭ 241 (-90.92%)
Mutual labels:  material-design
Wallpaperboard
Android Json based wallpaper dashboard library
Stars: ✭ 235 (-91.14%)
Mutual labels:  material-design
Material Datetime Picker
A material design date-time picker for the web
Stars: ✭ 238 (-91.03%)
Mutual labels:  material-design
Angularmaterialfirebase
🔥 Full stack starter app with Angular 8, Material Design and Firebase (+ demo)
Stars: ✭ 229 (-91.37%)
Mutual labels:  material-design
Nice Spinner
A nice spinner for Android
Stars: ✭ 2,643 (-0.38%)
Mutual labels:  material-design
Materialchipsinput
Implementation of Material Design Chips component for Android
Stars: ✭ 2,605 (-1.81%)
Mutual labels:  material-design
Phonograph
A material designed music player for Android
Stars: ✭ 2,595 (-2.19%)
Mutual labels:  material-design
Expenso Ios
A Simple Expense Tracker App built to demonstrate the use of SwiftUI, CoreData, Charts, Biometrics (Face & Touch ID) and MVVM Architecture.
Stars: ✭ 191 (-92.8%)
Mutual labels:  material-design
Togglebuttonlayout
Easy creation and management of toggle buttons on Android from the Material Design spec.
Stars: ✭ 225 (-91.52%)
Mutual labels:  material-design
Musicplayer
A music player with pretty ui/ux design.
Stars: ✭ 232 (-91.26%)
Mutual labels:  material-design
Pandaeye
一款基于 mvp+rxjava+retrofit+Picasso 的应用,内容来自知乎日报,网易新闻,咪咕视频。实现了新闻列表的磁盘缓存
Stars: ✭ 242 (-90.88%)
Mutual labels:  material-design
Responsive scaffold
Responsive Scaffold - On mobile it shows a list and pushes to details and on tablet it shows the List and the selected item. Maintainer: @rodydavis
Stars: ✭ 238 (-91.03%)
Mutual labels:  material-design
Diagonallayout
With Diagonal Layout explore new styles and approaches on material design
Stars: ✭ 2,591 (-2.34%)
Mutual labels:  material-design

PatternLockView

PatternLockView

An easy-to-use, customizable, Material Design ready Pattern Lock view for Android.

Specs

Download API License Android Arsenal

This library allows you to implement pattern locking mechanism in your app easily and quickly. It is very easy to use and there are plenty of customization options available to change the functionality and look-and-feel of this view to match your needs.

It also supports RxJava 2 view bindings, so if you are a fan of reactive programming (just like me), you can get a stream of updates as the user draws the pattern.

PatternLockView PatternLockView

Download

This library is available in jCenter which is the default Maven repository used in Android Studio.

Gradle

dependencies {
    // other dependencies here
    
    compile 'com.andrognito.patternlockview:patternlockview:1.0.0'
    // Optional, for RxJava2 adapter
    compile 'com.andrognito.patternlockview:patternlockview-reactive:1.0.0'
}

Spread Some ❤️

GitHub stars GitHub followers
Twitter Follow

Usage

We recommend you to check the sample project to get a complete understanding of the library. The step-by-step implementation guide is as follows.

Step 1

Place the view in your XML layout file.

    <com.andrognito.patternlockview.PatternLockView
        android:id="@+id/pattern_lock_view"
        android:layout_width="280dp"
        android:layout_height="280dp"/>

This is enough to get the view rendered in your layout. But you would certainly want to add a callback listener to listen to pattern changes.

Step 2

Reference the view in code and add a listener to it.

mPatternLockView = (PatternLockView) findViewById(R.id.pattern_lock_view);
mPatternLockView.addPatternLockListener(mPatternLockViewListener);

Implement the listener interface as follows,

private PatternLockViewListener mPatternLockViewListener = new PatternLockViewListener() {
        @Override
        public void onStarted() {
            Log.d(getClass().getName(), "Pattern drawing started");
        }

        @Override
        public void onProgress(List<PatternLockView.Dot> progressPattern) {
            Log.d(getClass().getName(), "Pattern progress: " +
                    PatternLockUtils.patternToString(mPatternLockView, progressPattern));
        }

        @Override
        public void onComplete(List<PatternLockView.Dot> pattern) {
            Log.d(getClass().getName(), "Pattern complete: " +
                    PatternLockUtils.patternToString(mPatternLockView, pattern));
        }

        @Override
        public void onCleared() {
            Log.d(getClass().getName(), "Pattern has been cleared");
        }
    };

And that's it! Your PatternLockView is ready to rock. You might also want to remove the listeners when not needed, removePatternLockListener(mPatternLockViewListener);

Step 3 (Optional: ReactiveX Interface)

For the RxJava fanboys, this library supports RxJava 2 view bindings. You can subscribe to this view to get a stream of pattern change updates.

RxPatternLockView.patternChanges(mPatternLockView)
                .subscribe(new Consumer<PatternLockCompoundEvent>() {
                    @Override
                    public void accept(PatternLockCompoundEvent event) throws Exception {
                        if (event.getEventType() == PatternLockCompoundEvent.EventType.PATTERN_STARTED) {
                            Log.d(getClass().getName(), "Pattern drawing started");
                        } else if (event.getEventType() == PatternLockCompoundEvent.EventType.PATTERN_PROGRESS) {
                            Log.d(getClass().getName(), "Pattern progress: " +
                                    PatternLockUtils.patternToString(mPatternLockView, event.getPattern()));
                        } else if (event.getEventType() == PatternLockCompoundEvent.EventType.PATTERN_COMPLETE) {
                            Log.d(getClass().getName(), "Pattern complete: " +
                                    PatternLockUtils.patternToString(mPatternLockView, event.getPattern()));
                        } else if (event.getEventType() == PatternLockCompoundEvent.EventType.PATTERN_CLEARED) {
                            Log.d(getClass().getName(), "Pattern has been cleared");
                        }
                    }
                });

If you are not interested in getting the compound event, you should subscribe to patternComplete() and/or patternProgress() for the specific updates. Have a detailed look here.

Customization

There are several customization options available which you can use to completely change the look-and-feel and functionality of this view to match your needs.

XML (Quick and Easy)

You can add various attributes to the PatternLockView from your XML layout.

  app:dotCount="3"                                        // Change the no.of dots in a row (or column)
  app:dotNormalSize="12dp"                                // Change the size of the dots in normal state
  app:dotSelectedSize="24dp"                              // Change the size of the dots in selected state
  app:pathWidth="4dp"                                     // Change the width of the path
  app:aspectRatioEnabled="true"                           // Set if the view should respect custom aspect ratio
  app:aspectRatio="square"                                // Set between "square", "width_bias", "height_bias"
  app:normalStateColor="@color/white"                     // Set the color of the pattern view in normal state
  app:correctStateColor="@color/primary"                  // Set the color of the pattern view in correct state
  app:wrongStateColor="@color/pomegranate"                // Set the color of the pattern view in error state     
  app:dotAnimationDuration="200"                          // Change the duration of the animating dots
  app:pathEndAnimationDuration="100"                      // Change the duration of the path end animaiton

JAVA (Programatically)

You can also programatically change the properties of the view, thereby having more control over it.

mPatternLockView.setViewMode(PatternLockView.PatternViewMode.CORRECT);       // Set the current viee more 
mPatternLockView.setInStealthMode(true);                                     // Set the pattern in stealth mode (pattern drawing is hidden)
mPatternLockView.setTactileFeedbackEnabled(true);                            // Enables vibration feedback when the pattern is drawn
mPatternLockView.setInputEnabled(false);                                     // Disables any input from the pattern lock view completely

mPatternLockView.setDotCount(3);
mPatternLockView.setDotNormalSize((int) ResourceUtils.getDimensionInPx(this, R.dimen.pattern_lock_dot_size));
mPatternLockView.setDotSelectedSize((int) ResourceUtils.getDimensionInPx(this, R.dimen.pattern_lock_dot_selected_size));
mPatternLockView.setPathWidth((int) ResourceUtils.getDimensionInPx(this, R.dimen.pattern_lock_path_width));
mPatternLockView.setAspectRatioEnabled(true);
mPatternLockView.setAspectRatio(PatternLockView.AspectRatio.ASPECT_RATIO_HEIGHT_BIAS); 
mPatternLockView.setNormalStateColor(ResourceUtils.getColor(this, R.color.white));
mPatternLockView.setCorrectStateColor(ResourceUtils.getColor(this, R.color.primary));
mPatternLockView.setWrongStateColor(ResourceUtils.getColor(this, R.color.pomegranate));
mPatternLockView.setDotAnimationDuration(150);
mPatternLockView.setPathEndAnimationDuration(100);

Contribution

This library is inspired from AOSP's LockPatternView. There are lots of improvements and customization options added so that you can get started without any hassle. If you find a bug or would like to improve any aspect of it, feel free to contribute with pull requests.

About The Author

Aritra Roy

Android & Backend Developer. Blogger. Designer. Fitness Enthusiast.

License

Copyright 2017 aritraroy

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].