Introduction: Login Device With Android Draw Pattern and a Leonardo Board, No More Passwords, No More Logins.

About: Welcome, tech enthusiasts and curious minds! I'm a seasoned programmer with years of experience in Java and various technologies. Join me as we unlock the secrets of automation with Arduino and other boards. P…

Welcome again to this new Amburo tutorial. This is a new chapter of the noLoginSeries. On this occasion, we will be discussing a new way of sending a UDP signal to unlock our computer through an Android device. Of course, with the help of our NODEJS server implemented here. So we will be working on the code in our Android studio.

So let's get into it:

Supplies

For this project, you will need a computer(in which you want to log in), a phone (that will be your authenticator device, which could be a tablet as well), Install Android Studio, and of course, check the tutorials related will be a definitive plus.

Step 1: Diagram

Here you have the diagram showing how the different components interact.

Step 2: Check Out the Code

You can download the code from here: UnlockWithPattern

You will be able to play around with it by changing things to fit your needs.

Step 3: Main Activity Class

As you can see we have our main Activity class extending Activity that will bring us the inherit oncreate method to let us set the basic configurations. Among the basic configurations, we will set the pattern lock view and its listener. Bear in mind that you will have to implement the PatternLockView library and of course, have ready the main activity layout with pattern view configuration. You will find all the details in the repository.

Going back to our listener, we will set the base behavior related to an incorrect pattern draw. And a correct one. The first one will print the message "Wrong password". The latter one will execute the SendBroadcast method.

Also is worth mentioning that the pattern drawn translates to a number. In our example, the pattern translates to "630487". So if you want to change the pattern, I suggest you modify slightly the code so that the toast prints the entered number:

public void onComplete(List<PatternLockView.Dot> pattern) {
if (password.equals(PatternLockUtils.patternToString(mPatternLockView, pattern))) {
Toast.makeText(MainActivity.this, "The number is " + pattern, Toast.LENGTH_SHORT).show();

Take note of the printed new number and write it down to the original code as a new password.

Step 4: Send Broadcast Method

Now, this method has all the necessary instructions to prepare and send the incoming string parameter as a broadcast message. That means that will send the message to the network. This method has an auxiliary method that returns the network address of our local network dynamically. This will let us execute this program in all networks we are connected with; without having to put/modify the actual address. And will let us use this app on different networks. Once the method sendBroadcast gets the local network it will send the packet built by the actual message, the length, the address, and the port, which by now will be fixed to this number, which of course you can change. Once the packet is sent successfully, another message will be constructed and returned as a method return.

Step 5: One More Thing

Once the broadcast signal is sent. The NODEJS server will be in charge of interacting with the Leonardo board. And finally, send the password to our machine to let us in. We will set to sleep the app for 4 seconds to show "Password ok" and finally call the inherit finish method to close the activity hence the app.

Step 6: What Is Next

We will keep on working on other ways to unlock to entertain more ideas for this No More Login Series. Please consider this as another idea starter for you. Think in what way this could be helpful for your day-to-day chores. Like for example to control some tasks in some applications. I will be delivering some ideas in future chapters. Take a look at other works of mine as well. See you in the next one.