If you’ve been following our tutorials feed, then you’ll know by now that we love finding ways to take advantage of Android O’s new nav bar customizer. Through the power of the popular automation app known as Tasker, we can contextually change the nav bar to include nav keys that are useful in specific contexts. In this tutorial, we will demonstrate how to add a contacts shortcut and an end call shortcut to the nav bar while you are in the middle of a phone call.
Thanks to Eli Irvin for being my guinea pig and getting this screen capture.
In the video above, my tester initiated a phone call with me which caused Tasker to display two new icons in the navigation bar. The contacts shortcut, when pressed, calls KEYCODE_CONTACTS while the end call button calls KEYCODE_ENDCALL.
The icons that I’m using are not icons normally accessible in Android O’s navigation bar customizer, but are instead custom icons that I am using. You can read my previous tutorial on how to add custom icons to Android O’s nav bar here. For the sake of this tutorial, you’ll need to download two icons from Icons Database based on your device’s DPI. The first is a contacts icon which you should save as /NavIcons/contacts.png and the second is an end call icon which needs to be saved as /NavIcons/endcall.png.
We’ll show you how to replicate this setup on your own device so you can learn how to make your own custom nav bar configurations, but we’ll also provide a download link at the end of the article if you would rather skip to that.
Custom Nav Bar Keys while in a Phone Call
Tasker is necessary because it is the automation app we’re using to detect what application we’re in and send commands through the SecureTask plug-in, which is what will handle changing our navigation bar. Once you’ve installed both applications, we need to set up SecureTask.
We need to grant SecureTask the ability to modify system settings on our device. In order to do so, we have to grant SecureTask a special permission known as WRITE_SECURE_SETTINGS which is normally inaccessible to regular applications, but can be granted manually by a user through the use of ADB. Thus, you’ll need to have ADB up and running on your machine to get this working. Fortunately, granting this permission is only a one-time thing, and we’ll be using SecureTask in future Android O-related tutorials (of which there are a couple more), so it’s definitely worth doing it.
Setting up ADB
The first thing you’ll need to do is download the ADB binary for your particular OS. You can do so here. Once you’ve downloaded them, you need to then make sure you have the proper driver if you’re on Windows.
Once you’ve extracted the binary to a separate folder and have installed the driver, we need to next enable USB Debugging on the smartphone. In order to do so, open up Settings and go to About Phone. Tap on Build Number 7 times until you get a dialog telling you that you’ve unlocked Developer Options. You can access Developer Options in Settings now. Apparently in Android O, you have to enter your pin/password before you can open Developer Options. Do so and look for USB Debugging, then enable it.
Now plug in your phone and open up a command prompt in the same directory where you extracted the ADB binary. (Windows users, hold shift+right-click in that folder and select “open command prompt here.”) Type adb devices
into the command prompt. You’ll see a message that the ADB server is being started, then on your phone you’ll see a prompt asking you to grant your computer ADB access. Accept it. Now when you enter adb devices
into the command prompt, you should see your device’s serial number, if so then you were successful.
Granting WRITE_SECURE_SETTINGS to SecureTask
With an ADB command prompt opened up, enter the following command to grant SecureTask the requisite permission.
adb shell pm grant com.balda.securetask android.permission.WRITE_SECURE_SETTINGS
SecureTask will now have the ability to modify system settings without root access! Now we’re ready to move on to Tasker.
Setting up the Tasker Profiles
We will need to set up two different Tasker Profiles. One will trigger when you enter a phone call, the other will trigger when you hang up. The former will show the two nav bar keys, the latter will disable them. Pretty straightforward.
For the first Profile, open up Tasker and press the + button in the bottom right to create it. Choose the Event Context and go to Phone –> Phone Offhook. Press back to return to Tasker’s main screen. Name it “Enable Phone Nav Bar Keys.”
Tasker will ask you to either attach an existing Task or create a new one. Create a new one, and once you’re in the Task editing screen, add the following Actions:
- Plugin –> SecureTask –> Secure Settings. Action: Write. Setting:
secure sysui_nav_bar_left
. Value:key(207:file:///storage/emulated/0/NavIcons/contacts.png)
- Plugin –> SecureTask –> Secure Settings. Action: Write. Setting:
secure sysui_nav_bar_right
. Value:key(6:file:///storage/emulated/0/NavIcons/endcall.png)
Exit back to Tasker’s main menu. Create a new Profile and again select the Event context, but this time choose Phone –> Phone Idle. Name it “Disable Phone Nav Bar Keys.”
Again create a new Task, and when you’re in the Task editing screen, add the following two Actions to it:
- Plugin –> SecureTask –> Secure Settings. Action: Write. Setting:
secure sysui_nav_bar_left
. Value:null
- Plugin –> SecureTask –> Secure Settings. Action: Write. Setting:
secure sysui_nav_bar_right
. Value:null
Now you’re done. When you accept an incoming call, or connect an outgoing call, Tasker will show a contacts shortcut key as well as an end call key. These keys can be accessed while you’re using any app, so long as the phone call is still ongoing. Once the phone call ends, Tasker will disable these nav bar keys.
Download and Import
As with all Tasker related tutorials, we will be providing the XML files you can download and import. Download the .prf.xml file from AndroidFileHost below and save it to your internal storage. Open up Tasker and long-press on the Profiles tab up top until you see an Import button. Tap on that and look for the XML files you just saved, then select them to import them, one at a time. Make sure you have granted the WRITE_SECURE_SETTINGS to SecureTask as mentioned in my article, otherwise the Profiles will not do anything on your phone!
Download the “Enable Phone Nav Bar Keys” Profile from AndroidFileHost Download the “Disable Phone Nav Bar Keys” Profile from AndroidFileHostWhile we don’t have any more Android O navigation bar related tutorials to share, we do have one more tutorial related to Android O pending. Stay tuned to the portal for more tutorials!
from xda-developers http://ift.tt/2obixLk
via IFTTT
Aucun commentaire:
Enregistrer un commentaire