WhatsApp number

Post your questions and help other users.

Moderator: Martin

Post Reply
Akt
Posts: 133
Joined: 25 May 2014 08:57

WhatsApp number

Post by Akt » 17 Aug 2020 02:21

Hello
I have made an flow to search the copied number on WhatsApp.

I have used an condition to check that the length of copied text is 10 or 13.

But i am facing an problem.

It also executes when some text or photo is copied.
I want to execute only when number is copied ( length of number is 10 or 13 ).

http://automagic4android.com/flow.php?i ... 8542a31a74

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: WhatsApp number

Post by Desmanto » 17 Aug 2020 07:36

If both branch are doing the same thing, only differ in the url, you can combine them to single branch, rather than 2 or more branches. In the second expressions, use only one expression. Then put the code

Code: Select all

if(length(text) == 10 OR length(text) == 13)
{
  if(length(text) == 10)
    text = "+91" + text; //this add +91 if 10 digit
  return true;
}
return false;
You can remove the 2nd branch then.


Next is on the trigger. You filter for all package, your flow will trigger too frequently. You should have limit it to whatsapp. Even then, it still trigger on every long press. Better limit it directly to phone number only, using matches regex in UI Event. But the Text field - Matches regex, doesn't support variable/inline expression. So I copy the result from java code (from anuraag), getJavaStaticField("android.util.Patterns", "PHONE"), the result is below

Code: Select all

(\+[0-9]+[\- \.]*)?(\([0-9]+\)[\- \.]*)?([0-9][0-9\- \.]+[0-9])
Put this in the text Field - Matches regex in UI Event Trigger. This will ensure the long click only filter out phone number, reducing false trigger. Don't worry to remember the regex, it is provided by the java function already, I only copy paste here.


There are other way to do it. I also have CUI to grab text on the whatsapp. I can then decide to extract out only particular number (using input dialog) and then phone call/WA call/WA chat to them. I trigger it using Smartbar navbar. You can also use quick tile setting for the trigger.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Post Reply