App
This commit is contained in:
commit
b38e8971cf
20 changed files with 557 additions and 0 deletions
|
@ -0,0 +1,24 @@
|
|||
package ru.dc09.replaceinput
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExampleInstrumentedTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("ru.dc09.replaceinput", appContext.packageName)
|
||||
}
|
||||
}
|
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"
|
||||
/>
|
17
app/src/test/java/ru/dc09/replaceinput/ExampleUnitTest.kt
Normal file
17
app/src/test/java/ru/dc09/replaceinput/ExampleUnitTest.kt
Normal file
|
@ -0,0 +1,17 @@
|
|||
package ru.dc09.replaceinput
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
class ExampleUnitTest {
|
||||
@Test
|
||||
fun addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue