Probably not easy. AI has an Orientation.Sensor and an Accelerormeter.Sensor (Gyroscope equivalent? I do not know).
Accelerometer has an Acceleratction.Changed event handler and other tools that allow you to select the monitoring level and other goodies.
Orientation sensor has Orientation.Changed event handler.
Look here for what AI has available:
CONTROLS.
So, the basic tools are there. I believe you have the concept OK : Record a pattern and then compare it to trigger an event.
Consider Activity.launcher is your friend, but can it launch the apps you are interested in..getting it to work with some apps might be a challenge.
I can think of two ways to record a pattern
1) use a list to temporarily store pattern; possibly tag1 with the pattern to monitor;tag 2 with a recording of the most recent pattern.
2)Use a TinyDB. Possibly not as fast as #1 but more persistent.
3) Use a timer (the clock) to sample events and or use the frequency of sampling tools in the two sensors to obtain what goes into in the list slot of Tag2. Use the timer or a second timer to periodically monitor and compare the two list items. What you compare might be just a boolean (true/false) event ... found the pattern, did not find the pattern. You probably will have lots of logic blocks.
Compare with logic blocks and if..then statements.
Do not waste your time immediately programming this. Learn what functions are available for each of the controls and how to use them. Think about how you want this to work and make a diagram on paper. Yes, stores still sell paper..you also need a pencil or pen. I am not being sarcastic, it is just that you will have to make a flow chart diagram to see how this might be possible.
Consider, multiple gestures might be more difficult to compare than a single gesture executed multiple times withing a few seconds.. that is, it might be easier to count the number of occurrences of a single gesture repeated.
Consider, AI2 is not Eclipse or Android Studio. Those tool probably were what were used to develop the program you wish to reproduce. The tools available to that product's developer may not be available on AI2. You will have to be clever.
I hope this is helpful. Perhaps someone else will supply a link for an algorithm. My guess, is you might be the first person to do this with AI2. try googling things like "app inventor orientation sensor" or "app inventor accelerometer sensor"..for more ideas.
Is this what you needed?
Regards,
Steve