Tap "cancel" on an input dialog

Post your questions and help other users.

Moderator: Martin

Post Reply
User avatar
tsolignani
Posts: 187
Joined: 12 Jan 2019 11:53
Location: Vignola, Mo, Italy
Contact:

Tap "cancel" on an input dialog

Post by tsolignani » 20 Mar 2020 18:36

Good evening everyone.

Sometimes I tap cancel by mistake and lose the text I was entering or the thing I was doing.

Is there a way to ask for a confirmation when the user press cancel on an input dialog?

I suppose the text that was into the dialog box does not populate the value variable, is there a way to retrieve it?

Thank you.

Micky Micky
Posts: 179
Joined: 16 Oct 2019 17:38

Re: Tap "cancel" on an input dialog

Post by Micky Micky » 20 Mar 2020 20:57

Hello

Cancel seems to lose the input.
You can create a confirmation dialog for the cancel button but the input is still lost.

Hopefully someone might have a workaround.

Good luck

Micky
Crude but it works.

User avatar
tsolignani
Posts: 187
Joined: 12 Jan 2019 11:53
Location: Vignola, Mo, Italy
Contact:

Re: Tap "cancel" on an input dialog

Post by tsolignani » 20 Mar 2020 21:13

Thank you.

That's the matter, no point in doing a confirmation dialog if the input is lost anyway.

Let's see if someone else has something to say.

Thank you.

Micky Micky
Posts: 179
Joined: 16 Oct 2019 17:38

Re: Tap "cancel" on an input dialog

Post by Micky Micky » 20 Mar 2020 22:20

Hello

It's possible.

UI EVENT trigger can watch for Input Dialog WINDOW OPENED. This enables another flow with UI EVENT trigger watching for TEXT CHANGED.

I set it to watch for 1234 being typed and it triggered and returned a variable containing 1234.
This could be written to a text file until you press OK on your Input Dialog.

What I don't know is the Regex or Glob pattern to get it to watch for the whole keyboard.

I don't have time to show you a working example, but here's the bit watching for the 1234. The variable returned is called 'text'

http://automagic4android.com/flow.php?i ... ae536dabb9

Hope this helps

Micky
Crude but it works.

User avatar
Rafi4
Posts: 281
Joined: 01 Dec 2017 05:23

Re: Tap "cancel" on an input dialog

Post by Rafi4 » 21 Mar 2020 05:56

Hi tsolignani
Action input dialog default value as global_a
Action script as example global_a = value;
Condition confirmation dialog as in screen shot

I hope I have explained better

from record4
Attachments
IMG_20200321_112223-1.jpg
Screen shot
IMG_20200321_112223-1.jpg (81.7 KiB) Viewed 13813 times
No.1 Automation app in play store Automagic Premium
Samsung Galaxy j2 non rooted.
Android 5.1.1

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

Re: Tap "cancel" on an input dialog

Post by Desmanto » 21 Mar 2020 17:32

It can be done by using Control UI. Put a control UI parallel to the input dialog (so both get executed at the same time). Both input dialog and control UI connected to previous same element.

Code: Select all

sleep(1000);
while(existsElementById("android:id/alertTitle"))
{
  savedtext = getTextById("ch.gridvision.ppam.androidautomagic:id/edit_text");
  sleep(1000);
}
This CUI script will loop every second and save the text in the input field to the [savedtext} variable. If you accidentally press cancel, you can still use {savedtext} as the output result. Check it using script after the input dialog. The Control UI ends there, not connected to any other element after it.
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.

User avatar
tsolignani
Posts: 187
Joined: 12 Jan 2019 11:53
Location: Vignola, Mo, Italy
Contact:

Re: Tap "cancel" on an input dialog

Post by tsolignani » 22 Mar 2020 13:06

Thank you everybody.

I guess Desmanto solution did the trick.

It works, I put a block with that code and if cancel gets hit by mistake its content get copied to the clipboard.

You could imagine even stricter solutions, like writing the variable to a file maybe, so that you are safe even when the phone crash or does otherwise.

Thanks again, wonderful app and wonderful forum!

Post Reply