Recent

Author Topic: [SOLVED]LAMW - accessibility setting- Floating - Service -jUSSDService  (Read 3440 times)

Guser979

  • New Member
  • *
  • Posts: 40
Hi. I have modified the JUSSD component to work as an accessibility service which lists package name and all currently active screen content. I used this service together with jWindowManager . After a lot of testing and modifications now everything works perfectly as I imagined. Only one detail is missing: I want the application to open the accessibility setting so that I can activate the service on the first run. Thanks in advance.

PS: My intention with this one is to automate tasks. There are many, I know. But nothing like having a custom one. And with LAWM this is possible.


EDIT :

Done with :

In modified Jussdservice ....

import android.provider.Settings;

 Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);

 controls.activity. startActivity(intent);

Code


Code: Java  [Select][+][-]
  1. package com.example.appwindowmanagerdemo1;
  2. import android.provider.Settings;
  3. import android.accessibilityservice.AccessibilityService;
  4. import android.accessibilityservice.AccessibilityServiceInfo;
  5. import android.content.Context;
  6. import android.content.Intent;
  7. import android.os.Build;
  8. import android.text.TextUtils;
  9. import android.util.Log;
  10. import android.view.accessibility.AccessibilityEvent;
  11. import android.view.accessibility.AccessibilityNodeInfo;
  12. import java.util.Collections;
  13. import java.util.List;
  14.  
  15. import android.accessibilityservice.GestureDescription;
  16. import android.graphics.Path;
  17. import android.graphics.PixelFormat;
  18. import android.media.AudioManager;
  19. import android.view.Gravity;
  20. import android.view.LayoutInflater;
  21. import android.view.View;
  22. import android.view.WindowManager;
  23.  
  24. import android.widget.Button;
  25. import android.widget.FrameLayout;
  26.  
  27. import java.util.ArrayDeque;
  28. import java.util.Deque;
  29. /*Draft java code by "Lazarus Android Module Wizard" [7/14/2020 16:47:51]*/
  30. /*https://github.com/jmpessoa/lazandroidmodulewizard*/
  31. /*jControl LAMW template*/
  32.  
  33. // ref. https://stackoverflow.com/questions/22057625/prevent-ussd-dialog-and-read-ussd-response
  34. // ref. http://habrahabr.ru/post/234425/
  35.  
  36. public class jUSSDService extends AccessibilityService {
  37.     private Path path;
  38.     private GestureDescription.Builder builder;
  39.     private GestureDescription.StrokeDescription strokeDescription;
  40.     private GestureResultCallback gestureResultCallback;
  41.     private GestureDescription gestureDescription;
  42.        
  43.        
  44.     private long pascalObj = 0;        //Pascal Object
  45.     private Controls controls  = null; //Java/Pascal [events] Interface ...
  46.     private Context  context   = null;
  47.  
  48.     /*.*/public static String TAG = jUSSDService.class.getSimpleName();
  49.  
  50.     //GUIDELINE: please, preferentially, init all yours params names with "_", ex: int _flag, String _hello ...
  51.  
  52.     /*.*/public jUSSDService() {
  53.         //super();
  54.     }
  55.  
  56.     public jUSSDService(Controls _ctrls, long _Self) { //Add more others news "_xxx" params if needed!
  57.        //super(_ctrls.activity);
  58.        context   = _ctrls.activity;
  59.        pascalObj = _Self;
  60.        controls  = _ctrls;
  61.     }
  62.  
  63.     private String processUSSDText(List<CharSequence> eventText) {
  64.         for (CharSequence s : eventText) {
  65.             String text = String.valueOf(s);
  66.             // Return text if text is the expected ussd response
  67.             if( true ) {
  68.                 return text;
  69.             }
  70.         }
  71.         return null;
  72.     }
  73.  
  74.  
  75.  private String toString(AccessibilityEvent event) {
  76.       String str = "";
  77.       str += "eventtype: " + AccessibilityEvent.eventTypeToString(event.getEventType());
  78.       str += "\nsource: " + event.getSource();
  79.       str += "\npackagename: " + event.getPackageName();
  80.       str += "\nclassname: " + event.getClassName();
  81.  
  82.       return str;
  83.     }
  84.  
  85. //public static void
  86. public void logNodeHeirarchy(AccessibilityNodeInfo nodeInfo, int depth) {
  87.  
  88.    
  89. //if    nodeInfo.getText() = "Home" {
  90. //      //currentNode.performAction(AccessibilityNodeInfo.ACTION_CLICK);
  91. // }
  92.        
  93.         if (nodeInfo == null) return;
  94.  
  95.     String logString = "";
  96.  
  97.     for (int i = 0; i < depth; ++i) {
  98.         logString += " ";
  99.     }
  100.  
  101.     logString += "Text: " + nodeInfo.getText() + " " + " Content-Description: " + nodeInfo.getContentDescription();
  102.  
  103.     Log.v("Meu", logString);
  104.        
  105.          Intent intent = new Intent("org.lamw.action.USSDService");
  106.       intent.putExtra("message",logString ); //text
  107.   sendBroadcast(intent);
  108.  
  109.  
  110.  
  111.     for (int i = 0; i < nodeInfo.getChildCount(); ++i) {
  112.         logNodeHeirarchy(nodeInfo.getChild(i), depth + 1);
  113.     }
  114. }
  115.  
  116.  
  117.  
  118.  
  119.  
  120.     @Override
  121.     /*.*/public void onAccessibilityEvent(AccessibilityEvent event) {
  122.         //Log.d(TAG, "onAccessibilityEvent");
  123.  
  124.         AccessibilityNodeInfo source = event.getSource();
  125.  
  126.            if (source == null) {
  127.            return;}
  128.            String text= "";
  129.  
  130.  
  131.  if (event.getEventType()==AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED){
  132.          
  133.         if (source.getPackageName()!=null) {
  134.  
  135.  
  136.  
  137.                
  138.          if (!source.getPackageName().equals("com.sec.android.app.launcher"))   {
  139.      if (!source.getPackageName().equals("com.example.appwindowmanagerdemo1"))   {
  140.  Intent intent = new Intent("org.lamw.action.USSDService");
  141. intent.putExtra("message","Package:"+source.getPackageName() ); //text
  142.   sendBroadcast(intent);
  143.  AccessibilityNodeInfo currentNode=getRootInActiveWindow();
  144.             if (currentNode!=null) {
  145.  logNodeHeirarchy(currentNode, 0);
  146.  
  147.  
  148.                                 }
  149.  
  150.  
  151.         }
  152.         }
  153.          
  154.  }
  155.  }
  156.         return;
  157.         }
  158.  
  159.  
  160.     @Override
  161.     /*.*/public void onInterrupt() {
  162.        //
  163.     }
  164.  
  165.     @Override
  166.     protected void onServiceConnected() {
  167.         super.onServiceConnected();
  168.                 // pag1();
  169.                
  170.                
  171.                 // com.uieaser.atextwidget    class android.widget.TextView   id name R.id.textViewMain  parent android.widget.RelativeLayout(R.id.RelativeLayout1)
  172.  
  173.         //Log.d(TAG, "onServiceConnected");
  174.         AccessibilityServiceInfo info = new AccessibilityServiceInfo();
  175.         info.flags = AccessibilityServiceInfo.DEFAULT;
  176.  
  177.          info.packageNames = null;
  178.         info.eventTypes = AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED | AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED;
  179.         info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
  180.         setServiceInfo(info);
  181.     }
  182.  
  183.     public void jFree() {
  184.       //free local objects...
  185.     }
  186.  
  187.   //write others [public] methods code here......
  188.   //GUIDELINE: please, preferentially, init all yours params names with "_", ex: int _flag, String _hello ...
  189.  
  190.     //Method to start the service
  191.     public void Start() {
  192.         //Explicit intents explicitly define the component which should be called by the Android system,
  193.         //by using the Java class as identifier
  194.         //Create an intent for a specific component.
  195.        
  196.                  Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
  197.          controls.activity. startActivity(intent);
  198.        
  199.                
  200.     }
  201.  
  202.  
  203.  
  204.  
  205.  
  206. public void pag1() {
  207.         if (path == null) {
  208.             path = new Path();
  209.             path.moveTo(513, 1963);
  210.             path.lineTo(513, 1963);
  211.         }
  212.         if (builder == null)
  213.             builder = new GestureDescription.Builder();
  214.         if (strokeDescription == null) {
  215.             strokeDescription = new GestureDescription.StrokeDescription(path, 0, 1);
  216.             builder.addStroke(strokeDescription);
  217.         }
  218.         if (gestureResultCallback == null)
  219.             gestureResultCallback = new GestureResultCallback() {
  220.                 @Override
  221.                 public void onCompleted(GestureDescription gestureDescription) {
  222.                     pag1();
  223.                 }
  224.  
  225.                 @Override
  226.                 public void onCancelled(GestureDescription gestureDescription) {
  227.                     super.onCancelled(gestureDescription);
  228.                 }
  229.             };
  230.         if (gestureDescription == null)
  231.             gestureDescription = builder.build();
  232.         dispatchGesture(gestureDescription, gestureResultCallback, null);
  233.     }
  234.  
  235.  
  236.  
  237.  
  238.     public void Stop() {
  239.         controls.activity.stopService(new Intent(controls.activity,jUSSDService.class));
  240.     }
  241.  
  242. }
  243.  
  244.  
  245.  



Add in JwindowManager (java)

Code: Java  [Select][+][-]
  1.   @Override
  2.             public boolean onTouchEvent(MotionEvent event) {
  3.  
  4.                 switch (event.getAction()) {
  5.  
  6.                     case MotionEvent.ACTION_DOWN:
  7.                                         SetViewFocusable(true);//  add  
  8.                         //remember the initial position.
  9.                         if (mParams != null) {
  10.                             initialX = mParams.x;
  11.                             initialY = mParams.y;
  12.                             //get the touch location
  13.                             initialTouchX = event.getRawX();
  14.                             initialTouchY = event.getRawY();
  15.                                                        
  16.                         }
  17.                         break;
  18.                     case MotionEvent.ACTION_MOVE:
  19.                                          SetViewFocusable(true);
  20.                         //Calculate the X and Y coordinates of the view.
  21.                         if (mParams != null) {
  22.                             mParams.x = initialX + (int) (event.getRawX() - initialTouchX);
  23.                             mParams.y = initialY + (int) (event.getRawY() - initialTouchY);
  24.                             //Update the layout with new X & Y coordinate
  25.                          
  26.                                                    }
  27.                       case MotionEvent.ACTION_OUTSIDE: //  add  
  28.                                                         SetViewFocusable(false);//  add  
  29.  
  30.  


XML Service in Res\XML


Code: XML  [Select][+][-]
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
  3.    android:accessibilityEventTypes="typeWindowStateChanged|typeWindowContentChanged|typeViewClicked|typeViewFocused"
  4.    android:accessibilityFeedbackType="feedbackGeneric"
  5.    android:accessibilityFlags="flagDefault"
  6.    android:canRetrieveWindowContent="true"
  7.    android:description="@string/lamw_ussd_service"
  8.    android:notificationTimeout="100"
  9.         android:canPerformGestures="true"
  10.         android:canRequestTouchExplorationMode="true"
  11.    android:packageNames="@null"/>
  12.        
  13.        
  14.  

Sources: Many. Grateful to all who share knowledge.   
« Last Edit: September 21, 2021, 11:38:53 pm by Guser979 »

Guser979

  • New Member
  • *
  • Posts: 40
Re: [SOLVED]LAMW - accessibility setting- Floating - Service -jUSSDService
« Reply #1 on: September 22, 2021, 01:54:40 am »
Well.... I "cloned' JUSSDService and now I have the new JUSSDService2 component with the modifications I need. Question : If I want to share just this component with someone, is there a way? I think it's not difficult to do something in that direction. I just need to reproduce what I did. Clone , modify, add to Register_extras and compile.  I didn't use New JComponent from LAMW. I found it complicated
« Last Edit: September 22, 2021, 02:18:50 am by Guser979 »

jmpessoa

  • Hero Member
  • *****
  • Posts: 1946
Re: [SOLVED]LAMW - accessibility setting- Floating - Service -jUSSDService
« Reply #2 on: September 22, 2021, 05:13:31 am »
Quote
I "cloned' JUSSDService and now I have the new JUSSDService2

Nice!

But, the way to go is add your improvement to original component.... then I can update

the LAMW jUSSDService.

What about?
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Guser979

  • New Member
  • *
  • Posts: 40
Re: [SOLVED]LAMW - accessibility setting- Floating - Service -jUSSDService
« Reply #3 on: September 22, 2021, 10:55:55 am »
Yes Master. I will try. I'll end up learning Java by the way kkkk... It's not that difficult. But I just think it's "boring" language. Hahaha

Edit :

My solution is not that of a programmer, but it works... hehe

Here is the JUSSDService

Code: Java  [Select][+][-]
  1.  package org.lamw.appussdservicedemo1.App;
  2. import android.provider.Settings;
  3. import android.accessibilityservice.AccessibilityService;
  4. import android.accessibilityservice.AccessibilityServiceInfo;
  5. import android.content.Context;
  6. import android.content.Intent;
  7. import android.os.Build;
  8. import android.text.TextUtils;
  9. import android.util.Log;
  10. import android.view.accessibility.AccessibilityEvent;
  11. import android.view.accessibility.AccessibilityNodeInfo;
  12. import java.util.Collections;
  13. import java.util.List;
  14.  
  15. import android.accessibilityservice.GestureDescription;
  16. import android.graphics.Path;
  17. import android.graphics.PixelFormat;
  18. import android.media.AudioManager;
  19. import android.view.Gravity;
  20. import android.view.LayoutInflater;
  21. import android.view.View;
  22. import android.view.WindowManager;
  23.  
  24. import android.widget.Button;
  25. import android.widget.FrameLayout;
  26.  
  27. import java.util.ArrayDeque;
  28. import java.util.Deque;
  29.  
  30.  
  31.  
  32. /*Draft java code by "Lazarus Android Module Wizard" [7/14/2020 16:47:51]*/
  33. /*https://github.com/jmpessoa/lazandroidmodulewizard*/
  34. /*jControl LAMW template*/
  35.  
  36. // ref. https://stackoverflow.com/questions/22057625/prevent-ussd-dialog-and-read-ussd-response
  37. // ref. http://habrahabr.ru/post/234425/
  38.  
  39. public class jUSSDService extends AccessibilityService {
  40.  
  41.     private long pascalObj = 0;        //Pascal Object
  42.     private Controls controls  = null; //Java/Pascal [events] Interface ...
  43.     private Context  context   = null;
  44.  
  45.     /*.*/public static String TAG = jUSSDService.class.getSimpleName();
  46.  
  47.     //GUIDELINE: please, preferentially, init all yours params names with "_", ex: int _flag, String _hello ...
  48.  
  49.     /*.*/public jUSSDService() {
  50.         //super();
  51.     }
  52.  
  53.     public jUSSDService(Controls _ctrls, long _Self) { //Add more others news "_xxx" params if needed!
  54.        //super(_ctrls.activity);
  55.        context   = _ctrls.activity;
  56.        pascalObj = _Self;
  57.        controls  = _ctrls;
  58.     }
  59.  
  60.     private String processUSSDText(List<CharSequence> eventText) {
  61.         for (CharSequence s : eventText) {
  62.             String text = String.valueOf(s);
  63.             // Return text if text is the expected ussd response
  64.             if( true ) {
  65.                 return text;
  66.             }
  67.         }
  68.         return null;
  69.     }
  70.        
  71.        
  72.                 public void logNodeHeirarchy(AccessibilityNodeInfo nodeInfo, int depth) {
  73.  
  74.        
  75.                 if (nodeInfo == null) return;
  76.  
  77.                 String logString = "";
  78.  
  79.                 for (int i = 0; i < depth; ++i) {
  80.         logString += " ";
  81.                 }
  82.  
  83.                 logString += "Text: " + nodeInfo.getText() + " " + " Content-Description: " + nodeInfo.getContentDescription();
  84.  
  85.                 // Log.v("Meu", logString);
  86.        
  87.                 Intent intent = new Intent("org.lamw.action.USSDService");
  88.                 intent.putExtra("message",logString ); //text
  89.                 sendBroadcast(intent);
  90.  
  91.  
  92.  
  93.                 for (int i = 0; i < nodeInfo.getChildCount(); ++i) {
  94.         logNodeHeirarchy(nodeInfo.getChild(i), depth + 1);
  95.                 }
  96.                 }
  97.        
  98.        
  99.        
  100.        
  101.  
  102.     @Override
  103.     /*.*/public void onAccessibilityEvent(AccessibilityEvent event) {
  104.         //Log.d(TAG, "onAccessibilityEvent");
  105.  
  106.         AccessibilityNodeInfo source = event.getSource();
  107.                
  108.        if (source == null) {
  109.         return;}
  110.                 if (source.getPackageName().equals("com.android.phone"))  {    
  111.                
  112.                
  113.         /* if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED && !event.getClassName().equals("android.app.AlertDialog")) { // android.app.AlertDialog is the standard but not for all phones  */
  114.         if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED && !String.valueOf(event.getClassName()).contains("AlertDialog")) {
  115.             return;
  116.         }
  117.         if(event.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED && (source == null || !source.getClassName().equals("android.widget.TextView"))) {
  118.             return;
  119.         }
  120.         if(event.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED && TextUtils.isEmpty(source.getText())) {
  121.             return;
  122.         }
  123.  
  124.         List<CharSequence> eventText;
  125.         if(event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
  126.             eventText = event.getText();
  127.         } else {
  128.             eventText = Collections.singletonList(source.getText());
  129.         }
  130.  
  131.         String text = processUSSDText(eventText);
  132.  
  133.         if( TextUtils.isEmpty(text) ) return;
  134.  
  135.         if(Build.VERSION.SDK_INT >= 16) { //need API >= 16!
  136.             //[ifdef_api16up]
  137.              performGlobalAction(GLOBAL_ACTION_BACK); //api >= 16  (android >= 4.1)
  138.             //[endif_api16up]
  139.        }
  140.  
  141.         //Log.d(TAG, text); //Handle USSD response here
  142.  
  143.         Intent intent = new Intent("org.lamw.action.USSDService");
  144.         intent.putExtra("message", "USSD:"+text); //
  145.         sendBroadcast(intent);
  146.                 return;
  147.                 }
  148.                
  149.                 if (!source.getPackageName().equals("com.sec.android.app.launcher"))  {
  150.  
  151.  
  152.                 if (event.getEventType()==AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED){
  153.  
  154.  
  155.                  
  156.                  
  157.                 Intent intent = new Intent("org.lamw.action.USSDService");
  158.                 intent.putExtra("message","Package:"+source.getPackageName() ); //text
  159.                 sendBroadcast(intent);
  160.          
  161.  
  162.  
  163.                 AccessibilityNodeInfo currentNode=getRootInActiveWindow();
  164.                 if (currentNode!=null) {
  165.                 logNodeHeirarchy(currentNode, 0);
  166.                 }
  167.        
  168.                        
  169.          
  170.  
  171.                 }
  172.  
  173.                 }      
  174.                
  175.                
  176.                 }
  177.  
  178.     @Override
  179.     /*.*/public void onInterrupt() {
  180.        //
  181.     }
  182.  
  183.     @Override
  184.                 protected void onServiceConnected() {
  185.         super.onServiceConnected();
  186.         AccessibilityServiceInfo info = new AccessibilityServiceInfo();
  187.         info.flags = AccessibilityServiceInfo.DEFAULT;
  188.                 info.packageNames = null;
  189.         info.eventTypes = AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED | AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED;
  190.         info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
  191.         setServiceInfo(info);
  192.                 }
  193.  
  194.     public void jFree() {
  195.       //free local objects...
  196.     }
  197.  
  198.   //write others [public] methods code here......
  199.   //GUIDELINE: please, preferentially, init all yours params names with "_", ex: int _flag, String _hello ...
  200.  
  201.     //Method to start the service
  202.     public void Start() {
  203.         //Explicit intents explicitly define the component which should be called by the Android system,
  204.         //by using the Java class as identifier
  205.         //Create an intent for a specific component.
  206.        // Intent intent = new Intent(controls.activity, jUSSDService.class);
  207.        // controls.activity.startService(intent);
  208.                
  209.                 Intent intent  = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
  210.         controls.activity.startActivity(intent);
  211.     }
  212.  
  213.        
  214.        
  215.     public void Stop() {
  216.         controls.activity.stopService(new Intent(controls.activity,jUSSDService.class));
  217.     }
  218.  
  219. }
  220.  
  221.  
  222.  
  223.  






Important: In the Original Demo I added Uses strutils.
AND :
Code: Pascal  [Select][+][-]
  1. if findpart('USSD:',USSDResponse) >0 then ShowMessage(USSDResponse);
  2.  

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.jBroadcastReceiver1Receiver(Sender: TObject; intent: jObject);
  2. var
  3.    USSDResponse: string;
  4.    action: string;
  5. begin
  6.     action:= jIntentManager1.GetAction(intent);
  7.     if action = 'org.lamw.action.USSDService' then
  8.     begin
  9.        USSDResponse:= jIntentManager1.GetExtraString(intent, 'message');
  10.        if findpart('USSD:',USSDResponse) >0 then ShowMessage(USSDResponse);
  11.     end;
  12. end;
  13.  
  14.  


And XML

Code: XML  [Select][+][-]
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
  3.    android:accessibilityEventTypes="typeWindowStateChanged|typeWindowContentChanged|typeViewClicked|typeViewFocused"
  4.    android:accessibilityFeedbackType="feedbackGeneric"
  5.    android:accessibilityFlags="flagDefault"
  6.    android:canRetrieveWindowContent="true"
  7.    android:description="@string/lamw_ussd_service"
  8.    android:notificationTimeout="100"
  9. android:canPerformGestures="true"
  10. android:canRequestTouchExplorationMode="true"
  11.    android:packageNames="@null"/>
  12.  



note:

I kept the original code untouched, except in START()  and  in "USSD:"  in the USSD response .
  The rest is add...


There is an unnecessary line : 149. While I was testing  found it convenient not to receive messages from the Launcher. But it must be excluded.
« Last Edit: September 23, 2021, 01:37:35 am by Guser979 »

Guser979

  • New Member
  • *
  • Posts: 40
Re: [SOLVED]LAMW - accessibility setting- Floating - Service -jUSSDService
« Reply #4 on: September 23, 2021, 02:00:48 pm »
A very simple usage example... Read twitters, including replies... Obviously, it's not limited to that. Usage depends on need and imagination.


But a challenge for those who have time, being a programmer or not (like me).Having heard the tweets presented, it would be interesting to refresh the screen to continue reading while you're doing something else and don't want to or can't pick up the phone. Well, we would have to produce a gesture. In this case, Swipe Down.
We will try? I'll.

But if you can solve the challenge, share your (tested) solution.
« Last Edit: September 23, 2021, 05:26:30 pm by Guser979 »

jmpessoa

  • Hero Member
  • *****
  • Posts: 1946
Re: [SOLVED]LAMW - accessibility setting- Floating - Service -jUSSDService
« Reply #5 on: September 23, 2021, 10:53:25 pm »

Quote
My solution is not that of a programmer, but it works... hehe

Nice!

Please, put your code and demo in some "open drive" ...

I will commit your  improvements to LAMW github!

Thank you!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Guser979

  • New Member
  • *
  • Posts: 40
Re: [SOLVED]LAMW - accessibility setting- Floating - Service -jUSSDService
« Reply #6 on: September 24, 2021, 01:03:02 am »
Yes I'll do it. But it's sad to realize that so few programmers collaborate with this tool. It's light, practical and functional. It could be at a much higher level than it already is. I usually search for topics and with the word "Accessibility" the results are almost 0. Pure waste. But let's go ahead...


jmpessoa

  • Hero Member
  • *****
  • Posts: 1946
Re: [SOLVED]LAMW - accessibility setting- Floating - Service -jUSSDService
« Reply #8 on: September 26, 2021, 01:11:26 am »

Done!

Thank you!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Guser979

  • New Member
  • *
  • Posts: 40
Re: [SOLVED]LAMW - accessibility setting- Floating - Service -jUSSDService
« Reply #9 on: September 26, 2021, 04:29:55 pm »
Thank you Master.

Well.. Continuing with the challenge I set myself:

The code for Swipe is tested
Code: Java  [Select][+][-]
  1.         public void Swipe() {
  2.         if (path == null) {
  3.             path = new Path();
  4.             path.moveTo(513,400);//// only y change (values x and y : your device)
  5.             path.lineTo(513,1000);//// only y change (values x and y : your device)
  6.         }
  7.         if (builder == null)
  8.             builder = new GestureDescription.Builder();
  9.         if (strokeDescription == null) {
  10.             strokeDescription = new GestureDescription.StrokeDescription(path, 0, 100);
  11.             builder.addStroke(strokeDescription);
  12.         }
  13.         if (gestureResultCallback == null)
  14.             gestureResultCallback = new GestureResultCallback() {
  15.                 @Override
  16.                 public void onCompleted(GestureDescription gestureDescription) {
  17.                  
  18.                 }
  19.  
  20.                 @Override
  21.                 public void onCancelled(GestureDescription gestureDescription) {
  22.                     super.onCancelled(gestureDescription);
  23.                 }
  24.             };
  25.         if (gestureDescription == null)
  26.             gestureDescription = builder.build();
  27.         dispatchGesture(gestureDescription, gestureResultCallback, null);
  28.     }
  29.  


But now it is necessary to program the right moment to perform the gesture. In other words: exactly when jTextToSpeech finishes reading the twetts.

There are several possible solutions. I'm testing.



Guser979

  • New Member
  • *
  • Posts: 40
Re: [SOLVED]LAMW - accessibility setting- Floating - Service -jUSSDService
« Reply #10 on: October 10, 2021, 04:02:12 am »
https://drive.google.com/file/d/1a6X7vHYBhf0J8LZnJfxEwu8OlOI30jjh/view?usp=sharing

Not to leave without conclusion, here it is.

Goal : Read tweets using tts and refresh the screen by performing a Swipe gesture after reading.

The java service Ussd was used as a basis. I added tts (in the same java unit) to it, along with the code for swipe.

That is all. "Jussd Service" can now perform gestures in chosen apps, can speak and present the content of chosen screen. I think accessibility is being put to good use now.

The file contains only unit.pas and Jussdservice.java with the modifications. Therefore, it is for those who have some knowledge of how LAMW works.

Used : Jwindowmanager jBroadcastReceiver jUSSDService jPreferences jListView


I also finished a minimal version of Synapse on Desktop which function is just to receive voice commands from android (using jTCPSocketClient and jCustomSpeechToText   only) and perform any programmable action: Open programs, maximize minimize etc any window. Position windows. Change windows size. Submit any key combinations. Write texts.Position and click with the mouse anywhere on the screen, etc.

  I'll make it available soon.

« Last Edit: October 10, 2021, 04:33:25 am by Guser979 »

jmpessoa

  • Hero Member
  • *****
  • Posts: 1946
Re: [SOLVED]LAMW - accessibility setting- Floating - Service -jUSSDService
« Reply #11 on: October 10, 2021, 04:52:21 am »
Hi, Guser979!

What about an  "AppWindowManagerDemo2"  or  "AppUSSDServiceDemo2" ?

Then I can try unify/merge and improve the LAMW "jUSSDService.java"
« Last Edit: October 10, 2021, 04:58:55 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Guser979

  • New Member
  • *
  • Posts: 40
Re: [SOLVED]LAMW - accessibility setting- Floating - Service -jUSSDService
« Reply #12 on: October 10, 2021, 04:54:49 am »
Okay, master.


Edit :


I have been facing some health issues. Once I'm fine, I'll continue exploring this fantastic LAMW. I made some modifications before that and will share for those who want to use, modify, improve, etc.

To be useful for more people, in the input screen you need at least a package name, the Swipe gesture coordinates, a timer to ensure there is always update( in the case of Twitter) and etc. Hope to come back soon to explore LAMW.

https://drive.google.com/file/d/1raGd9kxDh_tRNNRjkQ5oniRA5AVAC6_q/view?usp=sharing



« Last Edit: October 16, 2021, 05:31:16 pm by Guser979 »

 

TinyPortal © 2005-2018