Switch Fragments or new Activities? - Android Studio

Hi guys,
I am new to android app development and have started creating my first simple app in Android Studio. So far everything is working, I have a drawer menu, the user can switch between screens, back button in the activity bar etc.
As I learned the basics with tutorials on the internet I could not find an answer to one question.
Some tutorials suggest/show that you should switch the Fragments when navigating to another screens when selecting an item from the drawer. So I create Fragments and when someone clicks on a button I change the fragment.
However there are also Activities, and I can make the same thing work by creating new Activities for each screen the user should see.
I cannot really see a clear benefit from one method compared to the other. Switching Fragments may be less work but may also get more messy.
What is in general the best practice here? Create Fragments for each menu item and switch the Fragments or create a new Activity for each menu item?
thanks
Arret

Arret said:
Hi guys,
I am new to android app development and have started creating my first simple app in Android Studio. So far everything is working, I have a drawer menu, the user can switch between screens, back button in the activity bar etc.
As I learned the basics with tutorials on the internet I could not find an answer to one question.
Some tutorials suggest/show that you should switch the Fragments when navigating to another screens when selecting an item from the drawer. So I create Fragments and when someone clicks on a button I change the fragment.
However there are also Activities, and I can make the same thing work by creating new Activities for each screen the user should see.
I cannot really see a clear benefit from one method compared to the other. Switching Fragments may be less work but may also get more messy.
What is in general the best practice here? Create Fragments for each menu item and switch the Fragments or create a new Activity for each menu item?
thanks
Arret
Click to expand...
Click to collapse
When using a navigation drawer fragments is the best technique.
All your fragments are housed inside one activity which will allow navigation through drawer. If you start new activity on item select, you will lose the navigation drawer(because new activity will not have the navigation drawer). Even if you add a navigation drawer in all activities you create, the flow itself will be a mess.
Also using many activities can make app look heavy. Fragments on the other hand are very light and provide good layout options(search coordinator layout).

Fragments vs Activity
It depends on the app that your working on.
With activity, it is very hard to achieve re-usability of components. Where as fragments can be used to create reusable modules.
If you see in modules in your activity, then go for one activity and fragment each module.
It may not be strictly one activity per app.

Related

[Q] Creating an Index/navigation page for an app

Hi, I'm new to Android Studios and have to develop a main menu for an application I have been set for school work. The main menu is very simple and only has to include one Picture (Company logo), a Title (Company name) and 4 Buttons that can be later used to navigate. I would appreciate it if anyone could point me in the direction of any tutorials for the process of creating such a page or provide me with some tips.
Thanks
There are many navigation methods that you can use for example navigation drawer, action bar buttons, tabs, etc.
Take a look at the following tutorial:
http://www.vogella.com/tutorials/AndroidActionBar/article.html

ReLaunch 1.4 (repost)

Can someone kindly repost the APK of ReLaunch 1.4?
The links on the original post are dead now.
Thanks!
marcoNST said:
Can someone kindly repost the APK of ReLaunch 1.4?
The links on the original post are dead now.
Thanks!
Click to expand...
Click to collapse
There seem to be at least 3 ReLaunch forks. The original ends at 1.3.8 (the easiest one to find--Google is your friend). There is then the sequence you are asking about, moving from 1.4 to now 1.4.8. I've attached 1.4.8 below. Don't know anything about it. The source is the Russian The-eBook.org forum and the original ReLaunch thread. Going back from the end of the thread, all earlier versions (all dropbox links) seem to not be available, just like 1.4.
Then there is ReLaunchX which supposedly takes up where the original 1.3.8 left off and renumbers the newer versions starting again with 1.0 (now at 2.x). The GitHub for ReLaunchX is here: https://github.com/Leszek111/ReLaunchX and the app is available on F-Droid: https://f-droid.org/en/packages/com.gacode.relaunchx/
You have many choices!
Edit: one more choice. Member @digixmax offers 1.4.3 here: https://forum.xda-developers.com/showpost.php?p=72246935&postcount=42
Thank you so much @nmyshkin !
You are a star
nmyshkin said:
There seem to be at least 3 ReLaunch forks. The original ends at 1.3.8 (the easiest one to find--Google is your friend). There is then the sequence you are asking about, moving from 1.4 to now 1.4.8. I've attached 1.4.8 below. Don't know anything about it. The source is the Russian The-eBook.org forum and the original ReLaunch thread. Going back from the end of the thread, all earlier versions (all dropbox links) seem to not be available, just like 1.4.
Then there is ReLaunchX which supposedly takes up where the original 1.3.8 left off and renumbers the newer versions starting again with 1.0 (now at 2.x). The GitHub for ReLaunchX is here: https://github.com/Leszek111/ReLaunchX and the app is available on F-Droid: https://f-droid.org/en/packages/com.gacode.relaunchx/
You have many choices!
Edit: one more choice. Member @digixmax offers 1.4.3 here: https://forum.xda-developers.com/showpost.php?p=72246935&postcount=42
Click to expand...
Click to collapse
marcoNST said:
Thank you so much @nmyshkin !
You are a star
Click to expand...
Click to collapse
I just rooted using NM and I am using the default system. ReLaunch seems to have a very barebones interface, and I wish I could do certain things (the two main ones is to toggle visibility of the statusbar at will (making any application full screen) using some button or button combination, and the other is to change orientation.
What benefits are there to using a new version?
Thanks!
Winston S. said:
I just rooted using NM and I am using the default system. ReLaunch seems to have a very barebones interface, and I wish I could do certain things (the two main ones is to toggle visibility of the statusbar at will (making any application full screen) using some button or button combination, and the other is to change orientation.
Thanks!
Click to expand...
Click to collapse
I don't think you can exercise much control over the visibility of the status bar--at least not in Android 2.1. App developers either choose full-screen as the default display mode or give a programmed option which regulates the size of the window in which the app is viewed (essentially covering the status bar). I'd like to be wrong about that and I'll keep looking around a little, but I am not hopeful.
Screen orientation is easily regulated with an app. Probably the best one for the NST is Rotation Locker (there's a copy attached to this post: https://forum.xda-developers.com/nook-touch/themes-apps/app-reading-button-menu-t3815212).
You could theoretically assign a hardware button to the app. All it does is bring up a small menu (Portrait, Landscape, Auto). A simple tap on your choice makes the change, but a long-press sets up a background service that forces the change, even when apps want to resist. You'll see a notification that the service is running. You really need this for the NST because it does not much care for being in landscape mode and many apps will try to escape back into portrait with only a single tap on landscape.
Unfortunately the app suffers from a problem common to many in that it was not designed with e-ink devices in mind. Colors were used in the menu system and they are such that you don't see anything but the menu boxes! I've given you the correct order above, from top to bottom in the menu. A better and more general solution is to slightly darken the background color on all NST menus. This makes most of the offending "invisible" menu choices at least somewhat visible. The change is effected by replacing about 30 images in framework-res.apk. Two sets of images were prepared by someone on the Russian e-book forum. One is lighter and the other darker, but both are darker than the originals. I use the lighter ones.
Alternatively, if you don't expect to be running a lot of apps with potentially unreadable settings or menus but you would like a simple orientation toggle to assign to a hardware button, I could probably just extract that portion from my Reading Now menu app and assemble it as a stand-alone. It still relies on the Rotation Locker app, but you'd never see or interact with the menu, just press a hardware button.
nmyshkin said:
I don't think you can exercise much control over the visibility of the status bar--at least not in Android 2.1. App developers either choose full-screen as the default display mode or give a programmed option which regulates the size of the window in which the app is viewed (essentially covering the status bar). I'd like to be wrong about that and I'll keep looking around a little, but I am not hopeful.
Screen orientation is easily regulated with an app. Probably the best one for the NST is Rotation Locker (there's a copy attached to this post: https://forum.xda-developers.com/nook-touch/themes-apps/app-reading-button-menu-t3815212).
You could theoretically assign a hardware button to the app. All it does is bring up a small menu (Portrait, Landscape, Auto). A simple tap on your choice makes the change, but a long-press sets up a background service that forces the change, even when apps want to resist. You'll see a notification that the service is running. You really need this for the NST because it does not much care for being in landscape mode and many apps will try to escape back into portrait with only a single tap on landscape.
Unfortunately the app suffers from a problem common to many in that it was not designed with e-ink devices in mind. Colors were used in the menu system and they are such that you don't see anything but the menu boxes! I've given you the correct order above, from top to bottom in the menu. A better and more general solution is to slightly darken the background color on all NST menus. This makes most of the offending "invisible" menu choices at least somewhat visible. The change is effected by replacing about 30 images in framework-res.apk. Two sets of images were prepared by someone on the Russian e-book forum. One is lighter and the other darker, but both are darker than the originals. I use the lighter ones.
Alternatively, if you don't expect to be running a lot of apps with potentially unreadable settings or menus but you would like a simple orientation toggle to assign to a hardware button, I could probably just extract that portion from my Reading Now menu app and assemble it as a stand-alone. It still relies on the Rotation Locker app, but you'd never see or interact with the menu, just press a hardware button.
Click to expand...
Click to collapse
You are correct about the status bar visibility, I think there is nothing you can do about it if any specific app forces that setting. There is a configuration setting for ReLaunch to not show the status bar, but even then PocketBook Reader will display it.
For the orientation right now I am resorting to starting APV PDF Viewer (which I have set to landscape,) and then starting PocketBook Reader. Because PocketBook doesn't force a specific setting, it will continue on Landscape until I go out and something else changes orientation to Portrait. Rotation Locker seems like the perfect solution to somewhat streamline orientation selection a bit more. Also, I think I'll manage by knowing which selection to press and not care about the lack of visibility of its menu.
Thank you for your kind offer to assemble that menu app with the toggle built in, but I'd hate you to spend time doing that. Instead, I'll investigate more and go through all the posts you have already provided! :good:

Resize "Popup task buttons" layout

I created a task which show the "Popup task buttons", but unfortunately the default window which popups is really too small. I tried to manually resize the layout but the result was a true mess: the buttons size and position behave erratically between the Scene editor and the real window which popup. Any idea?
Hard to tell what is happening without seeing how you are trying to resize. I have attached a modified pop-up task button scene. You could import this into your tasker and see if it is closer to what you want.
To import the modified scene, put it in a scenes subdirectory within the Tasker folder on your device, which is usually:
Code:
/sdcard/tasker/scenes/
The scene name can be changed I've imported. These days, I tend to add my user name to prevent import issues due to name space collisions.
I've made only small a change so I can try to get an idea as to what you want. Showing a picture of what the stock scene is doing that you want to fix might help.
Thanks for your reply. What I'd like to get is something like this:
https://ibb.co/WkSSs3K
but if I create this in Scene Editor, what I get in the real task is this
https://ibb.co/ncgNZbP
Obviously I am missing something here but what?
When you tried to resize the buttons, did you use the resize touch mode (hand icon -> resize) or did you try to drag in either the default normal touch mode (hand icon -> normal) or edit touch mode (hand icon -> edit)? It's easier to control using the resize and move touch modes. But, in order to enter the element editor, it helps to be in normal touch mode.
There is a magnifying glass at the lower right. Tapping that will toggle between the editor (default - magnifying glass will display a minus sign) and display (default - magnifying glass will display a plus sign). When in the editor, the scene is often zoomed in which can change how the scene appears.
If it helps, I've attached a scene modified similar to your first picture.
I really don't know what is going on here, but something odd is happening.
I create a simple task using your layout (which is exactly what I'd like to get), but when I actually run the preview of the task i see this instead.
https://ibb.co/n00VqhH
This behaviour is the same with almost every layout I create: I see an image in the scene editor and a totally different one when I run the task.
Any ideas?
daniele62 said:
I really don't know what is going on here, but something odd is happening.
I create a simple task using your layout (which is exactly what I'd like to get), but when I actually run the preview of the task i see this instead.
https://ibb.co/n00VqhH
This behaviour is the same with almost every layout I create: I see an image in the scene editor and a totally different one when I run the task.
Any ideas?
Click to expand...
Click to collapse
I have no idea. Could you post your task that displays this scene. For help find that, please see this post.
Also, what device and OS is this?
Conferma (25)
A1: Popup Task Buttons [ Text:Sure? Mode:Text Task:Ripristina Task:No Task: Background Image: Layoutopup Task Buttons - Ktmom Larger Timeout (Seconds):10 Show Over Keyguardn ]
Sorry. This is a little different task because I deleted the previous one, but the behavior is exactly the same.
Ahhh, I see. Try using this scene, but use a display scene action. Make sure to have an action in the task or the tasks associated with pop-up buttons, which destroys the scene when you're done.
Thanks. I used "Display scene" instead of "Popup task button" and now it works as expected.
The pop-up button action "should" work. Unfortunately, Tasker's current developer has made it clear he will not support the built in scenes. I'm guessing there will be a day where the scenes become even more problematic and we'll be forced to AutoTools web scenes.
«rant»I have spent days trying to convert one of my many custom scenes to a web scene. You need html, css, and JavaScript plus an understanding of how to set and receive variables back and forth. It's second to impossible to develop on the device. Which at least in my case means I can't tweak when in at the doctors office or hospital with my son. And I rarely have time to sit on the computer at home «/rant»

[GUIDE] Advanced swipe gesture shortcuts using Tasker, for running any task or automations.

Table of Contents
Preface
Requirements
Difficulty
How it works!
Uses
Autorun
Demo, screenshots, TaskerNet & project backup
Tips
Why not those easy to use apps from PlayStore?
End note.
1. Preface​Before getting my hands on Pixel 6, I was using a Samsung Galaxy S8 running on an Android 10 custom ROM. Samsung provides an advanced, and very useful app called Good Lock, in which the "One Hand Operation +" feature helps us to set up upto freaking 36 number of swipe gesture shortcuts, from the left and right (top, center and bottom) sides of the screen, irrespective of which screen or app is currently active on the screen.
The only thing that I was sure about missing in Pixel 6 was this swipe gestures. That's why I did my research even before receiving my Pixel. Now I've successfully implemented a replica of the Samsung's swipe gesture into my Google Pixel.
These gestures makes it very easy to use this big and heavy smartphone.
This gesture setup made it easy for me to pull up my Control Panel created in Tasker, whenever I need, irrespective of which app or screen I'm in.
2. Requirements​
Tasker​
Tasker terms to understand (Only for those who are new to Tasker)​
TASK : An action or set of actions which will be later run by Tasker by itself, when defined conditions are met. Can also be run manually via the Tasker app.​
Examples: Launch an app, change ringer volume, toggle WiFI, disable auto rotation etc.​
PROJECT : An individual Tasker set up, where we define the conditions to meet, and the tasks to be performed when the defined conditions are met.​
Example 1: A profile which automatically enables the auto-rotation (task), when YouTube is opened (condition), and disables auto-rotation when you leave YouTube.​
Example 2: A profile which automatically enables mobile data (task), when your device is connected to your car WiFi (condition) or Android Auto.​
SCENE : A visible, or invisible shape which will be displayed on the screen, and can be configured to respond to a swipe, tap or long tap on it, and then accordingly perform a pre-defined task. A scene can only be enabled (show) and disabled (destroy) through a task or a project.​
Example 1: A visible button that can be displayed on the screen, or an invisible location on the screen, which disables WiFi when we long tap on it.​
Example 2: A visible button that can be displayed on the screen, or an invisible location on the screen, which opens recent apps list when we swipe on it.​
"If" variables to be used in scenes for assigning shortcuts, to each combination of a swipe length and a swipe direction:​
%stroke_len : Defines the length of the swipe in pixels.​
%stroke_dir : Defines the direction of the swipe. (Read How It Works! section)​
Actions that can be performed on a scene:​
Tap: A single touch ON the scene.​
Long tap: Single touch & holding, ON the scene.​
Stroke: A regular swipe started FROM the scene, and ended anywhere on the screen.​
Don't get confused, there are NO different swipe types like long swipe, or short swipe in Tasker by default. For this project, we can mention a swipe with %stroke_len more than a user specified number as a long swipe, and a swipe shorter than that as a short swipe.​
3. Difficulty​You only need to know the basics of Tasker app and scenes. If you are okay with creating, editing, showing and destroying scenes, then it's just a cakewalk.
You just need to create scenes wherever you want, then inside the tap, or long tap, or stroke tabs of your scene, add the if statements with any one of %stroke_len > or %stroke_len <, AND, %stroke_dir ~ as two conditions, and then your desired set of actions inside each if statement, between If and EndIf. (Refer Demo, Screenshots & Project Backup section)
If you are not comfortable with creating, editing, showing and destroying scenes, it will take maximum 1-2 hours to understand the same.
It is time consuming, only during the initial setup from the scratch.
After that, it is editing or adding conditions and shortcuts, again, it's just a cakewalk.
4. How it works!​Using the scenes inside Tasker, we are setting up three different areas on the screen, which are, top (horizontal), left and right (vertical). Inside each scene, we can make small multiple shapes, where we can add different tasks to each portion, when we do a swipe, tap or long tap on it.
When it comes to swipe, we can define the swipe length (using %stroke_len) and the swipe direction (using %stroke_dir), where we can assign different tasks to each conditions, which are made with a pair of a swipe length and a swipe direction.
What is more interesting is that the swipe directions can be any of vertical or horizontal directions like Up, Down, Left, or Right, and also diagonal directions like UpLeft, UpRight, DownLeft and DownRight. (But try not to use vertical and diagonal directions together at a single location, as it might bring conflicts and may end up giving you wrong response because of failing to read your swipe correctly).
These gestures are NOT restricted to homescreen, but works irrespective of which screen or app is currently active on the screen (Exception: To make scenes work in Settings app, you need to Allow Screen Overlays in Settings through developer options).
5. Uses​For instance, a task (set of actions) can be assigned into a swipe gesture like short swipe to UpLeft direction, and another task to another swipe long swipe to UpRight direction, etc.
Examples:
Short swipe from left center edge in UpRight direction, opens YouTube.​
Short swipe from right center edge in DownLeft direction, jump to last app.​
Long tap on the top middle (1st scene) of the screen, toggles WiFi.​
Long tap on the top middle (2nd scene) of the screen, toggles mobile data.​
Long swipe from right top edge in Up direction, takes a screenshot.​
Long swipe from right bottom edge in Down direction, kill foreground app.​
6. Autorun​You can assign the same task (which is set up to show the scene), to a new profile which gets triggered on the device boot. This will make these swipe gestures enable automatically few seconds (or so) after booting your smartphone.
However, you can always open the task inside Tasker app, and click on the play button (⏵) to run the task manually, which will show the scene (or enable the swipe gestures).
Since I'm using Nova Launcher, I also added the same task to a Nova's homescreen gesture, so that I can easily restart this swipe gesture from homescreen itself, whenever required, or just after editing the scene via Tasker. This is very helpful because whenever we edit a scene via Tasker, the scene will get automatically destroyed. So every time you modify a scene, we have to manually re-enable it.
7. Demo, screenshots, TaskerNet & project backup​
Demo:
Google Pixel: In this screenshot, I have mentioned all of the possibilities we have for the Pixel 6, which doesn't get into conflict with the existing system gestures provided by Google.
Others: I suggest using these kind of directions in other android devices which doesn't have native gestures like left swipe from the right edge, and right swipe from the left side edge.
Screenshots: This is the screen where we edit or add set of tasks to be performed, using if statements with conditions %stroke_len > (or %stroke_len <), AND %stroke_dir ~.
TaskerNet: Projects for Pixel 6 and Galaxy S8.
Project Backup: To start with setting up this project, if you want, you can also refer to these regularly updated backup of my setup where I included all the scenes, required task to activate the scene, and the project to autorun this setup on device boot. The folder includes files for both Galaxy S8 and Google Pixel 6. (You can refer here for assistance on how to import task and scene into your Tasker)
8. Tips​
If your device (like Google Pixel) already got a native swipe gesture like left swipe from the right screen edge, and right swipe from the left screen side edge, you should not create a similar gesture via Tasker, which will conflict with your existing system gestures.​
Swipe direction Down from a top horizontal scene might also end up in issues since most of the Android devices natively use the same gesture to pull down notification panel.​
Try not to use vertical directions and diagonal directions together. For example, in right side, don't use Up or Down series AND UpLeft, DownLeft series together. Both these series at a single location might bring conflicts and it may end up giving you wrong response because of failing to read your swipe correctly.​
Try not to avoid using tap. Instead, use long tap, to avoid accidental touches.​
Always keep the size of the scenes thin, because these scene are blocking scenes which makes area behind it untouchable. So anything below the scene is, impossible to touch. (Refer tip number 8 along with this)​
Always re-activate (show) the scene after making any changes, because making changes disables (destroy) the scene.​
Assign the (scene enabling) task to any swipe gestures of your launcher (if any) to make restarting the gesture easy. However, you can always open the task inside Tasker app, and click on the play button (⏵) to run the task manually.
This is a workaround to make these blocking scenes hide temporarily so that we can touch whatever was behind the scene. (Thanks to user ActivateGuacamole for this idea)
Few other valuable tips for choosing the right swipe length for tasks considering their frequency of usage. (Thanks to user ActivateGuacamole for this idea)
9. Why not those easy to use apps from PlayStore?
Because Tasker is powerful. Period.
I have tried few popular gesture setting apps but I always came back to Tasker itself because of the level of control, and customization we have here. Tasker can do impressive automations, which can also be implemented into this swipe gestures, something that can't be achieved with other easy to use and ready-made gesture apps.
With this method, I can add a set of actions (not just one single action), one by one, to be performed, into one single gesture. So if I wanted to do a swipe on the screen, and then another direction swipe, and then a click on a specific area, all these automatically, I can easily do with Tasker.
Examples:
Kill and remove foreground app from recent: You can watch this screen record video which shows my simple swipe gesture running the task where Tasker automates actions (a) open recent apps list, (b) a swipe action to swipe away the app, and (c) another swipe action to go to home screen. All this within a fraction of second. Impressive. isn't it?
Clear all recent apps: In Pixel 6, clear all button is placed at the end of the list. But watch this one, a simple gesture is enough. Tasker will take care of the rest. Again, Impressive. Isn't it?
For implementing such complicated automations, advanced settings and toggling, into a swipe gesture, Tasker is the best solution.
10. End note.​It took days of questions, answers, trail and errors to first understand, and then to make this thing work flawless. Me and my couple of friends really find this useful in our smartphones, so I decided to share it with you also. If you find this useful for you, go ahead. And if you think this is not worth the time and effort required, you can kindly ignore.
I, a noob, wouldn't have made this possible without receiving a help from another person. So, a big thanks to u/adbenj for the initial guide and idea.
Always remember that there is nothing in the world like suitable for everyone, so stick to whatever is suitable for you.​
Click to expand...
Click to collapse
.
UPDATE 1: Added TaskerNet in section "7. Demo, screenshots, TaskerNet & project backup".
Awesome information and Guide!
Thank you for taking the time to put all of this together from the Taker files themselves and then a complete and detailed write up!
.
coffee-turtle said:
Awesome information and Guide!
Thank you for taking the time to put all of this together from the Taker files themselves and then a complete and detailed write up!
Click to expand...
Click to collapse
I know this is not something that everyone considers worthy, because of the time and effort required for the initial setup. Most of the people might go with those free ready to use applications from Play Store. But I thought at least Tasker uses might consider this useful because they are already using the Tasker and automating lot of things like a power user, or a techie (like I pretend )
I did enjoy the whole process from research, trial & error, finishing and finally this write up.
Anyway, thanks for the nice words. It took half a day to finish this write up, after numerous editing formatting and reformatting.
Happy to know that the time that I spent for this write up didn't get wasted by mere replies like "not worthy".
Thanks
Actually, now I am replacing some apps! Tasker is great and nice to have everything under one roof with greater customizing! You should also post this on Joas main Tasker Reddit forum and consider adding the demos to TaskerNet. Not only will this get greater visibility, but a lot of action happens there especially when Joas comes up with new updates. One of his last videos really highlighted scenes because he made them even able to appear on the lock screen, navigation bar, and status bar. This will even add more power to what you present here.
Not everyone explains in such detail as you did here and you've inspired some ideas to make using my phone even easier.
Keep up your good work!
coffee-turtle said:
Not everyone explains in such detail as you did here and you've inspired some ideas to make using my phone even easier.
Click to expand...
Click to collapse
For the past 3 moths, I explained this briefly to many people in Reddit via comments. So I already know what all questions may pop up when explaining this, which helped me to make this final post very detailed.
consider adding the demos to TaskerNet
Click to expand...
Click to collapse
The thing is, I don't think there is a way to share the scenes via TaskerNet URLs. Only project and task can be shared via that. That's why I exported the project, required tasks and scenes, and uploaded to a shared Google Drive folder.
Will do post in Tasker subreddit also.
Anyway, thank you for your kind words
coffee-turtle said:
...and consider adding the demos to TaskerNet.
Click to expand...
Click to collapse
Hi.
To be honest, today only I learned how to move (rather than exporting, deleting & importing) a profile, task and relevant scenes into a new project.
So finally I updated the post with TaskerNet links in section "7. Demo, screenshots, TaskerNet & project backup"
Great work Thanks!
ShebeerPrince said:
Table of Contents
Preface
Requirements
Difficulty
How it works!
Uses
Autorun
Demo, screenshots, TaskerNet & project backup
Tips
Why not those easy to use apps from PlayStore?
End note.
1. Preface​Before getting my hands on Pixel 6, I was using a Samsung Galaxy S8 running on an Android 10 custom ROM. Samsung provides an advanced, and very useful app called Good Lock, in which the "One Hand Operation +" feature helps us to set up upto freaking 36 number of swipe gesture shortcuts, from the left and right (top, center and bottom) sides of the screen, irrespective of which screen or app is currently active on the screen.
The only thing that I was sure about missing in Pixel 6 was this swipe gestures. That's why I did my research even before receiving my Pixel. Now I've successfully implemented a replica of the Samsung's swipe gesture into my Google Pixel.
These gestures makes it very easy to use this big and heavy smartphone.
This gesture setup made it easy for me to pull up my Control Panel created in Tasker, whenever I need, irrespective of which app or screen I'm in.
2. Requirements​
Tasker​
Tasker terms to understand (Only for those who are new to Tasker)​
TASK : An action or set of actions which will be later run by Tasker by itself, when defined conditions are met. Can also be run manually via the Tasker app.​
Examples: Launch an app, change ringer volume, toggle WiFI, disable auto rotation etc.​
PROJECT : An individual Tasker set up, where we define the conditions to meet, and the tasks to be performed when the defined conditions are met.​
Example 1: A profile which automatically enables the auto-rotation (task), when YouTube is opened (condition), and disables auto-rotation when you leave YouTube.​
Example 2: A profile which automatically enables mobile data (task), when your device is connected to your car WiFi (condition) or Android Auto.​
SCENE : A visible, or invisible shape which will be displayed on the screen, and can be configured to respond to a swipe, tap or long tap on it, and then accordingly perform a pre-defined task. A scene can only be enabled (show) and disabled (destroy) through a task or a project.​
Example 1: A visible button that can be displayed on the screen, or an invisible location on the screen, which disables WiFi when we long tap on it.​
Example 2: A visible button that can be displayed on the screen, or an invisible location on the screen, which opens recent apps list when we swipe on it.​
"If" variables to be used in scenes for assigning shortcuts, to each combination of a swipe length and a swipe direction:​
%stroke_len : Defines the length of the swipe in pixels.​
%stroke_dir : Defines the direction of the swipe. (Read How It Works! section)​
Actions that can be performed on a scene:​
Tap: A single touch ON the scene.​
Long tap: Single touch & holding, ON the scene.​
Stroke: A regular swipe started FROM the scene, and ended anywhere on the screen.​
Don't get confused, there are NO different swipe types like long swipe, or short swipe in Tasker by default. For this project, we can mention a swipe with %stroke_len more than a user specified number as a long swipe, and a swipe shorter than that as a short swipe.​
3. Difficulty​You only need to know the basics of Tasker app and scenes. If you are okay with creating, editing, showing and destroying scenes, then it's just a cakewalk.
You just need to create scenes wherever you want, then inside the tap, or long tap, or stroke tabs of your scene, add the if statements with any one of %stroke_len > or %stroke_len <, AND, %stroke_dir ~ as two conditions, and then your desired set of actions inside each if statement, between If and EndIf. (Refer Demo, Screenshots & Project Backup section)
If you are not comfortable with creating, editing, showing and destroying scenes, it will take maximum 1-2 hours to understand the same.
It is time consuming, only during the initial setup from the scratch.
After that, it is editing or adding conditions and shortcuts, again, it's just a cakewalk.
4. How it works!​Using the scenes inside Tasker, we are setting up three different areas on the screen, which are, top (horizontal), left and right (vertical). Inside each scene, we can make small multiple shapes, where we can add different tasks to each portion, when we do a swipe, tap or long tap on it.
When it comes to swipe, we can define the swipe length (using %stroke_len) and the swipe direction (using %stroke_dir), where we can assign different tasks to each conditions, which are made with a pair of a swipe length and a swipe direction.
What is more interesting is that the swipe directions can be any of vertical or horizontal directions like Up, Down, Left, or Right, and also diagonal directions like UpLeft, UpRight, DownLeft and DownRight. (But try not to use vertical and diagonal directions together at a single location, as it might bring conflicts and may end up giving you wrong response because of failing to read your swipe correctly).
These gestures are NOT restricted to homescreen, but works irrespective of which screen or app is currently active on the screen (Exception: To make scenes work in Settings app, you need to Allow Screen Overlays in Settings through developer options).
5. Uses​For instance, a task (set of actions) can be assigned into a swipe gesture like short swipe to UpLeft direction, and another task to another swipe long swipe to UpRight direction, etc.
Examples:
Short swipe from left center edge in UpRight direction, opens YouTube.​
Short swipe from right center edge in DownLeft direction, jump to last app.​
Long tap on the top middle (1st scene) of the screen, toggles WiFi.​
Long tap on the top middle (2nd scene) of the screen, toggles mobile data.​
Long swipe from right top edge in Up direction, takes a screenshot.​
Long swipe from right bottom edge in Down direction, kill foreground app.​
6. Autorun​You can assign the same task (which is set up to show the scene), to a new profile which gets triggered on the device boot. This will make these swipe gestures enable automatically few seconds (or so) after booting your smartphone.
However, you can always open the task inside Tasker app, and click on the play button (⏵) to run the task manually, which will show the scene (or enable the swipe gestures).
Since I'm using Nova Launcher, I also added the same task to a Nova's homescreen gesture, so that I can easily restart this swipe gesture from homescreen itself, whenever required, or just after editing the scene via Tasker. This is very helpful because whenever we edit a scene via Tasker, the scene will get automatically destroyed. So every time you modify a scene, we have to manually re-enable it.
7. Demo, screenshots, TaskerNet & project backup​
Demo:
Google Pixel: In this screenshot, I have mentioned all of the possibilities we have for the Pixel 6, which doesn't get into conflict with the existing system gestures provided by Google.
Others: I suggest using these kind of directions in other android devices which doesn't have native gestures like left swipe from the right edge, and right swipe from the left side edge.
Screenshots: This is the screen where we edit or add set of tasks to be performed, using if statements with conditions %stroke_len > (or %stroke_len <), AND %stroke_dir ~.
TaskerNet: Projects for Pixel 6 and Galaxy S8.
Project Backup: To start with setting up this project, if you want, you can also refer to these regularly updated backup of my setup where I included all the scenes, required task to activate the scene, and the project to autorun this setup on device boot. The folder includes files for both Galaxy S8 and Google Pixel 6. (You can refer here for assistance on how to import task and scene into your Tasker)
8. Tips​
If your device (like Google Pixel) already got a native swipe gesture like left swipe from the right screen edge, and right swipe from the left screen side edge, you should not create a similar gesture via Tasker, which will conflict with your existing system gestures.​
Swipe direction Down from a top horizontal scene might also end up in issues since most of the Android devices natively use the same gesture to pull down notification panel.​
Try not to use vertical directions and diagonal directions together. For example, in right side, don't use Up or Down series AND UpLeft, DownLeft series together. Both these series at a single location might bring conflicts and it may end up giving you wrong response because of failing to read your swipe correctly.​
Try not to avoid using tap. Instead, use long tap, to avoid accidental touches.​
Always keep the size of the scenes thin, because these scene are blocking scenes which makes area behind it untouchable. So anything below the scene is, impossible to touch. (Refer tip number 8 along with this)​
Always re-activate (show) the scene after making any changes, because making changes disables (destroy) the scene.​
Assign the (scene enabling) task to any swipe gestures of your launcher (if any) to make restarting the gesture easy. However, you can always open the task inside Tasker app, and click on the play button (⏵) to run the task manually.
This is a workaround to make these blocking scenes hide temporarily so that we can touch whatever was behind the scene. (Thanks to user ActivateGuacamole for this idea)
Few other valuable tips for choosing the right swipe length for tasks considering their frequency of usage. (Thanks to user ActivateGuacamole for this idea)
9. Why not those easy to use apps from PlayStore?
Because Tasker is powerful. Period.
I have tried few popular gesture setting apps but I always came back to Tasker itself because of the level of control, and customization we have here. Tasker can do impressive automations, which can also be implemented into this swipe gestures, something that can't be achieved with other easy to use and ready-made gesture apps.
With this method, I can add a set of actions (not just one single action), one by one, to be performed, into one single gesture. So if I wanted to do a swipe on the screen, and then another direction swipe, and then a click on a specific area, all these automatically, I can easily do with Tasker.
Examples:
Kill and remove foreground app from recent: You can watch this screen record video which shows my simple swipe gesture running the task where Tasker automates actions (a) open recent apps list, (b) a swipe action to swipe away the app, and (c) another swipe action to go to home screen. All this within a fraction of second. Impressive. isn't it?
Clear all recent apps: In Pixel 6, clear all button is placed at the end of the list. But watch this one, a simple gesture is enough. Tasker will take care of the rest. Again, Impressive. Isn't it?
For implementing such complicated automations, advanced settings and toggling, into a swipe gesture, Tasker is the best solution.
10. End note.​It took days of questions, answers, trail and errors to first understand, and then to make this thing work flawless. Me and my couple of friends really find this useful in our smartphones, so I decided to share it with you also. If you find this useful for you, go ahead. And if you think this is not worth the time and effort required, you can kindly ignore.
I, a noob, wouldn't have made this possible without receiving a help from another person. So, a big thanks to u/adbenj for the initial guide and idea.
.
UPDATE 1: Added TaskerNet in section "7. Demo, screenshots, TaskerNet & project backup".
Click to expand...
Click to collapse
hey so i want to know how much extra battery this costs running.
And also i want to make some sort of simillar gesture swipe thing. i am wondering if via tasker i could do the following: keeping the regular side swipe horizontal to be back, and long swipe for previous app. but then also having the side gest. to be an app shortcut based on the current app running. so maybe like when youtube is running i can swipe up to open notes and write something down and then via previous app i am back to youtube. but when i am on the work app i can vertically swipe to bring the time tracker app. or a swipe down for the google maps route to home. etc. etc.
how would i manage to do this?
I am using a poco f2 pro if that matters and not rooted.

Question Hi all..

Anybody knows how to turn on Auto Arrange option on the AZF8?... it's so basic already years and i was looking anywhere and couldn't find how to make it auto arrange the apps icons / shortcuts on home screen and other "pages"... i mean that e.g. if i delete some app or it's shortcut, it's automaticall move all the other apps to take it's place... just keeping it in order... very basic and therefore odd it's no where 2B found easily...
Also for moving the app pages from one place to another, like if you want the apps to be right before or after some widget... it's very frustrating.. in Android 10 i think it was by marking some app (With V) on the edit page mode, so the bottom horizontal ribon of pages shown, then simply long tap and drag and drop the entire page to where you want.. but non of this here... it's very frustrating so any help would be very much appreciated here...
Thatks all ahead and have a nice day..

Categories

Resources