Page 1 of 1

WhatsApp number

Posted: 17 Aug 2020 02:21
by Akt
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

Re: WhatsApp number

Posted: 17 Aug 2020 07:36
by Desmanto
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.