dimanche 20 novembre 2016

Create a Context Aware Fingerprint Reader in Tasker

Fingerprint readers are fairly limited in their default state. Besides the obvious ability to unlock the phone or authorize some payments, there isn't much else you can do with the fingerprint reader on most Android phones. The feature always felt like a missed opportunity – until now!


Tasker-based, Context Aware Fingerprint Reader

Creating a customized fingerprint reader within Tasker is a fairly simple project. Tasker will  assign  multiple functionalities to the fingerprint reader depending on what you are doing or where you're located. In this example, I will show you how to instantly cast the current website to the big screen (in this case, my PC).  This way you will be able to add additional functions to the reader depending on windows opened or your location. Your imagination is your only limit.

How it works

Bear in mind that the Fingerprint Scanner Tools app is new and under active development. The Tasker support is currently limited to only executing tasks, however, that's all we're going to need. We are going to use variables within Tasker to assign more than one profile to the fingerprint scanner. When the fingerprint  is activated, Tasker will check what else you have been doing (or where you are) and will execute the correct profile accordingly.

Fingerprint scan

screenshot_20161120-173936 screenshot_20161120-173946

We need to get the reader to act as a universal trigger for our conditions. We will need to create a task, Scanned Finger, that will trigger other profiles for us. We can link this to a variable %FingerScanned. When the Fingerprint Scanner Tools app recognizes a fingerprint, it will launch our Scanned Finger task to temporarily set the value of %FingerScanned from 0 to 1 for 2 seconds. 2 seconds should be sufficient time for our other Tasker profiles to react to the variable change and respond to it. If you have any issues with Tasker responding to the variable change, try increasing the wait action to 3 seconds or longer. Open the Fingerprint scanner tools and assign this task. Next, we will create different profiles that are launched depending on the current context – whether or not a certain app is opened, what your current location is, etc.

Cast the current Chrome window

screenshot_20161120-173955 screenshot_20161120-175131

In this example, we will demonstrate how to cast the currently opened tab in Chrome. This profile will be triggered when the value is %FingerScanned is set to 1 (as per the task created previously) AND Tasker detects that the currently opened app is the Chrome browser. This requires you to enable the Accessibility service for Tasker, otherwise Tasker will not be able to detect when Chrome is opened. Furthermore, we will make use of AutoInput as well as Join by XDA Junior Member joaomgcd due to the extensive integration with Tasker.

First up, you'll need to create a profile with two contexts: first, a State context that is activated when %FingerScanned = 1; second, an App context that is activated when Chrome is opened. Next, you'll need to replicate the task as shown in the screenshot above, or as reproduced below. Once you're done, this task as set up will query the currently opened URL in Chrome and push it to your PC using Join. You can prompt a device selection if you wish, but for super fast sharing, I designated a single device for doing so.

I'm using the AutoInput UI Query to get the value of the URL in the browser. In most cases, the web address will start with www/http(s) or a combination thereof. To capture the URL we will need the following regex:

  ((?<=http:\/\/|https:\/\/|https:\/\/www.|http:\/\/www.|www.))?.*  

If you have any issues configuring the Query – use Variable Setup to return to Chrome and select the address bar. AutoInput will then help set up the URL capture automatically. I have set up a custom variable %address which will contain the URL address from the currently opened Chrome tab.

screenshot_20161120-175136 screenshot_20161120-175141

Before we can push the page to the computer, we need to check that the URL is formatted properly. Pushing a URL starting with www will not open the website automatically in your desktop browser. The easiest way to ensure we are sending a correctly formatted URL is to run a search/replace action. The default value for the %prefix variable will be "http://". We need this if a website does not support the https protocol. We will be looking for either http or https in the URL, and if %prefix is found it is set in the Join URL push. Look for https:// and select replace. Do not enter anything in the replace with field as we just want this to be removed from our address do the same for the http://. The last action is the Join Push.  Go to the URL and enter %prefix%address . This way the URL will be pushed correctly to  the PC and will open the website automatically.

If you're worried about security, many websites will automatically redirect you to their secure version if it exists, but if not you can use the HTTPS Everywhere extension to handle that for you.


Conclusion

As you can see, by assigning Fingerprint Scanner Tool's Tasker action to changing variables, we can assign multiple actions despite the limitations of a single Tasker task. I have reached out to the developer of Fingerprint Scanner Tools, Daniel Huber, and he states that more Tasker functionality is planned for the future. Now that you know how to use the fingerprint reader without bonding it to a single task, you can customize what contexts and what actions should be launched when a fingerprint is recognized.

Perhaps you can cast a YouTube  video with a single tap (no Chromecast needed). I might show this off in my next tutorial? If you want to see this, and other Tasker scripts, let us know your thoughts below!


Download/Import

As always, we will be providing ways to either download or manually import the work that we show off in these Tasker tutorials. You will have two options to add these scripts to your Tasker set-up.

First, you can download the entire Project by following the download link below. After downloading the Project XML file, you can import it by opening up Tasker then long-pressing on the Home icon at the bottom left. This will bring up the Tasker Project menu, which will allow you to import Projects located on the internal storage.

Download the Context Aware Fingerprint Reader Project

Alternatively, you can use the descriptions of the Profile/Task as contained in the two tabs below to guide you through the process of recreating this script on your own. We recommend this route if you want to learn how to get better at Tasker, so that you can make customizations or improvements to the script on your own.

  Profile: Cast Chrome          Application: Chrome          State: Variable Value [ %FingerScanned eq 1 ]  Enter: Chrome          A1: AutoInput UI Query [ Configuration:Only Visible: true  Only Clickable: false  App Package: com.android.chrome  Check Screen State: false  Text: ((?<=http:\/\/|https:\/\/|https:\/\/www.|http:\/\/www.|www.))?.*  Regex: true  Variables: address Timeout (Seconds):20 ]           A2: Variable Set [ Name:%prefix To:http:// Do Maths:Off Append:Off ]           A3: Variable Search Replace [ Variable:%address Search:https:// Ignore Case:On Multi-Line:Off One Match Only:On Store Matches In:%prefix Replace Matches:On Replace With: ]           A4: Variable Search Replace [ Variable:%address Search:http:// Ignore Case:On Multi-Line:Off One Match Only:On Store Matches In:%prefix Replace Matches:On Replace With: ]           A5: Join Send Push [ Configuration:Device: Chrome@Home              Url: %prefix%address Timeout (Seconds):60 ]  

  Scanned Finger
A1: Variable Set [ Name:%FingerScanned To:1 Do Maths:Off Append:Off ]
A2: Wait [ MS:0 Seconds:2 Minutes:0 Hours:0 Days:0 ]
A3: Variable Set [ Name:%FingerScanned To:0 Do Maths:Off Append:Off ]

Requirements:
Android version: 6.0+
Apps: Join (or AutoRemote), Fingerprint scanner tools (Tasker support needs to be unlocked)
Plugin: AutoInput
Hardware: Fingerprint Reader



from xda-developers http://ift.tt/2fhRMCe
via IFTTT

Aucun commentaire:

Enregistrer un commentaire