We've been having a lot of fun at XDA with the new navigation bar customizer this week. From custom keys to control music playback, toggle picture-in-picture mode while using YouTube, and finally add keys to move through your e-mail conversation list, there's a ton of ways you can take advantage of the nav bar customizer to enhance your favorite apps. Most recently, we also showed you how to add custom icons to your nav bar keys so you can more easily identify what your custom keys actually represent in your Tasker Profiles. And now, we'll show you an example that takes advantage of that to add page scroll keys to the navigation bar while using Google Chrome.
Thanks to Eli Irvin for testing out my script and capturing this screen recording.
As you can see in the video above, when my tester opened up Google Chrome, two new keys were added to the navigation bar that when pressed, scroll the page up or down. The keycodes that are sent are KEYCODE_PAGE_DOWN (#93) and KEYCODE_PAGE_UP (#92). The icons that pop up are fairly self-explanatory as to which one represents scrolling downwards versus upwards, thanks to the fact that I used custom icons from the Icons Database.
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.
Adding Nav Bar Scroll Keys while using Google Chrome
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 both of them up.
In order for Tasker to detect what application we're in, we need to grant its Accessibility Service. Doing so is very quick, simply go to Settings –> Accessibility and look for "Tasker" on the list of Services. Enable the Accessibility Service.
Next, 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 Profile
Before we begin with Tasker, you'll need to download a down arrow and an up arrow icon to use as custom icons for the scroll keys. Download the custom icons that are the appropriate size for your device's screen density and store them in /NavIcons. Name these icons down.png and up.png. Now we're ready to make our Tasker Profile.
Open up Tasker and create a new Profile by pressing the + button in the bottom right. Select the Application Context and then in the App Selection screen select all the apps you want to have the scroll keys show up in (such as Chrome).
Next, Tasker will ask you to either select an existing Task or create a new one. Create a new Task but don't bother giving it a name. Once you're in the Task creation screen, we'll need to add two Actions to it:
- A1: Plugin –> SecureTask –> Secure Settings. Action: Write. Setting:
secure sysui_nav_bar_left
. Value:key(93:file:///storage/emulated/0/NavIcons/down.png)
- A2: Plugin –> SecureTask –> Secure Settings. Action: Write. Setting:
secure sysui_nav_bar_right
. Value:key(92:file:///storage/emulated/0/NavIcons/up.png)
These two Actions will add two nav bar keys that correspond to KEYCODE_PAGE_DOWN and KEYCODE_PAGE_UP with a down arrow and up arrow icon that you downloaded off the Internet. These keys will only show up when you're in the app that you've chosen, in my case Chrome, so we'll need to disable them when we exit Chrome by adding an Exit Task.
You can add an Exit Task by long-pressing on the Task that you just made (while on the main screen of Tasker) and pressing "add exit task" on the pop-up. Once you've in, add the following two Actions:
- A1: Plugin –> SecureTask –> Secure Settings. Action: Write. Setting:
secure sysui_nav_bar_left
. Value:null
- A2: Plugin –> SecureTask –> Secure Settings. Action: Write. Setting:
secure sysui_nav_bar_right
. Value:null
And with the addition of this Exit Task, Tasker will now automatically remove these scroll keys when you exit the Chrome app. That way, you'll only have these scroll keys show up when they're useful.
Download and Import
As with all Tasker related tutorials, we will be providing the XML file 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 file you just saved, then select it to import it. Make sure you have Tasker's Accessibility Service enabled and have granted the WRITE_SECURE_SETTINGS to SecureTask as mentioned in my article, otherwise this Profile will not do anything on your phone!
Download the "Toggle Scroll Keys in Chrome" Profile from AndroidFileHostIf you're wondering what other useful keys we can add to the navigation bar to make browsing Chrome a more enjoyable experience, we'll show you an alternative setup in a future tutorial. Stay tuned to the portal for more tutorials!
from xda-developers http://ift.tt/2nFdrH8
via IFTTT
Aucun commentaire:
Enregistrer un commentaire