App
This commit is contained in:
commit
b38e8971cf
20 changed files with 557 additions and 0 deletions
25
app/src/main/AndroidManifest.xml
Normal file
25
app/src/main/AndroidManifest.xml
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="ru.dc09.replaceinput">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
tools:targetApi="31">
|
||||
<service
|
||||
android:name=".ReplaceInputService"
|
||||
android:exported="true"
|
||||
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
|
||||
android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.accessibilityservice.AccessibilityService" />
|
||||
</intent-filter>
|
||||
<meta-data
|
||||
android:name="android.accessibilityservice"
|
||||
android:resource="@xml/service_config" />
|
||||
</service>
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -0,0 +1,27 @@
|
|||
package ru.dc09.replaceinput
|
||||
|
||||
import android.accessibilityservice.AccessibilityService
|
||||
import android.os.Bundle
|
||||
import android.view.accessibility.AccessibilityEvent
|
||||
import android.view.accessibility.AccessibilityNodeInfo
|
||||
|
||||
class ReplaceInputService : AccessibilityService() {
|
||||
override fun onInterrupt() {}
|
||||
override fun onAccessibilityEvent(event: AccessibilityEvent?) {
|
||||
|
||||
if (event == null || event.source == null) return
|
||||
|
||||
val field: AccessibilityNodeInfo = event.source
|
||||
val txt: String = field.text?.toString()
|
||||
?.lowercase()
|
||||
?.replace('ё', 'е')
|
||||
?: ""
|
||||
|
||||
val args = Bundle()
|
||||
args.putCharSequence(
|
||||
AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE,
|
||||
txt
|
||||
)
|
||||
field.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, args)
|
||||
}
|
||||
}
|
3
app/src/main/res/values/strings.xml
Normal file
3
app/src/main/res/values/strings.xml
Normal file
|
@ -0,0 +1,3 @@
|
|||
<resources>
|
||||
<string name="app_name">Replace Input</string>
|
||||
</resources>
|
8
app/src/main/res/xml/service_config.xml
Normal file
8
app/src/main/res/xml/service_config.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:accessibilityEventTypes="typeViewTextChanged"
|
||||
android:accessibilityFlags="flagDefault"
|
||||
android:accessibilityFeedbackType="feedbackAllMask"
|
||||
android:notificationTimeout="100"
|
||||
android:canRetrieveWindowContent="true"
|
||||
/>
|
Loading…
Add table
Add a link
Reference in a new issue